xxxxxxxxxx
90
let numFrames = 300;
let radius = 15.5;
let frameCtr = 0;
let x, y;
let particles = [];
function setup() {
createCanvas(800, 800);
pixelDensity(1);
noiseDetail(8,0.55);
x = int(0);
y = int(height/2);
// let _r = width*0.25;
// for (let _ = 0; _ < 1000; _++) {
// particles.push({
// x:
// })
// }
noStroke();
fill(220);
}
function draw() {
background(color(20,20,20,10));
let t = 1.0 * frameCtr/numFrames;
let s = 0.02;
// loadPixels();
// for (let y = 0; y < height; y++) {
// for (let x = 0; x < width; x++) {
// let n = noise(s*x, s*y, radius*cos(TWO_PI*t), radius*sin(TWO_PI*t));
// let col = map(n, 0.0, 1.0, 0, 255);
// const idx = 4 * pixelDensity() * (int(y) * pixelDensity() * width + int(x));
// pixels[idx] = col;
// pixels[idx+1] = col;
// pixels[idx+2] = col;
// pixels[idx+3] = 255;
// }
// }
// updatePixels();
// rectMode(CENTER);
// let y = height / 2;
// for (let x = 10; x < width; x += 20) {
// let n = noise(s*x, s*y, radius*cos(TWO_PI*t), radius*sin(TWO_PI*t));
// let h = map(n, 0.0, 1.0, 1,height/2);
// rect(x,y,20,h);
// }
rectMode(CENTER);
let w = 20;
let hw = w/2;
for (let y = hw; y < height; y += w) {
for (let x = hw; x < width; x += w) {
let n = noise(s*x, s*y, radius*cos(TWO_PI*t), radius*sin(TWO_PI*t));
let _s = map(n, 0.0, 1.0, 0, w);
square(x,y,_s);
}
}
// let y = height/2;
// beginShape();
// for (let x = 0; x < width; x+=15) {
// let n = noise(s*x, s*y, radius*cos(TWO_PI*t), radius*sin(TWO_PI*t));
// let a = map(n, 0.0, 1.0, -height/4, height/4);
// let _y = y + a * cos(x);
// vertex(x, _y);
// }
// endShape();
// circle(width/2,height/2, map(n, 0.0, 1.0, 1, 100));
frameCtr++;
if (frameCtr > numFrames) {
// frameCtr = 0;
// saveGif("loop.gif",numFrames);
noLoop();
}
}
function keyPressed() {
if (key == "s") saveGif("loop.gif", (numFrames/30)-1);
}