canvas-confetti
Advanced tools
Comparing version
@@ -1,2 +0,2 @@ | ||
// canvas-confetti v1.5.1 built on 2022-02-08T22:20:40.944Z | ||
// canvas-confetti v1.6.0 built on 2022-10-24T21:26:41.619Z | ||
!(function (window, module) { | ||
@@ -145,3 +145,3 @@ // source content | ||
' } else if (msg.data.reset) {', | ||
' CONFETTI.reset();', | ||
' CONFETTI && CONFETTI.reset();', | ||
' } else if (msg.data.resize) {', | ||
@@ -341,2 +341,22 @@ ' SIZE.width = msg.data.resize.width;', | ||
ellipse(context, fetti.x, fetti.y, Math.abs(x2 - x1) * fetti.ovalScalar, Math.abs(y2 - y1) * fetti.ovalScalar, Math.PI / 10 * fetti.wobble, 0, 2 * Math.PI); | ||
} else if (fetti.shape === 'star') { | ||
var rot = Math.PI / 2 * 3; | ||
var innerRadius = 4 * fetti.scalar; | ||
var outerRadius = 8 * fetti.scalar; | ||
var x = fetti.x; | ||
var y = fetti.y; | ||
var spikes = 5; | ||
var step = Math.PI / spikes; | ||
while (spikes--) { | ||
x = fetti.x + Math.cos(rot) * outerRadius; | ||
y = fetti.y + Math.sin(rot) * outerRadius; | ||
context.lineTo(x, y); | ||
rot += step; | ||
x = fetti.x + Math.cos(rot) * innerRadius; | ||
y = fetti.y + Math.sin(rot) * innerRadius; | ||
context.lineTo(x, y); | ||
rot += step; | ||
} | ||
} else { | ||
@@ -343,0 +363,0 @@ context.moveTo(Math.floor(fetti.x), Math.floor(fetti.y)); |
{ | ||
"name": "canvas-confetti", | ||
"version": "1.5.1", | ||
"version": "1.6.0", | ||
"description": "performant confetti animation in the browser", | ||
@@ -5,0 +5,0 @@ "main": "src/confetti.js", |
@@ -74,3 +74,3 @@ # [](https://github.com/catdad/canvas-confetti/) | ||
- `colors` _Array<String>_: An array of color strings, in the HEX format... you know, like `#bada55`. | ||
- `shapes` _Array<String>_: An array of shapes for the confetti. The possible values are `square` and `circle`. The default is to use both shapes in an even mix. You can even change the mix by providing a value such as `['circle', 'circle', 'square']` to use two third circles and one third squares. | ||
- `shapes` _Array<String>_: An array of shapes for the confetti. The possible values are `square`, `circle`, and `star`. The default is to use both squares and circles in an even mix. To use a single shape, you can provide just one shape in the array, such as `['star']`. You can also change the mix by providing a value such as `['circle', 'circle', 'square']` to use two third circles and one third squares. | ||
- `scalar` _Number (default: 1)_: Scale factor for each confetti particle. Use decimals to make the confetti smaller. Go on, try teeny tiny confetti, they are adorable! | ||
@@ -77,0 +77,0 @@ - `zIndex` _Integer (default: 100)_: The confetti should be on top, after all. But if you have a crazy high page, you can set it even higher. |
@@ -142,3 +142,3 @@ (function main(global, module, isWorker, workerSize) { | ||
' } else if (msg.data.reset) {', | ||
' CONFETTI.reset();', | ||
' CONFETTI && CONFETTI.reset();', | ||
' } else if (msg.data.resize) {', | ||
@@ -338,2 +338,22 @@ ' SIZE.width = msg.data.resize.width;', | ||
ellipse(context, fetti.x, fetti.y, Math.abs(x2 - x1) * fetti.ovalScalar, Math.abs(y2 - y1) * fetti.ovalScalar, Math.PI / 10 * fetti.wobble, 0, 2 * Math.PI); | ||
} else if (fetti.shape === 'star') { | ||
var rot = Math.PI / 2 * 3; | ||
var innerRadius = 4 * fetti.scalar; | ||
var outerRadius = 8 * fetti.scalar; | ||
var x = fetti.x; | ||
var y = fetti.y; | ||
var spikes = 5; | ||
var step = Math.PI / spikes; | ||
while (spikes--) { | ||
x = fetti.x + Math.cos(rot) * outerRadius; | ||
y = fetti.y + Math.sin(rot) * outerRadius; | ||
context.lineTo(x, y); | ||
rot += step; | ||
x = fetti.x + Math.cos(rot) * innerRadius; | ||
y = fetti.y + Math.sin(rot) * innerRadius; | ||
context.lineTo(x, y); | ||
rot += step; | ||
} | ||
} else { | ||
@@ -340,0 +360,0 @@ context.moveTo(Math.floor(fetti.x), Math.floor(fetti.y)); |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
66321
3.03%1578
3.54%0
-100%