xxxxxxxxxx
let rScale
let xScale
let yScale
let xOutScale, yOutScale
let rotation
let bg = "#fff1dd"
let fg
const colors = ["#294984", "#6ca0a7", "#ffc789", "#df5f50", "#5a3034"]
function setup() {
createCanvas(windowWidth, windowHeight)
updateParams()
}
function updateParams() {
background(bg)
fg = random(colors)
rScale = pow(random(0.001, 0.1), 1.8)
xScale = random(0.5, 2)
yScale = random(0.5, 2)
rotation = random(-1, 1)
xOutScale = pow(random(1), 1.7)
yOutScale = pow(random(1), 1.7)
}
function draw() {
const perFrame = 10000
const f = frameCount % (1000000/perFrame + 60*2)
if (f === 0) updateParams()
if (f > 1000000/perFrame) return
strokeWeight(1)
stroke(fg)
for (let i = 0; i < perFrame; i++) {
const pt = createVector(
randomGaussian(width/2, width/6),
randomGaussian(height/2, height/6),
)
pt.x += height*xOutScale*sin(pt.y/height*TWO_PI*xScale)
pt.x -= width/2
pt.y -= height/2
pt.rotate(TWO_PI*rotation)
let a = Math.atan2(pt.y, pt.x)
let r = Math.hypot(pt.x, pt.y)
a += r * rScale
pt.x = r*Math.cos(a)
pt.y = r*Math.sin(a)
pt.x += width/2
pt.y += height/2
pt.y += height*yOutScale*sin(pt.x/width*TWO_PI*yScale)
point(pt.x, pt.y)
}
}