← Back

ofxVaseRenderer

github.com/ofxyz/ofxVaseRenderer · @ofxyz
OF 0.12 2D

VASEr by Tsang Hao Fung (Chris Tsang) inside OF

2 1 Last commit 2mo ago Created 5mo ago

README

ofxVaseRenderer



High-quality 2D shape renderer for openFrameworks with anti-aliased strokes, fills, variable width, per-vertex color, and smooth joints. Based on the VASE renderer algorithm by TSANG, Hao Fung.

sample

Features



Quick Start



#include "ofxVaseRenderer.h"

ofxVaseRenderer::Renderer renderer;

void ofApp::setup() {
    renderer.setup();
}

void ofApp::draw() {
    ofxVaseRenderer::Polyline poly(points, colors, widths, opts);
    renderer.begin();
    renderer.draw(poly);
    renderer.end();
}


Configuration



Joint Styles

Cap Styles

ofxVaseRenderer::Options opts;
opts.joint = ofxVaseRenderer::JointStyle::Round;
opts.cap   = ofxVaseRenderer::CapStyle::Round;
opts.miterLimit = 4.0f;


Variable Width and Color



std::vector<glm::vec2> points = {{100,100}, {200,200}, {300,150}, {400,200}};
std::vector<ofFloatColor> colors = {ofFloatColor::red, ofFloatColor::yellow,
                                     ofFloatColor::green, ofFloatColor::blue};
std::vector<float> widths = {5, 20, 10, 30};

ofxVaseRenderer::Polyline poly(points, colors, widths, opts);
renderer.draw(poly);


Smoothing (Catmull-Rom Splines)



opts.smoothing = 4;  // 4 subdivisions per segment


GPU Rendering



if (renderer.gpuAvailable()) {
    renderer.drawGPU(points, colors, widths, feather, capStyle);
}


Calligraphy Pen



renderer.drawPenGPU(points, colors, nibWidth, nibAngleDeg, feather);


License



BSD 3-Clause License - See LICENSE.txt

Get this addon

HTTPS
SSH