summaryrefslogtreecommitdiff
path: root/drawing/src/ofApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'drawing/src/ofApp.cpp')
-rw-r--r--drawing/src/ofApp.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/drawing/src/ofApp.cpp b/drawing/src/ofApp.cpp
index 28bca20..70a9f00 100644
--- a/drawing/src/ofApp.cpp
+++ b/drawing/src/ofApp.cpp
@@ -7,7 +7,7 @@ vector<std::string> cmdnames={"moveTo","lineTo","curveTo","bezierTo","quadBezier
//--------------------------------------------------------------
void ofApp::setup(){
ofxSVG svg;
- svg.load("haring.svg");
+ svg.load("bars.svg");
vector <ofPath> paths= svg.getPaths();
for (int i=0;i<paths.size();i++){
@@ -63,6 +63,14 @@ void ofApp::update(){
clipper.addPolylines(mask, ClipperLib::ptClip);
}
+ofPolyline ofApp::polyLineTransform(const ofPolyline& poly, ofMatrix4x4 xform){
+ ofPolyline tempPoly;
+ for (auto& p:poly){
+ tempPoly.addVertex(ofVec3f(p)*xform);
+ }
+ return tempPoly;
+}
+
//--------------------------------------------------------------
@@ -75,6 +83,8 @@ void ofApp::draw(){
float phase=fmod(ofGetElapsedTimef()/2,1);
+ //transform points of segmenter before intersecting with mask
+
switch (mode){
case 0:{
for (auto shape=segmenters.begin();shape!=segmenters.end();shape++){
@@ -124,6 +134,25 @@ void ofApp::draw(){
break;
}
case 3:{
+ vector <ofPolyline> shapes;
+ ofMatrix4x4 rm = ofMatrix4x4::newIdentityMatrix();
+ rm.translate(-600,-450,0);
+ rm.rotateRad(ofGetElapsedTimef(),0,0,1);
+ rm.translate(600,450,0);
+ for (auto& segment:segmenters){
+ shapes.push_back(polyLineTransform(segment.getPoly(),rm));
+ }
+ clipper.addPolylines(shapes,ClipperLib::ptSubject);
+ vector<ofPolyline> clipped = clipper.getClippedLines(ClipperLib::ctIntersection);
+ for (auto& clip: clipped)
+ {
+ clip.draw();
+ segmentsdrawn++;
+ pointsdrawn+=clip.size();
+ }
+ break;
+ }
+ case 4:{
int w=ofRandom(1000);
segmenters[w%segmenters.size()].draw();
segmentsdrawn=1;