Snowflake style body background color rgb 200 200 200 min height 600px canvas margin auto style script src https cdnjs cloudflare com ajax libs p5 js 0 7 1 p5 min js script script const count 17 let flakes let bgCol function setup createCanvas windowWidth windowHeight stroke 255 strokeWeight 1 bgCol color 20 0 10 255 for let i 0 i count i flakes i flakes i n 12 initFlake i flakes i pos x random width flakes i pos y random height function draw background bgCol for let i 0 i flakes length i push translate flakes i pos x flakes i pos y rotate frameCount flakes i rotspeed for let j 0 j 100 100 flakes i r 2 5 j let next random flakes i points if flakes i allowPp true next flakes i previous flakes i current x lerp flakes i current x next x flakes i percent flakes i current y lerp flakes i current y next y flakes i percent point flakes i current x flakes i current y flakes i previous next pop flakes i pos y flakes i speed flakes i pos x noise flakes i noiseSd 3 1 4 flakes i noiseSd 0 005 if flakes i pos y height flakes i r flakes i multVal initFlake i function initFlake i flakes i r random 10 25 flakes i percent random 0 68 0 84 flakes i multVal random 1 1 2 2 flakes i points initPoints flakes i n flakes i r flakes i multVal flakes i pos createVector random width 3 width 3 2 flakes i r flakes i multVal flakes i current createVector flakes i previous createVector flakes i allowPp getBool 5 flakes i speed random 5 1 5 flakes i rotspeed random 20 150 flakes i noiseSd random 1 1000 flakes i points initPoints flakes i n flakes i r flakes i multVal if getBool 5 flakes i rotspeed flakes i rotspeed if getBool 5 flakes i percent 2 flakes i percent function initPoints n r m let tmpArr for let i 0 i n i let angle i TWO_PI n let v p5 Vector fromAngle angle if i 2 0 v mult r else v mult r m tmpArr push v return tmpArr function getBool p if random p return true else return false console log ready script
es i noiseSd 3 1 4 flakes i noiseSd 0 005 if flakes i pos y height flakes i r flakes i multVal initFlake i function initFlake i flakes i r random 10 25 flakes i percent random 0 68 0 84 flakes i multVal random 1 1 2 2 flakes i points initPoints flakes i n flakes i r flakes i multVal flakes i pos createVector random width 3 width 3 2 flakes i r flakes i multVal flakes i current createVector flakes i previous createVector flakes i allowPp getBool 5 flakes i speed random 5 1 5 flakes i rotspeed random 20 150 flakes i noiseSd random 1 1000 flakes i points initPoints flakes i n flakes i r flakes i multVal if getBool 5 flakes i rotspeed flakes i rotspeed if getBool 5 flakes i percent 2 flakes i percent function initPoints n r m let tmpArr for let i 0 i n i let angle i TWO_PI n let v p5 Vector fromAngle angle if i 2 0 v mult r else v mult r m tmpArr push v return tmpArr function getBool p if random p return true else return false console log ready script