xxxxxxxxxx
123
let x1;
let y1;
let x1Direction;
let y1Direction;
let x2;
let y2;
let x2Direction;
let y2Direction;
let x3;
let y3;
let x3Direction;
let y3Direction;
let x4;
let y4;
let x4Direction;
let y4Direction;
let _x2;
let _y2;
let _x2Direction;
let _y2Direction;
let _x3;
let _y3;
let _x3Direction;
function setup() {
createCanvas(400, 400);
frameRate(60);
x1 = floor(random(width));
y1 = floor(random(height));
x1Direction = 1*4;
y1Direction = -1;
x2 = floor(random(width));;
y2 = floor(random(height));;
x2Direction = 1;
y2Direction = 1;
x3 = floor(random(width));
y3 = floor(random(height));
x3Direction = 1*3;
y3Direction = 1;
x4 = floor(random(width));
y4 = floor(random(height));
x4Direction = -1;
y4Direction = 1*2;
_x2Direction = 1;
_y2Direction = -1;
_x2 = floor(random(width));
_y2 = floor(random(height));
_x3 = floor(random(width));
_y3 = floor(random(height));
_x3Direction = 1;
_y3Direction = 1;
}
function draw() {
background("#222222");
noFill();
stroke("#00fbe1");
strokeWeight(2);
// line(85, 20, 10, 10);
// line(90, 90, 15, 80);
x1 += x1Direction;
if (x1 > width || x1 < 0) {
x1Direction = -x1Direction;
}
y1 += y1Direction;
if (y1 > height || y1 < 0) {
y1Direction = -y1Direction;
}
x2 += x2Direction;
if (x2 > width || x2 < 0) {
x2Direction = -x2Direction;
}
y2 += y2Direction;
if (y2 > height || y2 < 0) {
y2Direction = -y2Direction;
}
x3 += x3Direction;
if (x3 > width || x3 < 0) {
x3Direction = -x3Direction;
}
y3 += y3Direction;
if (y3 > height || y3 < 0) {
y3Direction = -y3Direction;
}
x4 += x4Direction;
if (x4 > width || x4 < 0) {
x4Direction = -x4Direction;
}
y4 += y4Direction;
if (y4 > height || y4 < 0) {
y4Direction = -y4Direction;
}
_x2 += _x2Direction;
if (_x2 > width || _x2 < 0) {
_x2Direction = -_x2Direction;
}
_y2 += _y2Direction;
if (_y2 > height || _y2 < 0) {
_y2Direction = -_y2Direction;
}
_x3 += _x3Direction;
if (_x3 > width || _x3 < 0) {
_x3Direction = -_x3Direction;
}
_y3 += -y3Direction;
if (_y3 > height || _y3 < 0) {
_y3Direction = -_y3Direction;
}
bezier(x1, y1, x2, y2, x3, y3, x4, y4);
bezier(x4, y4, _x2, _y2, _x3, _y3, x1, y1);
}