Particles 1
This particle system is made of particles that meaner between going left and right based on a sine function.
Press and hold to queue a burst of new particles.
Could you make money selling that? Friend I showed this to
Yeah, but I like open-source / open art. Maybe I can sell the service of making custom lock screens or such instead? 🤔 My reply
function setup() {
createCanvas(windowWidth, windowHeight);
angleMode(DEGREES)
background(0);
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
background(0);
}
let o = new Set()
let p = 0
function draw() {
background(40, 10, 0, 10);
noStroke()
translate(width/2, height/2)
let tx = mouseX-width/2, ty = mouseY-height/2
fill(200, 255, 201)
for (let e of o) {
let s = cos(e.l * 4) + 1
e.x += cos(e.a) * s
e.y += sin(e.a) * s
e.a += sin(e.l * 11) * s * 4
e.x += cos(e.a) * s
e.y += sin(e.a) * s
let td = dist(tx, ty, e.x, e.y) + 6
e.l ++
push()
translate(e.x, e.y)
rotate(e.a)
ellipse(0, 0, 10, 5)
pop()
if (abs(e.x) > width/2 + 50 || abs(e.y) > height/2 + 50) {
o.delete(e)
}
}
if (keyIsDown(32) || touches.length) {
p+=2
}
p+=0.5
if (mouseIsPressed) {
circle(0, 0, pow(p, 0.6) + 10)
p+=0.5
} else {
while (p > 0) {
o.add({x: 0, y: 0, a: random(360), l: random(360)})
p --
}
}
}(Originally seen at https://editor.p5js.org/bojidar-bg/sketches/tNcUGWzNY)
Browse more articles?
← Drifting car Experiments tagged p5 (13/85) Electric streaks →
|← Experiments tagged particles (1/3) Particle automata →
← Drifting car Experiments on this site (13/85) Electric streaks →