xxxxxxxxxx
let simplex
let dust=[]
let gravity
function preload(){
font= loadFont('FamiljenGrotesk-VariableFont_wght.ttf')
}
function setup() {
createCanvas(400, 400);
gravity= createVector(0, 0.01)
simplex= new openSimplexNoise(Date.now())
background('#f4f1de')
}
function draw(){
for(let i=0; i<6; i++){
dust.push(new particle(59, random(60, 340)))
}
for(let p of dust){
p.move()
p.show()
p.off()
}
fill('#f4f1de')
noStroke()
rect(0, 0, width, 60)
rect(0, 0, 60, height)
rect(340, 0, 60, height)
rect(0, 340, width, 60)
noFill()
stroke(100)
textFont(font)
fill(100)
strokeWeight(1)
stroke(100)
text('1.18', 20, 380)
}
class particle{
constructor(x, y){
this.pos= createVector(x, y)
this.vel= createVector( random(0.1), random(-0.1, 0.1))
}
move(){
let windA= map(simplex.noise3D(this.pos.x/70, this.pos.y/100, frameCount/200), -1, 1, -HALF_PI, HALF_PI)
let windMag= map(simplex.noise3D(this.pos.x/70, this.pos.y/100, frameCount/150), -1, 1, 0, 0.04)
let wind= p5.Vector.fromAngle(windA)
wind.setMag(windMag)
this.vel.add(wind)
this.vel.add(gravity)
this.vel.limit(1)
this.pos.add(this.vel)
}
show(){
blendMode(MULTIPLY)
stroke(100, 15)
strokeWeight(0.5)
point(this.pos.x, this.pos.y)
blendMode(BLEND)
}
off(){
if(this.pos.x>340){
let index= dust.indexOf(this)
dust.splice(index, 1)
}
}
}