xxxxxxxxxx
73
let ax,ay;
let bx,by;
let cx, cy;
let dx, dy;
//let ex, ey;
let x,y;
let lastR, lastlastR;
let r;
function setup() {
createCanvas(windowWidth, windowHeight);
ax = 0;
ay = 0;
bx = width;
by = 0;
cx = 0;
cy = height;
dx = width;
dy = height;
/*ex = random(width);
ey = random(height);*/
x = random(height)
y = random(width)
lastR = 0;
lastlastR= 0;
background(0);
stroke(255,0,255);
strokeWeight(2);
point(ax,ay);
point(bx,by);
point(cx,cy);
point(dx,dy);
//point(ex,ey);
}
function draw() {
for(let i =0; i<100; i++){
point(x,y);
r = floor(random(4))
while(r == (lastR+1)%4||r == (lastlastR+3)%4) {
r = floor(random(4))
}
if(r == 0){
stroke(255,0,0,80);
x = lerp(x,ax,0.5);
y = lerp(y,ay,0.5);
} else if (r == 1){
stroke(0,255,0,80);
x = lerp(x,cx,0.5);
y = lerp(y,cy,0.5);
} else if (r == 2){
stroke(0,0,255,80);
x = lerp(x,dx, 0.5);
y = lerp(y,dy, 0.5);
} else if (r == 3){
stroke(0,255,255,80);
x = lerp(x,bx,0.5);
y = lerp(y,by,0.5);
}
/* else if (r == 4){
stroke(255,80);
x = lerp(x,dx, 0.5);
y = lerp(y,dy, 0.5);
}*/
lastlastR = lastR;
lastR = r;
}
}