mirror of
https://github.com/dyne/FreeJ.git
synced 2026-02-08 22:09:17 +01:00
processing-js 0.4 has been merged in some relevant parts basic and topic scripts added for test color handling fixed, more scripts show up now
39 lines
724 B
Plaintext
39 lines
724 B
Plaintext
int[] x = new int[0];
|
|
int[] y = new int[0];
|
|
|
|
void setup()
|
|
{
|
|
size(200, 200);
|
|
}
|
|
|
|
void draw()
|
|
{
|
|
background(204);
|
|
stroke(0);
|
|
noFill();
|
|
beginShape();
|
|
for (int i = 0; i < x.length; i++) {
|
|
vertex(x[i], y[i]);
|
|
}
|
|
endShape();
|
|
// Show the next segment to be added
|
|
if (x.length >= 1) {
|
|
stroke(255);
|
|
line(mouseX, mouseY, x[x.length-1], y[x.length-1]);
|
|
}
|
|
}
|
|
|
|
void mousePressed() { // Click to add a line segment
|
|
x = append(x, mouseX);
|
|
y = append(y, mouseY);
|
|
}
|
|
|
|
void keyPressed() { // Press a key to save the data
|
|
String[] lines = new String[x.length];
|
|
for (int i = 0; i < x.length; i++) {
|
|
lines[i] = x[i] + "\t" + y[i];
|
|
}
|
|
saveStrings("lines.txt", lines);
|
|
exit(); // Stop the program
|
|
}
|