diff options
Diffstat (limited to 'drawing/src')
| -rw-r--r-- | drawing/src/lineSegmenter.h | 3 | ||||
| -rw-r--r-- | drawing/src/ofApp.cpp | 31 | ||||
| -rw-r--r-- | drawing/src/ofApp.h | 2 |
3 files changed, 35 insertions, 1 deletions
diff --git a/drawing/src/lineSegmenter.h b/drawing/src/lineSegmenter.h index 5b2aab3..d858ba2 100644 --- a/drawing/src/lineSegmenter.h +++ b/drawing/src/lineSegmenter.h @@ -11,6 +11,9 @@ class lineSegmenter{ } } const vector <ofPolyline> &getSegments(int num,float coverage, float phase); + ofPolyline getPoly(){ + return line; + } void draw(); int size(); private: 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; diff --git a/drawing/src/ofApp.h b/drawing/src/ofApp.h index ae4c1a3..c63533a 100644 --- a/drawing/src/ofApp.h +++ b/drawing/src/ofApp.h @@ -32,6 +32,8 @@ class ofApp : public ofBaseApp{ void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); + ofPolyline polyLineTransform(const ofPolyline& poly, ofMatrix4x4 xform); + vector <lineSegmenter> segmenters; vector <ofPolyline> mask; |
