Hi !
I'm currently trying to convert a Svg image to an ilda Laser.
I've succeeded to convert the image into several ofPolyline (in order to draw differents shape with no lines between them).
The problem is that I can draw the vector of polylines but with real dimensions (like a 500*500 px), but no in (0-1).
I tried to normalise the polyline but it returns a weird thing (see the image).
I tried to make an ofmap to map values to 0-1, but It doesn't work too.
Here is some code and pictures :
In Setup :
svg.load("batman.svg");
for (int i = 0; i < svg.getNumPath(); i++){
ofPath p = svg.getPathAt(i);
// svg defaults to non zero winding which doesn't look so good as contours
p.setPolyWindingMode(OF_POLY_WINDING_ODD);
for(int j = 0; j < p.getOutline().size(); j++) {
ofPolyline lineTest = p.getOutline().at(j);
outlines.push_back(lineTest.getResampledBySpacing(1)); //outlines is a vector of ofPolyline
// Here I have a vector of ofPolylines with all the coordinates
}
}
//Normal way to add Vertices with the normal coordinates, then normalise
for (int i = 0; i < (int)outlines.size(); i++){
ofPolyline lineTest2;
lineVectored.push_back(outlines[i]);
lineVectored[i] = outlines[i];
lineShared = shared_ptr<ofxIlda::Poly>(new ofxIlda::Poly);
for (int j = 0; j < lineVectored.size(); j++){
lineShared.get()->addVertices(lineVectored[i].getVertices());
lineSharedOk.push_back(lineShared);
lineSharedOk[i]->normalise();
}
}
But It returns me :
I tried with the OfMap Function and it returns me :
for (int i = 0; i < (int)outlines.size(); i++){
ofPolyline lineTest2;
lineVectored.push_back(outlines[i]);
lineVectored[i] = outlines[i];
lineShared = shared_ptr<ofxIlda::Poly>(new ofxIlda::Poly);
for (int j = 0; j < lineVectored.size(); j++){
lineShared.get()->addVertex(ofMap(lineVectored[i][j].x, 0, svg.getWidth(), 0, 1),
ofMap(lineVectored[i][j].y, 0, svg.getHeight(), 0, 1), 0 );
lineSharedOk.push_back(lineShared);
}
}
Here is the result :
The original image drawn with Polyline is ok (not passed through Etherdream) :
So my problem isn't to draw an svg image to a vector of polylines, but it's to map originals coordinates (0-ofGetWidth) to Ilda coordinates (0-1), in order to send them to the laser.
Someone knows how I can do it ? Maybe @memo ?
Thanks !
Cyril