Generates triangle mesh strokes from ofPolyline or ofPath with configurable stroke width, cap and join types, and variable width.
README
ofxStrokeMesh
openFrameworks addon for generating triangle mesh strokes from ofPolyline/ofPath.

Features
- Generate triangle mesh from polyline with configurable stroke width
- Support for Cap types: BUTT, ROUND, SQUARE
- Support for Join types: MITER, ROUND, BEVEL
- Works with ofPolyline, ofPath, or manual vertex input
- Closed shape support
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
CAP_BUTT- Flat end (default)CAP_ROUND- Semicircle endCAP_SQUARE- Flat end extended by half stroke width
Join Types
JOIN_MITER- Sharp corner (default)JOIN_ROUND- Rounded cornerJOIN_BEVEL- Flat cut corner
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
- openFrameworks 0.12.x
License
MIT License
ofxAddons