diff options
| author | Tim Redfern <tim@getdrop.com> | 2018-11-29 03:01:05 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@getdrop.com> | 2018-11-29 03:01:05 +0000 |
| commit | 11779cd013e4b8f8d8e298e480d7cf763a21e4e2 (patch) | |
| tree | c4afe354fced7f01ce6aab1e720a1a1717bbf4fc /gui/src | |
| parent | 2dcde7e8eb69d6e1139838555ea77d1ef6a84548 (diff) | |
maybe..
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/lineSegmenter.cpp | 38 | ||||
| -rw-r--r-- | gui/src/ofApp.cpp | 18 | ||||
| -rw-r--r-- | gui/src/ofApp.h | 2 |
3 files changed, 50 insertions, 8 deletions
diff --git a/gui/src/lineSegmenter.cpp b/gui/src/lineSegmenter.cpp index 14f6e24..495190d 100644 --- a/gui/src/lineSegmenter.cpp +++ b/gui/src/lineSegmenter.cpp @@ -62,6 +62,44 @@ int lineSegmenter::size(){ return line.size(); } +const vector <colourPolyline> & colourLineSegmenter::getSegments(int num,float coverage, float phase){ + + segments.clear(); + + for (int i=0;i<num;i++){ + float startIndex=line.getIndexAtPercent((phase+i)/num); //always <1 + float endPoint=(phase+i+coverage)/num; //can be >1 + float endIndex=line.getIndexAtPercent(endPoint>1.0f?endPoint-1.0f:endPoint); + colourPolyline segment; + segment.addVertex(line.getPointAtIndexInterpolated(startIndex),line.getColourAtIndexInterpolated(startIndex)); + for (int j=(int)ceil(startIndex);j<(endPoint>1?line.size():(int)ceil(endIndex));j++){ + segment.addVertex(line[j],line.getColourAt(j)); + } + if (endPoint>1){ + segments.push_back(segment); + segment.clear(); + for (int j=0;j<(int)ceil(endIndex);j++){ + segment.addVertex(line[j],line.getColourAt(j)); + } + segment.addVertex(line.getPointAtIndexInterpolated(endIndex),line.getColourAtIndexInterpolated(endIndex)); + } + else { + segment.addVertex(line.getPointAtIndexInterpolated(endIndex),line.getColourAtIndexInterpolated(endIndex)); + } + segments.push_back(segment); + } + + return segments; +} + +void colourLineSegmenter::draw(){ + line.draw(); + return; +} +int colourLineSegmenter::size(){ + return line.size(); +} + /* diff --git a/gui/src/ofApp.cpp b/gui/src/ofApp.cpp index cfa9df1..3514776 100644 --- a/gui/src/ofApp.cpp +++ b/gui/src/ofApp.cpp @@ -1,4 +1,4 @@ -#include "ofApp.h" + #include "ofApp.h" #include "glew.h" const ofPoint outputWindowSize=ofPoint(1200,900); @@ -758,11 +758,13 @@ void ofApp::drawOutput(ofEventArgs & args){ if (use_segmenter){ auto segments=segmenters[s].getSegments(segmenter_number,segmenter_length,phase); for (auto segment=segments.begin();segment!=segments.end();segment++){ - polyOutput.push_back(colourPolyline(*segment,ofColor(laser_R,laser_G,laser_B))); + //polyOutput.push_back(colourPolyline(*segment,ofColor(laser_R,laser_G,laser_B))); + polyOutput.push_back(*segment); } } else { - polyOutput.push_back(colourPolyline(segmenters[s].getPoly(),ofColor(laser_R,laser_G,laser_B))); + //polyOutput.push_back(colourPolyline(segmenters[s].getPoly(),ofColor(laser_R,laser_G,laser_B))); + polyOutput.push_back(segmenters[s].getPoly()); } } framecounter--; @@ -772,12 +774,13 @@ void ofApp::drawOutput(ofEventArgs & args){ if (use_segmenter){ auto segments=shape->getSegments(segmenter_number,segmenter_length,phase); for (auto segment=segments.begin();segment!=segments.end();segment++){ - polyOutput.push_back(colourPolyline(*segment,ofColor(laser_R,laser_G,laser_B))); + //polyOutput.push_back(colourPolyline(*segment,ofColor(laser_R,laser_G,laser_B))); + polyOutput.push_back(*segment); } } else { - polyOutput.push_back(colourPolyline(shape->getPoly(),ofColor(laser_R,laser_G,laser_B))); - + //polyOutput.push_back(colourPolyline(shape->getPoly(),ofColor(laser_R,laser_G,laser_B))); + polyOutput.push_back(shape->getPoly()); } } } @@ -837,6 +840,7 @@ void ofApp::drawOutput(ofEventArgs & args){ { clip.simplify(contour_simplify); clippedOutput.push_back(colourPolyline(clip,ofColor(laser_R,laser_G,laser_B))); + clippedOutput.push_back(colourPolyline(clip,ofColor(laser_R,laser_G,laser_B))); } } else { @@ -1109,7 +1113,7 @@ void ofApp::dragEvent(ofDragInfo dragInfo){ strm << outline.size() << "->"; outline.simplify(contour_simplify); strm << outline.size() << " "; - segmenters.push_back(lineSegmenter(outline)); + segmenters.push_back(colourLineSegmenter(outline,path.getStrokeColor())); } strm << " , "; } diff --git a/gui/src/ofApp.h b/gui/src/ofApp.h index 3d9a646..8772ad2 100644 --- a/gui/src/ofApp.h +++ b/gui/src/ofApp.h @@ -236,7 +236,7 @@ class ofApp: public ofBaseApp, public ofxMidiListener { //======================================= //SVG player ofxSVG svg; - vector <lineSegmenter> segmenters; + vector <colourLineSegmenter> segmenters; set <int> shape_selection; int framecounter; float phase,prev_time; //to calculate phase |
