random line between two given points
in
Programming Questions
•
2 years ago
hi. i'm still quite a beginner here and have a little question.
i have a code here which draws a random line (thank you amnon.owed for the code!) now i would like it to start at a given point (i've figured that out) and also to end at another given point. suggestions, anybody?
here's the code for the random line:
float px,py;
void setup() {
size(960,640);
smooth();
background(255);
frameRate(10);
px = width/2;
py = height/2;
}
void draw() {
float x = px + random(-50,50);
float y = py + random(-50,50);
line(px,py,x,y);
px = x;
py = y;
}
i have a code here which draws a random line (thank you amnon.owed for the code!) now i would like it to start at a given point (i've figured that out) and also to end at another given point. suggestions, anybody?
here's the code for the random line:
float px,py;
void setup() {
size(960,640);
smooth();
background(255);
frameRate(10);
px = width/2;
py = height/2;
}
void draw() {
float x = px + random(-50,50);
float y = py + random(-50,50);
line(px,py,x,y);
px = x;
py = y;
}
1