xxxxxxxxxx
let rows, cols;
let s = 16;
let points = [];
function setup()
{
createCanvas(windowWidth, windowHeight);
background(255);
rows = int(height/s);
cols = int(width/s);
for(let i = 0; i < (rows + 3); i++)
{
let aux = [];
for(let j = 0; j < (cols + 3); j++)
{
aux.push(createVector((j*s-s)+random(-s*0.5, s*0.5),(i*s-s)+random(-s*0.5, s*0.5)));
}
points.push(aux);
}
stroke(0,100,255, 200);
for(let i = 0; i < (rows + 2); i+=3)
{
for(let j = 0; j < (cols + 2); j++)
{
line((points[i][j].x+points[i+1][j].x)*0.5, (points[i][j].y+points[i+1][j].y)*0.5,
(points[i][j+1].x+points[i+1][j+1].x)*0.5, (points[i][j+1].y+points[i+1][j+1].y)*0.5);
}
}
noStroke();
for(let i = 0; i < (rows + 2); i++)
{
for(let j = 0; j < (cols + 2); j++)
{
fill(0,0,0,int(random(10))*2);
quad(points[i][j].x, points[i][j].y,
points[i][j+1].x, points[i][j+1].y,
points[i+1][j].x, points[i+1][j].y,
points[i+1][j+1].x, points[i+1][j+1].y);
}
}
}
function drawLine(xo, yo, xf, yf)
{
noStroke();
let dx = (xf-xo);
let dy = (yf-yo);
let incX = 0.7;
let incY = 0.7;
let xRight = true;
let yRight = true;
if (xo > xf)
{
incX *= -1;
xRight = false;
}
if (yo > yf)
{
incY *= -1;
yRight = false;
}
let x = xo+incX;
let y = yo+incY;
while((x < xf) == xRight || (y < yf) == yRight)
{
fill(0,100,255, random(100,200));
circle(x, y, random(1,3));
x += incX;
y += incY;
}
}