Skip to content

Commit

Permalink
Release v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tswaters committed Feb 19, 2024
1 parent 45d0a09 commit 83a4b3b
Show file tree
Hide file tree
Showing 8 changed files with 1,662 additions and 2,691 deletions.
5 changes: 5 additions & 0 deletions CHANGES.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 3.0.0

- Update all dev depencencies.
- BREAKING: Now using named export, `Fireworks` instead of default export.

## 2.6.2

- Add `height` and `width` properties to `FireworksOptions` typescript definition
Expand Down
17 changes: 5 additions & 12 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ npm install --save fireworks-canvas
## usage

```js
import * as Fireworks from 'fireworks-canvas' // mjs
import { Fireworks } from 'fireworks-canvas' // mjs

const Fireworks = require('fireworks-canvas') // cjs
const { Fireworks } = require('fireworks-canvas') // cjs

requirejs(['Fireworks'], Fireworks => {}) // amd
requirejs(['Fireworks'], ({ Fireworks }) => {}) // amd

const Fireworks = window.Fireworks // browser global
const { Fireworks } = window.Fireworks // browser global

// needs at least a container element, you can provide options
// (options are optional, defaults defined below)
Expand Down Expand Up @@ -61,14 +61,7 @@ fireworks.onFinish(() => container.remove()) // callback when the last firework
## usage with typscript

```ts
import * as FireworksCanvas from 'fireworks-canvas'
const fireworks = new FireworksCanvas(container)
```

OR

```ts
import FireworksCanvas = require('fireworks-canvas')
import { Fireworks } from 'fireworks-canvas'
const fireworks = new FireworksCanvas(container)
```

Expand Down
2 changes: 1 addition & 1 deletion fireworks.node.js → fireworks.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,4 @@ class Fireworks {
}
}

module.exports = Fireworks;
exports.Fireworks = Fireworks;
53 changes: 30 additions & 23 deletions fireworks.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define('Fireworks', factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Fireworks = factory());
}(this, (function () { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define('Fireworks', ['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Fireworks = {}));
})(this, (function (exports) { 'use strict';

/*! *****************************************************************************
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
Expand All @@ -18,6 +18,8 @@
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol */


var __assign = function() {
__assign = Object.assign || function __assign(t) {
Expand All @@ -40,7 +42,12 @@
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
}

typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};

function random(min, max) {
return Math.random() * (max - min) + min;
Expand All @@ -56,7 +63,7 @@
if (this.isRocket) {
this.velocity = {
x: random(-3, 3),
y: random(-7, -3)
y: random(-7, -3),
};
this.shrink = 0.999;
this.resistance = 1;
Expand All @@ -66,7 +73,7 @@
var speed = Math.cos(random(0, TAU)) * 15;
this.velocity = {
x: Math.cos(angle) * speed,
y: Math.sin(angle) * speed
y: Math.sin(angle) * speed,
};
this.shrink = random(0, 0.05) + 0.93;
this.resistance = 0.92;
Expand All @@ -82,10 +89,10 @@
return new Particle({
position: {
x: this.position.x,
y: this.position.y
y: this.position.y,
},
hue: this.hue,
brightness: this.brightness
brightness: this.brightness,
});
};
Particle.prototype.shouldRemove = function (cw, ch) {
Expand Down Expand Up @@ -130,7 +137,7 @@
ctx.lineTo(this.position.x, this.position.y);
ctx.lineWidth = this.size;
ctx.lineCap = 'round';
ctx.strokeStyle = "hsla(" + this.hue + ", 100%, " + this.brightness + "%, " + this.alpha + ")";
ctx.strokeStyle = "hsla(".concat(this.hue, ", 100%, ").concat(this.brightness, "%, ").concat(this.alpha, ")");
ctx.stroke();
};
return Particle;
Expand Down Expand Up @@ -161,8 +168,8 @@
this._set.clear();
this.rockets = 0;
};
Things.prototype["delete"] = function (thing) {
this._set["delete"](thing);
Things.prototype.delete = function (thing) {
this._set.delete(thing);
if (thing.isRocket)
this.rockets--;
};
Expand All @@ -173,15 +180,15 @@
for (var i = 0; i < this.numParticles; i += 1) {
this.add(particle.clone());
}
this["delete"](particle);
this.delete(particle);
};
Things.prototype.spawnRocket = function () {
this.rockets++;
var cannonIndex = Math.floor(random(0, this.cannons.length));
var cannon = this.cannons[cannonIndex] || {};
this.add(new Particle({
isRocket: true,
position: __assign(__assign(__assign({}, cannon), (cannon.x == null && { x: random(0, this.cw) })), (cannon.y == null && { y: this.ch }))
position: __assign(__assign(__assign({}, cannon), (cannon.x == null && { x: random(0, this.cw) })), (cannon.y == null && { y: this.ch })),
}));
};
Things.prototype.spawnRockets = function () {
Expand Down Expand Up @@ -214,7 +221,7 @@
cw: this.cw,
ch: this.ch,
rocketInitialPoint: rocketInitialPoint,
cannons: cannons
cannons: cannons,
});
this.updateDimensions();
}
Expand All @@ -234,8 +241,8 @@
Fireworks.prototype.updateDimensions = function () {
this.canvas.width = this.cw * this.pixelRatio;
this.canvas.height = this.ch * this.pixelRatio;
this.canvas.style.width = this.cw + "px";
this.canvas.style.height = this.ch + "px";
this.canvas.style.width = "".concat(this.cw, "px");
this.canvas.style.height = "".concat(this.ch, "px");
this.ctx.scale(this.pixelRatio, this.pixelRatio);
this.things.cw = this.cw;
this.things.ch = this.ch;
Expand Down Expand Up @@ -273,7 +280,7 @@
Fireworks.prototype._clear = function (force) {
if (force === void 0) { force = false; }
this.ctx.globalCompositeOperation = 'destination-out';
this.ctx.fillStyle = "rgba(0, 0, 0 " + (force ? '' : ', 0.5') + ")";
this.ctx.fillStyle = "rgba(0, 0, 0 ".concat(force ? '' : ', 0.5', ")");
this.ctx.fillRect(0, 0, this.cw, this.ch);
this.ctx.globalCompositeOperation = 'lighter';
};
Expand All @@ -292,7 +299,7 @@
particle.draw(this.ctx);
particle.update();
if (particle.shouldRemove(this.cw, this.ch)) {
this.things["delete"](particle);
this.things.delete(particle);
}
else if (particle.shouldExplode(this.maxH, this.minH, this.chance)) {
this.things.explode(particle);
Expand All @@ -302,7 +309,7 @@
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
Expand All @@ -316,6 +323,6 @@
return Fireworks;
}());

return Fireworks;
exports.Fireworks = Fireworks;

})));
}));
Loading

0 comments on commit 83a4b3b

Please sign in to comment.