xxxxxxxxxx
69
let amplitude;
let amplitudeMin = 10;
let amplitudeMax = 200;
let period;
let periodMin = 40;
let periodMax = 300;
let shiftX;
let shiftY;
let dotRadiusMin = 1;
let dotRadiusMax = 1;
let powerBase = 1.02;
let x = 0;
let y = 0;
let done = false;
function setup()
{
createCanvas(400, 400);
fill(40);
Begin();
}
function keyPressed()
{
if (keyCode === 32)
Begin();
}
function draw()
{
if (done === true)
return;
for (y = 0; y < height; ++y)
{
let sine = amplitude * sin((x + shiftX) * TAU / period) + shiftY;
let distance = abs(y - sine);
let alpha = pow(powerBase, -distance);
stroke(alpha * 250, alpha * 180, alpha * 50);
strokeWeight( (dotRadiusMax - dotRadiusMin) * pow(Math.random(), 3) + dotRadiusMin);
point(x, y);
}
++x;
if (x >= width)
{
done = true;
}
}
function Begin()
{
blendMode(BLEND);
background(40);
blendMode(ADD);
amplitude = (amplitudeMax - amplitudeMin) * Math.random() + amplitudeMin;
period = (periodMax - periodMin) * Math.random() + periodMin;
shiftX = Math.random() * period;
shiftY = Math.random() * height;
x = 0;
y = 0;
done = false;
}