summaryrefslogtreecommitdiff
path: root/nextus/src
diff options
context:
space:
mode:
Diffstat (limited to 'nextus/src')
-rw-r--r--nextus/src/ofApp.cpp15
-rw-r--r--nextus/src/ofApp.h57
2 files changed, 62 insertions, 10 deletions
diff --git a/nextus/src/ofApp.cpp b/nextus/src/ofApp.cpp
index 3ace079..088c394 100644
--- a/nextus/src/ofApp.cpp
+++ b/nextus/src/ofApp.cpp
@@ -63,6 +63,21 @@ void ofApp::draw(){
svginput.draw();
textinput.draw();
+ //process the pipeline
+ vector<colourPolyline> output=svginput.getLines();
+
+ ofPushMatrix();
+ ofTranslate(695,5);
+ ofSetColor(255);
+ ofNoFill();
+ ofDrawRectangle(0,0,500,500);
+ ofTranslate(250,250);
+ ofScale(250.0f);
+ for (auto poly:output){
+ poly.draw();
+ }
+ ofPopMatrix();
+
}
diff --git a/nextus/src/ofApp.h b/nextus/src/ofApp.h
index 352c6ca..a484129 100644
--- a/nextus/src/ofApp.h
+++ b/nextus/src/ofApp.h
@@ -36,11 +36,15 @@ class vectorPanel {
panel.draw();
ofPushMatrix();
ofTranslate(size/2);
- drawcontent();
+ ofScale(DISPLAYSIZE.x/2.0f);
+ vector<colourPolyline> lines=getLines();
+ for (auto& line:lines){
+ line.draw();
+ }
ofPopMatrix();
ofPopMatrix();
}
- virtual void drawcontent() {};;
+ virtual vector<colourPolyline> getLines() {};
private:
ofVec2f size;
@@ -56,16 +60,29 @@ class svgPanel: public vectorPanel{
ofVec2f _pos=ofPoint(5,5)
) : vectorPanel(_title,_size,_pos){}
void load(string filename){
- ofLog()<<"loading SVG "<<filename;
-
+
ofxSVG svg;
svg.load(filename);
//normalise the SVG paths to a square format
- float scale=max(svg.getWidth(),svg.getHeight());
+ 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)
+ };
- ofMatrix4x4 xform;
+ 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 <ofPath> imagepaths= svg.getPaths();
@@ -82,7 +99,19 @@ class svgPanel: public vectorPanel{
//strm << outline.size() << "->";
//outline.simplify(contour_simplify);
//strm << outline.size() << " ";
- segmenters.push_back(colourLineSegmenter(outline,path.getStrokeColor()));
+ ofPolyline xformed=lineTransformer::polyLineTransform(xform,outline);
+ ofColor c1=path.getStrokeColor();
+ ofColor colour=path.getFillColor();
+ if (colour.r==colour.g&&colour.g==colour.b){
+ colour=c1;
+ }
+
+ segmenters.push_back(
+ colourLineSegmenter(
+ xformed,
+ path.getStrokeColor()
+ )
+ );
//shape_selection_durations.push_back(0.0f);
}
@@ -105,12 +134,20 @@ class svgPanel: public vectorPanel{
//cout << "SVG: selected paths [ "<<strom.str() << " ]" <<std::endl;
//cout << "SVG: found " << imagepaths.size() << " paths with " << segmenters.size() << " shapes [ " << strm.str() << " ]" <<std::endl;
//select_random_shapes(shapes_duration);
+ ofLog()<<"loaded SVG "<<filename<<", "<<segmenters.size()<<" paths";
+
+ }
+ else {
+ ofLog()<<"could not load SVG "<<filename;
}
}
- void drawcontent(){
- for (auto shape=segmenters.begin();shape!=segmenters.end();shape++){
- shape->getPoly().draw();
+ vector<colourPolyline> getLines(){
+ vector<colourPolyline> output;
+ for (auto& shape:segmenters){
+ output.push_back(shape.getPoly());
}
+ //ofLog()<<"svg found "<<output.size()<<" lines";
+ return output;
}
private: