← Back

ofxStrokeMesh

github.com/tettou771/ofxStrokeMesh · @tettou771
OF 0.12 Geometry

Generates triangle mesh strokes from ofPolyline or ofPath with configurable stroke width, cap and join types, and variable width.

1 0 Last commit 10mo ago Created 10mo ago

README

ofxStrokeMesh



openFrameworks addon for generating triangle mesh strokes from ofPolyline/ofPath.

example

Features



Usage



#include "ofxStrokeMesh.h"

// Basic usage
ofxStrokeMesh stroke;
stroke.addVertex(100, 100);
stroke.addVertex(200, 150);
stroke.addVertex(300, 100);
stroke.setWidth(10);
stroke.setColor(ofColor::red);
stroke.setCapType(ofxStrokeMesh::CAP_ROUND);
stroke.setJoinType(ofxStrokeMesh::JOIN_ROUND);
stroke.update();
stroke.draw();

// From ofPolyline
ofPolyline line;
line.addVertex(0, 0);
line.addVertex(100, 50);
line.addVertex(200, 0);

ofxStrokeMesh stroke(line);
stroke.setWidth(5);
stroke.update();
stroke.draw();

// From ofPath (e.g., text outline)
ofPath path;
// ... setup path ...
ofxStrokeMesh stroke(path);
stroke.update();
stroke.draw();

// Variable width stroke
ofxStrokeMesh brush;
brush.addVertexWithWidth(100, 100, 5.0f);   // thin
brush.addVertexWithWidth(200, 150, 30.0f);  // thick
brush.addVertexWithWidth(300, 100, 10.0f);  // medium
brush.setCapType(ofxStrokeMesh::CAP_ROUND);
brush.setJoinType(ofxStrokeMesh::JOIN_ROUND);
brush.update();
brush.draw();


API



Cap Types

Join Types

Methods



// Settings
void setWidth(float width);
void setColor(ofColor color);
void setCapType(CapType type);
void setJoinType(JoinType type);
void setMiterLimit(float limit);

// Input
void addVertex(float x, float y, float z = 0);
void addVertexWithWidth(float x, float y, float width);  // Variable width
void setWidths(const vector<float>& widths);             // Set width array
void setShape(const ofPath& path);
void setShape(const ofPolyline& polyline);
void setClosed(bool closed);

// Core
void update();  // Call after changing settings
void draw();

// Access
ofMesh& getMesh();
vector<ofPolyline>& getPolylines();


Compatibility



License



MIT License

Get this addon

HTTPS
SSH