├── EPSy.csproj
├── EPSy.v12.suo
├── Gruntfile.js
├── README.md
├── build
├── EPSY.CanvasHelper.js
├── EPSY.Phaser.js
├── EPSY.Pixi.js
├── EPSY.d.ts
├── EPSY.js
├── EPSY.js.map
└── EPSY.min.js
├── core
├── Emitter.class.ts
├── EmitterEntity.ts
└── Particle.class.ts
├── lib
├── PIXI.d.ts
├── phaser.js
└── pixi.dev.js
├── package.json
├── plugins
├── EPSY.CanvasHelper.js
├── EPSY.Phaser.js
└── EPSY.Pixi.js
├── render
├── CanvasRenderer.ts
└── PixiRenderer.ts
└── utils
├── math.ts
└── obj.ts
/EPSy.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | {D9B6D3C2-F5B7-40C5-B200-A62651E27730}
7 | {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
8 | Library
9 | bin
10 | v4.5
11 | full
12 | true
13 | 1.0
14 | true
15 |
16 |
17 |
18 |
19 |
20 |
21 | 12.0
22 |
23 |
24 | EPSy
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | True
33 | True
34 | 62149
35 | /
36 | http://localhost:62149/
37 | False
38 | False
39 |
40 |
41 | False
42 |
43 |
44 |
45 |
46 |
47 | True
48 | true
49 |
50 |
51 | true
52 | false
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | build\EPSY.js
78 |
79 |
80 | True
81 | False
82 |
83 |
84 |
--------------------------------------------------------------------------------
/EPSy.v12.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Ezelia/EPSy/63de8305858037ad30d6a4afd4e02628fea33ed2/EPSy.v12.suo
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function (grunt) {
2 | grunt.loadNpmTasks('grunt-typescript');
3 |
4 | // Project configuration.
5 | grunt.initConfig({
6 | pkg: grunt.file.readJSON('package.json'),
7 | typescript: {
8 | base: {
9 | src: ['utils/*.ts', 'core/*.ts', 'render/*.ts'],
10 | dest: 'build/<%= pkg.name %>.js',
11 | options: {
12 | target: 'es5',
13 | sourceMap: true,
14 | declaration: true
15 | }
16 | }
17 | },
18 | uglify: {
19 | options: {
20 | banner: '/*! <%= pkg.name %> v<%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
21 | },
22 | build: {
23 | src: 'build/<%= pkg.name %>.js',
24 | dest: 'build/<%= pkg.name %>.min.js'
25 | },
26 | plugins: {
27 | options: {
28 | banner: ''
29 | },
30 |
31 | files: [{
32 | expand: true,
33 | src: '**/*.js',
34 | dest: 'build',
35 | cwd: 'plugins'
36 | }]
37 | }
38 | }
39 | });
40 |
41 | // Load the plugin that provides the "uglify" task.
42 | grunt.loadNpmTasks('grunt-contrib-uglify');
43 |
44 | // Default task(s).
45 | grunt.registerTask('default', ['typescript', 'uglify']);
46 |
47 | };
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | EPSy
2 | =========
3 |
4 | EPSy (Ezelia Particles Syetem) is a particle system mainly designed for [Phaser.io](https://github.com/photonstorm/phaser) and [Pixi.js](https://github.com/GoodBoyDigital/pixi.js/),
5 | but can also be used standalone with an integrated Canvas renderer.
6 |
7 | Use the [online editor](http://labs.ezelia.com/epsy/) to generate awesome particles then export and use the data with EPSY !
8 |
9 | EPSy is inspired from [Matt Greer](http://www.mattgreer.org/) excellent tutorial about particles systems.
10 |
11 | Usage
12 | ======
13 | First you'll need to reference EPSY.js or EPSY.min.js script in your html file
14 |
15 | ```
16 |
17 | ```
18 |
19 | then reference one of the plugins, depending on your library
20 |
21 | ### Pixi plugin
22 | reference the Pixi plugin
23 |
24 | ```
25 |
26 | ```
27 |
28 | ```
29 | stage = new PIXI.Stage(0x000000);
30 | renderer = PIXI.autoDetectRenderer(800, 600);
31 | document.getElementById('canvasContainer').appendChild(renderer.view);
32 |
33 | //Creating EPSy emitter instance
34 | var epsy = new PIXI.EPSY();
35 |
36 | //creating a particle system from a given configuration
37 | epsy.loadSystem(config, 400, 400);
38 |
39 |
40 | stage.addChild(epsy);
41 |
42 |
43 | ```
44 |
45 |
46 | ### Phaser plugin
47 | reference the Phaser plugin
48 |
49 | ```
50 |
51 | ```
52 |
53 | ```
54 | var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'gameContainer', { preload: preload, create: create, update: update, render: render });
55 | function create() {
56 | // ... your game creation code ...
57 |
58 | //Registering EPSy plugin
59 | var epsy = game.plugins.add(Phaser.Plugin.EPSY);
60 |
61 | //creating a particle system from a given configuration
62 | var particleSystem1 = epsy.loadSystem(config, 200, 200);
63 |
64 |
65 | // you can let Phaser add the particle system to world group or choose to add it to a specific group
66 | var myGroup = game.add.group();
67 |
68 | myGroup.add(particleSystem1);
69 |
70 | }
71 | ```
72 |
73 |
74 | ### Standalone Canvas Renderer plugin
75 | reference the CanvasHelper plugin
76 |
77 | ```
78 |
79 | ```
80 |
81 | ```
82 | var context = canvas.getContext('2d');
83 |
84 | //creating canvas helper instance
85 | var canvasHelper = new EPSY.CanvasHelper(context);
86 |
87 | //creating a particle system from a given configuration
88 | canvasHelper.loadSystem(config, 400, 400);
89 |
90 | ```
91 |
92 | then in your drawing loop call
93 |
94 | ```
95 | canvasHelper.draw();
96 | ```
97 |
98 |
99 | Particle System Configuration
100 | =============================
101 | You can use the online editor to generate configurations : http://labs.ezelia.com/epsy/
102 |
103 | or you can write them manually.
104 |
105 |
106 | EPSy configuration can be an object or an array of objects containing each the following configuration
107 |
108 | ### id: string
109 | you can use this to identify your emitter
110 |
111 | ### pos : {x:number, y:number}
112 |
113 | ### border : {top: number, left: number, bottom: number, right: number}
114 |
115 | ### posVar : {x:number, y:number}
116 |
117 |
118 | ### gravity : {x:number, y:number}
119 |
120 | ### speed : number
121 |
122 | ### speedVar : number
123 |
124 | ### radialAccel :number
125 | ### radialAccelVar :number
126 | ### tangentialAccel : number
127 | ### tangentialAccelVar : number
128 |
129 |
130 | ### angle : number
131 |
132 | ### angleVar : number
133 |
134 | ### life : number
135 | Particles life in seconds
136 |
137 | ### lifeVar : number
138 | Particles life variance
139 |
140 |
141 | ### radius : number
142 | Particles start radius (will be modified whith the scale parameter)
143 |
144 | ### radiusVar : number
145 |
146 | ### startScale : number
147 |
148 | ### startScaleVar: number
149 |
150 | ### endScale: number
151 |
152 | ### endScaleVar: number
153 |
154 |
155 | ### textureAdditive: boolean
156 |
157 | ### texture : string
158 | a path to an image or URL data
159 |
160 | ### startColor: [r,g,b,a]
161 | ### startColorVar: [r,g,b,a]
162 | ### endColor: [r,g,b,a]
163 | ### endColorVar: [r,g,b,a]
164 |
165 |
166 | ### totalParticles: number
167 | ### emissionRate: number
168 |
169 |
170 | ### duration: number or Infininy
171 | emitter life duration in seconds
172 |
173 |
174 | ### zIndex: number
175 | in case of an array of emitters, this will determine the Z order
176 |
177 |
178 |
179 | Examples
180 | ========
181 |
182 | ### Flame emitter configuration example
183 |
184 | ```
185 | var config = {
186 | totalParticles: 150,
187 | emissionRate: 80,
188 | pos: {
189 | x: 150,
190 | y: 250
191 | },
192 | posVar: {
193 | y: 0,
194 | x: 10
195 | },
196 | gravity: {
197 | x: - 0,
198 | y: - 200
199 | },
200 | texture: "img/particle.png",
201 | xEquation: '',
202 | yEquation: '',
203 | angle: 90,
204 | angleVar: 360,
205 | speed: 15,
206 | speedVar: 5,
207 | life: 2,
208 | lifeVar: 1,
209 | radialAccel: 0,
210 | radialAccelVar: 0,
211 | tangentialAccel: 0,
212 | tangentialAccelVar: 0,
213 | textureEnabled: true,
214 | textureAdditive: true,
215 | radius: 30,
216 | radiusVar: 5,
217 | startScale: 2,
218 | endScale: 1,
219 | startColor: [178, 102, 51, 1],
220 | startColorVar: [0, 0, 51, 0.1],
221 | endColor: [0, 0, 0, 1],
222 | active: true,
223 | duration: Infinity
224 | }
225 | ```
226 |
227 |
228 | ### Flame with smoke configuration example
229 | this one uses an array of two emitters
230 | ```
231 | var config = [
232 | {
233 | "pos": {
234 | "x": 3,
235 | "y": -5
236 | },
237 | "posVar": {
238 | "x": 10,
239 | "y": 0
240 | },
241 | "speed": 15,
242 | "speedVar": 5,
243 | "angle": 90,
244 | "angleVar": 360,
245 | "life": 2,
246 | "lifeVar": 1,
247 | "radius": 30,
248 | "radiusVar": 5,
249 | "textureAdditive": true,
250 | "startScale": 2,
251 | "startScaleVar": 0,
252 | "endScale": 1,
253 | "endScaleVar": 0,
254 | "startColor": [
255 | 178,
256 | 102,
257 | 51,
258 | 1
259 | ],
260 | "startColorVar": [
261 | 0,
262 | 0,
263 | 51,
264 | 0.1
265 | ],
266 | "endColor": [
267 | 0,
268 | 0,
269 | 0,
270 | 1
271 | ],
272 | "endColorVar": [
273 | 0,
274 | 0,
275 | 0,
276 | 0
277 | ],
278 | "gravity": {
279 | "x": 0,
280 | "y": -200
281 | },
282 | "radialAccel": 0,
283 | "radialAccelVar": 0,
284 | "tangentialAccel": 0,
285 | "tangentialAccelVar": 0,
286 | "texture": "img/particle.png",
287 | "totalParticles": 50,
288 | "emissionRate": 20,
289 | "textureEnabled": true,
290 | "active": true,
291 | "duration": null,
292 | "id": "emitter1",
293 | "border": {
294 | "top": 57.80186188689731,
295 | "left": 200,
296 | "bottom": 200,
297 | "right": 200
298 | },
299 | "zIndex": 1
300 | },
301 | {
302 | "pos": {
303 | "x": 1,
304 | "y": -32
305 | },
306 | "posVar": {
307 | "x": 5,
308 | "y": 0
309 | },
310 | "speed": 15,
311 | "speedVar": 5,
312 | "angle": 90,
313 | "angleVar": 20,
314 | "life": 2,
315 | "lifeVar": 0.5,
316 | "radius": 20,
317 | "radiusVar": 5,
318 | "textureAdditive": false,
319 | "startScale": 2,
320 | "startScaleVar": 0,
321 | "endScale": 4,
322 | "endScaleVar": 0,
323 | "startColor": [
324 | 144,
325 | 144,
326 | 144,
327 | 1
328 | ],
329 | "startColorVar": [
330 | 0,
331 | 0,
332 | 0,
333 | 0
334 | ],
335 | "endColor": [
336 | 187,
337 | 187,
338 | 187,
339 | 0.2
340 | ],
341 | "endColorVar": [
342 | 0,
343 | 0,
344 | 0,
345 | 0
346 | ],
347 | "colorList": [],
348 | "gravity": {
349 | "x": 0,
350 | "y": -50
351 | },
352 | "radialAccel": 0,
353 | "radialAccelVar": 0,
354 | "tangentialAccel": 0,
355 | "tangentialAccelVar": 0,
356 | "texture": "img/particle.png",
357 | "totalParticles": 20,
358 | "emissionRate": 20,
359 |
360 | "textureEnabled": true,
361 | "active": true,
362 | "duration": null,
363 | "id": "emitter2",
364 | "border": {
365 | "top": 200,
366 | "left": 200,
367 | "bottom": 200,
368 | "right": 200
369 | },
370 | "zIndex": 0
371 | }
372 | ]
373 |
374 | ```
--------------------------------------------------------------------------------
/build/EPSY.CanvasHelper.js:
--------------------------------------------------------------------------------
1 | EPSY.CanvasHelper=function(a){this.lastTimestamp=Date.now(),this.emitters=[],this.canvasRenderer=new EPSY.CanvasRenderer(a)},EPSY.CanvasHelper.prototype.draw=function(){var a=(new Date).getTime(),b=a-(this.lastTimestamp||a);this.lastTimestamp=a,b/=1e3;for(var c=0;c0&&e.color&&updateParticle.call(this.particleSystem,c,e)}},Phaser.Plugin.EPSY.Emitter.prototype.reset=function(){var a=this.emitter.buffer,b=this.emitter.container;do{var c=a.pop();c&&(b.removeChild(c),c.__parentParticle&&(c.__parentParticle.inserted=!1))}while(a.length>0)},Phaser.Plugin.EPSY.prototype.createEmitter=function(a,b,c){b=b||0,c=c||0;var d=new EPSY.Emitter(a);return d.buffer=[],d.settings.pos.x=0,d.settings.pos.y=0,this.emitters.push(d),d.container=new Phaser.Plugin.EPSY.Emitter(this,d),d.container.position.x=b,d.container.position.y=c,d.zIndex=a.zIndex,d.container.__ez_parent=d,d.lastTimestamp=Date.now(),d.container},Phaser.Plugin.EPSY.prototype.loadSystem=function(a,b,c){b=b||0,c=c||0;var d,e=game.add.group();d="string"==typeof a?JSON.parse(_data):"object"!=typeof a||a instanceof Array?a:[a];for(var f=0;f
2 | declare module EPSY.utils.math {
3 | function toRad(deg: any): number;
4 | function isNumber(i: any): boolean;
5 | function isInteger(num: any): boolean;
6 | function frandom(min: any, max: any): any;
7 | function irandom(min: any, max: any): number;
8 | function normalize(vector: any): void;
9 | }
10 | declare module EPSY.utils.obj {
11 | function clone(obj: any, props: any): {};
12 | function extend(obj: any, config: any): void;
13 | function recursiveExtend(obj: any, config: any, exceptions: any): void;
14 | function recursiveExtendInclusive(obj: any, config: any, whitelist: any[]): void;
15 | }
16 | declare module EPSY {
17 | var EmitterParams: string[];
18 | class Emitter {
19 | public id: string;
20 | public container: any;
21 | public settings: EmitterEntity;
22 | private time;
23 | public _baseSystem: any;
24 | public _totalParticles: number;
25 | public emissionRate: number;
26 | public allOrNone: boolean;
27 | public aFactor: {
28 | x: number;
29 | y: number;
30 | };
31 | public xFactor: {
32 | x: number;
33 | y: number;
34 | };
35 | private _xEquation;
36 | private _yEquation;
37 | private _xEqName;
38 | private _yEqName;
39 | private _posTransform;
40 | public active: boolean;
41 | public duration: number;
42 | public cycles: number;
43 | private _particlePool;
44 | private _particleCount;
45 | private _particleIndex;
46 | private _elapsed;
47 | private _curCycle;
48 | private _emitCounter;
49 | public border: {
50 | top: number;
51 | left: number;
52 | bottom: number;
53 | right: number;
54 | };
55 | public recyclable: any[];
56 | constructor(system: any);
57 | public zIndex : number;
58 | public xEquation : string;
59 | public yEquation : string;
60 | public posTransform : any;
61 | public particles : Particle[];
62 | public totalParticles : number;
63 | public load(config: any): void;
64 | public save(): any;
65 | public restart(): void;
66 | public reset(): void;
67 | private _isFull();
68 | private createParticle();
69 | private initParticle(particle);
70 | private updateParticle(p, delta, i);
71 | public kill(): void;
72 | public update(delta: any): void;
73 | }
74 | }
75 | declare module EPSY {
76 | class EmitterEntity {
77 | public pos: {
78 | x: number;
79 | y: number;
80 | };
81 | public posVar: {
82 | x: number;
83 | y: number;
84 | };
85 | public speed: number;
86 | public speedVar: number;
87 | public angle: number;
88 | public angleVar: number;
89 | public life: number;
90 | public lifeVar: number;
91 | public radius: number;
92 | public radiusVar: number;
93 | public texture: string;
94 | public textureAdditive: boolean;
95 | public startScale: number;
96 | public startScaleVar: number;
97 | public endScale: number;
98 | public endScaleVar: number;
99 | public startColor: number[];
100 | public startColorVar: number[];
101 | public endColor: number[];
102 | public endColorVar: number[];
103 | public colorList: any[];
104 | public gravity: {
105 | x: number;
106 | y: number;
107 | };
108 | public radialAccel: number;
109 | public radialAccelVar: number;
110 | public tangentialAccel: number;
111 | public tangentialAccelVar: number;
112 | }
113 | }
114 | declare module EPSY {
115 | class Particle extends EmitterEntity {
116 | public scale: number;
117 | public deltaScale: number;
118 | public deltaColor: any[];
119 | public lastpos: {
120 | x: number;
121 | y: number;
122 | };
123 | public vel: {
124 | x: number;
125 | y: number;
126 | };
127 | public color: any[];
128 | public forces: {
129 | x: number;
130 | y: number;
131 | };
132 | public radial: {
133 | x: number;
134 | y: number;
135 | };
136 | public tangential: {
137 | x: number;
138 | y: number;
139 | };
140 | public colorIdx: number;
141 | public recycled: boolean;
142 | constructor();
143 | public setVelocity(angle: any, speed: any): void;
144 | }
145 | }
146 | declare module EPSY {
147 | class CanvasRenderer {
148 | public context: any;
149 | private defaultTexture;
150 | constructor(context: any);
151 | private renderParticle(particle);
152 | public render(emitter: Emitter): void;
153 | public reset(): void;
154 | }
155 | }
156 | declare module EPSY {
157 | class PixiRenderer {
158 | public context: any;
159 | private defaultTexture;
160 | private buffer;
161 | private _sortFn;
162 | constructor(context: any);
163 | private updateParticleSprite(emitter, particle);
164 | public render(emitter: Emitter): void;
165 | public hideAllParticles(emitter: Emitter): void;
166 | public sort(): void;
167 | public reset(): void;
168 | }
169 | }
170 |
--------------------------------------------------------------------------------
/build/EPSY.js:
--------------------------------------------------------------------------------
1 | var EPSY;
2 | (function (EPSY) {
3 | (function (utils) {
4 | (function (math) {
5 | function toRad(deg) {
6 | return Math.PI * deg / 180;
7 | }
8 | math.toRad = toRad;
9 |
10 | function isNumber(i) {
11 | return typeof i === 'number';
12 | }
13 | math.isNumber = isNumber;
14 |
15 | function isInteger(num) {
16 | return num === (num | 0);
17 | }
18 | math.isInteger = isInteger;
19 |
20 | function frandom(min, max) {
21 | return Math.random() * (max - min) + min;
22 | }
23 | math.frandom = frandom;
24 |
25 | function irandom(min, max) {
26 | return Math.floor(Math.random() * (max - min + 1) + min);
27 | }
28 | math.irandom = irandom;
29 |
30 | function normalize(vector) {
31 | var length = Math.sqrt(vector.x * vector.x + vector.y * vector.y);
32 |
33 | vector.x /= length;
34 | vector.y /= length;
35 | }
36 | math.normalize = normalize;
37 | })(utils.math || (utils.math = {}));
38 | var math = utils.math;
39 | })(EPSY.utils || (EPSY.utils = {}));
40 | var utils = EPSY.utils;
41 | })(EPSY || (EPSY = {}));
42 | var EPSY;
43 | (function (EPSY) {
44 | (function (utils) {
45 | (function (_obj) {
46 | function clone(obj, props) {
47 | var clone = {};
48 | this.extend(clone, obj);
49 | return clone;
50 | }
51 | _obj.clone = clone;
52 | function extend(obj, config) {
53 | for (var prop in config) {
54 | if (config.hasOwnProperty(prop)) {
55 | obj[prop] = config[prop];
56 | }
57 | }
58 | }
59 | _obj.extend = extend;
60 |
61 | function recursiveExtend(obj, config, exceptions) {
62 | exceptions = exceptions || [];
63 | for (var prop in config) {
64 | if (config.hasOwnProperty(prop)) {
65 | if (exceptions.indexOf(prop) > -1) {
66 | obj[prop] = config[prop];
67 | } else {
68 | if (typeof config[prop] === 'object') {
69 | this.recursiveExtend(obj[prop], config[prop], exceptions);
70 | } else {
71 | obj[prop] = config[prop];
72 | }
73 | }
74 | }
75 | }
76 | }
77 | _obj.recursiveExtend = recursiveExtend;
78 | function recursiveExtendInclusive(obj, config, whitelist) {
79 | if (!whitelist || !whitelist.length || whitelist.length <= 0)
80 | return;
81 |
82 | for (var prop in config) {
83 | if (whitelist.indexOf(prop) >= 0) {
84 | if (typeof config[prop] === 'object') {
85 | if (!obj[prop])
86 | obj[prop] = {};
87 | this.recursiveExtend(obj[prop], config[prop]);
88 | } else {
89 | obj[prop] = config[prop];
90 | }
91 | }
92 | }
93 | }
94 | _obj.recursiveExtendInclusive = recursiveExtendInclusive;
95 | })(utils.obj || (utils.obj = {}));
96 | var obj = utils.obj;
97 | })(EPSY.utils || (EPSY.utils = {}));
98 | var utils = EPSY.utils;
99 | })(EPSY || (EPSY = {}));
100 | var EPSY;
101 | (function (EPSY) {
102 | EPSY.EmitterParams = ['id', 'border', 'duration', 'emissionRate', 'totalParticles', 'xFactor', 'aFactor', 'xEquation', 'yEquation', 'posTransform', 'zIndex'];
103 |
104 | var Emitter = (function () {
105 | function Emitter(system) {
106 | this.id = (Math.random() * 1e20).toString(36);
107 | this.settings = new EPSY.EmitterEntity();
108 | this.time = Date.now();
109 | this._totalParticles = 0;
110 | this.emissionRate = 0;
111 | this.allOrNone = false;
112 | this.aFactor = { x: 0, y: 0 };
113 | this.xFactor = { x: 0, y: 0 };
114 | this._xEqName = '';
115 | this._yEqName = '';
116 | this.active = false;
117 | this.duration = 0;
118 | this.cycles = Infinity;
119 | this._particlePool = [];
120 | this._particleCount = 0;
121 | this._particleIndex = 0;
122 | this._elapsed = 0;
123 | this._curCycle = 0;
124 | this._emitCounter = 0;
125 | this.border = { top: 100, left: 100, bottom: 100, right: 100 };
126 | this.recyclable = [];
127 | this._baseSystem = EPSY.utils.obj.clone(system, ['texture']);
128 | this.load(system);
129 | }
130 | Object.defineProperty(Emitter.prototype, "zIndex", {
131 | get: function () {
132 | if (this.container) {
133 | return this.container.__z || 0;
134 | }
135 |
136 | return 0;
137 | },
138 | set: function (value) {
139 | if (this.container) {
140 | this.container.__z = ~~value;
141 | }
142 | },
143 | enumerable: true,
144 | configurable: true
145 | });
146 |
147 | Object.defineProperty(Emitter.prototype, "xEquation", {
148 | get: function () {
149 | return this._xEqName;
150 | },
151 | set: function (value) {
152 | if (typeof Math[value] == 'function') {
153 | this._xEqName = value;
154 | this._xEquation = Math[value];
155 | } else {
156 | this._xEqName = '';
157 | this._xEquation = undefined;
158 | }
159 | },
160 | enumerable: true,
161 | configurable: true
162 | });
163 | Object.defineProperty(Emitter.prototype, "yEquation", {
164 | get: function () {
165 | return this._yEqName;
166 | },
167 | set: function (value) {
168 | if (typeof Math[value] == 'function') {
169 | this._yEqName = value;
170 | this._yEquation = Math[value];
171 | } else {
172 | this._yEqName = '';
173 | this._yEquation = undefined;
174 | }
175 | },
176 | enumerable: true,
177 | configurable: true
178 | });
179 |
180 | Object.defineProperty(Emitter.prototype, "posTransform", {
181 | get: function () {
182 | if (!this._posTransform)
183 | return undefined;
184 |
185 | var code = this._posTransform.toString();
186 | return code.match(/[^{]+(.+)\}/g)[0];
187 | },
188 | set: function (fn) {
189 | if (typeof fn == 'function') {
190 | this._posTransform = fn;
191 | } else {
192 | this._posTransform = new Function('pos', 'particle', fn);
193 | }
194 | },
195 | enumerable: true,
196 | configurable: true
197 | });
198 |
199 | Object.defineProperty(Emitter.prototype, "particles", {
200 | get: function () {
201 | return this._particlePool;
202 | },
203 | set: function (value) {
204 | this._particlePool = value;
205 | },
206 | enumerable: true,
207 | configurable: true
208 | });
209 |
210 | Object.defineProperty(Emitter.prototype, "totalParticles", {
211 | get: function () {
212 | return this._totalParticles;
213 | },
214 | set: function (tp) {
215 | tp = tp | 0;
216 | if (tp !== this._totalParticles) {
217 | this._totalParticles = tp;
218 | this.restart();
219 | }
220 | },
221 | enumerable: true,
222 | configurable: true
223 | });
224 |
225 | Emitter.prototype.load = function (config) {
226 | this._totalParticles = 0;
227 | this.emissionRate = 0;
228 |
229 | this.active = false;
230 | this.duration = 0;
231 |
232 | this.settings.pos.x = 0;
233 | this.settings.pos.y = 0;
234 |
235 | this.settings.posVar.x = 0;
236 | this.settings.posVar.y = 0;
237 |
238 | this.settings.speed = 0;
239 | this.settings.speedVar = 0;
240 |
241 | this.settings.angle = 0;
242 | this.settings.angleVar = 0;
243 |
244 | this.settings.life = 0;
245 | this.settings.lifeVar = 0;
246 |
247 | this.settings.radius = 0;
248 | this.settings.radiusVar = 0;
249 |
250 | this.settings.texture = null;
251 |
252 | this.settings.textureAdditive = false;
253 |
254 | this.settings.startScale = 0;
255 | this.settings.startScaleVar = 0;
256 | this.settings.endScale = 0;
257 | this.settings.endScaleVar = 0;
258 |
259 | this.settings.startColor[0] = 0;
260 | this.settings.startColor[1] = 0;
261 | this.settings.startColor[2] = 0;
262 | this.settings.startColor[3] = 0;
263 |
264 | this.settings.startColorVar[0] = 0;
265 | this.settings.startColorVar[1] = 0;
266 | this.settings.startColorVar[2] = 0;
267 | this.settings.startColorVar[3] = 0;
268 |
269 | this.settings.endColor[0] = 0;
270 | this.settings.endColor[1] = 0;
271 | this.settings.endColor[2] = 0;
272 | this.settings.endColor[3] = 0;
273 |
274 | this.settings.endColorVar[0] = 0;
275 | this.settings.endColorVar[1] = 0;
276 | this.settings.endColorVar[2] = 0;
277 | this.settings.endColorVar[3] = 0;
278 |
279 | this.settings.gravity.x = 0;
280 | this.settings.gravity.y = 0;
281 |
282 | this.settings.radialAccel = 0;
283 | this.settings.radialAccelVar = 0;
284 | this.settings.tangentialAccel = 0;
285 | this.settings.tangentialAccelVar = 0;
286 |
287 | EPSY.utils.obj.recursiveExtend(this.settings, config, EPSY.EmitterParams);
288 | EPSY.utils.obj.recursiveExtendInclusive(this, config, EPSY.EmitterParams);
289 |
290 | if (isNaN(this.duration))
291 | this.duration = Infinity;
292 |
293 | this.id = config.name || this.id;
294 |
295 | this.restart();
296 | };
297 |
298 | Emitter.prototype.save = function () {
299 | var pconfig = JSON.parse(JSON.stringify(this.settings));
300 | EPSY.utils.obj.recursiveExtendInclusive(pconfig, this, EPSY.EmitterParams);
301 |
302 | return pconfig;
303 | };
304 |
305 | Emitter.prototype.restart = function () {
306 | if (this._particlePool.length < this.totalParticles) {
307 | for (var i = this._particlePool.length; i < this.totalParticles; ++i) {
308 | this._particlePool.push(new EPSY.Particle());
309 | }
310 | }
311 |
312 | if (this._particlePool.length > this.totalParticles) {
313 | var spliced = this._particlePool.splice(this.totalParticles);
314 |
315 | this.recyclable = this.recyclable.concat(spliced);
316 | }
317 |
318 | for (var i = 0; i < this.totalParticles; ++i) {
319 | var particle = this._particlePool[i];
320 | particle.recycled = true;
321 | }
322 |
323 | this._particleCount = 0;
324 | this._particleIndex = 0;
325 | this._elapsed = 0;
326 | this._curCycle = 0;
327 | this._emitCounter = 0;
328 | };
329 |
330 | Emitter.prototype.reset = function () {
331 | this.load(this._baseSystem);
332 | };
333 |
334 | Emitter.prototype._isFull = function () {
335 | return this._particleCount === this.totalParticles;
336 | };
337 |
338 | Emitter.prototype.createParticle = function () {
339 | if (this._isFull()) {
340 | return false;
341 | }
342 |
343 | var p = this._particlePool[this._particleCount];
344 |
345 | this.initParticle(p);
346 |
347 | this._particleCount++;
348 |
349 | return true;
350 | };
351 |
352 | Emitter.prototype.initParticle = function (particle) {
353 | particle.texture = this.settings.texture;
354 | particle.textureAdditive = this.settings.textureAdditive;
355 |
356 | var posVar = {
357 | x: this.settings.posVar.x * EPSY.utils.math.frandom(-1, 1),
358 | y: this.settings.posVar.y * EPSY.utils.math.frandom(-1, 1)
359 | };
360 | if (this._posTransform) {
361 | posVar = this._posTransform.call(this, posVar, particle);
362 | }
363 |
364 | particle.pos.x = this.settings.pos.x + posVar.x;
365 | particle.pos.y = this.settings.pos.y + posVar.y;
366 |
367 | var angle = this.settings.angle + this.settings.angleVar * EPSY.utils.math.frandom(-1, 1);
368 | var speed = this.settings.speed + this.settings.speedVar * EPSY.utils.math.frandom(-1, 1);
369 |
370 | particle.setVelocity(angle, speed);
371 |
372 | particle.radialAccel = this.settings.radialAccel + this.settings.radialAccelVar * EPSY.utils.math.frandom(-1, 1) || 0;
373 | particle.tangentialAccel = this.settings.tangentialAccel + this.settings.tangentialAccelVar * EPSY.utils.math.frandom(-1, 1) || 0;
374 |
375 | var life = this.settings.life + this.settings.lifeVar * EPSY.utils.math.frandom(-1, 1) || 0;
376 | particle.life = Math.max(0, life);
377 |
378 | particle.scale = EPSY.utils.math.isNumber(this.settings.startScale) ? this.settings.startScale : 1;
379 | particle.deltaScale = EPSY.utils.math.isNumber(this.settings.endScale) ? (this.settings.endScale - this.settings.startScale) : 0;
380 | particle.deltaScale /= particle.life;
381 |
382 | particle.radius = EPSY.utils.math.isNumber(this.settings.radius) ? this.settings.radius + (this.settings.radiusVar || 0) * EPSY.utils.math.frandom(-1, 1) : 0;
383 |
384 | if (this.settings.startColor) {
385 | var startColor = [this.settings.startColor[0] + this.settings.startColorVar[0] * EPSY.utils.math.frandom(-1, 1), this.settings.startColor[1] + this.settings.startColorVar[1] * EPSY.utils.math.frandom(-1, 1), this.settings.startColor[2] + this.settings.startColorVar[2] * EPSY.utils.math.frandom(-1, 1), this.settings.startColor[3] + this.settings.startColorVar[3] * EPSY.utils.math.frandom(-1, 1)];
386 |
387 | var endColor = startColor;
388 | if (this.settings.endColor) {
389 | endColor = [this.settings.endColor[0] + this.settings.endColorVar[0] * EPSY.utils.math.frandom(-1, 1), this.settings.endColor[1] + this.settings.endColorVar[1] * EPSY.utils.math.frandom(-1, 1), this.settings.endColor[2] + this.settings.endColorVar[2] * EPSY.utils.math.frandom(-1, 1), this.settings.endColor[3] + this.settings.endColorVar[3] * EPSY.utils.math.frandom(-1, 1)];
390 | }
391 |
392 | particle.color = startColor;
393 | particle.deltaColor = [(endColor[0] - startColor[0]) / particle.life, (endColor[1] - startColor[1]) / particle.life, (endColor[2] - startColor[2]) / particle.life, (endColor[3] - startColor[3]) / particle.life];
394 |
395 | for (var c = 0; c < 3; c++) {
396 | particle.startColor[c] = ~~particle.startColor[c];
397 | particle.endColor[c] = ~~particle.endColor[c];
398 | particle.deltaColor[c] = ~~particle.deltaColor[c];
399 | }
400 | }
401 | };
402 |
403 | Emitter.prototype.updateParticle = function (p, delta, i) {
404 | var inEdge = (!this.border) || (p.pos.x >= this.settings.pos.x - this.border.left && p.pos.y >= this.settings.pos.y - this.border.top && p.pos.x <= this.settings.pos.x + this.border.right && p.pos.y <= this.settings.pos.y + this.border.bottom);
405 |
406 | if (!inEdge) {
407 | p.life = 0;
408 | }
409 |
410 | if (p.life > 0) {
411 | p.radial.x = 0;
412 | p.radial.y = 0;
413 | p.forces.x = 0;
414 | p.forces.y = 0;
415 |
416 | if ((p.pos.x !== this.settings.pos.x || p.pos.y !== this.settings.pos.y) && (p.radialAccel || p.tangentialAccel)) {
417 | p.radial.x = p.pos.x - this.settings.pos.x;
418 | p.radial.y = p.pos.y - this.settings.pos.y;
419 |
420 | EPSY.utils.math.normalize(p.radial);
421 | }
422 |
423 | p.tangential.x = p.radial.x;
424 | p.tangential.y = p.radial.y;
425 |
426 | p.radial.x *= p.radialAccel;
427 | p.radial.y *= p.radialAccel;
428 |
429 | var newy = p.tangential.x;
430 | p.tangential.x = -p.tangential.y;
431 | p.tangential.y = newy;
432 |
433 | p.tangential.x *= p.tangentialAccel;
434 | p.tangential.y *= p.tangentialAccel;
435 |
436 | p.forces.x = p.radial.x + p.tangential.x + this.settings.gravity.x;
437 | p.forces.y = p.radial.y + p.tangential.y + this.settings.gravity.y;
438 |
439 | p.forces.x *= delta;
440 | p.forces.y *= delta;
441 |
442 | p.vel.x += p.forces.x;
443 | p.vel.y += p.forces.y;
444 |
445 | p.lastpos.x = p.pos.x;
446 | p.lastpos.y = p.pos.y;
447 |
448 | var ax = 0;
449 | var ay = 0;
450 | if (this._xEquation)
451 | ax = this.aFactor.x * this._xEquation(p.life * this.xFactor.x * Math.PI);
452 | if (this._yEquation)
453 | ay = this.aFactor.y * this._yEquation(p.life * this.xFactor.y * Math.PI);
454 |
455 | p.pos.x += p.vel.x * delta + ax;
456 | p.pos.y += p.vel.y * delta + ay;
457 |
458 | p.life -= delta;
459 |
460 | p.scale += p.deltaScale * delta;
461 |
462 | if (p.color) {
463 | if (this.settings.colorList.length > 0) {
464 | p.color[0] = this.settings.colorList[p.colorIdx][0];
465 | p.color[1] = this.settings.colorList[p.colorIdx][1];
466 | p.color[2] = this.settings.colorList[p.colorIdx][2];
467 | p.color[3] = this.settings.colorList[p.colorIdx][3];
468 |
469 | p.colorIdx++;
470 | if (p.colorIdx >= this.settings.colorList.length)
471 | p.colorIdx = 0;
472 | } else {
473 | p.color[0] += p.deltaColor[0] * delta;
474 | p.color[1] += p.deltaColor[1] * delta;
475 | p.color[2] += p.deltaColor[2] * delta;
476 | p.color[3] += p.deltaColor[3] * delta;
477 | }
478 | }
479 |
480 | ++this._particleIndex;
481 | } else {
482 | p.color[3] = 0;
483 |
484 | var temp = this._particlePool[i];
485 |
486 | this._particlePool[i] = this._particlePool[this._particleCount - 1];
487 | this._particlePool[this._particleCount - 1] = temp;
488 |
489 | --this._particleCount;
490 | }
491 | };
492 |
493 | Emitter.prototype.kill = function () {
494 | for (var i = 0; i < this._particlePool.length; i++) {
495 | var p = this._particlePool[i];
496 | p.life = 0;
497 | }
498 |
499 | this._particlePool = [];
500 |
501 | this.duration = -1;
502 | this._particleCount = 0;
503 | this._particleIndex = 0;
504 | this._elapsed = 0;
505 | this._emitCounter = 0;
506 | };
507 | Emitter.prototype.update = function (delta) {
508 | this._elapsed += delta;
509 | this.active = this._elapsed < this.duration;
510 |
511 | if (!this.active) {
512 | return;
513 | }
514 |
515 | if (this.emissionRate) {
516 | var rate = 1.0 / this.emissionRate;
517 | this._emitCounter += delta;
518 | if (!this.allOrNone) {
519 | while (!this._isFull() && this._emitCounter > rate) {
520 | this.createParticle();
521 | this._emitCounter -= rate;
522 | }
523 | ;
524 | } else if (this._particleCount == 0 && this._curCycle < this.cycles) {
525 | while (!this._isFull()) {
526 | this.createParticle();
527 | }
528 | ;
529 | this._curCycle++;
530 | }
531 | }
532 |
533 | this._particleIndex = 0;
534 |
535 | while (this._particleIndex < this._particleCount) {
536 | var p = this._particlePool[this._particleIndex];
537 | this.updateParticle(p, delta, this._particleIndex);
538 | }
539 | };
540 | return Emitter;
541 | })();
542 | EPSY.Emitter = Emitter;
543 | ;
544 | })(EPSY || (EPSY = {}));
545 | var EPSY;
546 | (function (EPSY) {
547 | var EmitterEntity = (function () {
548 | function EmitterEntity() {
549 | this.pos = { x: 0, y: 0 };
550 | this.posVar = { x: 0, y: 0 };
551 | this.speed = 0;
552 | this.speedVar = 0;
553 | this.angle = 0;
554 | this.angleVar = 0;
555 | this.life = 0;
556 | this.lifeVar = 0;
557 | this.radius = 0;
558 | this.radiusVar = 0;
559 | this.textureAdditive = false;
560 | this.startScale = 0;
561 | this.startScaleVar = 0;
562 | this.endScale = 0;
563 | this.endScaleVar = 0;
564 | this.startColor = [0, 0, 0, 0];
565 | this.startColorVar = [0, 0, 0, 0];
566 | this.endColor = [0, 0, 0, 0];
567 | this.endColorVar = [0, 0, 0, 0];
568 | this.colorList = [];
569 | this.gravity = { x: 0, y: 0 };
570 | this.radialAccel = 0;
571 | this.radialAccelVar = 0;
572 | this.tangentialAccel = 0;
573 | this.tangentialAccelVar = 0;
574 | }
575 | return EmitterEntity;
576 | })();
577 | EPSY.EmitterEntity = EmitterEntity;
578 | })(EPSY || (EPSY = {}));
579 | var __extends = this.__extends || function (d, b) {
580 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
581 | function __() { this.constructor = d; }
582 | __.prototype = b.prototype;
583 | d.prototype = new __();
584 | };
585 | var EPSY;
586 | (function (EPSY) {
587 | var Particle = (function (_super) {
588 | __extends(Particle, _super);
589 | function Particle() {
590 | _super.call(this);
591 | this.lastpos = { x: -1, y: -1 };
592 | this.vel = { x: 0, y: 0 };
593 | this.forces = { x: 0, y: 0 };
594 | this.radial = { x: 0, y: 0 };
595 | this.tangential = { x: 0, y: 0 };
596 | this.colorIdx = 0;
597 | this.recycled = false;
598 | this.setVelocity(0, 0);
599 | }
600 | Particle.prototype.setVelocity = function (angle, speed) {
601 | this.vel.x = Math.cos(EPSY.utils.math.toRad(angle)) * speed;
602 | this.vel.y = -Math.sin(EPSY.utils.math.toRad(angle)) * speed;
603 | };
604 | return Particle;
605 | })(EPSY.EmitterEntity);
606 | EPSY.Particle = Particle;
607 | })(EPSY || (EPSY = {}));
608 | var EPSY;
609 | (function (EPSY) {
610 | var bufferCache = {};
611 |
612 | function colorArrayToString(array, overrideAlpha) {
613 | var r = array[0] | 0;
614 | var g = array[1] | 0;
615 | var b = array[2] | 0;
616 | var a = overrideAlpha || array[3];
617 |
618 | return 'rgba(' + r + ', ' + g + ', ' + b + ', ' + a + ')';
619 | }
620 |
621 | function getBuffer(particle) {
622 | var img = particle.img;
623 | if (!img) {
624 | img = new Image();
625 | particle.ready = false;
626 | img.onload = function () {
627 | particle.ready = true;
628 | };
629 | img.src = particle.texture;
630 | particle.img = img;
631 | }
632 |
633 | if (!particle.ready)
634 | return undefined;
635 |
636 | var size = '' + img.width + 'x' + img.height;
637 |
638 | var canvas = bufferCache[size];
639 |
640 | if (!canvas) {
641 | canvas = document.createElement('canvas');
642 | canvas.width = img.width;
643 | canvas.height = img.height;
644 | bufferCache[size] = canvas;
645 | }
646 |
647 | return canvas;
648 | }
649 |
650 | var CanvasRenderer = (function () {
651 | function CanvasRenderer(context) {
652 | this.context = context;
653 | this.defaultTexture = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACz0lEQVR42t2XP0hbURTGnfp/KK3QFiylCG11aRYpBQWFDiJCg266BNQtdnBQyOASQjp1KS4KGVw6iXMWEUdHUShkCBhSQpaQkJg/Jmm/H3xLEdtaWvLawMfJvfec79x77jnnvdfX96/9MpnM9VwudzOfz98qFAq3kYyZ/6tOi8XinVKpdLdSqfRXq9UHwsNarfYIyZh51tH7Y5s5Pj6+BqHI7+OsXq8/aTQag8LzZrM5JAwjGTPPOnroY4f9bzvPZrM3OBEnFPFTOXohvGy1WiPC6/Pz81FhDMmYedbRQx877OG5snPutFwu3zs7OxvQyZ6JPGSnE8KkMN1ut98KYSRjz094MyHssIcHviud3M4fE15OJuJxOZoSZoU5ISIsCIuWEc+zPoW+IzIED3y/FAnujLCxczt/JbI3Pum8sCQsCyudTmdVWEMy9vyS9cLYYe9NDMD705wgcbg7h33Ezmd8wqidrgtxISm8t4x7ns1ErT/jTYzABy/8Pyw1spcE4g4d9rDJ3ok8JiSED8KGsClsWW54nvUY+rYL+zpC8MJ/aYmyO0qILCaRfOfzPnnMJ/0opIRPwk63291FepzyetKbiNp+Cj544b80CtwRdUwpkc1OqCWHPWHybTtNS+5LHlimPb9tvYSvg5yYhQ9e+PFzWfj7aSa++0ln9bLvlvCm7GRP8lDySDhBerzn9ZT1152Yc/A5Fwbxc+EaqFPaKR3N9T7tO1xxgm04zJz0UPis/6fCFyRjbyJtPfTjro4IfPDCj58LfYEHCllKydDZ3GQWHP6kE23H4T6y05Jk1fLUkdh3TmzabtV9gmY1Cj9+8PfdBniqOQGHaa/O/kXXOaW25fAeOOycvPpVP6THJ86JXVcHdmtuVlTDGPz4wV+wItDzHOh5FfS8DwSiE/b8WdDzp2Eg3gd6/kYUiHfCQLwVB+K7IBBfRoH5Nvyvf98A3rZr7fen7G8AAAAASUVORK5CYII=';
654 | }
655 | CanvasRenderer.prototype.renderParticle = function (particle) {
656 | if (!particle.texture)
657 | particle.texture = this.defaultTexture;
658 |
659 | particle.buffer = particle.buffer || getBuffer(particle);
660 |
661 | if (!particle.buffer)
662 | return;
663 |
664 | var bufferContext = particle.buffer.getContext('2d');
665 |
666 | var w = (particle.img.width * particle.scale) | 0;
667 | var h = (particle.img.height * particle.scale) | 0;
668 |
669 | var x = particle.pos.x - w / 2;
670 | var y = particle.pos.y - h / 2;
671 |
672 | bufferContext.clearRect(0, 0, particle.buffer.width, particle.buffer.height);
673 | bufferContext.globalAlpha = particle.color[3];
674 | bufferContext.drawImage(particle.img, 0, 0);
675 |
676 | bufferContext.globalCompositeOperation = "source-atop";
677 | bufferContext.fillStyle = colorArrayToString(particle.color, 1);
678 | bufferContext.fillRect(0, 0, particle.buffer.width, particle.buffer.height);
679 |
680 | bufferContext.globalCompositeOperation = "source-over";
681 | bufferContext.globalAlpha = 1;
682 |
683 | if (particle.textureAdditive) {
684 | this.context.globalCompositeOperation = 'lighter';
685 | } else {
686 | this.context.globalCompositeOperation = 'source-over';
687 | }
688 |
689 | this.context.drawImage(particle.buffer, 0, 0, particle.buffer.width, particle.buffer.height, x, y, w, h);
690 | };
691 |
692 | CanvasRenderer.prototype.render = function (emitter) {
693 | var particles = emitter.particles;
694 | for (var i = 0; i < particles.length; ++i) {
695 | var p = particles[i];
696 | if (p.life > 0 && p.color) {
697 | this.renderParticle(p);
698 | }
699 | }
700 | this.context.globalCompositeOperation = 'source-over';
701 | };
702 |
703 | CanvasRenderer.prototype.reset = function () {
704 | return;
705 | };
706 | return CanvasRenderer;
707 | })();
708 | EPSY.CanvasRenderer = CanvasRenderer;
709 | })(EPSY || (EPSY = {}));
710 | var EPSY;
711 | (function (EPSY) {
712 | var PixiRenderer = (function () {
713 | function PixiRenderer(context) {
714 | this.context = context;
715 | this.defaultTexture = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACz0lEQVR42t2XP0hbURTGnfp/KK3QFiylCG11aRYpBQWFDiJCg266BNQtdnBQyOASQjp1KS4KGVw6iXMWEUdHUShkCBhSQpaQkJg/Jmm/H3xLEdtaWvLawMfJvfec79x77jnnvdfX96/9MpnM9VwudzOfz98qFAq3kYyZ/6tOi8XinVKpdLdSqfRXq9UHwsNarfYIyZh51tH7Y5s5Pj6+BqHI7+OsXq8/aTQag8LzZrM5JAwjGTPPOnroY4f9bzvPZrM3OBEnFPFTOXohvGy1WiPC6/Pz81FhDMmYedbRQx877OG5snPutFwu3zs7OxvQyZ6JPGSnE8KkMN1ut98KYSRjz094MyHssIcHviud3M4fE15OJuJxOZoSZoU5ISIsCIuWEc+zPoW+IzIED3y/FAnujLCxczt/JbI3Pum8sCQsCyudTmdVWEMy9vyS9cLYYe9NDMD705wgcbg7h33Ezmd8wqidrgtxISm8t4x7ns1ErT/jTYzABy/8Pyw1spcE4g4d9rDJ3ok8JiSED8KGsClsWW54nvUY+rYL+zpC8MJ/aYmyO0qILCaRfOfzPnnMJ/0opIRPwk63291FepzyetKbiNp+Cj544b80CtwRdUwpkc1OqCWHPWHybTtNS+5LHlimPb9tvYSvg5yYhQ9e+PFzWfj7aSa++0ln9bLvlvCm7GRP8lDySDhBerzn9ZT1152Yc/A5Fwbxc+EaqFPaKR3N9T7tO1xxgm04zJz0UPis/6fCFyRjbyJtPfTjro4IfPDCj58LfYEHCllKydDZ3GQWHP6kE23H4T6y05Jk1fLUkdh3TmzabtV9gmY1Cj9+8PfdBniqOQGHaa/O/kXXOaW25fAeOOycvPpVP6THJ86JXVcHdmtuVlTDGPz4wV+wItDzHOh5FfS8DwSiE/b8WdDzp2Eg3gd6/kYUiHfCQLwVB+K7IBBfRoH5Nvyvf98A3rZr7fen7G8AAAAASUVORK5CYII=';
716 | this.buffer = [];
717 | this._sortFn = function (a, b) {
718 | return (a.__z || 0) - (b.__z || 0);
719 | };
720 | }
721 | PixiRenderer.prototype.updateParticleSprite = function (emitter, particle) {
722 | if (particle.life <= 0 && particle.sprite) {
723 | particle.sprite.visible = false;
724 | return;
725 | }
726 |
727 | if (!particle.sprite || particle.recycled) {
728 | var texture = PIXI.Texture.fromImage(particle.texture || this.defaultTexture);
729 |
730 | if (particle.recycled && particle.sprite) {
731 | particle.sprite.texture = texture;
732 | } else {
733 | particle.sprite = new PIXI.Sprite(texture);
734 | }
735 |
736 | particle.sprite.__parentParticle = particle;
737 |
738 | particle.sprite.anchor.x = 0.5;
739 | particle.sprite.anchor.y = 0.5;
740 |
741 | particle.sprite.tail = 0;
742 | }
743 |
744 | if (!particle.inserted) {
745 | particle.inserted = true;
746 | this.buffer.push(particle.sprite);
747 | emitter.container.addChild(particle.sprite);
748 | }
749 |
750 | particle.sprite.visible = particle.life > 0;
751 | particle.sprite.width = particle.radius * particle.scale;
752 | particle.sprite.height = particle.radius * particle.scale;
753 |
754 | particle.sprite.position.x = particle.pos.x;
755 | particle.sprite.position.y = particle.pos.y;
756 | if (particle.textureAdditive) {
757 | particle.sprite.blendMode = PIXI.blendModes.ADD;
758 | } else {
759 | particle.sprite.blendMode = PIXI.blendModes.NORMAL;
760 | }
761 |
762 | particle.sprite.tint = ~~particle.color[2] + 256 * ~~particle.color[1] + 65536 * ~~particle.color[0];
763 | particle.sprite.alpha = particle.color[3];
764 | };
765 |
766 | PixiRenderer.prototype.render = function (emitter) {
767 | var particles = emitter.particles;
768 |
769 | if (!emitter.container) {
770 | emitter.container = new PIXI.DisplayObjectContainer();
771 | this.context.addChild(emitter.container);
772 | }
773 |
774 | for (var i = 0; i < particles.length; ++i) {
775 | var p = particles[i];
776 | if (p.color) {
777 | this.updateParticleSprite(emitter, p);
778 | }
779 | }
780 |
781 | if (emitter.recyclable.length > 0) {
782 | var particle;
783 | while (particle = emitter.recyclable.pop()) {
784 | particle.life = 0;
785 | if (particle.sprite) {
786 | particle.sprite.visible = false;
787 | if (particle.sprite.__parentParticle)
788 | particle.sprite.__parentParticle.inserted = false;
789 | }
790 | }
791 | }
792 | };
793 |
794 | PixiRenderer.prototype.hideAllParticles = function (emitter) {
795 | for (var i = 0; i < emitter.particles.length; i++) {
796 | var particle = emitter.particles[i];
797 | particle.life = 0;
798 | }
799 | };
800 |
801 | PixiRenderer.prototype.sort = function () {
802 | this.context.children.sort(this._sortFn);
803 | };
804 | PixiRenderer.prototype.reset = function () {
805 | var removed = 0;
806 | do {
807 | var sprite = this.buffer.pop();
808 | if (!sprite)
809 | continue;
810 | for (var i = 0; i < this.context.children.length; i++) {
811 | var emitterContext = this.context.children[i];
812 | if (!emitterContext)
813 | continue;
814 |
815 | try {
816 | emitterContext.removeChild(sprite);
817 |
818 | removed++;
819 | continue;
820 | } catch (ex) {
821 | }
822 | }
823 |
824 | if (sprite.__parentParticle) {
825 | sprite.__parentParticle.inserted = false;
826 | sprite.__parentParticle.life = 0;
827 | }
828 | } while(this.buffer.length > 0);
829 | console.log('reset particles = ', removed);
830 | };
831 | return PixiRenderer;
832 | })();
833 | EPSY.PixiRenderer = PixiRenderer;
834 | })(EPSY || (EPSY = {}));
835 | //# sourceMappingURL=EPSY.js.map
836 |
--------------------------------------------------------------------------------
/build/EPSY.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"EPSY.js","sourceRoot":"","sources":["../utils/math.ts","../utils/obj.ts","../core/Emitter.class.ts","../core/EmitterEntity.ts","../core/Particle.class.ts","../render/CanvasRenderer.ts","../render/PixiRenderer.ts"],"names":["EPSY","EPSY.utils","EPSY.utils.math","EPSY.utils.math.toRad","EPSY.utils.math.isNumber","EPSY.utils.math.isInteger","EPSY.utils.math.frandom","EPSY.utils.math.irandom","EPSY.utils.math.normalize","EPSY.utils.obj","EPSY.utils.obj.clone","EPSY.utils.obj.extend","EPSY.utils.obj.recursiveExtend","EPSY.utils.obj.recursiveExtendInclusive","EPSY.Emitter","EPSY.Emitter.constructor","EPSY.Emitter.load","EPSY.Emitter.save","EPSY.Emitter.restart","EPSY.Emitter.reset","EPSY.Emitter._isFull","EPSY.Emitter.createParticle","EPSY.Emitter.initParticle","EPSY.Emitter.updateParticle","EPSY.Emitter.kill","EPSY.Emitter.update","EPSY.EmitterEntity","EPSY.EmitterEntity.constructor","EPSY.Particle","EPSY.Particle.constructor","EPSY.Particle.setVelocity","EPSY.colorArrayToString","EPSY.getBuffer","EPSY.CanvasRenderer","EPSY.CanvasRenderer.constructor","EPSY.CanvasRenderer.renderParticle","EPSY.CanvasRenderer.render","EPSY.CanvasRenderer.reset","EPSY.PixiRenderer","EPSY.PixiRenderer.constructor","EPSY.PixiRenderer.updateParticleSprite","EPSY.PixiRenderer.render","EPSY.PixiRenderer.hideAllParticles","EPSY.PixiRenderer.sort","EPSY.PixiRenderer.reset"],"mappings":"AAAA,IAAO,IAAI;AAiCV,CAjCD,UAAO,IAAI;KAAXA,UAAYA,KAAKA;SAAjBC,UAAkBA,IAAIA;YAClBC,SAAgBA,KAAKA,CAACA,GAAGA;gBACrBC,OAAOA,IAAIA,CAACA,EAAEA,GAAGA,GAAGA,GAAGA,GAAGA;YAC9BA,CAACA;YAFDD,m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ACA,CAACA,QAAQA,CAACA,UAAUA,CAACA,CAACA,CAACA;oBACjDA,QAAQA,CAACA,QAAQA,CAACA,CAACA,CAACA,GAAGA,CAACA,CAACA,QAAQA,CAACA,QAAQA,CAACA,CAACA,CAACA;oBAC7CA,QAAQA,CAACA,UAAUA,CAACA,CAACA,CAACA,GAAGA,CAACA,CAACA,QAAQA,CAACA,UAAUA,CAACA,CAACA,CAACA;iBACpDA;aACJA;QACLA,CAACA;;QAGDR,mCAAAA,UAAuBA,CAAUA,EAAEA,KAAKA,EAAEA,CAACA;YACvCS,IAAIA,MAAMA,GAAGA,CAACA,CAACA,IAAIA,CAACA,MAAMA,CAACA,IACvBA,CAACA,CAACA,CAACA,GAAGA,CAACA,CAACA,IAAIA,IAAIA,CAACA,QAAQA,CAACA,GAAGA,CAACA,CAACA,GAAGA,IAAIA,CAACA,MAAMA,CAACA,IAAIA,IAAIA,CAACA,CAACA,GAAGA,CAACA,CAACA,IAAIA,IAAIA,CAACA,QAAQA,CAACA,GAAGA,CAACA,CAACA,GAAGA,IAAIA,CAACA,MAAMA,CAACA,GAAGA,IAAIA,CAACA,CAACA,GAAGA,CAACA,CAACA,IAAIA,IAAIA,CAACA,QAAQA,CAACA,GAAGA,CAACA,CAACA,GAAGA,IAAIA,CAACA,MAAMA,CAACA,KAAKA,IAAIA,CAACA,CAACA,GAAGA,CAACA,CAACA,IAAIA,IAAIA,CAACA,QAAQA,CAACA,GAAGA,CAACA,CAACA,GAAGA,IAAIA,CAACA,MAAMA,CAACA,MAAMA,CAACA;;YAGxNA,IAAIA,CAACA,MAAMA,CAAEA;gBAETA,CAACA,CAACA,IAAIA,GAAGA,CAACA;aACbA;;YAEDA,IAAIA,CAACA,CAACA,IAAIA,GAAGA,CAACA,CAAEA;gBAEZA,CAACA,CAACA,MAAMA,CAACA,CAACA,GAAGA,CAACA;gBACdA,CAACA,CAACA,MAAMA,CAACA,CAACA,GAAGA,CAACA;gBACdA,CAACA,CAACA,MAAMA,CAACA,CAACA,GAAGA,CAACA;gBACdA,CAACA,CAACA,MAAMA,CAACA,CAACA,GAAGA,CAACA;;gBAIdA,IAAIA,CAACA,CAACA,CAACA,GAAGA,CAACA,CAACA,KAAKA,IAAIA,CAACA,QAAQA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,GAAGA,CAACA,CAACA,KAAKA,IAAIA,CAACA,QAAQA,CAACA,GAAGA,CAACA,CAACA,CAACA,IAAIA,CAACA,CAACA,CAACA,WAAWA,IAAIA,CAACA,CAACA,eAAeA,CAACA,CAAEA;oBAC9GA,CAACA,CAACA,MAAMA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,IAAIA,CAACA,QAAQA,CAACA,GAAGA,CAACA,CAACA;oBAC1CA,CAACA,CAACA,MAAMA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,IAAIA,CAACA,QAAQA,CAACA,GAAGA,CAACA,CAACA;;oBAE1CA,UAAKA,CAACA,IAAIA,CAACA,SAASA,CAACA,CAACA,CAACA,MAAMA,CAACA;iBACjCA;;gBAEDA,CAACA,CAACA,UAAUA,CAACA,CAACA,GAAGA,CAACA,CAACA,MAAMA,CAACA,CAACA;gBAC3BA,CAACA,CAACA,UAAUA,CAACA,CAACA,GAAGA,CAACA,CAACA,MAAMA,CAACA,CAACA;;gBAE3BA,CAACA,CAACA,MAAMA,CAACA,CAACA,IAAIA,CAACA,CAACA,WAAWA;gBAC3BA,CAACA,CAACA,MAAMA,CAACA,CAACA,IAAIA,CAACA,CAACA,WAAWA;;gBAE3BA,IAAIA,IAAIA,GAAGA,CAACA,CAACA,UAAUA,CAACA,CAACA;gBACzBA,CAACA,CAACA,UAAUA,CAACA,CAACA,GAAGA,CAAEA,CAACA,CAACA,UAAUA,CAACA,CAACA;gBACjCA,CAACA,CAACA,UAAUA,CAACA,CAACA,GAAGA,IAAIA;;gBAErBA,CAACA,CAACA,UAAUA,CAACA,CAACA,IAAIA,CAACA,CAACA,eAAeA;gBACnCA,CAACA,CAACA,UAAUA,CAACA,CAACA,IAAIA,CAACA,CAACA,eAAeA;;gBAEnCA,CAACA,CAACA,MAAMA,CAACA,CAACA,GAAGA,CAACA,CAACA,MAAMA,CAACA,CAACA,GAAGA,CAACA,CAACA,UAAUA,CAACA,CAACA,GAAGA,IAAIA,CAACA,QAAQA,CAACA,OAAOA,CAACA,CAACA;gBAClEA,CAACA,CAACA,MAAMA,CAACA,CAACA,GAAGA,CAACA,CAACA,MAAMA,CAACA,CAACA,GAAGA,CAACA,CAACA,UAAUA,CAACA,CAACA,GAAGA,IAAIA,CAACA,QAAQA,CAACA,OAAOA,CAACA,CAACA;;gBAIlEA,CAACA,CAACA,MAAMA,CAACA,CAACA,IAAIA,KAAKA;gBACnBA,CAACA,CAACA,MAAMA,CAACA,CAACA,IAAIA,KAAKA;;gBAEnBA,CAACA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,MAAMA,CAACA,CAACA;gBACrBA,CAACA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,MAAMA,CAACA,CAACA;;gBAErBA,CAACA,CAACA,OAAOA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA;gBACrBA,CAACA,CAACA,OAAOA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA;;gBAIrBA,IAAIA,EAAEA,GAAGA,CAACA;gBACVA,IAAIA,EAAEA,GAAGA,CAACA;gBACVA,IAAIA,IAAIA,CAACA,UAAUA;oBAAEA,EAAEA,GAAGA,IAAIA,CAACA,OAAOA,CAACA,CAACA,GAAGA,IAAIA,CAACA,UAAUA,CAACA,CAACA,CAACA,IAAIA,GAAGA,IAAIA,CAACA,OAAOA,CAACA,CAACA,GAAGA,IAAIA,CAACA,EAAEA,CAACA,CAACA;gBAC9FA,IAAIA,IAAIA,CAACA,UAAUA;oBAAEA,EAAEA,GAAGA,IAAIA,CAACA,OAAOA,CAACA,CAACA,GAAGA,IAAIA,CAACA,UAAUA,CAACA,CAACA,CAACA,IAAIA,GAAGA,IAAIA,CAACA,OAAOA,CAACA,CAACA,GAAGA,IAAIA,CAACA,EAAEA,CAACA,CAACA;;gBAI9FA,CAACA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,KAAKA,GAAEA,EAAEA;gBAC9BA,CAACA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,KAAKA,GAAEA,EAAEA;;gBAE9BA,CAACA,CAACA,IAAIA,IAAIA,KAAKA;;gBAEfA,CAACA,CAACA,KAAKA,IAAIA,CAACA,CAACA,UAAUA,GAAGA,KAAKA;;gBAE/BA,IAAIA,CAACA,CAACA,KAAKA,CAAEA;oBACTA,IAAIA,IAAIA,CAACA,QAAQA,CAACA,SAASA,CAACA,MAAMA,GAACA,CAACA,CAAEA;wBAClCA,CAACA,CAACA,KAAKA,CAACA,CAACA,CAACA,GAAGA,IAAIA,CAACA,QAAQA,CAACA,SAASA,CAACA,CAACA,CAACA,QAAQA,CAACA,CAACA,CAACA,CAACA;wBACnDA,CAACA,CAACA,KAAKA,CAACA,CAACA,CAACA,GAAGA,IAAIA,CAACA,QAAQA,CAACA,SAASA,CAACA,CAACA,CAACA,QAAQA,CAACA,CAACA,CAACA,CAACA;wBACnDA,CAACA,CAACA,KAAKA,CAACA,CAACA,CAACA,GAAGA,IAAIA,CAACA,QAAQA,CAACA,SAASA,CAACA,CAACA,CAACA,QAAQA,CAACA,CAACA,CAACA,CAACA;wBACnDA,CAACA,CAACA,KAAKA,CAACA,CAACA,CAACA,GAAGA,IAAIA,CAACA,QAAQA,CAACA,SAASA,CAACA,CAACA,CAACA,QAAQA,CAACA,CAACA,CAACA,CAACA;;wBAEnDA,CAACA,CAACA,QAAQA,EAAEA;wBACZA,IAAIA,CAACA,CAACA,QAAQA,IAAIA,IAAIA,CAACA,QAAQA,CAACA,SAASA,CAACA,MAAMA;4BAAEA,CAACA,CAACA,QAAQA,GAAGA,CAACA,CAACA;qBACpEA,KACIA;wBACDA,CAACA,CAACA,KAAKA,CAACA,CAACA,CAACA,IAAIA,CAACA,CAACA,UAAUA,CAACA,CAACA,CAACA,GAAGA,KAAKA;wBACrCA,CAACA,CAACA,KAAKA,CAACA,CAACA,CAACA,IAAIA,CAACA,CAACA,UAAUA,CAACA,CAACA,CAACA,GAAGA,KAAKA;wBACrCA,CAACA,CAACA,KAAKA,CAACA,CAACA,CAACA,IAAIA,CAACA,CAACA,UAAUA,CAACA,CAACA,CAACA,GAAGA,KAAKA;wBACrCA,CAACA,CAACA,KAAKA,CAACA,CAACA,CAACA,IAAIA,CAACA,CAACA,UAAUA,CAACA,CAACA,CAACA,GAAGA,KAAKA;qBACxCA;iBACJA;;gBAGDA,EAAEA,IAAIA,CAACA,cAAcA;aACxBA,KAAMA;gBACHA,CAACA,CAACA,KAAKA,CAACA,CAACA,CAACA,GAAGA,CAACA;;gBAKdA,IAAIA,IAAIA,GAAGA,IAAIA,CAACA,aAAaA,CAACA,CAACA,CAACA;;gBAIhCA,IAAIA,CAACA,aAAaA,CAACA,CAACA,CAACA,GAAGA,IAAIA,CAACA,aAAaA,CAACA,IAAIA,CAACA,cAAcA,GAAGA,CAACA,CAACA;gBACnEA,IAAIA,CAACA,aAAaA,CAACA,IAAIA,CAACA,cAAcA,GAAGA,CAACA,CAACA,GAAGA,IAAIA;;gBAGlDA,EAAEA,IAAIA,CAACA,cAAcA;aAGxBA;QACLA,CAACA;;QAEDT,yBAAAA;YACIU,KAAKA,IAAIA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,IAAIA,CAACA,aAAaA,CAACA,MAAMA,EAAEA,CAACA,EAAEA,CAAEA;gBAChDA,IAAIA,CAACA,GAAGA,IAAIA,CAACA,aAAaA,CAACA,CAACA,CAACA;gBAC7BA,CAACA,CAACA,IAAIA,GAAGA,CAACA;aAC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CAACA,CAACA;gBACnCA,QAAQA,CAACA,IAAIA,GAAGA,CAACA;aACpBA;QACLA,CAACA;;QAGDJ,8BAAAA;YACIK,IAAIA,CAACA,OAAOA,CAACA,QAAQA,CAACA,IAAIA,CAACA,IAAIA,CAACA,OAAOA,CAACA;QAC5CA,CAACA;QACDL,+BAAAA;YACIM,IAAIA,OAAOA,GAAGA,CAACA;YACXA,EAAGA;gBACCA,IAAIA,MAAMA,GAAGA,IAAIA,CAACA,MAAMA,CAACA,GAAGA,CAACA,CAACA;gBAC9BA,IAAIA,CAACA,MAAMA;oBAAEA,QAASA,CAAAA;gBACtBA,KAAKA,IAAIA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,IAAIA,CAACA,OAAOA,CAACA,QAAQA,CAACA,MAAMA,EAAEA,CAACA,EAAEA,CAAEA;oBACnDA,IAAIA,cAAcA,GAAgCA,IAAIA,CAACA,OAAOA,CAACA,QAAQA,CAACA,CAACA,CAACA;oBAC1EA,IAAIA,CAACA,cAAcA;wBAAEA,QAASA,CAAAA;;oBAE9BA,IAAIA;wBACJA,cAAcA,CAACA,WAAWA,CAACA,MAAMA,CAACA;;wBAElCA,OAAOA,EAAEA;wBACLA,QAASA;qBACZA,CAACA,OAAOA,EAAEA,CAAEA;qBAAGA;iBAEnBA;;gBAIDA,IAAIA,MAAMA,CAACA,gBAAgBA,CAAEA;oBACzBA,MAAMA,CAACA,gBAAgBA,CAACA,QAAQA,GAAGA,KAAKA;oBACxCA,MAAMA,CAACA,gBAAgBA,CAACA,IAAIA,GAAGA,CAACA;iBACnCA;aAEJA,MAAMA,CAAEA,IAAIA,CAACA,MAAMA,CAACA,MAAMA,GAAGA,CAACA,CAAEA;YACrCA,OAAOA,CAACA,GAAGA,CAACA,oBAAoBA,EAAEA,OAAOA,CAACA;QAE9CA,CAACA;QAELN,oBAACA;IAADA,CAACA,IAAAtC;IAvJDA,iCAuJCA;AACLA,CAACA,uBAAA"}
--------------------------------------------------------------------------------
/build/EPSY.min.js:
--------------------------------------------------------------------------------
1 | /*! EPSY v0.3.1 2015-02-26 */
2 | var EPSY;!function(a){!function(a){!function(a){function b(a){return Math.PI*a/180}function c(a){return"number"==typeof a}function d(a){return a===(0|a)}function e(a,b){return Math.random()*(b-a)+a}function f(a,b){return Math.floor(Math.random()*(b-a+1)+a)}function g(a){var b=Math.sqrt(a.x*a.x+a.y*a.y);a.x/=b,a.y/=b}a.toRad=b,a.isNumber=c,a.isInteger=d,a.frandom=e,a.irandom=f,a.normalize=g}(a.math||(a.math={}));a.math}(a.utils||(a.utils={}));a.utils}(EPSY||(EPSY={}));var EPSY;!function(a){!function(a){!function(a){function b(a){var b={};return this.extend(b,a),b}function c(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])}function d(a,b,c){c=c||[];for(var d in b)b.hasOwnProperty(d)&&(c.indexOf(d)>-1?a[d]=b[d]:"object"==typeof b[d]?this.recursiveExtend(a[d],b[d],c):a[d]=b[d])}function e(a,b,c){if(c&&c.length&&!(c.length<=0))for(var d in b)c.indexOf(d)>=0&&("object"==typeof b[d]?(a[d]||(a[d]={}),this.recursiveExtend(a[d],b[d])):a[d]=b[d])}a.clone=b,a.extend=c,a.recursiveExtend=d,a.recursiveExtendInclusive=e}(a.obj||(a.obj={}));a.obj}(a.utils||(a.utils={}));a.utils}(EPSY||(EPSY={}));var EPSY;!function(a){a.EmitterParams=["id","border","duration","emissionRate","totalParticles","xFactor","aFactor","xEquation","yEquation","posTransform","zIndex"];var b=function(){function b(b){this.id=(1e20*Math.random()).toString(36),this.settings=new a.EmitterEntity,this.time=Date.now(),this._totalParticles=0,this.emissionRate=0,this.allOrNone=!1,this.aFactor={x:0,y:0},this.xFactor={x:0,y:0},this._xEqName="",this._yEqName="",this.active=!1,this.duration=0,this.cycles=1/0,this._particlePool=[],this._particleCount=0,this._particleIndex=0,this._elapsed=0,this._curCycle=0,this._emitCounter=0,this.border={top:100,left:100,bottom:100,right:100},this.recyclable=[],this._baseSystem=a.utils.obj.clone(b,["texture"]),this.load(b)}return Object.defineProperty(b.prototype,"zIndex",{get:function(){return this.container?this.container.__z||0:0},set:function(a){this.container&&(this.container.__z=~~a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"xEquation",{get:function(){return this._xEqName},set:function(a){"function"==typeof Math[a]?(this._xEqName=a,this._xEquation=Math[a]):(this._xEqName="",this._xEquation=void 0)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"yEquation",{get:function(){return this._yEqName},set:function(a){"function"==typeof Math[a]?(this._yEqName=a,this._yEquation=Math[a]):(this._yEqName="",this._yEquation=void 0)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"posTransform",{get:function(){if(!this._posTransform)return void 0;var a=this._posTransform.toString();return a.match(/[^{]+(.+)\}/g)[0]},set:function(a){this._posTransform="function"==typeof a?a:new Function("pos","particle",a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"particles",{get:function(){return this._particlePool},set:function(a){this._particlePool=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"totalParticles",{get:function(){return this._totalParticles},set:function(a){a=0|a,a!==this._totalParticles&&(this._totalParticles=a,this.restart())},enumerable:!0,configurable:!0}),b.prototype.load=function(b){this._totalParticles=0,this.emissionRate=0,this.active=!1,this.duration=0,this.settings.pos.x=0,this.settings.pos.y=0,this.settings.posVar.x=0,this.settings.posVar.y=0,this.settings.speed=0,this.settings.speedVar=0,this.settings.angle=0,this.settings.angleVar=0,this.settings.life=0,this.settings.lifeVar=0,this.settings.radius=0,this.settings.radiusVar=0,this.settings.texture=null,this.settings.textureAdditive=!1,this.settings.startScale=0,this.settings.startScaleVar=0,this.settings.endScale=0,this.settings.endScaleVar=0,this.settings.startColor[0]=0,this.settings.startColor[1]=0,this.settings.startColor[2]=0,this.settings.startColor[3]=0,this.settings.startColorVar[0]=0,this.settings.startColorVar[1]=0,this.settings.startColorVar[2]=0,this.settings.startColorVar[3]=0,this.settings.endColor[0]=0,this.settings.endColor[1]=0,this.settings.endColor[2]=0,this.settings.endColor[3]=0,this.settings.endColorVar[0]=0,this.settings.endColorVar[1]=0,this.settings.endColorVar[2]=0,this.settings.endColorVar[3]=0,this.settings.gravity.x=0,this.settings.gravity.y=0,this.settings.radialAccel=0,this.settings.radialAccelVar=0,this.settings.tangentialAccel=0,this.settings.tangentialAccelVar=0,a.utils.obj.recursiveExtend(this.settings,b,a.EmitterParams),a.utils.obj.recursiveExtendInclusive(this,b,a.EmitterParams),isNaN(this.duration)&&(this.duration=1/0),this.id=b.name||this.id,this.restart()},b.prototype.save=function(){var b=JSON.parse(JSON.stringify(this.settings));return a.utils.obj.recursiveExtendInclusive(b,this,a.EmitterParams),b},b.prototype.restart=function(){if(this._particlePool.lengththis.totalParticles){var c=this._particlePool.splice(this.totalParticles);this.recyclable=this.recyclable.concat(c)}for(var b=0;bi;i++)b.startColor[i]=~~b.startColor[i],b.endColor[i]=~~b.endColor[i],b.deltaColor[i]=~~b.deltaColor[i]}},b.prototype.updateParticle=function(b,c,d){var e=!this.border||b.pos.x>=this.settings.pos.x-this.border.left&&b.pos.y>=this.settings.pos.y-this.border.top&&b.pos.x<=this.settings.pos.x+this.border.right&&b.pos.y<=this.settings.pos.y+this.border.bottom;if(e||(b.life=0),b.life>0){b.radial.x=0,b.radial.y=0,b.forces.x=0,b.forces.y=0,b.pos.x===this.settings.pos.x&&b.pos.y===this.settings.pos.y||!b.radialAccel&&!b.tangentialAccel||(b.radial.x=b.pos.x-this.settings.pos.x,b.radial.y=b.pos.y-this.settings.pos.y,a.utils.math.normalize(b.radial)),b.tangential.x=b.radial.x,b.tangential.y=b.radial.y,b.radial.x*=b.radialAccel,b.radial.y*=b.radialAccel;var f=b.tangential.x;b.tangential.x=-b.tangential.y,b.tangential.y=f,b.tangential.x*=b.tangentialAccel,b.tangential.y*=b.tangentialAccel,b.forces.x=b.radial.x+b.tangential.x+this.settings.gravity.x,b.forces.y=b.radial.y+b.tangential.y+this.settings.gravity.y,b.forces.x*=c,b.forces.y*=c,b.vel.x+=b.forces.x,b.vel.y+=b.forces.y,b.lastpos.x=b.pos.x,b.lastpos.y=b.pos.y;var g=0,h=0;this._xEquation&&(g=this.aFactor.x*this._xEquation(b.life*this.xFactor.x*Math.PI)),this._yEquation&&(h=this.aFactor.y*this._yEquation(b.life*this.xFactor.y*Math.PI)),b.pos.x+=b.vel.x*c+g,b.pos.y+=b.vel.y*c+h,b.life-=c,b.scale+=b.deltaScale*c,b.color&&(this.settings.colorList.length>0?(b.color[0]=this.settings.colorList[b.colorIdx][0],b.color[1]=this.settings.colorList[b.colorIdx][1],b.color[2]=this.settings.colorList[b.colorIdx][2],b.color[3]=this.settings.colorList[b.colorIdx][3],b.colorIdx++,b.colorIdx>=this.settings.colorList.length&&(b.colorIdx=0)):(b.color[0]+=b.deltaColor[0]*c,b.color[1]+=b.deltaColor[1]*c,b.color[2]+=b.deltaColor[2]*c,b.color[3]+=b.deltaColor[3]*c)),++this._particleIndex}else{b.color[3]=0;var i=this._particlePool[d];this._particlePool[d]=this._particlePool[this._particleCount-1],this._particlePool[this._particleCount-1]=i,--this._particleCount}},b.prototype.kill=function(){for(var a=0;ab;)this.createParticle(),this._emitCounter-=b}for(this._particleIndex=0;this._particleIndex0&&d.color&&this.renderParticle(d)}this.context.globalCompositeOperation="source-over"},a.prototype.reset=function(){},a}();a.CanvasRenderer=e}(EPSY||(EPSY={}));var EPSY;!function(a){var b=function(){function a(a){this.context=a,this.defaultTexture="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACz0lEQVR42t2XP0hbURTGnfp/KK3QFiylCG11aRYpBQWFDiJCg266BNQtdnBQyOASQjp1KS4KGVw6iXMWEUdHUShkCBhSQpaQkJg/Jmm/H3xLEdtaWvLawMfJvfec79x77jnnvdfX96/9MpnM9VwudzOfz98qFAq3kYyZ/6tOi8XinVKpdLdSqfRXq9UHwsNarfYIyZh51tH7Y5s5Pj6+BqHI7+OsXq8/aTQag8LzZrM5JAwjGTPPOnroY4f9bzvPZrM3OBEnFPFTOXohvGy1WiPC6/Pz81FhDMmYedbRQx877OG5snPutFwu3zs7OxvQyZ6JPGSnE8KkMN1ut98KYSRjz094MyHssIcHviud3M4fE15OJuJxOZoSZoU5ISIsCIuWEc+zPoW+IzIED3y/FAnujLCxczt/JbI3Pum8sCQsCyudTmdVWEMy9vyS9cLYYe9NDMD705wgcbg7h33Ezmd8wqidrgtxISm8t4x7ns1ErT/jTYzABy/8Pyw1spcE4g4d9rDJ3ok8JiSED8KGsClsWW54nvUY+rYL+zpC8MJ/aYmyO0qILCaRfOfzPnnMJ/0opIRPwk63291FepzyetKbiNp+Cj544b80CtwRdUwpkc1OqCWHPWHybTtNS+5LHlimPb9tvYSvg5yYhQ9e+PFzWfj7aSa++0ln9bLvlvCm7GRP8lDySDhBerzn9ZT1152Yc/A5Fwbxc+EaqFPaKR3N9T7tO1xxgm04zJz0UPis/6fCFyRjbyJtPfTjro4IfPDCj58LfYEHCllKydDZ3GQWHP6kE23H4T6y05Jk1fLUkdh3TmzabtV9gmY1Cj9+8PfdBniqOQGHaa/O/kXXOaW25fAeOOycvPpVP6THJ86JXVcHdmtuVlTDGPz4wV+wItDzHOh5FfS8DwSiE/b8WdDzp2Eg3gd6/kYUiHfCQLwVB+K7IBBfRoH5Nvyvf98A3rZr7fen7G8AAAAASUVORK5CYII=",this.buffer=[],this._sortFn=function(a,b){return(a.__z||0)-(b.__z||0)}}return a.prototype.updateParticleSprite=function(a,b){if(b.life<=0&&b.sprite)return void(b.sprite.visible=!1);if(!b.sprite||b.recycled){var c=PIXI.Texture.fromImage(b.texture||this.defaultTexture);b.recycled&&b.sprite?b.sprite.texture=c:b.sprite=new PIXI.Sprite(c),b.sprite.__parentParticle=b,b.sprite.anchor.x=.5,b.sprite.anchor.y=.5,b.sprite.tail=0}b.inserted||(b.inserted=!0,this.buffer.push(b.sprite),a.container.addChild(b.sprite)),b.sprite.visible=b.life>0,b.sprite.width=b.radius*b.scale,b.sprite.height=b.radius*b.scale,b.sprite.position.x=b.pos.x,b.sprite.position.y=b.pos.y,b.sprite.blendMode=b.textureAdditive?PIXI.blendModes.ADD:PIXI.blendModes.NORMAL,b.sprite.tint=~~b.color[2]+256*~~b.color[1]+65536*~~b.color[0],b.sprite.alpha=b.color[3]},a.prototype.render=function(a){var b=a.particles;a.container||(a.container=new PIXI.DisplayObjectContainer,this.context.addChild(a.container));for(var c=0;c0)for(var e;e=a.recyclable.pop();)e.life=0,e.sprite&&(e.sprite.visible=!1,e.sprite.__parentParticle&&(e.sprite.__parentParticle.inserted=!1))},a.prototype.hideAllParticles=function(a){for(var b=0;b0);console.log("reset particles = ",a)},a}();a.PixiRenderer=b}(EPSY||(EPSY={}));
--------------------------------------------------------------------------------
/core/Emitter.class.ts:
--------------------------------------------------------------------------------
1 |
2 | module EPSY {
3 | export var EmitterParams = ['id', 'border', 'duration', 'emissionRate', 'totalParticles', 'xFactor', 'aFactor', 'xEquation', 'yEquation', 'posTransform', 'zIndex'];
4 |
5 | export class Emitter {
6 | public id = (Math.random() * 1e20).toString(36);
7 |
8 |
9 |
10 | public container: any;
11 |
12 | public settings = new EmitterEntity();
13 |
14 |
15 | private time = Date.now();
16 |
17 | //public _defaultTexture: any;
18 | //public _predefinedSystemName: any;
19 | public _baseSystem: any;
20 | public _totalParticles = 0;
21 |
22 |
23 | public emissionRate = 0;
24 | public allOrNone = false;
25 |
26 |
27 | public aFactor = { x: 0, y: 0 };
28 | public xFactor = { x: 0, y: 0 };
29 | private _xEquation: (number) => any;
30 | private _yEquation: (number) => any;
31 | private _xEqName: string = '';
32 | private _yEqName: string = '';
33 | private _posTransform: (...any) => any;
34 |
35 |
36 |
37 |
38 | public active = false;
39 | public duration = 0;
40 | public cycles = Infinity;
41 |
42 |
43 |
44 |
45 | private _particlePool: Particle[] = [];
46 | private _particleCount = 0;
47 | private _particleIndex = 0;
48 | private _elapsed = 0;
49 | private _curCycle = 0;
50 | private _emitCounter = 0;
51 |
52 | public border = {top:100, left:100, bottom:100, right:100};
53 |
54 | public recyclable = [];
55 |
56 | constructor(system) {
57 | this._baseSystem = utils.obj.clone(system, ['texture']);
58 | this.load(system);
59 | }
60 |
61 |
62 | //#region [Getters/Setters] ===========================================
63 | get zIndex(): number {
64 | if (this.container) {
65 | return this.container.__z || 0;
66 | }
67 |
68 | return 0;
69 | }
70 | set zIndex(value: number) {
71 | if (this.container) {
72 | this.container.__z = ~~value;
73 | }
74 | }
75 |
76 | get xEquation(): string {
77 | return this._xEqName;
78 | }
79 | set xEquation(value: string) {
80 | if (typeof Math[value] == 'function') {
81 | this._xEqName = value;
82 | this._xEquation = Math[value];
83 | }
84 | else {
85 | this._xEqName = '';
86 | this._xEquation = undefined;
87 | }
88 | }
89 | get yEquation(): string {
90 | return this._yEqName;
91 | }
92 | set yEquation(value: string) {
93 | if (typeof Math[value] == 'function') {
94 | this._yEqName = value;
95 | this._yEquation = Math[value];
96 | }
97 | else {
98 | this._yEqName = '';
99 | this._yEquation = undefined;
100 | }
101 | }
102 |
103 |
104 | get posTransform(): any {
105 | if (!this._posTransform) return undefined;
106 |
107 |
108 | var code = this._posTransform.toString();
109 | return code.match(/[^{]+(.+)\}/g)[0]
110 | }
111 | set posTransform(fn: any) {
112 | if (typeof fn == 'function') {
113 | this._posTransform = fn;
114 | }
115 | else {
116 | this._posTransform = <(...any)=>any>new Function('pos', 'particle', fn);
117 | }
118 | }
119 |
120 |
121 |
122 |
123 | get particles(): Particle[] {
124 | return this._particlePool;
125 | }
126 | set particles(value: Particle[]) {
127 | this._particlePool = value;
128 | }
129 |
130 |
131 |
132 | get totalParticles(): number {
133 | return this._totalParticles;
134 | }
135 | set totalParticles(tp: number) {
136 | tp = tp | 0;
137 | if (tp !== this._totalParticles) {
138 | this._totalParticles = tp;
139 | this.restart();
140 | }
141 | }
142 |
143 | //#endregion ===========================================================
144 |
145 |
146 |
147 | /*
148 | * Applies all the properties in config to the particle system,
149 | * a good way to change just one or two things about the system
150 | * on the fly
151 | */
152 | //public overlay(config) {
153 | // util.extend(this, config);
154 | // this.restart();
155 | //}
156 |
157 | //public resetTexture() {
158 | // this.overlay({
159 | // texture: this._defaultTexture
160 | // });
161 | //}
162 |
163 | /*
164 | * completely reconfigures the particle system. First applies all
165 | * the defaults, then overlays everything found in config
166 | */
167 | public load(config) {
168 | this._totalParticles = 0;
169 | this.emissionRate = 0;
170 |
171 | this.active = false;
172 | this.duration = 0;
173 |
174 |
175 | this.settings.pos.x = 0;
176 | this.settings.pos.y = 0;
177 |
178 |
179 | this.settings.posVar.x = 0;
180 | this.settings.posVar.y = 0;
181 |
182 | this.settings.speed = 0;
183 | this.settings.speedVar = 0;
184 |
185 | this.settings.angle = 0;
186 | this.settings.angleVar = 0;
187 |
188 | this.settings.life = 0;
189 | this.settings.lifeVar = 0;
190 |
191 | this.settings.radius = 0;
192 | this.settings.radiusVar = 0;
193 |
194 | this.settings.texture = null;
195 |
196 | this.settings.textureAdditive = false;
197 |
198 | this.settings.startScale = 0;
199 | this.settings.startScaleVar = 0;
200 | this.settings.endScale = 0;
201 | this.settings.endScaleVar = 0;
202 |
203 |
204 | this.settings.startColor[0] = 0;
205 | this.settings.startColor[1] = 0;
206 | this.settings.startColor[2] = 0;
207 | this.settings.startColor[3] = 0;
208 |
209 |
210 | this.settings.startColorVar[0] = 0;
211 | this.settings.startColorVar[1] = 0;
212 | this.settings.startColorVar[2] = 0;
213 | this.settings.startColorVar[3] = 0;
214 |
215 |
216 | this.settings.endColor[0] = 0;
217 | this.settings.endColor[1] = 0;
218 | this.settings.endColor[2] = 0;
219 | this.settings.endColor[3] = 0;
220 |
221 |
222 | this.settings.endColorVar[0] = 0;
223 | this.settings.endColorVar[1] = 0;
224 | this.settings.endColorVar[2] = 0;
225 | this.settings.endColorVar[3] = 0;
226 |
227 |
228 | this.settings.gravity.x = 0;
229 | this.settings.gravity.y = 0;
230 |
231 | this.settings.radialAccel = 0;
232 | this.settings.radialAccelVar = 0;
233 | this.settings.tangentialAccel = 0;
234 | this.settings.tangentialAccelVar = 0;
235 |
236 |
237 | utils.obj.recursiveExtend(this.settings, config, EmitterParams);
238 | utils.obj.recursiveExtendInclusive(this, config, EmitterParams);
239 |
240 | if (isNaN(this.duration)) this.duration = Infinity;
241 |
242 |
243 | this.id = config.name || this.id;
244 |
245 |
246 | this.restart();
247 | }
248 |
249 | public save() {
250 | var pconfig = JSON.parse(JSON.stringify(this.settings));
251 | utils.obj.recursiveExtendInclusive(pconfig, this, EmitterParams);
252 |
253 | return pconfig;
254 |
255 | }
256 |
257 | /*
258 | */
259 | public restart() {
260 | if (this._particlePool.length < this.totalParticles) {
261 | for (var i = this._particlePool.length; i < this.totalParticles; ++i) {
262 | this._particlePool.push(new Particle());
263 | }
264 | }
265 |
266 | if (this._particlePool.length > this.totalParticles) {
267 | var spliced = this._particlePool.splice(this.totalParticles);
268 |
269 | this.recyclable = this.recyclable.concat(spliced);
270 | }
271 |
272 |
273 |
274 | for (var i = 0; i < this.totalParticles; ++i) {
275 | var particle: Particle = this._particlePool[i];
276 | particle.recycled = true;
277 |
278 |
279 | }
280 |
281 | this._particleCount = 0;
282 | this._particleIndex = 0;
283 | this._elapsed = 0;
284 | this._curCycle = 0;
285 | this._emitCounter = 0;
286 | }
287 |
288 | public reset() {
289 | this.load(this._baseSystem);
290 | }
291 |
292 | /*
293 | * Returns whether all the particles in the pool are currently active
294 | */
295 | private _isFull() {
296 | return this._particleCount === this.totalParticles;
297 | }
298 |
299 | /*
300 | * Recycle particle if available, otherwise do nothing
301 | */
302 | private createParticle() {
303 | if (this._isFull()) {
304 | return false;
305 | }
306 |
307 | var p = this._particlePool[this._particleCount];
308 |
309 | this.initParticle(p);
310 |
311 | this._particleCount++;
312 |
313 | return true;
314 | }
315 |
316 |
317 |
318 | /*
319 | * Initializes the particle based on the current settings
320 | * of the particle system
321 | */
322 | private initParticle(particle:Particle) {
323 | particle.texture = this.settings.texture;
324 | particle.textureAdditive = this.settings.textureAdditive;
325 |
326 |
327 | var posVar = {
328 | x: this.settings.posVar.x * utils.math.frandom(-1,1),
329 | y: this.settings.posVar.y * utils.math.frandom(-1, 1)
330 | };
331 | if (this._posTransform) {
332 | posVar = this._posTransform.call(this, posVar, particle);
333 | }
334 |
335 |
336 | particle.pos.x = this.settings.pos.x + posVar.x;
337 | particle.pos.y = this.settings.pos.y + posVar.y;
338 |
339 | var angle = this.settings.angle + this.settings.angleVar * utils.math.frandom(-1, 1);
340 | var speed = this.settings.speed + this.settings.speedVar * utils.math.frandom(-1, 1);
341 |
342 | // it's easier to set speed and angle at this level
343 | // but once the particle is active and being updated, it's easier
344 | // to use a vector to indicate speed and angle. So particle.setVelocity
345 | // converts the angle and speed values to a velocity vector
346 | particle.setVelocity(angle, speed);
347 |
348 | particle.radialAccel = this.settings.radialAccel + this.settings.radialAccelVar * utils.math.frandom(-1, 1) || 0;
349 | particle.tangentialAccel = this.settings.tangentialAccel + this.settings.tangentialAccelVar * utils.math.frandom(-1, 1) || 0;
350 |
351 | var life = this.settings.life + this.settings.lifeVar * utils.math.frandom(-1, 1) || 0;
352 | particle.life = Math.max(0, life);
353 |
354 | particle.scale = utils.math.isNumber(this.settings.startScale) ? this.settings.startScale : 1;
355 | particle.deltaScale = utils.math.isNumber(this.settings.endScale) ? (this.settings.endScale - this.settings.startScale) : 0;
356 | particle.deltaScale /= particle.life;
357 |
358 | particle.radius = utils.math.isNumber(this.settings.radius) ? this.settings.radius + (this.settings.radiusVar || 0) * utils.math.frandom(-1, 1) : 0;
359 |
360 |
361 | if (this.settings.startColor) {
362 | var startColor = [
363 | this.settings.startColor[0] + this.settings.startColorVar[0] * utils.math.frandom(-1, 1), this.settings.startColor[1] + this.settings.startColorVar[1] * utils.math.frandom(-1, 1), this.settings.startColor[2] + this.settings.startColorVar[2] * utils.math.frandom(-1, 1), this.settings.startColor[3] + this.settings.startColorVar[3] * utils.math.frandom(-1, 1)];
364 |
365 |
366 | var endColor = startColor;
367 | if (this.settings.endColor) {
368 | endColor = [
369 | this.settings.endColor[0] + this.settings.endColorVar[0] * utils.math.frandom(-1, 1), this.settings.endColor[1] + this.settings.endColorVar[1] * utils.math.frandom(-1, 1), this.settings.endColor[2] + this.settings.endColorVar[2] * utils.math.frandom(-1, 1), this.settings.endColor[3] + this.settings.endColorVar[3] * utils.math.frandom(-1, 1)];
370 | }
371 |
372 | particle.color = startColor;
373 | particle.deltaColor = [(endColor[0] - startColor[0]) / particle.life, (endColor[1] - startColor[1]) / particle.life, (endColor[2] - startColor[2]) / particle.life, (endColor[3] - startColor[3]) / particle.life];
374 |
375 | for (var c = 0; c < 3; c++) {
376 | particle.startColor[c] = ~~particle.startColor[c];
377 | particle.endColor[c] = ~~particle.endColor[c];
378 | particle.deltaColor[c] = ~~particle.deltaColor[c];
379 | }
380 | }
381 | }
382 |
383 |
384 | private updateParticle(p:Particle, delta, i) {
385 | var inEdge = (!this.border) ||
386 | (p.pos.x >= this.settings.pos.x - this.border.left && p.pos.y >= this.settings.pos.y - this.border.top && p.pos.x <= this.settings.pos.x + this.border.right && p.pos.y <= this.settings.pos.y + this.border.bottom);
387 |
388 |
389 | if (!inEdge) {
390 |
391 | p.life = 0;
392 | }
393 |
394 | if (p.life > 0) {
395 |
396 | p.radial.x = 0;
397 | p.radial.y = 0;
398 | p.forces.x = 0;
399 | p.forces.y = 0;
400 |
401 |
402 | // dont apply radial forces until moved away from the emitter
403 | if ((p.pos.x !== this.settings.pos.x || p.pos.y !== this.settings.pos.y) && (p.radialAccel || p.tangentialAccel)) {
404 | p.radial.x = p.pos.x - this.settings.pos.x;
405 | p.radial.y = p.pos.y - this.settings.pos.y;
406 |
407 | utils.math.normalize(p.radial);
408 | }
409 |
410 | p.tangential.x = p.radial.x;
411 | p.tangential.y = p.radial.y;
412 |
413 | p.radial.x *= p.radialAccel;
414 | p.radial.y *= p.radialAccel;
415 |
416 | var newy = p.tangential.x;
417 | p.tangential.x = - p.tangential.y;
418 | p.tangential.y = newy;
419 |
420 | p.tangential.x *= p.tangentialAccel;
421 | p.tangential.y *= p.tangentialAccel;
422 |
423 | p.forces.x = p.radial.x + p.tangential.x + this.settings.gravity.x;
424 | p.forces.y = p.radial.y + p.tangential.y + this.settings.gravity.y;
425 |
426 |
427 |
428 | p.forces.x *= delta;
429 | p.forces.y *= delta;
430 |
431 | p.vel.x += p.forces.x;
432 | p.vel.y += p.forces.y;
433 |
434 | p.lastpos.x = p.pos.x;
435 | p.lastpos.y = p.pos.y;
436 |
437 |
438 |
439 | var ax = 0;
440 | var ay = 0;
441 | if (this._xEquation) ax = this.aFactor.x * this._xEquation(p.life * this.xFactor.x * Math.PI);
442 | if (this._yEquation) ay = this.aFactor.y * this._yEquation(p.life * this.xFactor.y * Math.PI);
443 |
444 |
445 |
446 | p.pos.x += p.vel.x * delta +ax;
447 | p.pos.y += p.vel.y * delta +ay;
448 |
449 | p.life -= delta;
450 |
451 | p.scale += p.deltaScale * delta;
452 |
453 | if (p.color) {
454 | if (this.settings.colorList.length>0) {
455 | p.color[0] = this.settings.colorList[p.colorIdx][0];
456 | p.color[1] = this.settings.colorList[p.colorIdx][1];
457 | p.color[2] = this.settings.colorList[p.colorIdx][2];
458 | p.color[3] = this.settings.colorList[p.colorIdx][3];
459 |
460 | p.colorIdx++;
461 | if (p.colorIdx >= this.settings.colorList.length) p.colorIdx = 0;
462 | }
463 | else {
464 | p.color[0] += p.deltaColor[0] * delta;
465 | p.color[1] += p.deltaColor[1] * delta;
466 | p.color[2] += p.deltaColor[2] * delta;
467 | p.color[3] += p.deltaColor[3] * delta;
468 | }
469 | }
470 |
471 |
472 | ++this._particleIndex;
473 | } else {
474 | p.color[3] = 0;
475 |
476 |
477 | // the particle has died, time to return it to the particle pool
478 | // take the particle at the current index
479 | var temp = this._particlePool[i];
480 |
481 | // and move it to the end of the active particles, keeping all alive particles pushed
482 | // up to the front of the pool
483 | this._particlePool[i] = this._particlePool[this._particleCount - 1];
484 | this._particlePool[this._particleCount - 1] = temp;
485 |
486 | // decrease the count to indicate that one less particle in the pool is active.
487 | --this._particleCount;
488 |
489 |
490 | }
491 | }
492 |
493 | public kill() {
494 | for (var i = 0; i < this._particlePool.length; i++) {
495 | var p = this._particlePool[i];
496 | p.life = 0;
497 | }
498 |
499 |
500 | this._particlePool = [];
501 |
502 | this.duration = -1;
503 | this._particleCount = 0;
504 | this._particleIndex = 0;
505 | this._elapsed = 0;
506 | this._emitCounter = 0;
507 |
508 | }
509 | public update(delta) {
510 |
511 | this._elapsed += delta;
512 | this.active = this._elapsed < this.duration;
513 |
514 | if (!this.active) {
515 | return;
516 | }
517 |
518 | if (this.emissionRate) {
519 | // emit new particles based on how much time has passed and the emission rate
520 | var rate = 1.0 / this.emissionRate;
521 | this._emitCounter += delta;
522 | if (!this.allOrNone) {
523 | while (!this._isFull() && this._emitCounter > rate) {
524 | this.createParticle();
525 | this._emitCounter -= rate;
526 | };
527 | }
528 | else if (this._particleCount == 0 && this._curCycle < this.cycles) {
529 | while (!this._isFull()) {
530 | this.createParticle();
531 |
532 | };
533 | this._curCycle++;
534 | }
535 | }
536 |
537 | this._particleIndex = 0;
538 |
539 | while (this._particleIndex < this._particleCount) {
540 | var p = this._particlePool[this._particleIndex];
541 | this.updateParticle(p, delta, this._particleIndex);
542 | }
543 | }
544 |
545 |
546 |
547 |
548 |
549 |
550 | };
551 |
552 |
553 |
554 |
555 | }
556 |
557 |
--------------------------------------------------------------------------------
/core/EmitterEntity.ts:
--------------------------------------------------------------------------------
1 | module EPSY {
2 |
3 | /*
4 | */
5 | export class EmitterEntity {
6 |
7 | public pos = { x: 0, y: 0 };
8 | public posVar = { x: 0, y: 0 };
9 |
10 | public speed = 0;
11 | public speedVar = 0;
12 |
13 | public angle = 0;
14 | public angleVar = 0;
15 |
16 | public life = 0;
17 | public lifeVar = 0;
18 |
19 | public radius = 0;
20 | public radiusVar = 0;
21 |
22 | public texture: string;
23 |
24 | public textureAdditive = false;
25 |
26 | public startScale = 0;
27 | public startScaleVar = 0;
28 | public endScale = 0;
29 | public endScaleVar = 0;
30 |
31 | public startColor = [0,0,0,0];
32 | public startColorVar = [0,0,0,0];
33 | public endColor=[0,0,0,0];
34 | public endColorVar = [0, 0, 0, 0];
35 |
36 |
37 | public colorList = [];
38 |
39 | public gravity = { x: 0, y: 0 };
40 |
41 | public radialAccel = 0;
42 | public radialAccelVar = 0;
43 | public tangentialAccel = 0;
44 | public tangentialAccelVar = 0;
45 |
46 | }
47 | }
48 |
49 |
50 |
--------------------------------------------------------------------------------
/core/Particle.class.ts:
--------------------------------------------------------------------------------
1 | module EPSY {
2 | export class Particle extends EmitterEntity {
3 |
4 | public scale: number;
5 | public deltaScale: number;
6 | public deltaColor: any[];
7 |
8 | public lastpos = { x: -1, y: -1 };
9 | public vel = { x: 0, y: 0 };
10 | public color: any[];
11 |
12 | public forces = { x: 0, y: 0 };
13 | public radial = { x: 0, y: 0 };
14 | public tangential = { x: 0, y: 0 };
15 |
16 | public colorIdx = 0;
17 |
18 | public recycled = false;
19 |
20 | constructor() {
21 | super();
22 | this.setVelocity(0, 0);
23 | }
24 |
25 |
26 | setVelocity(angle, speed) {
27 | this.vel.x = Math.cos(utils.math.toRad(angle)) * speed;
28 | this.vel.y = -Math.sin(utils.math.toRad(angle)) * speed;
29 | }
30 | }
31 | }
32 |
33 |
34 |
--------------------------------------------------------------------------------
/lib/PIXI.d.ts:
--------------------------------------------------------------------------------
1 | // Type definitions for PIXI 1.5.0
2 | // Project: https://github.com/GoodBoyDigital/pixi.js/
3 | // Definitions by: xperiments
4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped
5 |
6 | declare module PIXI {
7 |
8 | /* CONSTANTS */
9 | export var WEBGL_RENDERER: number;
10 | export var CANVAS_RENDERER: number;
11 | export var VERSION: string;
12 |
13 | export enum blendModes {
14 | NORMAL,
15 | ADD,
16 | MULTIPLY,
17 | SCREEN,
18 | OVERLAY,
19 | DARKEN,
20 | LIGHTEN,
21 | COLOR_DODGE,
22 | COLOR_BURN,
23 | HARD_LIGHT,
24 | SOFT_LIGHT,
25 | DIFFERENCE,
26 | EXCLUSION,
27 | HUE,
28 | SATURATION,
29 | COLOR,
30 | LUMINOSITY,
31 | }
32 |
33 | export var INTERACTION_REQUENCY: number;
34 | export var AUTO_PREVENT_DEFAULT: boolean;
35 | export var RAD_TO_DEG: number;
36 | export var DEG_TO_RAD: number;
37 |
38 | /* MODULE FUNCTIONS */
39 | export function autoDetectRenderer(width: number, height: number, view?: HTMLCanvasElement, transparent?, antialias?): IPixiRenderer;
40 | export function AjaxRequest(): XMLHttpRequest;
41 |
42 | /*INTERFACES*/
43 | export interface IBasicCallback {
44 | (): void
45 | }
46 |
47 | export interface IEventCallback {
48 | (e?: IEvent): void
49 | }
50 |
51 | export interface IEvent {
52 | type: string;
53 | content: any;
54 | }
55 |
56 | export interface IHitArea {
57 | contains(x: number, y: number): boolean;
58 | }
59 |
60 | export interface IInteractionDataCallback {
61 | (interactionData: InteractionData): void
62 | }
63 |
64 | export interface IPixiRenderer {
65 | type: number;
66 | transparent: boolean;
67 | width: number;
68 | height: number;
69 | view: HTMLCanvasElement;
70 |
71 | render(stage: Stage): void;
72 | resize(width: number, height: number): void;
73 | }
74 |
75 | export interface IBitmapTextStyle {
76 | font?: string;
77 | align?: string;
78 | tint?: string;
79 | }
80 |
81 | export interface ITextStyle {
82 | font?: string;
83 | stroke?: string;
84 | fill?: string;
85 | align?: string;
86 | strokeThickness?: number;
87 | wordWrap?: boolean;
88 | wordWrapWidth?: number;
89 | }
90 |
91 | export interface IUniform {
92 | type: string;
93 | value: any;
94 | }
95 |
96 | export interface ILoader {
97 | constructor(url: string, crossorigin: boolean);
98 | load();
99 | }
100 |
101 | export interface ITintMethod {
102 | (texture: Texture, color: number, canvas: HTMLCanvasElement): void;
103 | }
104 |
105 | export interface IMaskData {
106 | alpha: number;
107 | worldTransform: number[];
108 | }
109 |
110 | export interface IRenderSession // unclear; Taken from DisplayObjectContainer:152
111 | {
112 | context: CanvasRenderingContext2D;
113 | maskManager: CanvasMaskManager;
114 | scaleMode: scaleModes;
115 | smoothProperty: string;
116 | }
117 |
118 | export interface IShaderAttribute {
119 | // TODO: Find signature of shader attributes
120 | }
121 |
122 | export interface IFilterBlock {
123 | // TODO: Find signature of filterBlock
124 | }
125 |
126 | /* CLASSES */
127 |
128 | export class AbstractFilter {
129 | passes: AbstractFilter[];
130 | shaders: PixiShader[];
131 | dirty: boolean;
132 | padding: number;
133 | uniforms: { [name: string]: IUniform };
134 | fragmentSrc: any[];
135 | }
136 |
137 | export class AlphaMaskFilter extends AbstractFilter {
138 | map: Texture;
139 |
140 | constructor(texture: Texture);
141 | onTextureLoaded(): void;
142 | }
143 |
144 | export class AssetLoader extends EventTarget {
145 | assetURLs: string[];
146 | crossorigin: boolean;
147 | loadersByType: { [key: string]: ILoader };
148 |
149 | constructor(assetURLs: string[], crossorigin: boolean);
150 | load(): void;
151 | onComplete(): void;
152 | }
153 |
154 | export class AtlasLoader extends EventTarget {
155 | url: string;
156 | baseUrl: string;
157 | crossorigin: boolean;
158 | loaded: boolean;
159 |
160 | constructor(url: string, crossorigin: boolean);
161 | load(): void;
162 | }
163 |
164 | export class BaseTexture extends EventTarget {
165 | height: number;
166 | width: number;
167 | source: HTMLImageElement;
168 | scaleMode: scaleModes;
169 | hasLoaded: boolean;
170 |
171 | constructor(source: HTMLImageElement, scaleMode: scaleModes);
172 | constructor(source: HTMLCanvasElement, scaleMode: scaleModes);
173 | destroy(): void;
174 | updateSourceImage(newSrc: string): void;
175 |
176 | static fromImage(imageUrl: string, crossorigin: boolean, scaleMode: scaleModes): BaseTexture;
177 | static fromCanvas(canvas: HTMLCanvasElement, scaleMode: scaleModes): BaseTexture;
178 | }
179 |
180 | export class BitmapFontLoader extends EventTarget {
181 | baseUrl: string;
182 | crossorigin: boolean;
183 | texture: Texture;
184 | url: string;
185 |
186 | constructor(url: string, crossorigin: boolean);
187 | load(): void;
188 | }
189 |
190 | export class BitmapText extends DisplayObjectContainer {
191 | width: number;
192 | height: number;
193 | fontName: string;
194 | fontSize: number;
195 | tint: string;
196 |
197 | constructor(text: string, style: IBitmapTextStyle);
198 | setText(text: string): void;
199 | setStyle(style: IBitmapTextStyle): void;
200 | }
201 |
202 | export class BlurFilter extends AbstractFilter {
203 | blur: number;
204 | blurX: number;
205 | blurY: number;
206 | }
207 |
208 | export class CanvasMaskManager {
209 | pushMask(maskData: IMaskData, context: CanvasRenderingContext2D): void;
210 | popMask(context: CanvasRenderingContext2D): void;
211 | }
212 |
213 | export class CanvasRenderer implements IPixiRenderer {
214 | type: number;
215 | clearBeforeRender: boolean;
216 | roundPixels: boolean;
217 | transparent: boolean;
218 | width: number;
219 | height: number;
220 | view: HTMLCanvasElement;
221 | context: CanvasRenderingContext2D;
222 | refresh: boolean;
223 | count: number;
224 | maskManager: CanvasMaskManager;
225 | renderSession: IRenderSession;
226 |
227 | constructor(width: number, height: number, view?: HTMLCanvasElement, transparent?: boolean);
228 | render(stage: Stage): void;
229 | resize(width: number, height: number): void;
230 | }
231 |
232 | export class CanvasTinter {
233 | canvas: HTMLCanvasElement;
234 |
235 | getTintedTexture(sprite: Sprite, color: number): HTMLCanvasElement;
236 | tintWithMultiply(texture: Texture, color: number, canvas: HTMLCanvasElement): void;
237 | tintWithOverlay(texture: Texture, color: number, canvas: HTMLCanvasElement): void;
238 | tintWithPerPixel(texture: Texture, color: number, canvas: HTMLCanvasElement): void;
239 |
240 | static cacheStepsPerColorChannel: number;
241 | static convertTintToImage: boolean;
242 | static canUseMultiply: boolean;
243 | static tintMethod: ITintMethod;
244 |
245 | static roundColor(color: number): number;
246 | }
247 |
248 | export class Circle implements IHitArea {
249 | x: number;
250 | y: number;
251 | radius: number;
252 |
253 | constructor(x: number, y: number, radius: number);
254 | clone(): Circle;
255 | contains(x: number, y: number): boolean;
256 | }
257 |
258 | export class ColorMatrixFilter extends AbstractFilter {
259 | matrix: number[];
260 | }
261 |
262 | export class ColorStepFilter extends AbstractFilter {
263 | step: number;
264 | }
265 |
266 | export class DisplacementFilter extends AbstractFilter {
267 | map: Texture;
268 | offset: Point;
269 | scale: Point;
270 |
271 | constructor(texture: Texture);
272 | }
273 |
274 | export class DisplayObject {
275 | alpha: number;
276 | buttonMode: boolean;
277 | defaultCursor: string;
278 | filterArea: Rectangle;
279 | filters: AbstractFilter[];
280 | hitArea: IHitArea;
281 | interactive: boolean;
282 | mask: Graphics;
283 | parent: DisplayObjectContainer;
284 | pivot: Point;
285 | position: Point;
286 | renderable: boolean;
287 | rotation: number;
288 | scale: Point;
289 | stage: Stage;
290 | visible: boolean;
291 | worldAlpha: number;
292 | worldVisible: boolean;
293 | x: number;
294 | y: number;
295 |
296 | click(e: InteractionData): void;
297 | getBounds(): Rectangle;
298 | getLocalBounds(): Rectangle;
299 | mousedown(e: InteractionData): void;
300 | mouseout(e: InteractionData): void;
301 | mouseover(e: InteractionData): void;
302 | mouseup(e: InteractionData): void;
303 | mouseupoutside(e: InteractionData): void;
304 | setStateReference(stage: Stage): void;
305 | tap(e: InteractionData): void;
306 | touchend(e: InteractionData): void;
307 | touchendoutside(e: InteractionData): void;
308 | touchstart(e: InteractionData): void;
309 | touchmove(e: InteractionData): void;
310 | }
311 |
312 | export class DisplayObjectContainer extends DisplayObject {
313 | height: number;
314 | width: number;
315 | children: DisplayObject[];
316 | constructor();
317 | addChild(child: DisplayObject): void;
318 | addChildAt(child: DisplayObject, index: number): void;
319 | getChildAt(index: number): DisplayObject;
320 | removeChild(child: DisplayObject): DisplayObject;
321 | removeChildAt(index:number ): DisplayObject;
322 | removeStageReference(): void;
323 | }
324 |
325 | export class Ellipse implements IHitArea {
326 | x: number;
327 | y: number;
328 | width: number;
329 | height: number;
330 |
331 | constructor(x: number, y: number, width: number, height: number);
332 | clone(): Ellipse;
333 | contains(x: number, y: number): boolean;
334 | getBounds(): Rectangle;
335 | }
336 |
337 | export class EventTarget {
338 | listeners: { [key: string]: IEventCallback[] };
339 |
340 | addEventListener(type: string, listener: IEventCallback): void;
341 | dispatchEvent(event: IEvent): void;
342 | removeAllEventListeners(type: string): void;
343 | removeEventListener(type: string, listener: IEventCallback): void;
344 | }
345 |
346 | export class FilterTexture {
347 | fragmentSrc: string[];
348 | gl: WebGLRenderingContext;
349 | program: WebGLProgram;
350 |
351 | constructor(gl: WebGLRenderingContext, width: number, height: number);
352 | clear(): void;
353 | resize(width: number, height: number): void;
354 | destroy(): void;
355 | }
356 |
357 | export class Graphics extends DisplayObjectContainer {
358 | blendMode: blendModes;
359 | bounds: Rectangle;
360 | boundsPadding: number;
361 | fillAlpha: number;
362 | isMask: boolean;
363 | lineColor: string;
364 | lineWidth: number;
365 | tint: number;
366 |
367 | beginFill(color: number, alpha?: number): void;
368 | clear(): void;
369 | drawCircle(x: number, y: number, radius: number): void;
370 | drawEllipse(x: number, y: number, width: number, height: number): void;
371 | drawRect(x: number, y: number, width: number, height: number): void;
372 | endFill(): void;
373 | generateTexture(): Texture;
374 | getBounds(): Rectangle;
375 | lineStyle(lineWidth: number, color: number, alpha: number): void;
376 | lineTo(x: number, y: number): void;
377 | moveTo(x: number, y: number): void;
378 | updateBounds(): void;
379 | }
380 |
381 | export class GrayFilter extends AbstractFilter {
382 | gray: number;
383 | }
384 |
385 | export class ImageLoader extends EventTarget {
386 | texture: Texture;
387 |
388 | constructor(url: string, crossorigin?: boolean);
389 | load(): void;
390 | loadFramedSpriteSheet(frameWidth: number, frameHeight: number, textureName?: string): void;
391 | }
392 |
393 | export class InteractionData {
394 | global: Point;
395 | target: Sprite;
396 | originalEvent: Event;
397 |
398 | getLocalPosition(displayObject: DisplayObject): Point;
399 | }
400 |
401 | export class InteractionManager {
402 | currentCursorStyle: string;
403 | mouse: InteractionData;
404 | mouseOut: boolean;
405 | mouseoverEnabled: boolean;
406 | pool: InteractionData[];
407 | stage: Stage;
408 | touchs: { [id: string]: InteractionData };
409 |
410 | constructor(stage: Stage);
411 | }
412 |
413 | export class InvertFilter {
414 | invert: number;
415 | }
416 |
417 | export class JsonLoader extends EventTarget {
418 | baseUrl: string;
419 | crossorigin: boolean;
420 | loaded: boolean;
421 | url: string;
422 |
423 | constructor(url: string, crossorigin?: boolean);
424 | load(): void;
425 | }
426 |
427 | export class MovieClip extends Sprite {
428 | animationSpeed: number;
429 | currentFrame: number;
430 | loop: boolean;
431 | playing: boolean;
432 | textures: Texture[];
433 | totalFrames: number;
434 |
435 | constructor(textures: Texture[]);
436 | onComplete: IBasicCallback;
437 | gotoAndPlay(frameNumber: number): void;
438 | gotoAndStop(frameNumber: number): void;
439 | play(): void;
440 | stop(): void;
441 | }
442 |
443 | export class NormalMapFilter extends AbstractFilter {
444 | map: Texture;
445 | offset: Point;
446 | scale: Point;
447 | }
448 |
449 | export class PixelateFilter extends AbstractFilter {
450 | size: number;
451 | }
452 |
453 | export class PixiFastShader {
454 | gl: WebGLRenderingContext;
455 | fragmentSrc: string[];
456 | program: WebGLProgram;
457 | textureCount: number;
458 | vertexSrc: string[];
459 |
460 | constructor(gl: WebGLRenderingContext);
461 | destroy(): void;
462 | init(): void;
463 | }
464 |
465 | export class PixiShader {
466 | defaultVertexSrc: string;
467 | fragmentSrc: string[];
468 | gl: WebGLRenderingContext;
469 | program: WebGLProgram;
470 | textureCount: number;
471 | attributes: IShaderAttribute[];
472 |
473 | constructor(gl: WebGLRenderingContext);
474 | destroy(): void;
475 | init(): void;
476 | initSampler2D(): void;
477 | initUniforms(): void;
478 | syncUniforms(): void;
479 | }
480 |
481 | export class Point {
482 | x: number;
483 | y: number;
484 |
485 | constructor(x?: number, y?: number);
486 | clone(): Point;
487 | set(x: number, y: number): void;
488 | }
489 |
490 | export class Polygon implements IHitArea {
491 | points: Point[];
492 |
493 | constructor(points: Point[]);
494 | constructor(points: number[]);
495 | constructor(...points: Point[]);
496 | constructor(...points: number[]);
497 |
498 | clone(): Polygon;
499 | contains(x: number, y: number): boolean;
500 | }
501 |
502 | export class Rectangle implements IHitArea {
503 | x: number;
504 | y: number;
505 | width: number;
506 | height: number;
507 |
508 | constructor(x?: number, y?: number, width?: number, height?: number);
509 | clone(): Rectangle;
510 | contains(x: number, y: number): boolean
511 | }
512 |
513 | export class Rope {
514 | points: Point[];
515 | vertices: Float32Array;
516 | uvs: Float32Array;
517 | colors: Float32Array;
518 | indices: Uint16Array;
519 |
520 | constructor(texture: Texture, points: Point[]);
521 | refresh();
522 | setTexture(texture: Texture);
523 | }
524 |
525 | export class scaleModes {
526 | public static DEFAULT: number;
527 | public static LINEAR: number;
528 | public static NEAREST: number;
529 | }
530 |
531 | export class SepiaFilter {
532 | sepia: number;
533 | }
534 |
535 | export class Spine {
536 | url: string;
537 | crossorigin: boolean;
538 | loaded: boolean;
539 |
540 | constructor(url: string);
541 | load();
542 | }
543 |
544 | export class Sprite extends DisplayObjectContainer {
545 | anchor: Point;
546 | blendMode: number;
547 | texture: Texture;
548 | height: number;
549 | width: number;
550 | tint: number;
551 |
552 | constructor(texture: Texture);
553 | getBounds(): Rectangle;
554 | setTexture(texture: Texture): void;
555 |
556 | static fromFrame(frameId: string): Sprite;
557 | static fromImage(url: string): Sprite;
558 | }
559 |
560 | export class SpriteBatch extends PIXI.DisplayObjectContainer {
561 | constructor(texture?: Texture);
562 | }
563 |
564 | /* TODO determine type of frames */
565 | export class SpriteSheetLoader extends EventTarget {
566 | url: string;
567 | crossorigin: boolean;
568 | baseUrl: string;
569 | texture: Texture;
570 | frames: Object;
571 |
572 | constructor(url: string, crossorigin?: boolean);
573 | load();
574 | }
575 |
576 | export class Stage extends DisplayObjectContainer {
577 | interactive: boolean;
578 | interactionManager: InteractionManager;
579 |
580 | constructor(backgroundColor: number);
581 | getMousePosition(): Point;
582 | setBackgroundColor(backgroundColor: number): void;
583 | setInteractionDelegate(domElement: HTMLElement): void;
584 | }
585 |
586 | export class Strip extends DisplayObjectContainer {
587 | constructor(texture: Texture, width: number, height: number);
588 | }
589 |
590 | export class Text extends Sprite {
591 | canvas: HTMLCanvasElement;
592 | context: CanvasRenderingContext2D;
593 |
594 | constructor(text: string, style?: ITextStyle);
595 | destroy(destroyTexture: boolean): void;
596 | setText(text: string): void;
597 | setStyle(style: ITextStyle): void;
598 | }
599 |
600 | export class Texture extends EventTarget {
601 | baseTexture: BaseTexture;
602 | frame: Rectangle;
603 | trim: Point;
604 | width: number;
605 | height: number;
606 |
607 | constructor(baseTexture: BaseTexture, frame?: Rectangle);
608 | destroy(destroyBase: boolean): void;
609 | setFrame(frame: Rectangle): void;
610 | render(displayObject: DisplayObject, position?: Point, clear?: boolean): void;
611 | on(event: string, callback: Function): void;
612 |
613 | static fromImage(imageUrl: string, crossorigin?: boolean, scaleMode?: scaleModes): Texture;
614 | static fromFrame(frameId: string): Texture;
615 | static fromCanvas(canvas: HTMLCanvasElement, scaleMode?: scaleModes): Texture;
616 | static addTextureToCache(texture: Texture, id: string): void;
617 | static removeTextureFromCache(id: string): Texture;
618 | }
619 |
620 | export class TilingSprite extends DisplayObjectContainer {
621 | width: number;
622 | height: number;
623 | renderable: boolean;
624 | texture: Texture;
625 | tint: number;
626 | tilePosition: Point;
627 | tileScale: Point;
628 | tileScaleOffset: Point;
629 | blendMode: blendModes;
630 |
631 | constructor(texture: Texture, width: number, height: number);
632 | generateTilingTexture(forcePowerOfTwo: boolean): void;
633 | }
634 |
635 | export class TwistFilter extends AbstractFilter {
636 | size: Point;
637 | angle: number;
638 | radius: number;
639 | }
640 |
641 | export class WebGLFilterManager {
642 | filterStack: AbstractFilter[];
643 | transparent: boolean;
644 | offsetX: number;
645 | offsetY: number;
646 |
647 | constructor(gl: WebGLRenderingContext, transparent: boolean);
648 | setContext(gl: WebGLRenderingContext);
649 | begin(renderSession: IRenderSession, buffer: ArrayBuffer): void;
650 | pushFilter(filterBlock: IFilterBlock): void;
651 | popFilter(): void;
652 | applyFilterPass(filter: AbstractFilter, filterArea: Texture, width: number, height: number): void;
653 | initShaderBuffers(): void;
654 | destroy(): void;
655 | }
656 |
657 | export class WebGLGraphics { }
658 |
659 | export class WebGLMaskManager {
660 | constructor(gl: WebGLRenderingContext);
661 | setContext(gl: WebGLRenderingContext);
662 | pushMask(maskData: any[], renderSession: IRenderSession): void;
663 | popMask(renderSession: IRenderSession): void;
664 | destroy(): void;
665 | }
666 |
667 | export class WebGLRenderer implements IPixiRenderer {
668 | type: number;
669 | contextLost: boolean;
670 | width: number;
671 | height: number;
672 | transparent: boolean;
673 | view: HTMLCanvasElement;
674 |
675 | constructor(width: number, height: number, view?: HTMLCanvasElement, transparent?: boolean, antialias?: boolean);
676 | destroy(): void;
677 | render(stage: Stage): void;
678 | renderDisplayObject(displayObject: DisplayObject, projection: Point, buffer: WebGLBuffer): void;
679 | resize(width: number, height: number): void;
680 |
681 | static createWebGLTexture(texture: Texture, gl: WebGLRenderingContext): void;
682 | }
683 |
684 | export class WebGLShaderManager {
685 | activatePrimitiveShader(): void;
686 | activateShader(shader: PixiShader): void;
687 | deactivatePrimitiveShader(): void;
688 | destroy(): void;
689 | setAttribs(attribs: IShaderAttribute[]): void;
690 | setContext(gl: WebGLRenderingContext, transparent: boolean);
691 | }
692 |
693 | export class WebGLSpriteBatch {
694 | indices: Uint16Array;
695 | size: number;
696 | vertices: Float32Array;
697 | vertSize: number;
698 |
699 | constructor(gl: WebGLRenderingContext);
700 | begin(renderSession: IRenderSession): void;
701 | flush(): void;
702 | end(): void;
703 | destroy(): void;
704 | render(sprite: Sprite): void;
705 | renderTilingSprite(sprite: TilingSprite): void;
706 | setBlendMode(blendMode: blendModes): void;
707 | setContext(gl: WebGLRenderingContext): void;
708 | start(): void;
709 | stop(): void;
710 | }
711 |
712 | export class RenderTexture extends Texture{
713 | width:number;
714 | height:number;
715 | frame:Rectangle;
716 | baseTexture:BaseTexture;
717 | renderer:IPixiRenderer;
718 |
719 | constructor(width, height, renderer?, scaleMode?);
720 | resize(width, height);
721 | renderWebGL(displayObject:DisplayObject, position, clear);
722 | renderCanvas(displayObject:DisplayObject, position, clear);
723 |
724 | }
725 |
726 | }
727 |
728 | declare function requestAnimFrame( animate: PIXI.IBasicCallback );
729 |
730 | declare module PIXI.PolyK {
731 | export function Triangulate(p: number[]): number[];
732 | }
733 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "EPSY",
3 | "version": "0.3.1",
4 | "devDependencies": {
5 | "grunt": "~0.4.5",
6 | "grunt-typescript": "~1.0.0",
7 | "grunt-contrib-jshint": "~0.10.0",
8 | "grunt-contrib-nodeunit": "~0.4.1",
9 | "grunt-contrib-uglify": "~0.5.0",
10 | "grunt-contrib-copy" : "~0.5.0"
11 | }
12 | }
--------------------------------------------------------------------------------
/plugins/EPSY.CanvasHelper.js:
--------------------------------------------------------------------------------
1 | EPSY.CanvasHelper = function (context) {
2 | this.lastTimestamp = Date.now();
3 | this.emitters = [];
4 |
5 | this.canvasRenderer = new EPSY.CanvasRenderer(context);
6 | }
7 |
8 |
9 |
10 | EPSY.CanvasHelper.prototype.draw = function () {
11 | var timestamp = new Date().getTime();
12 | var delta = timestamp - (this.lastTimestamp || timestamp);
13 | this.lastTimestamp = timestamp;
14 | delta /= 1000;
15 |
16 | for (var i = 0; i < this.emitters.length; i++) {
17 | var emitter = this.emitters[i];
18 | if (!emitter) continue;
19 |
20 | emitter.update(delta);
21 | this.canvasRenderer.render(emitter);
22 | }
23 | }
24 |
25 | EPSY.CanvasHelper.prototype.createEmitter = function (config, x, y) {
26 |
27 | var emitter = new EPSY.Emitter(config);
28 | if (x != undefined) emitter.settings.pos.x = x;
29 | if (y != undefined) emitter.settings.pos.y = y;
30 |
31 | emitter.restart();
32 |
33 | this.emitters.push(emitter);
34 | return emitter;
35 | }
36 |
37 | EPSY.CanvasHelper.prototype.loadSystem = function (config, x, y) {
38 | x = x || 0;
39 | y = y || 0;
40 |
41 | var parseddata;
42 |
43 | if (typeof config == 'string') {
44 | parseddata = JSON.parse(config);
45 | }
46 | else {
47 | if (typeof config == 'object' && !(config instanceof Array)) parseddata = [config];
48 | else parseddata = config;
49 | }
50 |
51 | for (var i = 0; i < parseddata.length; i++) {
52 | var config = parseddata[i];
53 | config.pos.x += x;
54 | config.pos.y += y;
55 |
56 | this.createEmitter(config);
57 | }
58 |
59 | }
--------------------------------------------------------------------------------
/plugins/EPSY.Phaser.js:
--------------------------------------------------------------------------------
1 | Phaser.Plugin.EPSY = function (game, parent) {
2 | Phaser.Plugin.call(this, game, parent);
3 |
4 |
5 |
6 | //this.hasUpdate = true;
7 | //this.hasRender = true;
8 |
9 |
10 | this.emitters = [];
11 |
12 | this.defaultTexture = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACz0lEQVR42t2XP0hbURTGnfp/KK3QFiylCG11aRYpBQWFDiJCg266BNQtdnBQyOASQjp1KS4KGVw6iXMWEUdHUShkCBhSQpaQkJg/Jmm/H3xLEdtaWvLawMfJvfec79x77jnnvdfX96/9MpnM9VwudzOfz98qFAq3kYyZ/6tOi8XinVKpdLdSqfRXq9UHwsNarfYIyZh51tH7Y5s5Pj6+BqHI7+OsXq8/aTQag8LzZrM5JAwjGTPPOnroY4f9bzvPZrM3OBEnFPFTOXohvGy1WiPC6/Pz81FhDMmYedbRQx877OG5snPutFwu3zs7OxvQyZ6JPGSnE8KkMN1ut98KYSRjz094MyHssIcHviud3M4fE15OJuJxOZoSZoU5ISIsCIuWEc+zPoW+IzIED3y/FAnujLCxczt/JbI3Pum8sCQsCyudTmdVWEMy9vyS9cLYYe9NDMD705wgcbg7h33Ezmd8wqidrgtxISm8t4x7ns1ErT/jTYzABy/8Pyw1spcE4g4d9rDJ3ok8JiSED8KGsClsWW54nvUY+rYL+zpC8MJ/aYmyO0qILCaRfOfzPnnMJ/0opIRPwk63291FepzyetKbiNp+Cj544b80CtwRdUwpkc1OqCWHPWHybTtNS+5LHlimPb9tvYSvg5yYhQ9e+PFzWfj7aSa++0ln9bLvlvCm7GRP8lDySDhBerzn9ZT1152Yc/A5Fwbxc+EaqFPaKR3N9T7tO1xxgm04zJz0UPis/6fCFyRjbyJtPfTjro4IfPDCj58LfYEHCllKydDZ3GQWHP6kE23H4T6y05Jk1fLUkdh3TmzabtV9gmY1Cj9+8PfdBniqOQGHaa/O/kXXOaW25fAeOOycvPpVP6THJ86JXVcHdmtuVlTDGPz4wV+wItDzHOh5FfS8DwSiE/b8WdDzp2Eg3gd6/kYUiHfCQLwVB+K7IBBfRoH5Nvyvf98A3rZr7fen7G8AAAAASUVORK5CYII=';
13 | //this.buffer = [];
14 |
15 |
16 |
17 | //this.loader = new Phaser.Loader(game);
18 |
19 |
20 | this._sortFn = function (a, b) { return (a.__z || 0) - (b.__z || 0) };
21 |
22 |
23 | var _this = this;
24 |
25 |
26 |
27 | this._onResume = function (event) {
28 | //var timestamp = Date.now();
29 | for (var i = 0; i < _this.emitters.length; i++) {
30 | //_this.emitters[i].lastTimestamp = timestamp;
31 | _this.emitters[i].lastTimestamp = Date.now();
32 | }
33 | }
34 |
35 | game.onResume.add(this._onResume, this);
36 |
37 |
38 | this.game.epsy = this;
39 | };
40 |
41 | Phaser.Plugin.EPSY.prototype = Object.create(Phaser.Plugin.prototype);
42 | Phaser.Plugin.EPSY.prototype.constructor = Phaser.Plugin.EPSY;
43 | Phaser.Plugin.EPSY.VERSION = '0.5.1';
44 |
45 |
46 |
47 |
48 | var updateParticle = function (emitter, particle) {
49 | if (!particle.sprite) {
50 |
51 | // PIXI.Sprite.fromImage and PIXI.Texture.fromImage methods were
52 | // removed from Phaser 2.5.x.
53 | if (PIXI.Sprite.fromImage) {
54 | particle.sprite = PIXI.Sprite.fromImage(particle.texture || this.defaultTexture);
55 | }
56 | else {
57 | PIXI.TextureCache = [];
58 | PIXI.BaseTextureCache = [];
59 | PIXI.Sprite.fromImage = function(imageId, crossorigin, scaleMode)
60 | {
61 | var texture = PIXI.Texture.fromImage(imageId, crossorigin, scaleMode);
62 | return new PIXI.Sprite(texture);
63 | };
64 | PIXI.Texture.fromImage = function(imageUrl, crossorigin, scaleMode)
65 | {
66 | var texture = PIXI.TextureCache[imageUrl];
67 | if(!texture)
68 | {
69 | texture = new PIXI.Texture(PIXI.BaseTexture.fromImage(imageUrl, crossorigin, scaleMode));
70 | PIXI.TextureCache[imageUrl] = texture;
71 | }
72 | return texture;
73 | };
74 | PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin, scaleMode)
75 | {
76 | var baseTexture = PIXI.BaseTextureCache[imageUrl];
77 |
78 | if(crossorigin === undefined && imageUrl.indexOf('data:') === -1) crossorigin = true;
79 |
80 | if(!baseTexture)
81 | {
82 | // new Image() breaks tex loading in some versions of Chrome.
83 | // See https://code.google.com/p/chromium/issues/detail?id=238071
84 | var image = new Image();
85 |
86 | if (crossorigin)
87 | {
88 | image.crossOrigin = '';
89 | }
90 |
91 | image.src = imageUrl;
92 | baseTexture = new PIXI.BaseTexture(image, scaleMode);
93 | baseTexture.imageUrl = imageUrl;
94 | PIXI.BaseTextureCache[imageUrl] = baseTexture;
95 |
96 | // if there is an @2x at the end of the url we are going to assume its a highres image
97 | if( imageUrl.indexOf(PIXI.RETINA_PREFIX + '.') !== -1)
98 | {
99 | baseTexture.resolution = 2;
100 | }
101 | }
102 |
103 | return baseTexture;
104 | };
105 | particle.sprite = PIXI.Sprite.fromImage(particle.texture || this.defaultTexture);
106 | }
107 |
108 | particle.sprite.__parentParticle = particle;
109 |
110 |
111 | particle.sprite.anchor.x = 0.5;
112 | particle.sprite.anchor.y = 0.5;
113 |
114 | particle.sprite.tail = 0;
115 |
116 | particle.ready = true;
117 | }
118 |
119 |
120 |
121 | if (!particle.inserted) {
122 | particle.inserted = true;
123 | emitter.buffer.push(particle.sprite);
124 | emitter.container.addChild(particle.sprite);
125 | //this.context.addChild(particle.graphics);
126 | }
127 |
128 |
129 |
130 | particle.sprite.width = particle.radius * particle.scale;
131 | particle.sprite.height = particle.radius * particle.scale;
132 |
133 |
134 | particle.sprite.position.x = particle.pos.x;
135 | particle.sprite.position.y = particle.pos.y;
136 | if (particle.textureAdditive) {
137 | particle.sprite.blendMode = PIXI.blendModes.ADD;
138 | }
139 | else {
140 | particle.sprite.blendMode = PIXI.blendModes.NORMAL;
141 | }
142 |
143 | particle.sprite.tint = ~~particle.color[2] + 256 * ~~particle.color[1] + 65536 * ~~particle.color[0];
144 | particle.sprite.alpha = particle.color[3];
145 |
146 | }
147 |
148 |
149 |
150 | /**
151 | * we need a phaser-compatible object that hold the emitter particles
152 | */
153 | Phaser.Plugin.EPSY.Emitter = function (particleSystem, emitter) {
154 | PIXI.DisplayObjectContainer.call(this);
155 | this.particleSystem = particleSystem;
156 | this.emitter = emitter;
157 | }
158 | Phaser.Plugin.EPSY.Emitter.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);
159 | Phaser.Plugin.EPSY.Emitter.prototype.constructor = Phaser.Plugin.EPSY.Emitter;
160 |
161 |
162 | Phaser.Plugin.EPSY.Emitter.prototype.preUpdate = function () { };
163 | Phaser.Plugin.EPSY.Emitter.prototype.postUpdate = function () { };
164 | Phaser.Plugin.EPSY.Emitter.prototype.destroy = function () { };
165 | Phaser.Plugin.EPSY.Emitter.prototype.update = function () {
166 | var timestamp = Date.now();
167 | var delta = timestamp - (this.__ez_parent.lastTimestamp || timestamp);
168 |
169 | this.__ez_parent.lastTimestamp = timestamp;
170 | delta /= 1000;
171 |
172 |
173 | var emitter = this.emitter;
174 | emitter.update(delta);
175 | for (var i = 0; i < emitter.particles.length; ++i) {
176 | var p = emitter.particles[i];
177 | if (p.life > 0 && p.color) {
178 | updateParticle.call(this.particleSystem, emitter, p);
179 | }
180 |
181 | }
182 | };
183 |
184 | Phaser.Plugin.EPSY.Emitter.prototype.reset = function () {
185 | var buffer = this.emitter.buffer;
186 | var container = this.emitter.container;
187 |
188 | do {
189 | var sprite = buffer.pop();
190 | if (!sprite) continue;
191 | container.removeChild(sprite);
192 |
193 | if (sprite.__parentParticle) sprite.__parentParticle.inserted = false;
194 |
195 | } while (buffer.length > 0);
196 | }
197 |
198 |
199 |
200 | Phaser.Plugin.EPSY.prototype.createEmitter = function (config, x, y) {
201 | x = x || 0;
202 | y = y || 0;
203 | var emitter = new EPSY.Emitter(config);
204 |
205 | emitter.buffer = [];
206 | //force particle system pos to 0,0 so we can position it with phaser positions.x/y
207 | emitter.settings.pos.x = 0;
208 | emitter.settings.pos.y = 0;
209 |
210 |
211 | this.emitters.push(emitter);
212 | emitter.container = new Phaser.Plugin.EPSY.Emitter(this, emitter);
213 | emitter.container.position.x = x;
214 | emitter.container.position.y = y;
215 |
216 | emitter.zIndex = config.zIndex;
217 |
218 | emitter.container.__ez_parent = emitter;
219 | emitter.lastTimestamp = Date.now();
220 |
221 | return emitter.container;
222 | }
223 |
224 | Phaser.Plugin.EPSY.prototype.loadSystem = function (config, x, y) {
225 |
226 | x = x || 0;
227 | y = y || 0;
228 |
229 | var systemGroup = game.add.group();
230 | var origin = { x: 0, y: 0 };
231 |
232 | var parseddata;
233 |
234 | if (typeof config == 'string') {
235 | parseddata = JSON.parse(_data);
236 | }
237 | else {
238 | if (typeof config == 'object' && !(config instanceof Array)) parseddata = [config];
239 | else parseddata = config;
240 | }
241 |
242 |
243 | for (var i = 0; i < parseddata.length; i++) {
244 | var config = parseddata[i];
245 | var emitter = this.createEmitter(config, config.pos.x, config.pos.y);
246 | systemGroup.add(emitter);
247 | }
248 | systemGroup.position.x = x;
249 | systemGroup.position.y = y;
250 | systemGroup.children.sort(this._sortFn);
251 |
252 | return systemGroup;
253 | }
--------------------------------------------------------------------------------
/plugins/EPSY.Pixi.js:
--------------------------------------------------------------------------------
1 | PIXI.EPSY = function () {
2 | PIXI.DisplayObjectContainer.call(this);
3 |
4 |
5 | //this.container = new PIXI.EPSYContainer(this);
6 |
7 | this._sortFn = function (a, b) { return (a.__z || 0) - (b.__z || 0) };
8 |
9 | this.lastTimestamp = Date.now();
10 | this.emitters = [];
11 |
12 | this.particleRenderer = new EPSY.PixiRenderer(this);
13 | }
14 | PIXI.EPSY.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);
15 | PIXI.EPSY.prototype.constructor = PIXI.EPSY;
16 |
17 | PIXI.EPSY.prototype.updateTransform = function () {
18 | var timestamp = new Date().getTime();
19 | var delta = timestamp - (this.lastTimestamp || timestamp);
20 | this.lastTimestamp = timestamp;
21 | delta /= 1000;
22 |
23 | for (var i = 0; i < this.emitters.length; i++) {
24 | var emitter = this.emitters[i];
25 | if (!emitter) continue;
26 |
27 | emitter.update(delta);
28 | this.particleRenderer.render(emitter);
29 | }
30 |
31 |
32 | PIXI.DisplayObjectContainer.prototype.updateTransform.call(this);
33 | };
34 |
35 | PIXI.EPSY.prototype.createEmitter = function (config, x, y) {
36 |
37 | var emitter = new EPSY.Emitter(config);
38 | if (x != undefined) emitter.settings.pos.x = x;
39 | if (y != undefined) emitter.settings.pos.y = y;
40 |
41 | emitter.restart();
42 |
43 | this.emitters.push(emitter);
44 |
45 | emitter.container = new PIXI.DisplayObjectContainer();
46 | this.addChild(emitter.container);
47 |
48 | emitter.zIndex = config.zIndex;
49 |
50 | return emitter;
51 | }
52 |
53 | PIXI.EPSY.prototype.loadSystem = function (config, x, y) {
54 | x = x || 0;
55 | y = y || 0;
56 |
57 | var parseddata;
58 |
59 | if (typeof config == 'string') {
60 | parseddata = JSON.parse(config);
61 | }
62 | else {
63 | if (typeof config == 'object' && !(config instanceof Array)) parseddata = [config];
64 | else parseddata = config;
65 | }
66 |
67 | for (var i = 0; i < parseddata.length; i++) {
68 | var config = parseddata[i];
69 | config.pos.x += x;
70 | config.pos.y += y;
71 |
72 | this.createEmitter(config);
73 | }
74 |
75 | this.children.sort(this._sortFn);
76 | }
--------------------------------------------------------------------------------
/render/CanvasRenderer.ts:
--------------------------------------------------------------------------------
1 |
2 | module EPSY {
3 |
4 | var bufferCache = {};
5 |
6 | function colorArrayToString(array: any, overrideAlpha?) {
7 | var r = array[0] | 0;
8 | var g = array[1] | 0;
9 | var b = array[2] | 0;
10 | var a = overrideAlpha || array[3];
11 |
12 | return 'rgba(' + r + ', ' + g + ', ' + b + ', ' + a + ')';
13 | }
14 | /*
15 | * Utility method to create a canvas the same size as the passed in texture (which is
16 | * an Image element). Used for _renderParticleTexture
17 | */
18 | function getBuffer(particle) {
19 |
20 | var img = particle.img;
21 | if (!img) {
22 | img = new Image();
23 | particle.ready = false;
24 | img.onload = function () {
25 | particle.ready = true;
26 | }
27 | img.src = particle.texture;
28 | particle.img = img;
29 | }
30 |
31 | if (!particle.ready) return undefined;
32 |
33 |
34 | var size = '' + img.width + 'x' + img.height;
35 |
36 | var canvas = bufferCache[size];
37 |
38 | if (!canvas) {
39 | canvas = document.createElement('canvas');
40 | canvas.width = img.width;
41 | canvas.height = img.height;
42 | bufferCache[size] = canvas;
43 | }
44 |
45 | return canvas;
46 | }
47 |
48 |
49 | export class CanvasRenderer {
50 | private defaultTexture = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACz0lEQVR42t2XP0hbURTGnfp/KK3QFiylCG11aRYpBQWFDiJCg266BNQtdnBQyOASQjp1KS4KGVw6iXMWEUdHUShkCBhSQpaQkJg/Jmm/H3xLEdtaWvLawMfJvfec79x77jnnvdfX96/9MpnM9VwudzOfz98qFAq3kYyZ/6tOi8XinVKpdLdSqfRXq9UHwsNarfYIyZh51tH7Y5s5Pj6+BqHI7+OsXq8/aTQag8LzZrM5JAwjGTPPOnroY4f9bzvPZrM3OBEnFPFTOXohvGy1WiPC6/Pz81FhDMmYedbRQx877OG5snPutFwu3zs7OxvQyZ6JPGSnE8KkMN1ut98KYSRjz094MyHssIcHviud3M4fE15OJuJxOZoSZoU5ISIsCIuWEc+zPoW+IzIED3y/FAnujLCxczt/JbI3Pum8sCQsCyudTmdVWEMy9vyS9cLYYe9NDMD705wgcbg7h33Ezmd8wqidrgtxISm8t4x7ns1ErT/jTYzABy/8Pyw1spcE4g4d9rDJ3ok8JiSED8KGsClsWW54nvUY+rYL+zpC8MJ/aYmyO0qILCaRfOfzPnnMJ/0opIRPwk63291FepzyetKbiNp+Cj544b80CtwRdUwpkc1OqCWHPWHybTtNS+5LHlimPb9tvYSvg5yYhQ9e+PFzWfj7aSa++0ln9bLvlvCm7GRP8lDySDhBerzn9ZT1152Yc/A5Fwbxc+EaqFPaKR3N9T7tO1xxgm04zJz0UPis/6fCFyRjbyJtPfTjro4IfPDCj58LfYEHCllKydDZ3GQWHP6kE23H4T6y05Jk1fLUkdh3TmzabtV9gmY1Cj9+8PfdBniqOQGHaa/O/kXXOaW25fAeOOycvPpVP6THJ86JXVcHdmtuVlTDGPz4wV+wItDzHOh5FfS8DwSiE/b8WdDzp2Eg3gd6/kYUiHfCQLwVB+K7IBBfRoH5Nvyvf98A3rZr7fen7G8AAAAASUVORK5CYII=';
51 |
52 |
53 | constructor(public context) {
54 |
55 | }
56 |
57 |
58 | /*
59 | * renders a particle using the particle's texture. The texture is typically a white
60 | * image and so need to use a secondary buffer to "tint" this image based on the
61 | * particle's color.
62 | */
63 | private renderParticle(particle) {
64 | if (!particle.texture) particle.texture = this.defaultTexture;
65 |
66 | particle.buffer = particle.buffer || getBuffer(particle);
67 |
68 | if (!particle.buffer) return;
69 |
70 | var bufferContext = particle.buffer.getContext('2d');
71 |
72 | // figure out what size to draw the texture at, based on the particle's
73 | // current scale
74 | var w = (particle.img.width * particle.scale) | 0;
75 | var h = (particle.img.height * particle.scale) | 0;
76 |
77 | // figure out the x and y locations to render at, to center the texture in the buffer
78 | var x = particle.pos.x - w / 2;
79 | var y = particle.pos.y - h / 2;
80 |
81 | bufferContext.clearRect(0, 0, particle.buffer.width, particle.buffer.height);
82 | bufferContext.globalAlpha = particle.color[3];
83 | bufferContext.drawImage(particle.img, 0, 0);
84 |
85 | // now use source-atop to "tint" the white texture, here we want the particle's pure color,
86 | // not including alpha. As we already used the particle's alpha to render the texture above
87 | bufferContext.globalCompositeOperation = "source-atop";
88 | bufferContext.fillStyle = colorArrayToString(particle.color, 1);
89 | bufferContext.fillRect(0, 0, particle.buffer.width, particle.buffer.height);
90 |
91 | // reset the buffer's context for the next time we draw the particle
92 | bufferContext.globalCompositeOperation = "source-over";
93 | bufferContext.globalAlpha = 1;
94 |
95 |
96 | if (particle.textureAdditive) {
97 | this.context.globalCompositeOperation = 'lighter';
98 | } else {
99 | this.context.globalCompositeOperation = 'source-over';
100 | }
101 |
102 | // finally, take the rendered and tinted texture and draw it into the main canvas, at the
103 | // particle's location
104 | this.context.drawImage(particle.buffer, 0, 0, particle.buffer.width, particle.buffer.height, x, y, w, h);
105 | }
106 |
107 | public render(emitter:EPSY.Emitter) {
108 | var particles = emitter.particles
109 | for (var i = 0; i < particles.length; ++i) {
110 | var p = particles[i];
111 | if (p.life > 0 && p.color) {
112 |
113 | this.renderParticle(p);
114 | }
115 | }
116 | this.context.globalCompositeOperation = 'source-over';
117 | }
118 |
119 | public reset() {
120 | return;
121 | }
122 | }
123 | }
124 |
125 |
--------------------------------------------------------------------------------
/render/PixiRenderer.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | module EPSY {
4 |
5 |
6 |
7 | export class PixiRenderer {
8 | private defaultTexture = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACz0lEQVR42t2XP0hbURTGnfp/KK3QFiylCG11aRYpBQWFDiJCg266BNQtdnBQyOASQjp1KS4KGVw6iXMWEUdHUShkCBhSQpaQkJg/Jmm/H3xLEdtaWvLawMfJvfec79x77jnnvdfX96/9MpnM9VwudzOfz98qFAq3kYyZ/6tOi8XinVKpdLdSqfRXq9UHwsNarfYIyZh51tH7Y5s5Pj6+BqHI7+OsXq8/aTQag8LzZrM5JAwjGTPPOnroY4f9bzvPZrM3OBEnFPFTOXohvGy1WiPC6/Pz81FhDMmYedbRQx877OG5snPutFwu3zs7OxvQyZ6JPGSnE8KkMN1ut98KYSRjz094MyHssIcHviud3M4fE15OJuJxOZoSZoU5ISIsCIuWEc+zPoW+IzIED3y/FAnujLCxczt/JbI3Pum8sCQsCyudTmdVWEMy9vyS9cLYYe9NDMD705wgcbg7h33Ezmd8wqidrgtxISm8t4x7ns1ErT/jTYzABy/8Pyw1spcE4g4d9rDJ3ok8JiSED8KGsClsWW54nvUY+rYL+zpC8MJ/aYmyO0qILCaRfOfzPnnMJ/0opIRPwk63291FepzyetKbiNp+Cj544b80CtwRdUwpkc1OqCWHPWHybTtNS+5LHlimPb9tvYSvg5yYhQ9e+PFzWfj7aSa++0ln9bLvlvCm7GRP8lDySDhBerzn9ZT1152Yc/A5Fwbxc+EaqFPaKR3N9T7tO1xxgm04zJz0UPis/6fCFyRjbyJtPfTjro4IfPDCj58LfYEHCllKydDZ3GQWHP6kE23H4T6y05Jk1fLUkdh3TmzabtV9gmY1Cj9+8PfdBniqOQGHaa/O/kXXOaW25fAeOOycvPpVP6THJ86JXVcHdmtuVlTDGPz4wV+wItDzHOh5FfS8DwSiE/b8WdDzp2Eg3gd6/kYUiHfCQLwVB+K7IBBfRoH5Nvyvf98A3rZr7fen7G8AAAAASUVORK5CYII=';
9 | private buffer = [];
10 |
11 | private _sortFn = function (a, b) {return (a.__z || 0) - (b.__z || 0) };
12 | constructor(public context) {
13 |
14 | }
15 | /*
16 | * renders a particle using the particle's texture. The texture is typically a white
17 | * image and so need to use a secondary buffer to "tint" this image based on the
18 | * particle's color.
19 | */
20 | private updateParticleSprite(emitter:Emitter, particle) {
21 | if (particle.life <= 0 && particle.sprite) {
22 |
23 | particle.sprite.visible = false;
24 | return;
25 | }
26 |
27 | if (!particle.sprite || particle.recycled) {
28 |
29 |
30 | var texture = PIXI.Texture.fromImage(particle.texture || this.defaultTexture);
31 |
32 | if (particle.recycled && particle.sprite) {
33 | (particle.sprite).texture = texture;
34 | }
35 | else {
36 | particle.sprite = new PIXI.Sprite(texture);
37 | }
38 |
39 | particle.sprite.__parentParticle = particle;
40 |
41 |
42 | particle.sprite.anchor.x = 0.5;
43 | particle.sprite.anchor.y = 0.5;
44 |
45 | particle.sprite.tail = 0;
46 | }
47 |
48 | if (!particle.inserted) {
49 | particle.inserted = true;
50 | this.buffer.push(particle.sprite);
51 | emitter.container.addChild(particle.sprite);
52 | //this.context.addChild(particle.graphics);
53 | }
54 |
55 |
56 | particle.sprite.visible = particle.life > 0;
57 | particle.sprite.width = particle.radius * particle.scale;
58 | particle.sprite.height = particle.radius * particle.scale;
59 |
60 | //particle.sprite.scale.x = particle.scale || 1;
61 | //particle.sprite.scale.y = particle.scale || 1;
62 |
63 |
64 |
65 | particle.sprite.position.x = particle.pos.x;
66 | particle.sprite.position.y = particle.pos.y;
67 | if (particle.textureAdditive) {
68 | particle.sprite.blendMode = PIXI.blendModes.ADD;
69 | }
70 | else {
71 | particle.sprite.blendMode = PIXI.blendModes.NORMAL;
72 | }
73 | //particle.sprite.texture.tintCache = undefined;
74 |
75 | particle.sprite.tint = ~~particle.color[2] + 256 * ~~particle.color[1] + 65536 * ~~particle.color[0];
76 | particle.sprite.alpha = particle.color[3];
77 |
78 |
79 | }
80 |
81 |
82 |
83 |
84 | public render(emitter:Emitter) {
85 | var particles = emitter.particles;
86 |
87 | if (!emitter.container) {
88 | emitter.container = new PIXI.DisplayObjectContainer();
89 | this.context.addChild(emitter.container);
90 | }
91 |
92 | for (var i = 0; i < particles.length; ++i) {
93 | var p = particles[i];
94 | if (p.color) {
95 | this.updateParticleSprite(emitter, p);
96 | }
97 |
98 | }
99 |
100 | if (emitter.recyclable.length > 0) {
101 |
102 | var particle:any;
103 | while (particle = emitter.recyclable.pop()) {
104 | particle.life = 0;
105 | if (particle.sprite) {
106 | //this.context.removeChild(particle.sprite);
107 | particle.sprite.visible = false;
108 | if (particle.sprite.__parentParticle) particle.sprite.__parentParticle.inserted = false;
109 |
110 | //particle.sprite = null;
111 | }
112 | }
113 | }
114 |
115 | }
116 |
117 | public hideAllParticles(emitter: Emitter) {
118 | for (var i = 0; i < emitter.particles.length; i++) {
119 | var particle = emitter.particles[i];
120 | particle.life = 0;
121 | }
122 | }
123 |
124 |
125 | public sort() {
126 | this.context.children.sort(this._sortFn);
127 | }
128 | public reset() {
129 | var removed = 0;
130 | do {
131 | var sprite = this.buffer.pop();
132 | if (!sprite) continue;
133 | for (var i = 0; i < this.context.children.length; i++) {
134 | var emitterContext: PIXI.DisplayObjectContainer = this.context.children[i];
135 | if (!emitterContext) continue;
136 |
137 | try {
138 | emitterContext.removeChild(sprite);
139 |
140 | removed++;
141 | continue;
142 | } catch (ex) { }
143 |
144 | }
145 |
146 |
147 |
148 | if (sprite.__parentParticle) {
149 | sprite.__parentParticle.inserted = false;
150 | sprite.__parentParticle.life = 0;
151 | }
152 |
153 | } while (this.buffer.length > 0);
154 | console.log('reset particles = ', removed);
155 |
156 | }
157 |
158 | }
159 | }
160 |
161 |
--------------------------------------------------------------------------------
/utils/math.ts:
--------------------------------------------------------------------------------
1 | module EPSY.utils.math {
2 | export function toRad(deg) {
3 | return Math.PI * deg / 180;
4 | }
5 |
6 | export function isNumber(i) {
7 | return typeof i === 'number';
8 | }
9 |
10 | export function isInteger(num) {
11 | return num === (num | 0);
12 | }
13 |
14 |
15 | export function frandom(min, max) {
16 | return Math.random() * (max - min) + min;
17 | }
18 |
19 | export function irandom(min, max) {
20 | return Math.floor(Math.random() * (max - min + 1) + min);
21 | }
22 |
23 |
24 | /*
25 | * Given a vector of any length, returns a vector
26 | * pointing in the same direction but with a magnitude of 1
27 | */
28 | export function normalize(vector) {
29 | var length = Math.sqrt(vector.x * vector.x + vector.y * vector.y);
30 |
31 | vector.x /= length;
32 | vector.y /= length;
33 | }
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/utils/obj.ts:
--------------------------------------------------------------------------------
1 | module EPSY.utils.obj {
2 |
3 |
4 |
5 | export function clone(obj, props) {
6 | var clone = {};
7 | this.extend(clone, obj);
8 | return clone;
9 | }
10 | export function extend(obj, config) {
11 | for (var prop in config) {
12 | if (config.hasOwnProperty(prop)) {
13 | obj[prop] = config[prop];
14 | }
15 | }
16 | }
17 |
18 | export function recursiveExtend(obj, config, exceptions) {
19 | exceptions = exceptions || [];
20 | for (var prop in config) {
21 | if (config.hasOwnProperty(prop)) {
22 | if (exceptions.indexOf(prop) > - 1) {
23 | obj[prop] = config[prop];
24 | } else {
25 | if (typeof config[prop] === 'object') {
26 | this.recursiveExtend(obj[prop], config[prop], exceptions);
27 | } else {
28 | obj[prop] = config[prop];
29 | }
30 | }
31 | }
32 | }
33 | }
34 | export function recursiveExtendInclusive(obj, config, whitelist:any[]) {
35 | if (!whitelist || !whitelist.length || whitelist.length <= 0) return;
36 |
37 | for (var prop in config) {
38 | if (whitelist.indexOf(prop) >= 0) {
39 |
40 | if (typeof config[prop] === 'object') {
41 | if (!obj[prop]) obj[prop] = {};
42 | this.recursiveExtend(obj[prop], config[prop]);
43 | } else {
44 | obj[prop] = config[prop];
45 | }
46 |
47 | }
48 | }
49 | }
50 |
51 |
52 |
53 |
54 | }
55 |
56 |
--------------------------------------------------------------------------------