diff options
Diffstat (limited to 'drawing/src')
| -rw-r--r-- | drawing/src/ofApp.cpp | 87 | ||||
| -rw-r--r-- | drawing/src/ofApp.h | 3 |
2 files changed, 82 insertions, 8 deletions
diff --git a/drawing/src/ofApp.cpp b/drawing/src/ofApp.cpp index 70a9f00..91daee1 100644 --- a/drawing/src/ofApp.cpp +++ b/drawing/src/ofApp.cpp @@ -8,21 +8,21 @@ vector<std::string> cmdnames={"moveTo","lineTo","curveTo","bezierTo","quadBezier void ofApp::setup(){ ofxSVG svg; svg.load("bars.svg"); - vector <ofPath> paths= svg.getPaths(); + imagepaths= svg.getPaths(); - for (int i=0;i<paths.size();i++){ - vector <ofPolyline> outlines= paths[i].getOutline(); + for (int i=0;i<imagepaths.size();i++){ + vector <ofPolyline> outlines= imagepaths[i].getOutline(); for (int j=0;j<outlines.size();j++){ segmenters.push_back(lineSegmenter(outlines[j])); } } - cout << "Drawing: found " << paths.size() << " paths with " << segmenters.size() << " shapes" <<std::endl; + cout << "Drawing: found " << maskpaths.size() << " paths with " << segmenters.size() << " shapes" <<std::endl; svg.load("lorenzo.svg"); - paths= svg.getPaths(); + maskpaths= svg.getPaths(); - for (auto& path:paths){ + for (auto& path:maskpaths){ //paths[i].setMode(ofPath::COMMANDS); path.setPolyWindingMode(OF_POLY_WINDING_ODD); @@ -45,7 +45,7 @@ void ofApp::setup(){ } - cout << "Mask: found " << paths.size() << " paths with " << mask.size() << " shapes" <<std::endl; + cout << "Mask: found " << maskpaths.size() << " paths with " << mask.size() << " shapes" <<std::endl; numsegments=1; coverage=0.5; @@ -153,6 +153,77 @@ void ofApp::draw(){ break; } case 4:{ + vector<ofPolyline> clipped = clipper.getOffsets(maskpaths,((sin(ofGetElapsedTimef())+1)*5)+1,true); + for (auto& clip: clipped) + { + clip.draw(); + segmentsdrawn++; + pointsdrawn+=clip.size(); + } + break; + } + case 5:{ + vector<ofPolyline> clipped = clipper.getOffsets(maskpaths,(phase*20)+1,true); + + vector<ofPolyline> simplified = clipper.simplifyPolylines(clipped); + + ofSetColor(255*(1.0f-phase),255*(1.0f-phase),255*(1.0f-phase)); + + for (auto& clip: simplified) + { + + clip.draw(); + segmentsdrawn++; + pointsdrawn+=clip.size(); + } + + float phase1=fmod(phase+0.5f,1.0f); + + clipped.clear(); + + clipped = clipper.getOffsets(maskpaths,(phase1*20)+1,true); + + simplified.clear(); + + simplified = clipper.simplifyPolylines(clipped); + + ofSetColor(255*(1.0f-phase1),255*(1.0f-phase1),255*(1.0f-phase1)); + + for (auto& clip: simplified) + { + + clip.draw(); + segmentsdrawn++; + pointsdrawn+=clip.size(); + } + + + break; + } + case 6:{ + + vector <ofPolyline> shapes; + for (auto& shape: mask) + { + shape.close(); + shapes.push_back(shape); + } + vector<ofPolyline> clipped = clipper.getOffsets(shapes,((sin(ofGetElapsedTimef())+1)*5)+1); + + + vector<ofPolyline> simplified = clipper.simplifyPolylines(clipped); + + for (auto& clip: simplified) + { + clip.draw(); + segmentsdrawn++; + pointsdrawn+=clip.size(); + } + + + break; + } + case 7:{ int w=ofRandom(1000); segmenters[w%segmenters.size()].draw(); segmentsdrawn=1; @@ -213,7 +284,7 @@ void ofApp::keyReleased(int key){ break; } case 'p':{ - mode=(mode+1)%4; + mode=(mode+1)%8; break; } } diff --git a/drawing/src/ofApp.h b/drawing/src/ofApp.h index c63533a..4e8dc69 100644 --- a/drawing/src/ofApp.h +++ b/drawing/src/ofApp.h @@ -42,6 +42,9 @@ class ofApp : public ofBaseApp{ int mode; + vector <ofPath> imagepaths; + vector <ofPath> maskpaths; + ofx::Clipper clipper; ofxSyphonServer mainOutputSyphonServer; |
