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().