Hi, I’m trying to create a proper path from shapes.
I would like to use the svg as path for my pen plotter (here Axidraw).
The svg file opened in inkscape made has a deepness and is doubled for every line.
How can I simplify ?
Here’s the creater svg code :
ArrayList<Cuber> cubs = new ArrayList<Cuber>();
import processing.svg.*;
boolean record;
void setup() {
size(360, 240, P2D);
for (int i=0; i<2; i++) cubs.add(new Cuber(120+i*124, 120, 60));
}
void draw() {
if (record) beginRaw(SVG, "output.svg");
background(220);
stroke(0);
strokeWeight(1);
noFill();
for (Cuber c : cubs) c.display();
if (record) {
endRaw();
record = false;
}
}
void keyPressed() {
if (key == 'r') {
record = true;
print("svg saved");
}
}
The class :
class Cuber {
int x, y;
PVector ray, center;
PVector[] pts = new PVector[6];
Cuber(int x, int y, int r) {
this.x = x;
this.y = y;
ray = new PVector(0, r);
center = new PVector(0, 0);
for (int i=0; i<pts.length; i++) pts[i] = center.copy().add(ray).rotate((PI/3.0)*i);
}
void display() {
pushMatrix();
translate(x, y);
beginShape();
for (int i=0; i<pts.length; i++) vertex(pts[i].x, pts[i].y);
endShape(CLOSE);
popMatrix();
}
}