xxxxxxxxxx
63
let pts;
let gfx;
function setup() {
createCanvas(1000, 1000, WEBGL);
gfx = createGraphics(width, height);
background(220);
gfx.background(0);
pts = [];
let low = 0.01 * width;
let high = 0.25 * width;
for (let y = 0; y < height; y++) {
let num = map(y, 0, height, low, high);
for (let _ = 0; _ < num; _++) {
let _c = random(20,140);
pts.push({
x: random(width),
y: y + random(-1, 1),
c: color(
_c,//random(10, 80),
_c,//random(10, 80),
_c,//random(10, 80),
random(60, 120)
),
});
}
}
}
let step = 0;
function draw() {
translate(-width/2, -height/2);
for (let _ = 0; _ < 5; _++) {
if (step == 0) {
let idx = min(100, pts.length - 1);
for (let i = idx; i >= 0; i--) {
gfx.stroke(pts[i].c);
gfx.point(pts[i].x, pts[i].y);
pts.splice(i, 1);
}
if (pts.length == 0) {
console.log("0 done");
image(gfx, 0, 0);
step++;
}
} else {
push();
lightFalloff(1, 0, 0);
translate(width/2, height/2)
fill(color(20, 20, 20, 80));
noStroke();
// stroke(color(40))
// directionalLight(250,0,0, 0, 0, -1);
pointLight(250, 0, 0, 0, 0/*width*0.55, height*0.55*/, 25);//25);
sphere(width/4, 24, 24);
pop();
noLoop();
}
}
}