xxxxxxxxxx
38
const tileSize = 1;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(0);
noStroke()
for (let y = 0; y < 400; y+=tileSize) {
for (let x = 0; x < 400; x+=tileSize) {
const uv = new Vec2(
x / width ,
y / height
);
const d = circ(uv, .5);
fill(255*d);
rect(x, y, tileSize);
}
}
noLoop();
}
function circ(uv, radius) {
const dist = Vec2.sub(uv, new Vec2(.5));
const sqrDist = Vec2.dot(dist, dist)
const sqrRadius = radius*radius
const edgeSize = (sqrRadius * 0.01)
return 1- math.smoothStep(sqrRadius-edgeSize,sqrRadius+edgeSize, sqrDist)
}