xxxxxxxxxx
34
function setup() {
createCanvas(400, 400);
noLoop();
}
// treat the rectangle as a large stroke
function draw() {
x1 = random() * width / 2;
x2 = (random() * width / 2) + width / 2;
x3 = (random() * width / 2) + width / 2;
x4 = random() * width / 2;
y1 = random() * (height / 2);
y2 = (random() * (height / 2)) + (height / 2);
y3 = (random() * (height / 2)) + (height / 2);
y4 = random() * (height / 2);
noFill();
quad(x1, y1, x2, y2, x3, y3, x4, y4);
threshold = 10
counter = 1
dx1 = (x4 - x1) / threshold
dx2 = (x3- x2) / threshold
dy1 = (y4 - y1) / threshold
dy2 = (y3 - y2) / threshold
while(counter < 10){
line(x1, y1, x2, y2)
x1 += dx1
x2 += dx2
y1 += dy1
y2 += dy2
counter += 1
}
}