Created
April 29, 2019 05:35
-
-
Save qcgm1978/e367d1c1114f7ad8f1006740e4d76abf to your computer and use it in GitHub Desktop.
Confetti WIP DEMO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>Copy from <a href='https://twitter.com/Una/status/1122555800264814592/photo/1' target='_blank'>Una's twitter</a></p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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