From 3b89e73c157f0eef8a3479b613491c8343f9c43b Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Tue, 18 Apr 2023 17:41:57 +0100 Subject: loads SVGs --- nextus/src/ofApp.cpp | 15 ++++++++++++++ nextus/src/ofApp.h | 57 +++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 62 insertions(+), 10 deletions(-) diff --git a/nextus/src/ofApp.cpp b/nextus/src/ofApp.cpp index 3ace079..088c394 100644 --- a/nextus/src/ofApp.cpp +++ b/nextus/src/ofApp.cpp @@ -63,6 +63,21 @@ void ofApp::draw(){ svginput.draw(); textinput.draw(); + //process the pipeline + vector output=svginput.getLines(); + + ofPushMatrix(); + ofTranslate(695,5); + ofSetColor(255); + ofNoFill(); + ofDrawRectangle(0,0,500,500); + ofTranslate(250,250); + ofScale(250.0f); + for (auto poly:output){ + poly.draw(); + } + ofPopMatrix(); + } diff --git a/nextus/src/ofApp.h b/nextus/src/ofApp.h index 352c6ca..a484129 100644 --- a/nextus/src/ofApp.h +++ b/nextus/src/ofApp.h @@ -36,11 +36,15 @@ class vectorPanel { panel.draw(); ofPushMatrix(); ofTranslate(size/2); - drawcontent(); + ofScale(DISPLAYSIZE.x/2.0f); + vector lines=getLines(); + for (auto& line:lines){ + line.draw(); + } ofPopMatrix(); ofPopMatrix(); } - virtual void drawcontent() {};; + virtual vector getLines() {}; private: ofVec2f size; @@ -56,16 +60,29 @@ class svgPanel: public vectorPanel{ ofVec2f _pos=ofPoint(5,5) ) : vectorPanel(_title,_size,_pos){} void load(string filename){ - ofLog()<<"loading SVG "< imagepaths= svg.getPaths(); @@ -82,7 +99,19 @@ class svgPanel: public vectorPanel{ //strm << outline.size() << "->"; //outline.simplify(contour_simplify); //strm << outline.size() << " "; - segmenters.push_back(colourLineSegmenter(outline,path.getStrokeColor())); + ofPolyline xformed=lineTransformer::polyLineTransform(xform,outline); + ofColor c1=path.getStrokeColor(); + ofColor colour=path.getFillColor(); + if (colour.r==colour.g&&colour.g==colour.b){ + colour=c1; + } + + segmenters.push_back( + colourLineSegmenter( + xformed, + path.getStrokeColor() + ) + ); //shape_selection_durations.push_back(0.0f); } @@ -105,12 +134,20 @@ class svgPanel: public vectorPanel{ //cout << "SVG: selected paths [ "<getPoly().draw(); + vector getLines(){ + vector output; + for (auto& shape:segmenters){ + output.push_back(shape.getPoly()); } + //ofLog()<<"svg found "<