xxxxxxxxxx
36
let x;
let y;
function setup() {
createCanvas(400, 400);
x = 200;
y = 200;
background(0,0,0);
for (let i = 0; i < 100000; i++) {
draw();
}
}
function draw() {
//background(220);
stroke(random(255),random(255),random(255));
strokeWeight(5);
let randomValue = random();
if (randomValue < 0.25) {
x-=5; // x -= 1
}
else if (randomValue < 0.5) {
x+=5; // x += 1
}
else if (randomValue < 0.75) {
y-=5;
}
else {
y+=5;
}
point(x, y);
if (x > 400) {
x = 200
}
if (y > 400) {
y = 200;
}
}