We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
svg to arduino (Read 2320 times)
svg to arduino
Jan 19th, 2010, 12:18pm
 
Hi all,
I'm an intermediate arduino user and at the moment I'm trying to build something like a plotter from old computer parts (mainly stepper motors). At the end I would like to send vector graphic data (svg files) to the plotter, so I need some software for that. Processing is a good way to do this, isn't it?
But how?
Can someone only give me a hint, some links or something because I can't find anything that leads me further, maybe because of my lack of processing knowledge. I know programming in general, concepts of objects, vectors, files and all this stuff ... but where can be a starting point for me in this special case?
Thanks!
Christian
Re: svg to arduino
Reply #1 - Jan 19th, 2010, 2:10pm
 
first try to make it work as processing sketch only. I would start and try to load svgs and make a small dot follow the outline like a pen would, and draw the shape outline by doing this (call no background for example). you can do that using geomerative library to get the outline/points of a shape http://www.ricardmarxer.com/geomerative/
if that works fine, next step would be to connect it to your electronics. 2 servos, moving along the coodinates you get... not sure how, depends on your hardware, but thats the way i would start.
Re: svg to arduino
Reply #2 - Jan 19th, 2010, 2:32pm
 
Starting a similar project, I'm thinking about an own renderer, so when the line() methode is called I can catch the coords and send them to my arduino and also draw the line in my sketch.
Re: svg to arduino
Reply #3 - Jan 20th, 2010, 9:39am
 
Thanks for the fast responses!
I think I can get a step further now with this "geomative" library!

@eskimoblood: what did you mean with catching the coords when the line method is called?

best wishes,
christian
Re: svg to arduino
Reply #4 - Jan 20th, 2010, 12:51pm
 
You can create your own renderer like this:
Code:

ppackage plotter;

import processing.core.PGraphics2D;
import processing.serial.Serial;

public class Plotter extends PGraphics2D {

float currX, currY;
boolean startLine;
Serial serial;

public Plotter() {
super();
currX = 0;
currY = 0;
startLine = false;
serial = new Serial(super.parent);
}

public void beginShape() {
super.beginShape();
startLine = true;
}

public void vertex(float x, float y) {
super.vertex(x, y);
if (startLine) {
moveTo(x, y);
startLine = false;
} else {
lineTo(x, y);
}
}

private void lineTo(float x, float y) {
getLength(x, y);
}

private void moveTo(float x, float y) {
getLength(x, y);
}

private float[] getLength(float x, float y) {
float[] r = { currX - x, currY - y };
currX = x;
currX = y;
return r;
}
}



in processing you can use it like this
Code:

package test;

import processing.core.*;
import plotter.Plotter;

public class Test extends PApplet {

static public void main(String args[]) {
PApplet.main(new String[] { /* "--present", */"test.Test" });
}

public void setup(){
size(200, 200, "plotter.Plotter");
line(0,0,200,200);

}
}


Now you can use processing like before but the logic for the printing stuff is inside the renderer. Haven't test it yet with arduino but I hope thats the way to go. If I understand PGraphics, all the vector drawing stuff is done with beginShape(), endShape() and vertex().
Page Index Toggle Pages: 1