Skip to content

Instantly share code, notes, and snippets.

@qcgm1978
Created April 29, 2019 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qcgm1978/e367d1c1114f7ad8f1006740e4d76abf to your computer and use it in GitHub Desktop.
Save qcgm1978/e367d1c1114f7ad8f1006740e4d76abf to your computer and use it in GitHub Desktop.
Confetti WIP DEMO
<p>Copy from <a href='https://twitter.com/Una/status/1122555800264814592/photo/1' target='_blank'>Una's twitter</a></p>
const confettiWeight=getRandom(minWeight,maxWeight)
// Set Color
const hue=getRandom(0,360)
const sat=getRandom(90,100)
const light=getRandom(50,100)
const color=`hsl(${hue}deg, ${sat}%, ${light}%)`
// Set Paint Info
ctx.lineWidth=confettiWeight
ctx.strokeStyle=color
// Calculate New Position
const angle=getRandom(0,89)
const hypotenuse=confettiLength
const newX=x+Math.cos(angle)*hypotenuse
const newY=y+Math.sin(angle)*hypotenuse
console.log(` (${Math.round(x)},${Math.round(y)})(${Math.round(newX)},${Math.round(newY)})
hypotenuse: ${hypotenuse}
angle: ${angle}`
)
// Paint
// ctx rotate...Random(-90,90) * Math.PI / 180);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment