summaryrefslogtreecommitdiff
path: root/drawing/src/ofApp.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2018-01-21 12:39:07 +0000
committerTim Redfern <tim@getdrop.com>2018-01-21 12:39:07 +0000
commitfa8fd80b285e8b916afa5b0424bcd00e579c0771 (patch)
treeaf33c9a1cfb4727285ddd33ba1aabe46c7bdee95 /drawing/src/ofApp.cpp
parentaa7ff25decb259acf1c0f233990d9dfddf14a4d9 (diff)
outlining partially working
Diffstat (limited to 'drawing/src/ofApp.cpp')
-rw-r--r--drawing/src/ofApp.cpp87
1 files changed, 79 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;
}
}