We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everyone! I'm trying to make random lines that grows one after another. I got this far:
int xrand = 300;
int yrand = 300;
int py = 0;
int px = 0;
int x;
int y;
void setup () {
size (500,500);
smooth();
}
void draw () {
if (x<xrand) {
x = x + 1;
} else if (x>xrand) {
x = x - 1;
} else {
px = x;
xrand = (int) random(0,width);
}
if (y<yrand) {
y = y + 1;
} else if (y>yrand) {
y = y - 1;
} else {
py = y;
yrand = (int) random(0,height);
}
line (px,py,x,y);
}
void mousePressed () {
println(xrand,yrand,px,py,x,y);
}
The problem is that when the lines are growing they're drawing "every single step" but i only want the straight line. Anyone know how to solve it? Thanks!!
Answers
Like this?
Thanks Ater! Kind of... i want that with processing drawing the lines little by little and not all of sudden. That's why i put the
x = x + 1;
Maybe i misspelled the problem: i didn't want the "between lines" when i was drawing the random lines. Those "between line" are drawing shapes and i only want the
line(px,py,x,y);
How can i solve it?
look at lerp() to make a line grow slowly...