Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve scale/alpha/color behavoirs #208

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ npm install @pixi/particle-emitter
* [Snow](https://pixijs.github.io/particle-emitter/examples/snow.html)
* [Sparks](https://pixijs.github.io/particle-emitter/examples/sparks.html)
* [Fountain](https://pixijs.github.io/particle-emitter/examples/fountain.html)
* [Confetti](https://pixijs.github.io/particle-emitter/examples/confetti.html)
* [Animated Coins](https://pixijs.github.io/particle-emitter/examples/coins.html)
* [Animated Bubbles](https://pixijs.github.io/particle-emitter/examples/animatedBubbles.html)
* [Spaceship Destruction - Ordered Art](https://pixijs.github.io/particle-emitter/examples/spaceshipDestruction.html)
Expand Down
84 changes: 48 additions & 36 deletions docs/examples/bubbles.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Bubbles</title>
<meta name="description" content="bubble emitter">
<link rel="stylesheet" href="css/main.css">
<meta name="description" content="bubble emitter" />
<link rel="stylesheet" href="css/main.css" />

<!-- Required dependencies -->
<script src="libs/pixi.js/dist/browser/pixi.js"></script>
<script src="../dist/particle-emitter.js"></script>

<!-- Example scaffolding -->
<script src="js/ParticleExample.js"></script>

</head>
<body>
<div id="framerate"></div>
<div id="instructions">Click Anywhere</div>
<canvas id="stage" width="400" height="400"></canvas>
<script>

// See js/ParticleExample.js for actual setup
new ParticleExample(
// The image to use
Expand All @@ -31,33 +29,39 @@
{
"lifetime": {
"min": 4,
"max": 4
"max": 4,
},
"frequency": 0.016,
"emitterLifetime": 0,
"maxParticles": 500,
"addAtBack": false,
"pos": {
"x": 0,
"y": 0
"y": 0,
},
"behaviors": [
{
"type": "alphaStatic",
"config": {
"alpha": { "min": 0.5, "max": 1 },
},
},
{
"type": "alpha",
"config": {
"alpha": {
"list": [
{
"time": 0,
"value": 1
"value": 1,
},
{
"time": 1,
"value": 0.22
}
]
}
}
"value": 0.2,
},
],
},
},
},
{
"type": "moveSpeed",
Expand All @@ -66,15 +70,22 @@
"list": [
{
"time": 0,
"value": 200
"value": 200,
},
{
"time": 1,
"value": 50
}
]
}
}
"value": 50,
},
],
},
},
},
{
"type": "scaleStatic",
"config": {
"min": 0.5,
"max": 1,
},
},
{
"type": "scale",
Expand All @@ -83,16 +94,16 @@
"list": [
{
"time": 0,
"value": 0.25
"value": 0.25,
},
{
"time": 1,
"value": 0.75
}
]
"value": 0.75,
},
],
},
"minMult": 0.5
}
"minMult": 0.5,
},
},
{
"type": "rotation",
Expand All @@ -101,23 +112,24 @@
"minSpeed": 0,
"maxSpeed": 10,
"minStart": 0,
"maxStart": 360
}
"maxStart": 360,
},
},
{
"type": "textureRandom",
"config": {
"textures": [
"images/Bubbles99.png"
]
}
"images/Bubbles99.png"
],
},
},
{
"type": "spawnPoint",
"config": {}
}
]
});
"config": {},
},
],
}
);
</script>
</body>
</html>
</html>
122 changes: 122 additions & 0 deletions docs/examples/confetti.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Confetti</title>
<meta name="description" content="confetti emitter" />
<link rel="stylesheet" href="css/main.css" />

<!-- Required dependencies -->
<script src="libs/pixi.js/dist/browser/pixi.js"></script>
<script src="../dist/particle-emitter.js"></script>

<!-- Example scaffolding -->
<script src="js/ParticleExample.js"></script>
</head>
<body>
<div id="framerate"></div>
<div id="instructions">Click Anywhere</div>
<canvas id="stage" width="400" height="400"></canvas>
<script>
// See js/ParticleExample.js for actual setup
new ParticleExample(
// The image to use
[
"images/confetti-0.png",
"images/confetti-1.png",
"images/confetti-2.png",
],

// Emitter configuration, edit this to change the look
// of the emitter
{
"lifetime": {
"min": 5,
"max": 5,
},
"frequency": 0.02,
"spawnChance": 0.5,
"emitterLifetime": -1,
"maxParticles": 1000,
"addAtBack": false,
"pos": {
"x": 0,
"y": 0,
},
"behaviors": [
{
"type": "alphaStatic",
"config": {
"alpha": 1,
},
},
{
"type": "colorStatic",
"config": {
"color": [
"#1a1acb",
"#367beb",
"#ff6600",
"#19d016",
"#cc0000",
"#cc33ff",
"#ffcc00",
"#ffffff",
],
},
},
{
"type": "scaleStatic",
"config": {
"min": 0.3,
"max": 0.6,
},
},
{
"type": "moveSpeedStatic",
"config": {
"min": 150,
"max": 250,
},
},
{
"type": "spawnShape",
"config": {
"type": "rect",
"data": {
"x": -500,
"y": 0,
"w": 1000,
"h": 0,
},
},
},
{
"type": "rotation",
"config": {
"minStart": 80,
"maxStart": 100,
"minSpeed": -300,
"maxSpeed": 300,
"accel": 0,
},
},
{
"type": "textureRandom",
"config": {
"textures": [
"images/confetti-0.png",
"images/confetti-1.png",
"images/confetti-2.png",
],
},
},
],
"autoUpdate": true,
"emit": false,
}
);
</script>
</body>
</html>
Binary file added docs/examples/images/confetti-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/examples/images/confetti-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/examples/images/confetti-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ <h1>Emitter Examples</h1>
<li><a href="snow.html">Snow</a></li>
<li><a href="sparks.html">Sparks</a></li>
<li><a href="fountain.html">Fountain</a></li>
<li><a href="confetti.html">Confetti</a></li>
<li><a href="coins.html">Animated Coins</a></li>
<li><a href="animatedBubbles.html">Animated Bubbles</a></li>
<li><a href="spaceshipDestruction.html">Spaceship Destruction</a></li>
Expand Down
2 changes: 1 addition & 1 deletion src/EmitterConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function upgradeConfig(config: EmitterConfigV2|EmitterConfigV1, art: any)
// just ensure we aren't given any V3 config data
if ('behaviors' in config)
{
return config;
return config as EmitterConfigV3;
}

const out: EmitterConfigV3 = {
Expand Down
Loading