Oooooh....a lot!
Hilde and Susanne
void myLine(int p1x, int p1y, int p2x, int p2y)
{
//go to spot p1
myPort.write ( "PU;PA" + str(p1x) + "," + str( p1y) + ";");
//draw line to spot p2
myPort.write ( "PD;PA" + str(p2x) + "," + str( p2y) + ";PU;");
}
myLine(0, 0, 0, 200);
myLine(0, 200, 200, 200);
myLine(200, 200, 200, 0);
myLine(200, 0, 0, 0);
function myRectangle ( point leftTopPoint, point rightTopPoint, point rightBottomPoint, point leftBottomPoint)
{
myLine(leftTopPoint, rightTopPoint);
myLine(rightTopPoint, rightBottomPoint);
myLine(rightBottomPoint, leftBottomPoint);
myLine(leftBottomPoint, leftTopPoint);
}
float t = 0;
void setup() {
size(400, 400);
stroke(125);
}
void draw() {
while (t<7000){
int x = int(200 + 150 * sin ( t/100 ) );
int y = int(200 + 150 * cos ( t/100 ) );
ellipse(x,y, 2, 2); //plotter point
t++;// counter
}
}
int x ="
into
int x = int(200 + 150 * sin ( t/100 ) * sin ( t/99 ) );
void draw() {
while (t<700){
int x1 = int(100 + 100 * sin ( t/10 ) * sin ( t/15 ) );
int y1 = int(200 + 140 * cos ( t/10 ) );
int x2 = int(300 + 100 * sin ( t/10 ) * sin ( t/15 ) );
int y2 = int(200 + 140 * cos ( t/10 ) );
line(x1,y1, x2, y2); //plotter line
t+=1;// counter }
}
void draw() {
while (t<700){
int x1 = int(100 + 100 * sin ( t/100 ) * sin ( t/15 ) );
int y1 = int(200 + 140 * cos ( t/100 ) );
int x2 = int(300 + 100 * sin ( t/10 ) * sin ( t/15 ) );
int y2 = int(200 + 140 * cos ( t/10 ) );
line(x1,y1, x2, y2); //plotter line
t+=1;// counter
}
}
println( Serial.list() );
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 9600);
myPort.write("PU;");
myLine ( point1, point2 );
void plotterLine(float x1, float y1, float x2, float y2) {
println("plotterline");
myPort.write("PU");
myPort.write("PA" + str(x1) + "," + str(y1) +";");
myPort.write("PD");
myPort.write("PA" + str(x2) + "," + str(y2) +";");
myPort.write("PU");
}
if ( printOnce == 1 ){
float scaleF = 20;
plotterLine ( int(x1*scaleF), int(y1*scaleF), int(x2*scaleF), int(y2*scaleF));
println ( str(x1*scaleF) + " " + str(y1*scaleF) + " " + str(x2*scaleF) + " " + str(y2*scaleF) );
delay(250); //otherwise the commands are coming in to fast
}
<img alt="" class="aligncenter" src="http://www.contrechoc.com/blogPics/plotter/pi10.jpg" title="plotterdesign" width="400" />