#include "vectorPlugin.h" void svgPanel::load(string filename){ ofxSVG svg; svg.load(filename); //normalise the SVG paths to a square format float dimension=max(svg.getWidth(),svg.getHeight()); glm::vec2 src[]={ glm::vec2(0,0), glm::vec2(dimension,0), glm::vec2(dimension,dimension), glm::vec2(0,dimension) }; glm::vec2 dst[]={ //PONK coords glm::vec2(-1,-1), glm::vec2(1,-1), glm::vec2(1,1), glm::vec2(-1,1) }; ofMatrix4x4 xform=lineTransformer::getPerspectiveTransformMatrix(src,dst); vector imagepaths= svg.getPaths(); std::stringstream strm; if (imagepaths.size()){ segmenters.clear(); //shape_selection_durations.clear(); for (auto& path:imagepaths){ path.setPolyWindingMode(OF_POLY_WINDING_ODD); vector outlines= path.getOutline(); for (auto& outline:outlines){ //strm << outline.size() << "->"; //outline.simplify(contour_simplify); //?necessary //strm << outline.size() << " "; ofPolyline xformed=lineTransformer::polyLineTransform(xform,outline); ofColor c1=path.getStrokeColor(); ofColor colour=path.getFillColor(); if (colour.r==colour.g&&colour.g==colour.b){ //if there appears to be no fill colour resort to stroke colour=c1; }; segmenters.push_back( colourLineSegmenter( xformed, colour ) ); shape_selection_durations.push_back(0.0f); } //strm << " , "; } //std::stringstream strom; //last_frame_time=ofGetElapsedTimef(); //cout << "SVG: selected paths [ "<timedelta){ shape_selection_durations[i]-=timedelta; shape_selection.insert(i); } } // /* std::stringstream strom; for (auto& s:shape_selection){ strom << s <<":"< svgPanel::getAllLines(){ vector output; for (auto& shape:segmenters){ output.push_back(shape.getPoly()); } return output; } vector svgPanel::getLines(){ vector output; //if (!use_onset||onset_framegetSegments(segmenter_number,segmenter_length,phase); for (auto segment=segments.begin();segment!=segments.end();segment++){ //output.push_back(colourPolyline(*segment,ofColor(laser_R,laser_G,laser_B))); output.push_back(*segment); } } else { //output.push_back(colourPolyline(shape->getPoly(),ofColor(laser_R,laser_G,laser_B))); output.push_back(shape->getPoly()); } } } //this should happen at output stage? if (colourise){ for (auto p=output.begin();p!=output.end();p++){ p->setColour(ofColor(255,255,255)); } } //} return output; }