diff --git a/.babelrc b/.babelrc
new file mode 100644
index 0000000..014b1c1
--- /dev/null
+++ b/.babelrc
@@ -0,0 +1,6 @@
+{
+ "presets": [
+ "es2015-rollup",
+ "stage-0"
+ ]
+}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index c276c20..fce9b1a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@ node_modules
# documentation
build/docs/
+
+package-lock.json
diff --git a/README.md b/README.md
index aced88c..11d1143 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@ Proton
> The documentation is available [here](https://projects.jpeer.at/proton/)
-Proton is an easily customizable html5 particle engine including six different types of renderers.
+Proton is a lightweight and powerful javascript particle engine including six different types of renderers.
Check out examples at http://a-jie.github.io/Proton/
## Features
@@ -11,8 +11,8 @@ Check out examples at http://a-jie.github.io/Proton/
- canvas
- dom
- webgl
- - easeljs
- pixel
+ - easeljs
- pixijs
- Create cool effects like the demo of 71squared's ParticleDesigner in 10 lines of code.
- Integratable into any game engine
@@ -56,33 +56,34 @@ emitter.addBehaviour(new Proton.Alpha(1, 0));
//set emitter position
emitter.p.x = canvas.width / 2;
emitter.p.y = canvas.height / 2;
-emitter.emit();
+emitter.emit(5);
//add emitter to the proton
proton.addEmitter(emitter);
// add canvas renderer
-var renderer = new Proton.Renderer('canvas', proton, canvas);
-renderer.start();
+var renderer = new Proton.CanvasRenderer(canvas);
+proton.addRenderer(renderer);
//use Euler integration calculation is more accurate (default false)
Proton.USE_CLOCK = false or true;
```
## Building Proton
-Node is a dependency, use terminal to install it with with:
-`git clone git://github.com/a-jie/Proton.git`
-
-Then navigate to the build directory by running:
+Node is a dependency, use terminal to install it with:
-```
-cd ./build
-node build.js
+```javascript
+git clone git://github.com/a-jie/Proton.git
+...
+npm install
+npm run build
```
-Or use npm script
-```
-npm run build
+and run example
+
+```javascript
+npm start
+//vist http://localhost:3001/example/
```
## Changelog
diff --git a/bower.json b/bower.json
index b2f3f08..8fd0063 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "Proton",
- "version": "2.2.1",
+ "version": "3.0.1",
"homepage": "http://a-jie.github.io/Proton",
"authors": [
"a-jie "
diff --git a/build/build.js b/build/build.js
deleted file mode 100644
index a285307..0000000
--- a/build/build.js
+++ /dev/null
@@ -1,83 +0,0 @@
-var fs = require("fs"),
- uglify = {
- parser: require("./lib/parse-js.js"),
- processor: require("./lib/process.js")
- },
-
- // Set the config filename
- configfile = "config",
-
- config, version, source_dir, output_full, output_min, head, umd, filenames, foot, i,
- ast, minified_source,
-
- files = [],
- numFiles = 0,
-
- source = "";
-
-// Get config file
-console.log("Reading config file...");
-config = fs.readFileSync(configfile, "UTF-8");
-
-// Get variables from config file
-version = /^version = (.*)$/m.exec(config)[1],
- source_dir = /^source_dir = (.*)$/m.exec(config)[1],
- output_full = /^output_full = (.*)$/m.exec(config)[1].replace("{version}", version),
- output_min = /^output_min = (.*)$/m.exec(config)[1].replace("{version}", version),
- head = /head\s-----\s([\s\S]*?)-----\s/g.exec(config)[1].replace("{version}", version).replace("{year}", "2011-" + (new Date()).getFullYear()),
- umd = /umd\s-----\s([\s\S]*?)-----\s/g.exec(config)[1],
- filenames = /files\s-----\s([\s\S]*?)\s-----/g.exec(config)[1].split(/\s/);
-
-numFiles = filenames.length;
-
-// Get all the source files
-for (i = 0; i < filenames.length; i++) {
- console.log("Reading file: " + filenames[i]);
-
- // Add current file
- files.push({
- name: filenames[i],
- content: fs.readFileSync(source_dir + filenames[i], "UTF-8")
- });
-}
-
-// Start the building process
-console.log("Building source file...");
-
-source = head + umd;
-for (i = 0; i < numFiles; i++) {
-
- if (files[i].name === "core/Proton.js") {
- files[i].content = files[i].content.replace(/\}(\s|)\)(\s|)\(window(\s|)\);/, "");
- files[i].content = files[i].content.replace(/\(function\(window\,\sundefined\)\s\{/, "");
- files[i].content = files[i].content.replace(/window\.Proton\s\=\sProton\;/, "");
- } else {
- files[i].content = files[i].content.replace(/\(function(\s|)\((\s|)Proton,(\s|)undefined(\s|)\)(\s|)\{/, "");
- files[i].content = files[i].content.replace(/\}(\s|)\)(\s|)\((\s|)Proton(\s|)\);/, "");
- }
-
- // Append the file to the full source
- source += "\n" + files[i].content;
-
- // Append the end of the core wrapper
- if (i === numFiles - 1) {
- //source += "\n})(window);";
- source += "\n\n return Proton;\n}));";
- }
-}
-///console.log(umd);
-// Save source to output file
-fs.writeFile(output_full, source, "UTF-8");
-console.log("Source file saved as: " + output_full);
-
-// Run UglifyJS to minify the source
-console.log("Minifying source with UglifyJS...");
-ast = uglify.parser.parse(source);
-ast = uglify.processor.ast_mangle(ast);
-ast = uglify.processor.ast_squeeze(ast);
-ast = uglify.processor.ast_squeeze_more(ast);
-minified_source = uglify.processor.gen_code(ast);
-
-// Save minified source file
-fs.writeFile(output_min, head + minified_source, "UTF-8");
-console.log("Minified source file saved as: " + output_min);
\ No newline at end of file
diff --git a/build/config b/build/config
deleted file mode 100644
index dbbedc7..0000000
--- a/build/config
+++ /dev/null
@@ -1,91 +0,0 @@
-version = 2.2.1
-source_dir = ../src/
-output_full = proton.js
-output_min = proton.min.js
-
-head
------
-/*!
- * Proton v{version}
- * https://github.com/a-jie/Proton
- *
- * Copyright {year}, A-JIE
- * Licensed under the MIT license
- * http://www.opensource.org/licenses/mit-license
- *
- */
------
-
-umd
------
-(function (root, factory) {
- if (typeof define === 'function' && define.amd) {
- define([], factory);
- } else if (typeof module !== 'undefined' && module.exports) {
- module.exports = factory();
- } else {
- root.Proton = factory();
- }
-}(this, function () {
------
-
-files
------
-core/Proton.js
-events/EventDispatcher.js
-utils/Util.js
-utils/WebGLUtil.js
-utils/DomUtil.js
-utils/MStack.js
-core/Particle.js
-core/Pool.js
-math/MathUtils.js
-math/NumericalIntegration.js
-math/Vector2D.js
-math/Polar2D.js
-math/Span.js
-math/ColorSpan.js
-math/Rectangle.js
-math/Mat3.js
-behaviour/Behaviour.js
-initialize/Rate.js
-initialize/Initialize.js
-initialize/InitializeUtil.js
-initialize/Life.js
-initialize/Position.js
-initialize/Velocity.js
-initialize/Mass.js
-initialize/Radius.js
-initialize/ImageTarget.js
-behaviour/Force.js
-behaviour/Attraction.js
-behaviour/RandomDrift.js
-behaviour/Repulsion.js
-behaviour/Gravity.js
-behaviour/Collision.js
-behaviour/CrossZone.js
-behaviour/Alpha.js
-behaviour/Scale.js
-behaviour/Rotate.js
-behaviour/Color.js
-behaviour/GravityWell.js
-emitter/Emitter.js
-emitter/BehaviourEmitter.js
-emitter/FollowEmitter.js
-plus/ease.js
-render/Renderer.js
-render/BaseRender.js
-render/DomRender.js
-render/EaselRender.js
-render/CanvasRender.js
-render/PixelRender.js
-render/WebGLRender.js
-zone/Zone.js
-zone/LineZone.js
-zone/CircleZone.js
-zone/PointZone.js
-zone/RectZone.js
-zone/ImageZone.js
-debug/Debug.js
-plus/requestAnimationFrame.js
------
\ No newline at end of file
diff --git a/build/lib/parse-js.js b/build/lib/parse-js.js
deleted file mode 100644
index d4a04eb..0000000
--- a/build/lib/parse-js.js
+++ /dev/null
@@ -1,1320 +0,0 @@
-/***********************************************************************
-
- A JavaScript tokenizer / parser / beautifier / compressor.
-
- This version is suitable for Node.js. With minimal changes (the
- exports stuff) it should work on any JS platform.
-
- This file contains the tokenizer/parser. It is a port to JavaScript
- of parse-js [1], a JavaScript parser library written in Common Lisp
- by Marijn Haverbeke. Thank you Marijn!
-
- [1] http://marijn.haverbeke.nl/parse-js/
-
- Exported functions:
-
- - tokenizer(code) -- returns a function. Call the returned
- function to fetch the next token.
-
- - parse(code) -- returns an AST of the given JavaScript code.
-
- -------------------------------- (C) ---------------------------------
-
- Author: Mihai Bazon
-
- http://mihai.bazon.net/blog
-
- Distributed under the BSD license:
-
- Copyright 2010 (c) Mihai Bazon
- Based on parse-js (http://marijn.haverbeke.nl/parse-js/).
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- * Redistributions of source code must retain the above
- copyright notice, this list of conditions and the following
- disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- SUCH DAMAGE.
-
- ***********************************************************************/
-
-/* -----[ Tokenizer (constants) ]----- */
-
-var KEYWORDS = array_to_hash([
- "break",
- "case",
- "catch",
- "const",
- "continue",
- "default",
- "delete",
- "do",
- "else",
- "finally",
- "for",
- "function",
- "if",
- "in",
- "instanceof",
- "new",
- "return",
- "switch",
- "throw",
- "try",
- "typeof",
- "var",
- "void",
- "while",
- "with"
-]);
-
-var RESERVED_WORDS = array_to_hash([
- "abstract",
- "boolean",
- "byte",
- "char",
- "class",
- "debugger",
- "double",
- "enum",
- "export",
- "extends",
- "final",
- "float",
- "goto",
- "implements",
- "import",
- "int",
- "interface",
- "long",
- "native",
- "package",
- "private",
- "protected",
- "public",
- "short",
- "static",
- "super",
- "synchronized",
- "throws",
- "transient",
- "volatile"
-]);
-
-var KEYWORDS_BEFORE_EXPRESSION = array_to_hash([
- "return",
- "new",
- "delete",
- "throw",
- "else",
- "case"
-]);
-
-var KEYWORDS_ATOM = array_to_hash([
- "false",
- "null",
- "true",
- "undefined"
-]);
-
-var OPERATOR_CHARS = array_to_hash(characters("+-*&%=<>!?|~^"));
-
-var RE_HEX_NUMBER = /^0x[0-9a-f]+$/i;
-var RE_OCT_NUMBER = /^0[0-7]+$/;
-var RE_DEC_NUMBER = /^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;
-
-var OPERATORS = array_to_hash([
- "in",
- "instanceof",
- "typeof",
- "new",
- "void",
- "delete",
- "++",
- "--",
- "+",
- "-",
- "!",
- "~",
- "&",
- "|",
- "^",
- "*",
- "/",
- "%",
- ">>",
- "<<",
- ">>>",
- "<",
- ">",
- "<=",
- ">=",
- "==",
- "===",
- "!=",
- "!==",
- "?",
- "=",
- "+=",
- "-=",
- "/=",
- "*=",
- "%=",
- ">>=",
- "<<=",
- ">>>=",
- "%=",
- "|=",
- "^=",
- "&=",
- "&&",
- "||"
-]);
-
-var WHITESPACE_CHARS = array_to_hash(characters(" \n\r\t\u200b"));
-
-var PUNC_BEFORE_EXPRESSION = array_to_hash(characters("[{}(,.;:"));
-
-var PUNC_CHARS = array_to_hash(characters("[]{}(),;:"));
-
-var REGEXP_MODIFIERS = array_to_hash(characters("gmsiy"));
-
-/* -----[ Tokenizer ]----- */
-
-// regexps adapted from http://xregexp.com/plugins/#unicode
-var UNICODE = {
- letter: new RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0523\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0621-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971\\u0972\\u097B-\\u097F\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D28\\u0D2A-\\u0D39\\u0D3D\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC\\u0EDD\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8B\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10D0-\\u10FA\\u10FC\\u1100-\\u1159\\u115F-\\u11A2\\u11A8-\\u11F9\\u1200-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u1676\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19A9\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u2094\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2C6F\\u2C71-\\u2C7D\\u2C80-\\u2CE4\\u2D00-\\u2D25\\u2D30-\\u2D65\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31B7\\u31F0-\\u31FF\\u3400\\u4DB5\\u4E00\\u9FC3\\uA000-\\uA48C\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA65F\\uA662-\\uA66E\\uA67F-\\uA697\\uA717-\\uA71F\\uA722-\\uA788\\uA78B\\uA78C\\uA7FB-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA90A-\\uA925\\uA930-\\uA946\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAC00\\uD7A3\\uF900-\\uFA2D\\uFA30-\\uFA6A\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"),
- non_spacing_mark: new RegExp("[\\u0300-\\u036F\\u0483-\\u0487\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065E\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0900-\\u0902\\u093C\\u0941-\\u0948\\u094D\\u0951-\\u0955\\u0962\\u0963\\u0981\\u09BC\\u09C1-\\u09C4\\u09CD\\u09E2\\u09E3\\u0A01\\u0A02\\u0A3C\\u0A41\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70\\u0A71\\u0A75\\u0A81\\u0A82\\u0ABC\\u0AC1-\\u0AC5\\u0AC7\\u0AC8\\u0ACD\\u0AE2\\u0AE3\\u0B01\\u0B3C\\u0B3F\\u0B41-\\u0B44\\u0B4D\\u0B56\\u0B62\\u0B63\\u0B82\\u0BC0\\u0BCD\\u0C3E-\\u0C40\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C62\\u0C63\\u0CBC\\u0CBF\\u0CC6\\u0CCC\\u0CCD\\u0CE2\\u0CE3\\u0D41-\\u0D44\\u0D4D\\u0D62\\u0D63\\u0DCA\\u0DD2-\\u0DD4\\u0DD6\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0F19\\u0F35\\u0F37\\u0F39\\u0F71-\\u0F7E\\u0F80-\\u0F84\\u0F86\\u0F87\\u0F90-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102D-\\u1030\\u1032-\\u1037\\u1039\\u103A\\u103D\\u103E\\u1058\\u1059\\u105E-\\u1060\\u1071-\\u1074\\u1082\\u1085\\u1086\\u108D\\u109D\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17B7-\\u17BD\\u17C6\\u17C9-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u1922\\u1927\\u1928\\u1932\\u1939-\\u193B\\u1A17\\u1A18\\u1A56\\u1A58-\\u1A5E\\u1A60\\u1A62\\u1A65-\\u1A6C\\u1A73-\\u1A7C\\u1A7F\\u1B00-\\u1B03\\u1B34\\u1B36-\\u1B3A\\u1B3C\\u1B42\\u1B6B-\\u1B73\\u1B80\\u1B81\\u1BA2-\\u1BA5\\u1BA8\\u1BA9\\u1C2C-\\u1C33\\u1C36\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE0\\u1CE2-\\u1CE8\\u1CED\\u1DC0-\\u1DE6\\u1DFD-\\u1DFF\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2CEF-\\u2CF1\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099\\u309A\\uA66F\\uA67C\\uA67D\\uA6F0\\uA6F1\\uA802\\uA806\\uA80B\\uA825\\uA826\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA951\\uA980-\\uA982\\uA9B3\\uA9B6-\\uA9B9\\uA9BC\\uAA29-\\uAA2E\\uAA31\\uAA32\\uAA35\\uAA36\\uAA43\\uAA4C\\uAAB0\\uAAB2-\\uAAB4\\uAAB7\\uAAB8\\uAABE\\uAABF\\uAAC1\\uABE5\\uABE8\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE26]"),
- space_combining_mark: new RegExp("[\\u0903\\u093E-\\u0940\\u0949-\\u094C\\u094E\\u0982\\u0983\\u09BE-\\u09C0\\u09C7\\u09C8\\u09CB\\u09CC\\u09D7\\u0A03\\u0A3E-\\u0A40\\u0A83\\u0ABE-\\u0AC0\\u0AC9\\u0ACB\\u0ACC\\u0B02\\u0B03\\u0B3E\\u0B40\\u0B47\\u0B48\\u0B4B\\u0B4C\\u0B57\\u0BBE\\u0BBF\\u0BC1\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCC\\u0BD7\\u0C01-\\u0C03\\u0C41-\\u0C44\\u0C82\\u0C83\\u0CBE\\u0CC0-\\u0CC4\\u0CC7\\u0CC8\\u0CCA\\u0CCB\\u0CD5\\u0CD6\\u0D02\\u0D03\\u0D3E-\\u0D40\\u0D46-\\u0D48\\u0D4A-\\u0D4C\\u0D57\\u0D82\\u0D83\\u0DCF-\\u0DD1\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0F3E\\u0F3F\\u0F7F\\u102B\\u102C\\u1031\\u1038\\u103B\\u103C\\u1056\\u1057\\u1062-\\u1064\\u1067-\\u106D\\u1083\\u1084\\u1087-\\u108C\\u108F\\u109A-\\u109C\\u17B6\\u17BE-\\u17C5\\u17C7\\u17C8\\u1923-\\u1926\\u1929-\\u192B\\u1930\\u1931\\u1933-\\u1938\\u19B0-\\u19C0\\u19C8\\u19C9\\u1A19-\\u1A1B\\u1A55\\u1A57\\u1A61\\u1A63\\u1A64\\u1A6D-\\u1A72\\u1B04\\u1B35\\u1B3B\\u1B3D-\\u1B41\\u1B43\\u1B44\\u1B82\\u1BA1\\u1BA6\\u1BA7\\u1BAA\\u1C24-\\u1C2B\\u1C34\\u1C35\\u1CE1\\u1CF2\\uA823\\uA824\\uA827\\uA880\\uA881\\uA8B4-\\uA8C3\\uA952\\uA953\\uA983\\uA9B4\\uA9B5\\uA9BA\\uA9BB\\uA9BD-\\uA9C0\\uAA2F\\uAA30\\uAA33\\uAA34\\uAA4D\\uAA7B\\uABE3\\uABE4\\uABE6\\uABE7\\uABE9\\uABEA\\uABEC]"),
- connector_punctuation: new RegExp("[\\u005F\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]")
-};
-
-function is_letter(ch) {
- return UNICODE.letter.test(ch);
-};
-
-function is_digit(ch) {
- ch = ch.charCodeAt(0);
- return ch >= 48 && ch <= 57; //XXX: find out if "UnicodeDigit" means something else than 0..9
-};
-
-function is_alphanumeric_char(ch) {
- return is_digit(ch) || is_letter(ch);
-};
-
-function is_unicode_combining_mark(ch) {
- return UNICODE.non_spacing_mark.test(ch) || UNICODE.space_combining_mark.test(ch);
-};
-
-function is_unicode_connector_punctuation(ch) {
- return UNICODE.connector_punctuation.test(ch);
-};
-
-function is_identifier_start(ch) {
- return ch == "$" || ch == "_" || is_letter(ch);
-};
-
-function is_identifier_char(ch) {
- return is_identifier_start(ch)
- || is_unicode_combining_mark(ch)
- || is_digit(ch)
- || is_unicode_connector_punctuation(ch)
- || ch == "\u200c" // zero-width non-joiner
- || ch == "\u200d" // zero-width joiner (in my ECMA-262 PDF, this is also 200c)
- ;
-};
-
-function parse_js_number(num) {
- if (RE_HEX_NUMBER.test(num)) {
- return parseInt(num.substr(2), 16);
- } else if (RE_OCT_NUMBER.test(num)) {
- return parseInt(num.substr(1), 8);
- } else if (RE_DEC_NUMBER.test(num)) {
- return parseFloat(num);
- }
-};
-
-function JS_Parse_Error(message, line, col, pos) {
- this.message = message;
- this.line = line;
- this.col = col;
- this.pos = pos;
- try {
- ({})();
- } catch(ex) {
- this.stack = ex.stack;
- };
-};
-
-JS_Parse_Error.prototype.toString = function() {
- return this.message + " (line: " + this.line + ", col: " + this.col + ", pos: " + this.pos + ")" + "\n\n" + this.stack;
-};
-
-function js_error(message, line, col, pos) {
- throw new JS_Parse_Error(message, line, col, pos);
-};
-
-function is_token(token, type, val) {
- return token.type == type && (val == null || token.value == val);
-};
-
-var EX_EOF = {};
-
-function tokenizer($TEXT) {
-
- var S = {
- text : $TEXT.replace(/\r\n?|[\n\u2028\u2029]/g, "\n").replace(/^\uFEFF/, ''),
- pos : 0,
- tokpos : 0,
- line : 0,
- tokline : 0,
- col : 0,
- tokcol : 0,
- newline_before : false,
- regex_allowed : false,
- comments_before : []
- };
-
- function peek() { return S.text.charAt(S.pos); };
-
- function next(signal_eof) {
- var ch = S.text.charAt(S.pos++);
- if (signal_eof && !ch)
- throw EX_EOF;
- if (ch == "\n") {
- S.newline_before = true;
- ++S.line;
- S.col = 0;
- } else {
- ++S.col;
- }
- return ch;
- };
-
- function eof() {
- return !S.peek();
- };
-
- function find(what, signal_eof) {
- var pos = S.text.indexOf(what, S.pos);
- if (signal_eof && pos == -1) throw EX_EOF;
- return pos;
- };
-
- function start_token() {
- S.tokline = S.line;
- S.tokcol = S.col;
- S.tokpos = S.pos;
- };
-
- function token(type, value, is_comment) {
- S.regex_allowed = ((type == "operator" && !HOP(UNARY_POSTFIX, value)) ||
- (type == "keyword" && HOP(KEYWORDS_BEFORE_EXPRESSION, value)) ||
- (type == "punc" && HOP(PUNC_BEFORE_EXPRESSION, value)));
- var ret = {
- type : type,
- value : value,
- line : S.tokline,
- col : S.tokcol,
- pos : S.tokpos,
- nlb : S.newline_before
- };
- if (!is_comment) {
- ret.comments_before = S.comments_before;
- S.comments_before = [];
- }
- S.newline_before = false;
- return ret;
- };
-
- function skip_whitespace() {
- while (HOP(WHITESPACE_CHARS, peek()))
- next();
- };
-
- function read_while(pred) {
- var ret = "", ch = peek(), i = 0;
- while (ch && pred(ch, i++)) {
- ret += next();
- ch = peek();
- }
- return ret;
- };
-
- function parse_error(err) {
- js_error(err, S.tokline, S.tokcol, S.tokpos);
- };
-
- function read_num(prefix) {
- var has_e = false, after_e = false, has_x = false, has_dot = prefix == ".";
- var num = read_while(function(ch, i){
- if (ch == "x" || ch == "X") {
- if (has_x) return false;
- return has_x = true;
- }
- if (!has_x && (ch == "E" || ch == "e")) {
- if (has_e) return false;
- return has_e = after_e = true;
- }
- if (ch == "-") {
- if (after_e || (i == 0 && !prefix)) return true;
- return false;
- }
- if (ch == "+") return after_e;
- after_e = false;
- if (ch == ".") {
- if (!has_dot)
- return has_dot = true;
- return false;
- }
- return is_alphanumeric_char(ch);
- });
- if (prefix)
- num = prefix + num;
- var valid = parse_js_number(num);
- if (!isNaN(valid)) {
- return token("num", valid);
- } else {
- parse_error("Invalid syntax: " + num);
- }
- };
-
- function read_escaped_char() {
- var ch = next(true);
- switch (ch) {
- case "n" : return "\n";
- case "r" : return "\r";
- case "t" : return "\t";
- case "b" : return "\b";
- case "v" : return "\v";
- case "f" : return "\f";
- case "0" : return "\0";
- case "x" : return String.fromCharCode(hex_bytes(2));
- case "u" : return String.fromCharCode(hex_bytes(4));
- default : return ch;
- }
- };
-
- function hex_bytes(n) {
- var num = 0;
- for (; n > 0; --n) {
- var digit = parseInt(next(true), 16);
- if (isNaN(digit))
- parse_error("Invalid hex-character pattern in string");
- num = (num << 4) | digit;
- }
- return num;
- };
-
- function read_string() {
- return with_eof_error("Unterminated string constant", function(){
- var quote = next(), ret = "";
- for (;;) {
- var ch = next(true);
- if (ch == "\\") ch = read_escaped_char();
- else if (ch == quote) break;
- ret += ch;
- }
- return token("string", ret);
- });
- };
-
- function read_line_comment() {
- next();
- var i = find("\n"), ret;
- if (i == -1) {
- ret = S.text.substr(S.pos);
- S.pos = S.text.length;
- } else {
- ret = S.text.substring(S.pos, i);
- S.pos = i;
- }
- return token("comment1", ret, true);
- };
-
- function read_multiline_comment() {
- next();
- return with_eof_error("Unterminated multiline comment", function(){
- var i = find("*/", true),
- text = S.text.substring(S.pos, i),
- tok = token("comment2", text, true);
- S.pos = i + 2;
- S.line += text.split("\n").length - 1;
- S.newline_before = text.indexOf("\n") >= 0;
-
- // https://github.com/mishoo/UglifyJS/issues/#issue/100
- if (/^@cc_on/i.test(text)) {
- warn("WARNING: at line " + S.line);
- warn("*** Found \"conditional comment\": " + text);
- warn("*** UglifyJS DISCARDS ALL COMMENTS. This means your code might no longer work properly in Internet Explorer.");
- }
-
- return tok;
- });
- };
-
- function read_name() {
- var backslash = false, name = "", ch;
- while ((ch = peek()) != null) {
- if (!backslash) {
- if (ch == "\\") backslash = true, next();
- else if (is_identifier_char(ch)) name += next();
- else break;
- }
- else {
- if (ch != "u") parse_error("Expecting UnicodeEscapeSequence -- uXXXX");
- ch = read_escaped_char();
- if (!is_identifier_char(ch)) parse_error("Unicode char: " + ch.charCodeAt(0) + " is not valid in identifier");
- name += ch;
- backslash = false;
- }
- }
- return name;
- };
-
- function read_regexp() {
- return with_eof_error("Unterminated regular expression", function(){
- var prev_backslash = false, regexp = "", ch, in_class = false;
- while ((ch = next(true))) if (prev_backslash) {
- regexp += "\\" + ch;
- prev_backslash = false;
- } else if (ch == "[") {
- in_class = true;
- regexp += ch;
- } else if (ch == "]" && in_class) {
- in_class = false;
- regexp += ch;
- } else if (ch == "/" && !in_class) {
- break;
- } else if (ch == "\\") {
- prev_backslash = true;
- } else {
- regexp += ch;
- }
- var mods = read_name();
- return token("regexp", [ regexp, mods ]);
- });
- };
-
- function read_operator(prefix) {
- function grow(op) {
- if (!peek()) return op;
- var bigger = op + peek();
- if (HOP(OPERATORS, bigger)) {
- next();
- return grow(bigger);
- } else {
- return op;
- }
- };
- return token("operator", grow(prefix || next()));
- };
-
- function handle_slash() {
- next();
- var regex_allowed = S.regex_allowed;
- switch (peek()) {
- case "/":
- S.comments_before.push(read_line_comment());
- S.regex_allowed = regex_allowed;
- return next_token();
- case "*":
- S.comments_before.push(read_multiline_comment());
- S.regex_allowed = regex_allowed;
- return next_token();
- }
- return S.regex_allowed ? read_regexp() : read_operator("/");
- };
-
- function handle_dot() {
- next();
- return is_digit(peek())
- ? read_num(".")
- : token("punc", ".");
- };
-
- function read_word() {
- var word = read_name();
- return !HOP(KEYWORDS, word)
- ? token("name", word)
- : HOP(OPERATORS, word)
- ? token("operator", word)
- : HOP(KEYWORDS_ATOM, word)
- ? token("atom", word)
- : token("keyword", word);
- };
-
- function with_eof_error(eof_error, cont) {
- try {
- return cont();
- } catch(ex) {
- if (ex === EX_EOF) parse_error(eof_error);
- else throw ex;
- }
- };
-
- function next_token(force_regexp) {
- if (force_regexp)
- return read_regexp();
- skip_whitespace();
- start_token();
- var ch = peek();
- if (!ch) return token("eof");
- if (is_digit(ch)) return read_num();
- if (ch == '"' || ch == "'") return read_string();
- if (HOP(PUNC_CHARS, ch)) return token("punc", next());
- if (ch == ".") return handle_dot();
- if (ch == "/") return handle_slash();
- if (HOP(OPERATOR_CHARS, ch)) return read_operator();
- if (ch == "\\" || is_identifier_start(ch)) return read_word();
- parse_error("Unexpected character '" + ch + "'");
- };
-
- next_token.context = function(nc) {
- if (nc) S = nc;
- return S;
- };
-
- return next_token;
-
-};
-
-/* -----[ Parser (constants) ]----- */
-
-var UNARY_PREFIX = array_to_hash([
- "typeof",
- "void",
- "delete",
- "--",
- "++",
- "!",
- "~",
- "-",
- "+"
-]);
-
-var UNARY_POSTFIX = array_to_hash([ "--", "++" ]);
-
-var ASSIGNMENT = (function(a, ret, i){
- while (i < a.length) {
- ret[a[i]] = a[i].substr(0, a[i].length - 1);
- i++;
- }
- return ret;
-})(
- ["+=", "-=", "/=", "*=", "%=", ">>=", "<<=", ">>>=", "|=", "^=", "&="],
- { "=": true },
- 0
-);
-
-var PRECEDENCE = (function(a, ret){
- for (var i = 0, n = 1; i < a.length; ++i, ++n) {
- var b = a[i];
- for (var j = 0; j < b.length; ++j) {
- ret[b[j]] = n;
- }
- }
- return ret;
-})(
- [
- ["||"],
- ["&&"],
- ["|"],
- ["^"],
- ["&"],
- ["==", "===", "!=", "!=="],
- ["<", ">", "<=", ">=", "in", "instanceof"],
- [">>", "<<", ">>>"],
- ["+", "-"],
- ["*", "/", "%"]
- ],
- {}
-);
-
-var STATEMENTS_WITH_LABELS = array_to_hash([ "for", "do", "while", "switch" ]);
-
-var ATOMIC_START_TOKEN = array_to_hash([ "atom", "num", "string", "regexp", "name" ]);
-
-/* -----[ Parser ]----- */
-
-function NodeWithToken(str, start, end) {
- this.name = str;
- this.start = start;
- this.end = end;
-};
-
-NodeWithToken.prototype.toString = function() { return this.name; };
-
-function parse($TEXT, exigent_mode, embed_tokens) {
-
- var S = {
- input : typeof $TEXT == "string" ? tokenizer($TEXT, true) : $TEXT,
- token : null,
- prev : null,
- peeked : null,
- in_function : 0,
- in_loop : 0,
- labels : []
- };
-
- S.token = next();
-
- function is(type, value) {
- return is_token(S.token, type, value);
- };
-
- function peek() { return S.peeked || (S.peeked = S.input()); };
-
- function next() {
- S.prev = S.token;
- if (S.peeked) {
- S.token = S.peeked;
- S.peeked = null;
- } else {
- S.token = S.input();
- }
- return S.token;
- };
-
- function prev() {
- return S.prev;
- };
-
- function croak(msg, line, col, pos) {
- var ctx = S.input.context();
- js_error(msg,
- line != null ? line : ctx.tokline,
- col != null ? col : ctx.tokcol,
- pos != null ? pos : ctx.tokpos);
- };
-
- function token_error(token, msg) {
- croak(msg, token.line, token.col);
- };
-
- function unexpected(token) {
- if (token == null)
- token = S.token;
- token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");
- };
-
- function expect_token(type, val) {
- if (is(type, val)) {
- return next();
- }
- token_error(S.token, "Unexpected token " + S.token.type + ", expected " + type);
- };
-
- function expect(punc) { return expect_token("punc", punc); };
-
- function can_insert_semicolon() {
- return !exigent_mode && (
- S.token.nlb || is("eof") || is("punc", "}")
- );
- };
-
- function semicolon() {
- if (is("punc", ";")) next();
- else if (!can_insert_semicolon()) unexpected();
- };
-
- function as() {
- return slice(arguments);
- };
-
- function parenthesised() {
- expect("(");
- var ex = expression();
- expect(")");
- return ex;
- };
-
- function add_tokens(str, start, end) {
- return str instanceof NodeWithToken ? str : new NodeWithToken(str, start, end);
- };
-
- var statement = embed_tokens ? function() {
- var start = S.token;
- var ast = $statement.apply(this, arguments);
- ast[0] = add_tokens(ast[0], start, prev());
- return ast;
- } : $statement;
-
- function $statement() {
- if (is("operator", "/")) {
- S.peeked = null;
- S.token = S.input(true); // force regexp
- }
- switch (S.token.type) {
- case "num":
- case "string":
- case "regexp":
- case "operator":
- case "atom":
- return simple_statement();
-
- case "name":
- return is_token(peek(), "punc", ":")
- ? labeled_statement(prog1(S.token.value, next, next))
- : simple_statement();
-
- case "punc":
- switch (S.token.value) {
- case "{":
- return as("block", block_());
- case "[":
- case "(":
- return simple_statement();
- case ";":
- next();
- return as("block");
- default:
- unexpected();
- }
-
- case "keyword":
- switch (prog1(S.token.value, next)) {
- case "break":
- return break_cont("break");
-
- case "continue":
- return break_cont("continue");
-
- case "debugger":
- semicolon();
- return as("debugger");
-
- case "do":
- return (function(body){
- expect_token("keyword", "while");
- return as("do", prog1(parenthesised, semicolon), body);
- })(in_loop(statement));
-
- case "for":
- return for_();
-
- case "function":
- return function_(true);
-
- case "if":
- return if_();
-
- case "return":
- if (S.in_function == 0)
- croak("'return' outside of function");
- return as("return",
- is("punc", ";")
- ? (next(), null)
- : can_insert_semicolon()
- ? null
- : prog1(expression, semicolon));
-
- case "switch":
- return as("switch", parenthesised(), switch_block_());
-
- case "throw":
- return as("throw", prog1(expression, semicolon));
-
- case "try":
- return try_();
-
- case "var":
- return prog1(var_, semicolon);
-
- case "const":
- return prog1(const_, semicolon);
-
- case "while":
- return as("while", parenthesised(), in_loop(statement));
-
- case "with":
- return as("with", parenthesised(), statement());
-
- default:
- unexpected();
- }
- }
- };
-
- function labeled_statement(label) {
- S.labels.push(label);
- var start = S.token, stat = statement();
- if (exigent_mode && !HOP(STATEMENTS_WITH_LABELS, stat[0]))
- unexpected(start);
- S.labels.pop();
- return as("label", label, stat);
- };
-
- function simple_statement() {
- return as("stat", prog1(expression, semicolon));
- };
-
- function break_cont(type) {
- var name = is("name") ? S.token.value : null;
- if (name != null) {
- next();
- if (!member(name, S.labels))
- croak("Label " + name + " without matching loop or statement");
- }
- else if (S.in_loop == 0)
- croak(type + " not inside a loop or switch");
- semicolon();
- return as(type, name);
- };
-
- function for_() {
- expect("(");
- var init = null;
- if (!is("punc", ";")) {
- init = is("keyword", "var")
- ? (next(), var_(true))
- : expression(true, true);
- if (is("operator", "in"))
- return for_in(init);
- }
- return regular_for(init);
- };
-
- function regular_for(init) {
- expect(";");
- var test = is("punc", ";") ? null : expression();
- expect(";");
- var step = is("punc", ")") ? null : expression();
- expect(")");
- return as("for", init, test, step, in_loop(statement));
- };
-
- function for_in(init) {
- var lhs = init[0] == "var" ? as("name", init[1][0]) : init;
- next();
- var obj = expression();
- expect(")");
- return as("for-in", init, lhs, obj, in_loop(statement));
- };
-
- var function_ = embed_tokens ? function() {
- var start = prev();
- var ast = $function_.apply(this, arguments);
- ast[0] = add_tokens(ast[0], start, prev());
- return ast;
- } : $function_;
-
- function $function_(in_statement) {
- var name = is("name") ? prog1(S.token.value, next) : null;
- if (in_statement && !name)
- unexpected();
- expect("(");
- return as(in_statement ? "defun" : "function",
- name,
- // arguments
- (function(first, a){
- while (!is("punc", ")")) {
- if (first) first = false; else expect(",");
- if (!is("name")) unexpected();
- a.push(S.token.value);
- next();
- }
- next();
- return a;
- })(true, []),
- // body
- (function(){
- ++S.in_function;
- var loop = S.in_loop;
- S.in_loop = 0;
- var a = block_();
- --S.in_function;
- S.in_loop = loop;
- return a;
- })());
- };
-
- function if_() {
- var cond = parenthesised(), body = statement(), belse;
- if (is("keyword", "else")) {
- next();
- belse = statement();
- }
- return as("if", cond, body, belse);
- };
-
- function block_() {
- expect("{");
- var a = [];
- while (!is("punc", "}")) {
- if (is("eof")) unexpected();
- a.push(statement());
- }
- next();
- return a;
- };
-
- var switch_block_ = curry(in_loop, function(){
- expect("{");
- var a = [], cur = null;
- while (!is("punc", "}")) {
- if (is("eof")) unexpected();
- if (is("keyword", "case")) {
- next();
- cur = [];
- a.push([ expression(), cur ]);
- expect(":");
- }
- else if (is("keyword", "default")) {
- next();
- expect(":");
- cur = [];
- a.push([ null, cur ]);
- }
- else {
- if (!cur) unexpected();
- cur.push(statement());
- }
- }
- next();
- return a;
- });
-
- function try_() {
- var body = block_(), bcatch, bfinally;
- if (is("keyword", "catch")) {
- next();
- expect("(");
- if (!is("name"))
- croak("Name expected");
- var name = S.token.value;
- next();
- expect(")");
- bcatch = [ name, block_() ];
- }
- if (is("keyword", "finally")) {
- next();
- bfinally = block_();
- }
- if (!bcatch && !bfinally)
- croak("Missing catch/finally blocks");
- return as("try", body, bcatch, bfinally);
- };
-
- function vardefs(no_in) {
- var a = [];
- for (;;) {
- if (!is("name"))
- unexpected();
- var name = S.token.value;
- next();
- if (is("operator", "=")) {
- next();
- a.push([ name, expression(false, no_in) ]);
- } else {
- a.push([ name ]);
- }
- if (!is("punc", ","))
- break;
- next();
- }
- return a;
- };
-
- function var_(no_in) {
- return as("var", vardefs(no_in));
- };
-
- function const_() {
- return as("const", vardefs());
- };
-
- function new_() {
- var newexp = expr_atom(false), args;
- if (is("punc", "(")) {
- next();
- args = expr_list(")");
- } else {
- args = [];
- }
- return subscripts(as("new", newexp, args), true);
- };
-
- function expr_atom(allow_calls) {
- if (is("operator", "new")) {
- next();
- return new_();
- }
- if (is("operator") && HOP(UNARY_PREFIX, S.token.value)) {
- return make_unary("unary-prefix",
- prog1(S.token.value, next),
- expr_atom(allow_calls));
- }
- if (is("punc")) {
- switch (S.token.value) {
- case "(":
- next();
- return subscripts(prog1(expression, curry(expect, ")")), allow_calls);
- case "[":
- next();
- return subscripts(array_(), allow_calls);
- case "{":
- next();
- return subscripts(object_(), allow_calls);
- }
- unexpected();
- }
- if (is("keyword", "function")) {
- next();
- return subscripts(function_(false), allow_calls);
- }
- if (HOP(ATOMIC_START_TOKEN, S.token.type)) {
- var atom = S.token.type == "regexp"
- ? as("regexp", S.token.value[0], S.token.value[1])
- : as(S.token.type, S.token.value);
- return subscripts(prog1(atom, next), allow_calls);
- }
- unexpected();
- };
-
- function expr_list(closing, allow_trailing_comma, allow_empty) {
- var first = true, a = [];
- while (!is("punc", closing)) {
- if (first) first = false; else expect(",");
- if (allow_trailing_comma && is("punc", closing)) break;
- if (is("punc", ",") && allow_empty) {
- a.push([ "atom", "undefined" ]);
- } else {
- a.push(expression(false));
- }
- }
- next();
- return a;
- };
-
- function array_() {
- return as("array", expr_list("]", !exigent_mode, true));
- };
-
- function object_() {
- var first = true, a = [];
- while (!is("punc", "}")) {
- if (first) first = false; else expect(",");
- if (!exigent_mode && is("punc", "}"))
- // allow trailing comma
- break;
- var type = S.token.type;
- var name = as_property_name();
- if (type == "name" && (name == "get" || name == "set") && !is("punc", ":")) {
- a.push([ as_name(), function_(false), name ]);
- } else {
- expect(":");
- a.push([ name, expression(false) ]);
- }
- }
- next();
- return as("object", a);
- };
-
- function as_property_name() {
- switch (S.token.type) {
- case "num":
- case "string":
- return prog1(S.token.value, next);
- }
- return as_name();
- };
-
- function as_name() {
- switch (S.token.type) {
- case "name":
- case "operator":
- case "keyword":
- case "atom":
- return prog1(S.token.value, next);
- default:
- unexpected();
- }
- };
-
- function subscripts(expr, allow_calls) {
- if (is("punc", ".")) {
- next();
- return subscripts(as("dot", expr, as_name()), allow_calls);
- }
- if (is("punc", "[")) {
- next();
- return subscripts(as("sub", expr, prog1(expression, curry(expect, "]"))), allow_calls);
- }
- if (allow_calls && is("punc", "(")) {
- next();
- return subscripts(as("call", expr, expr_list(")")), true);
- }
- if (allow_calls && is("operator") && HOP(UNARY_POSTFIX, S.token.value)) {
- return prog1(curry(make_unary, "unary-postfix", S.token.value, expr),
- next);
- }
- return expr;
- };
-
- function make_unary(tag, op, expr) {
- if ((op == "++" || op == "--") && !is_assignable(expr))
- croak("Invalid use of " + op + " operator");
- return as(tag, op, expr);
- };
-
- function expr_op(left, min_prec, no_in) {
- var op = is("operator") ? S.token.value : null;
- if (op && op == "in" && no_in) op = null;
- var prec = op != null ? PRECEDENCE[op] : null;
- if (prec != null && prec > min_prec) {
- next();
- var right = expr_op(expr_atom(true), prec, no_in);
- return expr_op(as("binary", op, left, right), min_prec, no_in);
- }
- return left;
- };
-
- function expr_ops(no_in) {
- return expr_op(expr_atom(true), 0, no_in);
- };
-
- function maybe_conditional(no_in) {
- var expr = expr_ops(no_in);
- if (is("operator", "?")) {
- next();
- var yes = expression(false);
- expect(":");
- return as("conditional", expr, yes, expression(false, no_in));
- }
- return expr;
- };
-
- function is_assignable(expr) {
- if (!exigent_mode) return true;
- switch (expr[0]) {
- case "dot":
- case "sub":
- case "new":
- case "call":
- return true;
- case "name":
- return expr[1] != "this";
- }
- };
-
- function maybe_assign(no_in) {
- var left = maybe_conditional(no_in), val = S.token.value;
- if (is("operator") && HOP(ASSIGNMENT, val)) {
- if (is_assignable(left)) {
- next();
- return as("assign", ASSIGNMENT[val], left, maybe_assign(no_in));
- }
- croak("Invalid assignment");
- }
- return left;
- };
-
- function expression(commas, no_in) {
- if (arguments.length == 0)
- commas = true;
- var expr = maybe_assign(no_in);
- if (commas && is("punc", ",")) {
- next();
- return as("seq", expr, expression(true, no_in));
- }
- return expr;
- };
-
- function in_loop(cont) {
- try {
- ++S.in_loop;
- return cont();
- } finally {
- --S.in_loop;
- }
- };
-
- return as("toplevel", (function(a){
- while (!is("eof"))
- a.push(statement());
- return a;
- })([]));
-
-};
-
-/* -----[ Utilities ]----- */
-
-function curry(f) {
- var args = slice(arguments, 1);
- return function() { return f.apply(this, args.concat(slice(arguments))); };
-};
-
-function prog1(ret) {
- if (ret instanceof Function)
- ret = ret();
- for (var i = 1, n = arguments.length; --n > 0; ++i)
- arguments[i]();
- return ret;
-};
-
-function array_to_hash(a) {
- var ret = {};
- for (var i = 0; i < a.length; ++i)
- ret[a[i]] = true;
- return ret;
-};
-
-function slice(a, start) {
- return Array.prototype.slice.call(a, start == null ? 0 : start);
-};
-
-function characters(str) {
- return str.split("");
-};
-
-function member(name, array) {
- for (var i = array.length; --i >= 0;)
- if (array[i] === name)
- return true;
- return false;
-};
-
-function HOP(obj, prop) {
- return Object.prototype.hasOwnProperty.call(obj, prop);
-};
-
-var warn = function() {};
-
-/* -----[ Exports ]----- */
-
-exports.tokenizer = tokenizer;
-exports.parse = parse;
-exports.slice = slice;
-exports.curry = curry;
-exports.member = member;
-exports.array_to_hash = array_to_hash;
-exports.PRECEDENCE = PRECEDENCE;
-exports.KEYWORDS_ATOM = KEYWORDS_ATOM;
-exports.RESERVED_WORDS = RESERVED_WORDS;
-exports.KEYWORDS = KEYWORDS;
-exports.ATOMIC_START_TOKEN = ATOMIC_START_TOKEN;
-exports.OPERATORS = OPERATORS;
-exports.is_alphanumeric_char = is_alphanumeric_char;
-exports.set_logger = function(logger) {
- warn = logger;
-};
diff --git a/build/lib/process.js b/build/lib/process.js
deleted file mode 100644
index b8e5a8b..0000000
--- a/build/lib/process.js
+++ /dev/null
@@ -1,1609 +0,0 @@
-/***********************************************************************
-
- A JavaScript tokenizer / parser / beautifier / compressor.
-
- This version is suitable for Node.js. With minimal changes (the
- exports stuff) it should work on any JS platform.
-
- This file implements some AST processors. They work on data built
- by parse-js.
-
- Exported functions:
-
- - ast_mangle(ast, options) -- mangles the variable/function names
- in the AST. Returns an AST.
-
- - ast_squeeze(ast) -- employs various optimizations to make the
- final generated code even smaller. Returns an AST.
-
- - gen_code(ast, options) -- generates JS code from the AST. Pass
- true (or an object, see the code for some options) as second
- argument to get "pretty" (indented) code.
-
- -------------------------------- (C) ---------------------------------
-
- Author: Mihai Bazon
-
- http://mihai.bazon.net/blog
-
- Distributed under the BSD license:
-
- Copyright 2010 (c) Mihai Bazon
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- * Redistributions of source code must retain the above
- copyright notice, this list of conditions and the following
- disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
- TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
- THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- SUCH DAMAGE.
-
- ***********************************************************************/
-
-var jsp = require("./parse-js"),
- slice = jsp.slice,
- member = jsp.member,
- PRECEDENCE = jsp.PRECEDENCE,
- OPERATORS = jsp.OPERATORS;
-
-/* -----[ helper for AST traversal ]----- */
-
-function ast_walker(ast) {
- function _vardefs(defs) {
- return [ this[0], MAP(defs, function(def){
- var a = [ def[0] ];
- if (def.length > 1)
- a[1] = walk(def[1]);
- return a;
- }) ];
- };
- var walkers = {
- "string": function(str) {
- return [ this[0], str ];
- },
- "num": function(num) {
- return [ this[0], num ];
- },
- "name": function(name) {
- return [ this[0], name ];
- },
- "toplevel": function(statements) {
- return [ this[0], MAP(statements, walk) ];
- },
- "block": function(statements) {
- var out = [ this[0] ];
- if (statements != null)
- out.push(MAP(statements, walk));
- return out;
- },
- "var": _vardefs,
- "const": _vardefs,
- "try": function(t, c, f) {
- return [
- this[0],
- MAP(t, walk),
- c != null ? [ c[0], MAP(c[1], walk) ] : null,
- f != null ? MAP(f, walk) : null
- ];
- },
- "throw": function(expr) {
- return [ this[0], walk(expr) ];
- },
- "new": function(ctor, args) {
- return [ this[0], walk(ctor), MAP(args, walk) ];
- },
- "switch": function(expr, body) {
- return [ this[0], walk(expr), MAP(body, function(branch){
- return [ branch[0] ? walk(branch[0]) : null,
- MAP(branch[1], walk) ];
- }) ];
- },
- "break": function(label) {
- return [ this[0], label ];
- },
- "continue": function(label) {
- return [ this[0], label ];
- },
- "conditional": function(cond, t, e) {
- return [ this[0], walk(cond), walk(t), walk(e) ];
- },
- "assign": function(op, lvalue, rvalue) {
- return [ this[0], op, walk(lvalue), walk(rvalue) ];
- },
- "dot": function(expr) {
- return [ this[0], walk(expr) ].concat(slice(arguments, 1));
- },
- "call": function(expr, args) {
- return [ this[0], walk(expr), MAP(args, walk) ];
- },
- "function": function(name, args, body) {
- return [ this[0], name, args.slice(), MAP(body, walk) ];
- },
- "defun": function(name, args, body) {
- return [ this[0], name, args.slice(), MAP(body, walk) ];
- },
- "if": function(conditional, t, e) {
- return [ this[0], walk(conditional), walk(t), walk(e) ];
- },
- "for": function(init, cond, step, block) {
- return [ this[0], walk(init), walk(cond), walk(step), walk(block) ];
- },
- "for-in": function(vvar, key, hash, block) {
- return [ this[0], walk(vvar), walk(key), walk(hash), walk(block) ];
- },
- "while": function(cond, block) {
- return [ this[0], walk(cond), walk(block) ];
- },
- "do": function(cond, block) {
- return [ this[0], walk(cond), walk(block) ];
- },
- "return": function(expr) {
- return [ this[0], walk(expr) ];
- },
- "binary": function(op, left, right) {
- return [ this[0], op, walk(left), walk(right) ];
- },
- "unary-prefix": function(op, expr) {
- return [ this[0], op, walk(expr) ];
- },
- "unary-postfix": function(op, expr) {
- return [ this[0], op, walk(expr) ];
- },
- "sub": function(expr, subscript) {
- return [ this[0], walk(expr), walk(subscript) ];
- },
- "object": function(props) {
- return [ this[0], MAP(props, function(p){
- return p.length == 2
- ? [ p[0], walk(p[1]) ]
- : [ p[0], walk(p[1]), p[2] ]; // get/set-ter
- }) ];
- },
- "regexp": function(rx, mods) {
- return [ this[0], rx, mods ];
- },
- "array": function(elements) {
- return [ this[0], MAP(elements, walk) ];
- },
- "stat": function(stat) {
- return [ this[0], walk(stat) ];
- },
- "seq": function() {
- return [ this[0] ].concat(MAP(slice(arguments), walk));
- },
- "label": function(name, block) {
- return [ this[0], name, walk(block) ];
- },
- "with": function(expr, block) {
- return [ this[0], walk(expr), walk(block) ];
- },
- "atom": function(name) {
- return [ this[0], name ];
- }
- };
-
- var user = {};
- var stack = [];
- function walk(ast) {
- if (ast == null)
- return null;
- try {
- stack.push(ast);
- var type = ast[0];
- var gen = user[type];
- if (gen) {
- var ret = gen.apply(ast, ast.slice(1));
- if (ret != null)
- return ret;
- }
- gen = walkers[type];
- return gen.apply(ast, ast.slice(1));
- } finally {
- stack.pop();
- }
- };
-
- function with_walkers(walkers, cont){
- var save = {}, i;
- for (i in walkers) if (HOP(walkers, i)) {
- save[i] = user[i];
- user[i] = walkers[i];
- }
- var ret = cont();
- for (i in save) if (HOP(save, i)) {
- if (!save[i]) delete user[i];
- else user[i] = save[i];
- }
- return ret;
- };
-
- return {
- walk: walk,
- with_walkers: with_walkers,
- parent: function() {
- return stack[stack.length - 2]; // last one is current node
- },
- stack: function() {
- return stack;
- }
- };
-};
-
-/* -----[ Scope and mangling ]----- */
-
-function Scope(parent) {
- this.names = {}; // names defined in this scope
- this.mangled = {}; // mangled names (orig.name => mangled)
- this.rev_mangled = {}; // reverse lookup (mangled => orig.name)
- this.cname = -1; // current mangled name
- this.refs = {}; // names referenced from this scope
- this.uses_with = false; // will become TRUE if eval() is detected in this or any subscopes
- this.uses_eval = false; // will become TRUE if with() is detected in this or any subscopes
- this.parent = parent; // parent scope
- this.children = []; // sub-scopes
- if (parent) {
- this.level = parent.level + 1;
- parent.children.push(this);
- } else {
- this.level = 0;
- }
-};
-
-var base54 = (function(){
- var DIGITS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_";
- return function(num) {
- var ret = "";
- do {
- ret = DIGITS.charAt(num % 54) + ret;
- num = Math.floor(num / 54);
- } while (num > 0);
- return ret;
- };
-})();
-
-Scope.prototype = {
- has: function(name) {
- for (var s = this; s; s = s.parent)
- if (HOP(s.names, name))
- return s;
- },
- has_mangled: function(mname) {
- for (var s = this; s; s = s.parent)
- if (HOP(s.rev_mangled, mname))
- return s;
- },
- toJSON: function() {
- return {
- names: this.names,
- uses_eval: this.uses_eval,
- uses_with: this.uses_with
- };
- },
-
- next_mangled: function() {
- // we must be careful that the new mangled name:
- //
- // 1. doesn't shadow a mangled name from a parent
- // scope, unless we don't reference the original
- // name from this scope OR from any sub-scopes!
- // This will get slow.
- //
- // 2. doesn't shadow an original name from a parent
- // scope, in the event that the name is not mangled
- // in the parent scope and we reference that name
- // here OR IN ANY SUBSCOPES!
- //
- // 3. doesn't shadow a name that is referenced but not
- // defined (possibly global defined elsewhere).
- for (;;) {
- var m = base54(++this.cname), prior;
-
- // case 1.
- prior = this.has_mangled(m);
- if (prior && this.refs[prior.rev_mangled[m]] === prior)
- continue;
-
- // case 2.
- prior = this.has(m);
- if (prior && prior !== this && this.refs[m] === prior && !prior.has_mangled(m))
- continue;
-
- // case 3.
- if (HOP(this.refs, m) && this.refs[m] == null)
- continue;
-
- // I got "do" once. :-/
- if (!is_identifier(m))
- continue;
-
- return m;
- }
- },
- get_mangled: function(name, newMangle) {
- if (this.uses_eval || this.uses_with) return name; // no mangle if eval or with is in use
- var s = this.has(name);
- if (!s) return name; // not in visible scope, no mangle
- if (HOP(s.mangled, name)) return s.mangled[name]; // already mangled in this scope
- if (!newMangle) return name; // not found and no mangling requested
-
- var m = s.next_mangled();
- s.rev_mangled[m] = name;
- return s.mangled[name] = m;
- },
- define: function(name) {
- if (name != null)
- return this.names[name] = name;
- }
-};
-
-function ast_add_scope(ast) {
-
- var current_scope = null;
- var w = ast_walker(), walk = w.walk;
- var having_eval = [];
-
- function with_new_scope(cont) {
- current_scope = new Scope(current_scope);
- var ret = current_scope.body = cont();
- ret.scope = current_scope;
- current_scope = current_scope.parent;
- return ret;
- };
-
- function define(name) {
- return current_scope.define(name);
- };
-
- function reference(name) {
- current_scope.refs[name] = true;
- };
-
- function _lambda(name, args, body) {
- return [ this[0], define(name), args, with_new_scope(function(){
- MAP(args, define);
- return MAP(body, walk);
- })];
- };
-
- return with_new_scope(function(){
- // process AST
- var ret = w.with_walkers({
- "function": _lambda,
- "defun": _lambda,
- "with": function(expr, block) {
- for (var s = current_scope; s; s = s.parent)
- s.uses_with = true;
- },
- "var": function(defs) {
- MAP(defs, function(d){ define(d[0]) });
- },
- "const": function(defs) {
- MAP(defs, function(d){ define(d[0]) });
- },
- "try": function(t, c, f) {
- if (c != null) return [
- this[0],
- MAP(t, walk),
- [ define(c[0]), MAP(c[1], walk) ],
- f != null ? MAP(f, walk) : null
- ];
- },
- "name": function(name) {
- if (name == "eval")
- having_eval.push(current_scope);
- reference(name);
- }
- }, function(){
- return walk(ast);
- });
-
- // the reason why we need an additional pass here is
- // that names can be used prior to their definition.
-
- // scopes where eval was detected and their parents
- // are marked with uses_eval, unless they define the
- // "eval" name.
- MAP(having_eval, function(scope){
- if (!scope.has("eval")) while (scope) {
- scope.uses_eval = true;
- scope = scope.parent;
- }
- });
-
- // for referenced names it might be useful to know
- // their origin scope. current_scope here is the
- // toplevel one.
- function fixrefs(scope, i) {
- // do children first; order shouldn't matter
- for (i = scope.children.length; --i >= 0;)
- fixrefs(scope.children[i]);
- for (i in scope.refs) if (HOP(scope.refs, i)) {
- // find origin scope and propagate the reference to origin
- for (var origin = scope.has(i), s = scope; s; s = s.parent) {
- s.refs[i] = origin;
- if (s === origin) break;
- }
- }
- };
- fixrefs(current_scope);
-
- return ret;
- });
-
-};
-
-/* -----[ mangle names ]----- */
-
-function ast_mangle(ast, options) {
- var w = ast_walker(), walk = w.walk, scope;
- options = options || {};
-
- function get_mangled(name, newMangle) {
- if (!options.toplevel && !scope.parent) return name; // don't mangle toplevel
- if (options.except && member(name, options.except))
- return name;
- return scope.get_mangled(name, newMangle);
- };
-
- function _lambda(name, args, body) {
- if (name) name = get_mangled(name);
- body = with_scope(body.scope, function(){
- args = MAP(args, function(name){ return get_mangled(name) });
- return MAP(body, walk);
- });
- return [ this[0], name, args, body ];
- };
-
- function with_scope(s, cont) {
- var _scope = scope;
- scope = s;
- for (var i in s.names) if (HOP(s.names, i)) {
- get_mangled(i, true);
- }
- var ret = cont();
- ret.scope = s;
- scope = _scope;
- return ret;
- };
-
- function _vardefs(defs) {
- return [ this[0], MAP(defs, function(d){
- return [ get_mangled(d[0]), walk(d[1]) ];
- }) ];
- };
-
- return w.with_walkers({
- "function": _lambda,
- "defun": function() {
- // move function declarations to the top when
- // they are not in some block.
- var ast = _lambda.apply(this, arguments);
- switch (w.parent()[0]) {
- case "toplevel":
- case "function":
- case "defun":
- return MAP.at_top(ast);
- }
- return ast;
- },
- "var": _vardefs,
- "const": _vardefs,
- "name": function(name) {
- return [ this[0], get_mangled(name) ];
- },
- "try": function(t, c, f) {
- return [ this[0],
- MAP(t, walk),
- c != null ? [ get_mangled(c[0]), MAP(c[1], walk) ] : null,
- f != null ? MAP(f, walk) : null ];
- },
- "toplevel": function(body) {
- var self = this;
- return with_scope(self.scope, function(){
- return [ self[0], MAP(body, walk) ];
- });
- }
- }, function() {
- return walk(ast_add_scope(ast));
- });
-};
-
-/* -----[
- - compress foo["bar"] into foo.bar,
- - remove block brackets {} where possible
- - join consecutive var declarations
- - various optimizations for IFs:
- - if (cond) foo(); else bar(); ==> cond?foo():bar();
- - if (cond) foo(); ==> cond&&foo();
- - if (foo) return bar(); else return baz(); ==> return foo?bar():baz(); // also for throw
- - if (foo) return bar(); else something(); ==> {if(foo)return bar();something()}
- ]----- */
-
-var warn = function(){};
-
-function best_of(ast1, ast2) {
- return gen_code(ast1).length > gen_code(ast2[0] == "stat" ? ast2[1] : ast2).length ? ast2 : ast1;
-};
-
-function last_stat(b) {
- if (b[0] == "block" && b[1] && b[1].length > 0)
- return b[1][b[1].length - 1];
- return b;
-}
-
-function aborts(t) {
- if (t) {
- t = last_stat(t);
- if (t[0] == "return" || t[0] == "break" || t[0] == "continue" || t[0] == "throw")
- return true;
- }
-};
-
-function boolean_expr(expr) {
- return ( (expr[0] == "unary-prefix"
- && member(expr[1], [ "!", "delete" ])) ||
-
- (expr[0] == "binary"
- && member(expr[1], [ "in", "instanceof", "==", "!=", "===", "!==", "<", "<=", ">=", ">" ])) ||
-
- (expr[0] == "binary"
- && member(expr[1], [ "&&", "||" ])
- && boolean_expr(expr[2])
- && boolean_expr(expr[3])) ||
-
- (expr[0] == "conditional"
- && boolean_expr(expr[2])
- && boolean_expr(expr[3])) ||
-
- (expr[0] == "assign"
- && expr[1] === true
- && boolean_expr(expr[3])) ||
-
- (expr[0] == "seq"
- && boolean_expr(expr[expr.length - 1]))
- );
-};
-
-function make_conditional(c, t, e) {
- if (c[0] == "unary-prefix" && c[1] == "!") {
- return e ? [ "conditional", c[2], e, t ] : [ "binary", "||", c[2], t ];
- } else {
- return e ? [ "conditional", c, t, e ] : [ "binary", "&&", c, t ];
- }
-};
-
-function empty(b) {
- return !b || (b[0] == "block" && (!b[1] || b[1].length == 0));
-};
-
-function is_string(node) {
- return (node[0] == "string" ||
- node[0] == "unary-prefix" && node[1] == "typeof" ||
- node[0] == "binary" && node[1] == "+" &&
- (is_string(node[2]) || is_string(node[3])));
-};
-
-var when_constant = (function(){
-
- var $NOT_CONSTANT = {};
-
- // this can only evaluate constant expressions. If it finds anything
- // not constant, it throws $NOT_CONSTANT.
- function evaluate(expr) {
- switch (expr[0]) {
- case "string":
- case "num":
- return expr[1];
- case "name":
- case "atom":
- switch (expr[1]) {
- case "true": return true;
- case "false": return false;
- }
- break;
- case "unary-prefix":
- switch (expr[1]) {
- case "!": return !evaluate(expr[2]);
- case "typeof": return typeof evaluate(expr[2]);
- case "~": return ~evaluate(expr[2]);
- case "-": return -evaluate(expr[2]);
- case "+": return +evaluate(expr[2]);
- }
- break;
- case "binary":
- var left = expr[2], right = expr[3];
- switch (expr[1]) {
- case "&&" : return evaluate(left) && evaluate(right);
- case "||" : return evaluate(left) || evaluate(right);
- case "|" : return evaluate(left) | evaluate(right);
- case "&" : return evaluate(left) & evaluate(right);
- case "^" : return evaluate(left) ^ evaluate(right);
- case "+" : return evaluate(left) + evaluate(right);
- case "*" : return evaluate(left) * evaluate(right);
- case "/" : return evaluate(left) / evaluate(right);
- case "-" : return evaluate(left) - evaluate(right);
- case "<<" : return evaluate(left) << evaluate(right);
- case ">>" : return evaluate(left) >> evaluate(right);
- case ">>>" : return evaluate(left) >>> evaluate(right);
- case "==" : return evaluate(left) == evaluate(right);
- case "===" : return evaluate(left) === evaluate(right);
- case "!=" : return evaluate(left) != evaluate(right);
- case "!==" : return evaluate(left) !== evaluate(right);
- case "<" : return evaluate(left) < evaluate(right);
- case "<=" : return evaluate(left) <= evaluate(right);
- case ">" : return evaluate(left) > evaluate(right);
- case ">=" : return evaluate(left) >= evaluate(right);
- case "in" : return evaluate(left) in evaluate(right);
- case "instanceof" : return evaluate(left) instanceof evaluate(right);
- }
- }
- throw $NOT_CONSTANT;
- };
-
- return function(expr, yes, no) {
- try {
- var val = evaluate(expr), ast;
- switch (typeof val) {
- case "string": ast = [ "string", val ]; break;
- case "number": ast = [ "num", val ]; break;
- case "boolean": ast = [ "name", String(val) ]; break;
- default: throw new Error("Can't handle constant of type: " + (typeof val));
- }
- return yes.call(expr, ast, val);
- } catch(ex) {
- if (ex === $NOT_CONSTANT) {
- if (expr[0] == "binary"
- && (expr[1] == "===" || expr[1] == "!==")
- && ((is_string(expr[2]) && is_string(expr[3]))
- || (boolean_expr(expr[2]) && boolean_expr(expr[3])))) {
- expr[1] = expr[1].substr(0, 2);
- }
- return no ? no.call(expr, expr) : null;
- }
- else throw ex;
- }
- };
-
-})();
-
-function warn_unreachable(ast) {
- if (!empty(ast))
- warn("Dropping unreachable code: " + gen_code(ast, true));
-};
-
-function ast_squeeze(ast, options) {
- options = defaults(options, {
- make_seqs : true,
- dead_code : true,
- keep_comps : true,
- no_warnings : false
- });
-
- var w = ast_walker(), walk = w.walk, scope;
-
- function negate(c) {
- var not_c = [ "unary-prefix", "!", c ];
- switch (c[0]) {
- case "unary-prefix":
- return c[1] == "!" && boolean_expr(c[2]) ? c[2] : not_c;
- case "seq":
- c = slice(c);
- c[c.length - 1] = negate(c[c.length - 1]);
- return c;
- case "conditional":
- return best_of(not_c, [ "conditional", c[1], negate(c[2]), negate(c[3]) ]);
- case "binary":
- var op = c[1], left = c[2], right = c[3];
- if (!options.keep_comps) switch (op) {
- case "<=" : return [ "binary", ">", left, right ];
- case "<" : return [ "binary", ">=", left, right ];
- case ">=" : return [ "binary", "<", left, right ];
- case ">" : return [ "binary", "<=", left, right ];
- }
- switch (op) {
- case "==" : return [ "binary", "!=", left, right ];
- case "!=" : return [ "binary", "==", left, right ];
- case "===" : return [ "binary", "!==", left, right ];
- case "!==" : return [ "binary", "===", left, right ];
- case "&&" : return best_of(not_c, [ "binary", "||", negate(left), negate(right) ]);
- case "||" : return best_of(not_c, [ "binary", "&&", negate(left), negate(right) ]);
- }
- break;
- }
- return not_c;
- };
-
- function with_scope(s, cont) {
- var _scope = scope;
- scope = s;
- var ret = cont();
- ret.scope = s;
- scope = _scope;
- return ret;
- };
-
- function rmblock(block) {
- if (block != null && block[0] == "block" && block[1]) {
- if (block[1].length == 1)
- block = block[1][0];
- else if (block[1].length == 0)
- block = [ "block" ];
- }
- return block;
- };
-
- function _lambda(name, args, body) {
- return [ this[0], name, args, with_scope(body.scope, function(){
- return tighten(MAP(body, walk), "lambda");
- }) ];
- };
-
- // we get here for blocks that have been already transformed.
- // this function does a few things:
- // 1. discard useless blocks
- // 2. join consecutive var declarations
- // 3. remove obviously dead code
- // 4. transform consecutive statements using the comma operator
- // 5. if block_type == "lambda" and it detects constructs like if(foo) return ... - rewrite like if (!foo) { ... }
- function tighten(statements, block_type) {
- statements = statements.reduce(function(a, stat){
- if (stat[0] == "block") {
- if (stat[1]) {
- a.push.apply(a, stat[1]);
- }
- } else {
- a.push(stat);
- }
- return a;
- }, []);
-
- statements = (function(a, prev){
- statements.forEach(function(cur){
- if (prev && ((cur[0] == "var" && prev[0] == "var") ||
- (cur[0] == "const" && prev[0] == "const"))) {
- prev[1] = prev[1].concat(cur[1]);
- } else {
- a.push(cur);
- prev = cur;
- }
- });
- return a;
- })([]);
-
- if (options.dead_code) statements = (function(a, has_quit){
- statements.forEach(function(st){
- if (has_quit) {
- if (member(st[0], [ "function", "defun" , "var", "const" ])) {
- a.push(st);
- }
- else if (!options.no_warnings)
- warn_unreachable(st);
- }
- else {
- a.push(st);
- if (member(st[0], [ "return", "throw", "break", "continue" ]))
- has_quit = true;
- }
- });
- return a;
- })([]);
-
- if (options.make_seqs) statements = (function(a, prev) {
- statements.forEach(function(cur){
- if (prev && prev[0] == "stat" && cur[0] == "stat") {
- prev[1] = [ "seq", prev[1], cur[1] ];
- } else {
- a.push(cur);
- prev = cur;
- }
- });
- return a;
- })([]);
-
- if (block_type == "lambda") statements = (function(i, a, stat){
- while (i < statements.length) {
- stat = statements[i++];
- if (stat[0] == "if" && !stat[3]) {
- if (stat[2][0] == "return" && stat[2][1] == null) {
- a.push(make_if(negate(stat[1]), [ "block", statements.slice(i) ]));
- break;
- }
- var last = last_stat(stat[2]);
- if (last[0] == "return" && last[1] == null) {
- a.push(make_if(stat[1], [ "block", stat[2][1].slice(0, -1) ], [ "block", statements.slice(i) ]));
- break;
- }
- }
- a.push(stat);
- }
- return a;
- })(0, []);
-
- return statements;
- };
-
- function make_if(c, t, e) {
- return when_constant(c, function(ast, val){
- if (val) {
- warn_unreachable(e);
- return t;
- } else {
- warn_unreachable(t);
- return e;
- }
- }, function() {
- return make_real_if(c, t, e);
- });
- };
-
- function make_real_if(c, t, e) {
- c = walk(c);
- t = walk(t);
- e = walk(e);
-
- if (empty(t)) {
- c = negate(c);
- t = e;
- e = null;
- } else if (empty(e)) {
- e = null;
- } else {
- // if we have both else and then, maybe it makes sense to switch them?
- (function(){
- var a = gen_code(c);
- var n = negate(c);
- var b = gen_code(n);
- if (b.length < a.length) {
- var tmp = t;
- t = e;
- e = tmp;
- c = n;
- }
- })();
- }
- if (empty(e) && empty(t))
- return [ "stat", c ];
- var ret = [ "if", c, t, e ];
- if (t[0] == "if" && empty(t[3]) && empty(e)) {
- ret = best_of(ret, walk([ "if", [ "binary", "&&", c, t[1] ], t[2] ]));
- }
- else if (t[0] == "stat") {
- if (e) {
- if (e[0] == "stat") {
- ret = best_of(ret, [ "stat", make_conditional(c, t[1], e[1]) ]);
- }
- }
- else {
- ret = best_of(ret, [ "stat", make_conditional(c, t[1]) ]);
- }
- }
- else if (e && t[0] == e[0] && (t[0] == "return" || t[0] == "throw") && t[1] && e[1]) {
- ret = best_of(ret, [ t[0], make_conditional(c, t[1], e[1] ) ]);
- }
- else if (e && aborts(t)) {
- ret = [ [ "if", c, t ] ];
- if (e[0] == "block") {
- if (e[1]) ret = ret.concat(e[1]);
- }
- else {
- ret.push(e);
- }
- ret = walk([ "block", ret ]);
- }
- else if (t && aborts(e)) {
- ret = [ [ "if", negate(c), e ] ];
- if (t[0] == "block") {
- if (t[1]) ret = ret.concat(t[1]);
- } else {
- ret.push(t);
- }
- ret = walk([ "block", ret ]);
- }
- return ret;
- };
-
- function _do_while(cond, body) {
- return when_constant(cond, function(cond, val){
- if (!val) {
- warn_unreachable(body);
- return [ "block" ];
- } else {
- return [ "for", null, null, null, walk(body) ];
- }
- });
- };
-
- return w.with_walkers({
- "sub": function(expr, subscript) {
- if (subscript[0] == "string") {
- var name = subscript[1];
- if (is_identifier(name)) {
- return [ "dot", walk(expr), name ];
- }
- }
- },
- "if": make_if,
- "toplevel": function(body) {
- return [ "toplevel", with_scope(this.scope, function(){
- return tighten(MAP(body, walk));
- }) ];
- },
- "switch": function(expr, body) {
- var last = body.length - 1;
- return [ "switch", walk(expr), MAP(body, function(branch, i){
- var block = tighten(MAP(branch[1], walk));
- if (i == last && block.length > 0) {
- var node = block[block.length - 1];
- if (node[0] == "break" && !node[1])
- block.pop();
- }
- return [ branch[0] ? walk(branch[0]) : null, block ];
- }) ];
- },
- "function": function() {
- var ret = _lambda.apply(this, arguments);
- if (ret[1] && !HOP(scope.refs, ret[1])) {
- ret[1] = null;
- }
- return ret;
- },
- "defun": _lambda,
- "block": function(body) {
- if (body) return rmblock([ "block", tighten(MAP(body, walk)) ]);
- },
- "binary": function(op, left, right) {
- return when_constant([ "binary", op, walk(left), walk(right) ], function yes(c){
- return best_of(walk(c), this);
- }, function no() {
- return this;
- });
- },
- "conditional": function(c, t, e) {
- return make_conditional(walk(c), walk(t), walk(e));
- },
- "try": function(t, c, f) {
- return [
- "try",
- tighten(MAP(t, walk)),
- c != null ? [ c[0], tighten(MAP(c[1], walk)) ] : null,
- f != null ? tighten(MAP(f, walk)) : null
- ];
- },
- "unary-prefix": function(op, expr) {
- expr = walk(expr);
- var ret = [ "unary-prefix", op, expr ];
- if (op == "!")
- ret = best_of(ret, negate(expr));
- return when_constant(ret, function(ast, val){
- return walk(ast); // it's either true or false, so minifies to !0 or !1
- }, function() { return ret });
- },
- "name": function(name) {
- switch (name) {
- case "true": return [ "unary-prefix", "!", [ "num", 0 ]];
- case "false": return [ "unary-prefix", "!", [ "num", 1 ]];
- }
- },
- "new": function(ctor, args) {
- if (ctor[0] == "name" && ctor[1] == "Array" && !scope.has("Array")) {
- if (args.length != 1) {
- return [ "array", args ];
- } else {
- return [ "call", [ "name", "Array" ], args ];
- }
- }
- },
- "call": function(expr, args) {
- if (expr[0] == "name" && expr[1] == "Array" && args.length != 1 && !scope.has("Array")) {
- return [ "array", args ];
- }
- },
- "while": _do_while,
- "do": _do_while
- }, function() {
- return walk(ast_add_scope(ast));
- });
-};
-
-/* -----[ re-generate code from the AST ]----- */
-
-var DOT_CALL_NO_PARENS = jsp.array_to_hash([
- "name",
- "array",
- "string",
- "dot",
- "sub",
- "call",
- "regexp"
-]);
-
-function make_string(str, ascii_only) {
- var dq = 0, sq = 0;
- str = str.replace(/[\\\b\f\n\r\t\x22\x27]/g, function(s){
- switch (s) {
- case "\\": return "\\\\";
- case "\b": return "\\b";
- case "\f": return "\\f";
- case "\n": return "\\n";
- case "\r": return "\\r";
- case "\t": return "\\t";
- case '"': ++dq; return '"';
- case "'": ++sq; return "'";
- }
- return s;
- });
- if (ascii_only) str = to_ascii(str);
- if (dq > sq) return "'" + str.replace(/\x27/g, "\\'") + "'";
- else return '"' + str.replace(/\x22/g, '\\"') + '"';
-};
-
-function to_ascii(str) {
- return str.replace(/[\u0080-\uffff]/g, function(ch) {
- var code = ch.charCodeAt(0).toString(16);
- while (code.length < 4) code = "0" + code;
- return "\\u" + code;
- });
-};
-
-function gen_code(ast, options) {
- options = defaults(options, {
- indent_start : 0,
- indent_level : 4,
- quote_keys : false,
- space_colon : false,
- beautify : false,
- ascii_only : false
- });
- var beautify = !!options.beautify;
- var indentation = 0,
- newline = beautify ? "\n" : "",
- space = beautify ? " " : "";
-
- function encode_string(str) {
- return make_string(str, options.ascii_only);
- };
-
- function make_name(name) {
- name = name.toString();
- if (options.ascii_only)
- name = to_ascii(name);
- return name;
- };
-
- function indent(line) {
- if (line == null)
- line = "";
- if (beautify)
- line = repeat_string(" ", options.indent_start + indentation * options.indent_level) + line;
- return line;
- };
-
- function with_indent(cont, incr) {
- if (incr == null) incr = 1;
- indentation += incr;
- try { return cont.apply(null, slice(arguments, 1)); }
- finally { indentation -= incr; }
- };
-
- function add_spaces(a) {
- if (beautify)
- return a.join(" ");
- var b = [];
- for (var i = 0; i < a.length; ++i) {
- var next = a[i + 1];
- b.push(a[i]);
- if (next &&
- ((/[a-z0-9_\x24]$/i.test(a[i].toString()) && /^[a-z0-9_\x24]/i.test(next.toString())) ||
- (/[\+\-]$/.test(a[i].toString()) && /^[\+\-]/.test(next.toString())))) {
- b.push(" ");
- }
- }
- return b.join("");
- };
-
- function add_commas(a) {
- return a.join("," + space);
- };
-
- function parenthesize(expr) {
- var gen = make(expr);
- for (var i = 1; i < arguments.length; ++i) {
- var el = arguments[i];
- if ((el instanceof Function && el(expr)) || expr[0] == el)
- return "(" + gen + ")";
- }
- return gen;
- };
-
- function best_of(a) {
- if (a.length == 1) {
- return a[0];
- }
- if (a.length == 2) {
- var b = a[1];
- a = a[0];
- return a.length <= b.length ? a : b;
- }
- return best_of([ a[0], best_of(a.slice(1)) ]);
- };
-
- function needs_parens(expr) {
- if (expr[0] == "function") {
- // dot/call on a literal function requires the
- // function literal itself to be parenthesized
- // only if it's the first "thing" in a
- // statement. This means that the parent is
- // "stat", but it could also be a "seq" and
- // we're the first in this "seq" and the
- // parent is "stat", and so on. Messy stuff,
- // but it worths the trouble.
- var a = slice($stack), self = a.pop(), p = a.pop();
- while (p) {
- if (p[0] == "stat") return true;
- if ((p[0] == "seq" && p[1] === self) ||
- (p[0] == "call" && p[1] === self) ||
- (p[0] == "binary" && p[2] === self)) {
- self = p;
- p = a.pop();
- } else {
- return false;
- }
- }
- }
- return !HOP(DOT_CALL_NO_PARENS, expr[0]);
- };
-
- function make_num(num) {
- var str = num.toString(10), a = [ str.replace(/^0\./, ".") ], m;
- if (Math.floor(num) === num) {
- a.push("0x" + num.toString(16).toLowerCase(), // probably pointless
- "0" + num.toString(8)); // same.
- if ((m = /^(.*?)(0+)$/.exec(num))) {
- a.push(m[1] + "e" + m[2].length);
- }
- } else if ((m = /^0?\.(0+)(.*)$/.exec(num))) {
- a.push(m[2] + "e-" + (m[1].length + m[2].length),
- str.substr(str.indexOf(".")));
- }
- return best_of(a);
- };
-
- var generators = {
- "string": encode_string,
- "num": make_num,
- "name": make_name,
- "toplevel": function(statements) {
- return make_block_statements(statements)
- .join(newline + newline);
- },
- "block": make_block,
- "var": function(defs) {
- return "var " + add_commas(MAP(defs, make_1vardef)) + ";";
- },
- "const": function(defs) {
- return "const " + add_commas(MAP(defs, make_1vardef)) + ";";
- },
- "try": function(tr, ca, fi) {
- var out = [ "try", make_block(tr) ];
- if (ca) out.push("catch", "(" + ca[0] + ")", make_block(ca[1]));
- if (fi) out.push("finally", make_block(fi));
- return add_spaces(out);
- },
- "throw": function(expr) {
- return add_spaces([ "throw", make(expr) ]) + ";";
- },
- "new": function(ctor, args) {
- args = args.length > 0 ? "(" + add_commas(MAP(args, make)) + ")" : "";
- return add_spaces([ "new", parenthesize(ctor, "seq", "binary", "conditional", "assign", function(expr){
- var w = ast_walker(), has_call = {};
- try {
- w.with_walkers({
- "call": function() { throw has_call },
- "function": function() { return this }
- }, function(){
- w.walk(expr);
- });
- } catch(ex) {
- if (ex === has_call)
- return true;
- throw ex;
- }
- }) + args ]);
- },
- "switch": function(expr, body) {
- return add_spaces([ "switch", "(" + make(expr) + ")", make_switch_block(body) ]);
- },
- "break": function(label) {
- var out = "break";
- if (label != null)
- out += " " + make_name(label);
- return out + ";";
- },
- "continue": function(label) {
- var out = "continue";
- if (label != null)
- out += " " + make_name(label);
- return out + ";";
- },
- "conditional": function(co, th, el) {
- return add_spaces([ parenthesize(co, "assign", "seq", "conditional"), "?",
- parenthesize(th, "seq"), ":",
- parenthesize(el, "seq") ]);
- },
- "assign": function(op, lvalue, rvalue) {
- if (op && op !== true) op += "=";
- else op = "=";
- return add_spaces([ make(lvalue), op, parenthesize(rvalue, "seq") ]);
- },
- "dot": function(expr) {
- var out = make(expr), i = 1;
- if (expr[0] == "num")
- out += ".";
- else if (needs_parens(expr))
- out = "(" + out + ")";
- while (i < arguments.length)
- out += "." + make_name(arguments[i++]);
- return out;
- },
- "call": function(func, args) {
- var f = make(func);
- if (needs_parens(func))
- f = "(" + f + ")";
- return f + "(" + add_commas(MAP(args, function(expr){
- return parenthesize(expr, "seq");
- })) + ")";
- },
- "function": make_function,
- "defun": make_function,
- "if": function(co, th, el) {
- var out = [ "if", "(" + make(co) + ")", el ? make_then(th) : make(th) ];
- if (el) {
- out.push("else", make(el));
- }
- return add_spaces(out);
- },
- "for": function(init, cond, step, block) {
- var out = [ "for" ];
- init = (init != null ? make(init) : "").replace(/;*\s*$/, ";" + space);
- cond = (cond != null ? make(cond) : "").replace(/;*\s*$/, ";" + space);
- step = (step != null ? make(step) : "").replace(/;*\s*$/, "");
- var args = init + cond + step;
- if (args == "; ; ") args = ";;";
- out.push("(" + args + ")", make(block));
- return add_spaces(out);
- },
- "for-in": function(vvar, key, hash, block) {
- return add_spaces([ "for", "(" +
- (vvar ? make(vvar).replace(/;+$/, "") : make(key)),
- "in",
- make(hash) + ")", make(block) ]);
- },
- "while": function(condition, block) {
- return add_spaces([ "while", "(" + make(condition) + ")", make(block) ]);
- },
- "do": function(condition, block) {
- return add_spaces([ "do", make(block), "while", "(" + make(condition) + ")" ]) + ";";
- },
- "return": function(expr) {
- var out = [ "return" ];
- if (expr != null) out.push(make(expr));
- return add_spaces(out) + ";";
- },
- "binary": function(operator, lvalue, rvalue) {
- var left = make(lvalue), right = make(rvalue);
- // XXX: I'm pretty sure other cases will bite here.
- // we need to be smarter.
- // adding parens all the time is the safest bet.
- if (member(lvalue[0], [ "assign", "conditional", "seq" ]) ||
- lvalue[0] == "binary" && PRECEDENCE[operator] > PRECEDENCE[lvalue[1]]) {
- left = "(" + left + ")";
- }
- if (member(rvalue[0], [ "assign", "conditional", "seq" ]) ||
- rvalue[0] == "binary" && PRECEDENCE[operator] >= PRECEDENCE[rvalue[1]] &&
- !(rvalue[1] == operator && member(operator, [ "&&", "||", "*" ]))) {
- right = "(" + right + ")";
- }
- return add_spaces([ left, operator, right ]);
- },
- "unary-prefix": function(operator, expr) {
- var val = make(expr);
- if (!(expr[0] == "num" || (expr[0] == "unary-prefix" && !HOP(OPERATORS, operator + expr[1])) || !needs_parens(expr)))
- val = "(" + val + ")";
- return operator + (jsp.is_alphanumeric_char(operator.charAt(0)) ? " " : "") + val;
- },
- "unary-postfix": function(operator, expr) {
- var val = make(expr);
- if (!(expr[0] == "num" || (expr[0] == "unary-postfix" && !HOP(OPERATORS, operator + expr[1])) || !needs_parens(expr)))
- val = "(" + val + ")";
- return val + operator;
- },
- "sub": function(expr, subscript) {
- var hash = make(expr);
- if (needs_parens(expr))
- hash = "(" + hash + ")";
- return hash + "[" + make(subscript) + "]";
- },
- "object": function(props) {
- if (props.length == 0)
- return "{}";
- return "{" + newline + with_indent(function(){
- return MAP(props, function(p){
- if (p.length == 3) {
- // getter/setter. The name is in p[0], the arg.list in p[1][2], the
- // body in p[1][3] and type ("get" / "set") in p[2].
- return indent(make_function(p[0], p[1][2], p[1][3], p[2]));
- }
- var key = p[0], val = make(p[1]);
- if (options.quote_keys) {
- key = encode_string(key);
- } else if ((typeof key == "number" || !beautify && +key + "" == key)
- && parseFloat(key) >= 0) {
- key = make_num(+key);
- } else if (!is_identifier(key)) {
- key = encode_string(key);
- }
- return indent(add_spaces(beautify && options.space_colon
- ? [ key, ":", val ]
- : [ key + ":", val ]));
- }).join("," + newline);
- }) + newline + indent("}");
- },
- "regexp": function(rx, mods) {
- return "/" + rx + "/" + mods;
- },
- "array": function(elements) {
- if (elements.length == 0) return "[]";
- return add_spaces([ "[", add_commas(MAP(elements, function(el){
- if (!beautify && el[0] == "atom" && el[1] == "undefined") return "";
- return parenthesize(el, "seq");
- })), "]" ]);
- },
- "stat": function(stmt) {
- return make(stmt).replace(/;*\s*$/, ";");
- },
- "seq": function() {
- return add_commas(MAP(slice(arguments), make));
- },
- "label": function(name, block) {
- return add_spaces([ make_name(name), ":", make(block) ]);
- },
- "with": function(expr, block) {
- return add_spaces([ "with", "(" + make(expr) + ")", make(block) ]);
- },
- "atom": function(name) {
- return make_name(name);
- }
- };
-
- // The squeezer replaces "block"-s that contain only a single
- // statement with the statement itself; technically, the AST
- // is correct, but this can create problems when we output an
- // IF having an ELSE clause where the THEN clause ends in an
- // IF *without* an ELSE block (then the outer ELSE would refer
- // to the inner IF). This function checks for this case and
- // adds the block brackets if needed.
- function make_then(th) {
- if (th[0] == "do") {
- // https://github.com/mishoo/UglifyJS/issues/#issue/57
- // IE croaks with "syntax error" on code like this:
- // if (foo) do ... while(cond); else ...
- // we need block brackets around do/while
- return make([ "block", [ th ]]);
- }
- var b = th;
- while (true) {
- var type = b[0];
- if (type == "if") {
- if (!b[3])
- // no else, we must add the block
- return make([ "block", [ th ]]);
- b = b[3];
- }
- else if (type == "while" || type == "do") b = b[2];
- else if (type == "for" || type == "for-in") b = b[4];
- else break;
- }
- return make(th);
- };
-
- function make_function(name, args, body, keyword) {
- var out = keyword || "function";
- if (name) {
- out += " " + make_name(name);
- }
- out += "(" + add_commas(MAP(args, make_name)) + ")";
- return add_spaces([ out, make_block(body) ]);
- };
-
- function make_block_statements(statements) {
- for (var a = [], last = statements.length - 1, i = 0; i <= last; ++i) {
- var stat = statements[i];
- var code = make(stat);
- if (code != ";") {
- if (!beautify && i == last) {
- if ((stat[0] == "while" && empty(stat[2])) ||
- (member(stat[0], [ "for", "for-in"] ) && empty(stat[4])) ||
- (stat[0] == "if" && empty(stat[2]) && !stat[3]) ||
- (stat[0] == "if" && stat[3] && empty(stat[3]))) {
- code = code.replace(/;*\s*$/, ";");
- } else {
- code = code.replace(/;+\s*$/, "");
- }
- }
- a.push(code);
- }
- }
- return MAP(a, indent);
- };
-
- function make_switch_block(body) {
- var n = body.length;
- if (n == 0) return "{}";
- return "{" + newline + MAP(body, function(branch, i){
- var has_body = branch[1].length > 0, code = with_indent(function(){
- return indent(branch[0]
- ? add_spaces([ "case", make(branch[0]) + ":" ])
- : "default:");
- }, 0.5) + (has_body ? newline + with_indent(function(){
- return make_block_statements(branch[1]).join(newline);
- }) : "");
- if (!beautify && has_body && i < n - 1)
- code += ";";
- return code;
- }).join(newline) + newline + indent("}");
- };
-
- function make_block(statements) {
- if (!statements) return ";";
- if (statements.length == 0) return "{}";
- return "{" + newline + with_indent(function(){
- return make_block_statements(statements).join(newline);
- }) + newline + indent("}");
- };
-
- function make_1vardef(def) {
- var name = def[0], val = def[1];
- if (val != null)
- name = add_spaces([ make_name(name), "=", make(val) ]);
- return name;
- };
-
- var $stack = [];
-
- function make(node) {
- var type = node[0];
- var gen = generators[type];
- if (!gen)
- throw new Error("Can't find generator for \"" + type + "\"");
- $stack.push(node);
- var ret = gen.apply(type, node.slice(1));
- $stack.pop();
- return ret;
- };
-
- return make(ast);
-};
-
-function split_lines(code, max_line_length) {
- var splits = [ 0 ];
- jsp.parse(function(){
- var next_token = jsp.tokenizer(code);
- var last_split = 0;
- var prev_token;
- function current_length(tok) {
- return tok.pos - last_split;
- };
- function split_here(tok) {
- last_split = tok.pos;
- splits.push(last_split);
- };
- function custom(){
- var tok = next_token.apply(this, arguments);
- out: {
- if (prev_token) {
- if (prev_token.type == "keyword") break out;
- }
- if (current_length(tok) > max_line_length) {
- switch (tok.type) {
- case "keyword":
- case "atom":
- case "name":
- case "punc":
- split_here(tok);
- break out;
- }
- }
- }
- prev_token = tok;
- return tok;
- };
- custom.context = function() {
- return next_token.context.apply(this, arguments);
- };
- return custom;
- }());
- return splits.map(function(pos, i){
- return code.substring(pos, splits[i + 1] || code.length);
- }).join("\n");
-};
-
-/* -----[ Utilities ]----- */
-
-function repeat_string(str, i) {
- if (i <= 0) return "";
- if (i == 1) return str;
- var d = repeat_string(str, i >> 1);
- d += d;
- if (i & 1) d += str;
- return d;
-};
-
-function defaults(args, defs) {
- var ret = {};
- if (args === true)
- args = {};
- for (var i in defs) if (HOP(defs, i)) {
- ret[i] = (args && HOP(args, i)) ? args[i] : defs[i];
- }
- return ret;
-};
-
-function is_identifier(name) {
- return /^[a-z_$][a-z0-9_$]*$/i.test(name)
- && name != "this"
- && !HOP(jsp.KEYWORDS_ATOM, name)
- && !HOP(jsp.RESERVED_WORDS, name)
- && !HOP(jsp.KEYWORDS, name);
-};
-
-function HOP(obj, prop) {
- return Object.prototype.hasOwnProperty.call(obj, prop);
-};
-
-// some utilities
-
-var MAP;
-
-(function(){
- MAP = function(a, f, o) {
- var ret = [];
- for (var i = 0; i < a.length; ++i) {
- var val = f.call(o, a[i], i);
- if (val instanceof AtTop) ret.unshift(val.v);
- else ret.push(val);
- }
- return ret;
- };
- MAP.at_top = function(val) { return new AtTop(val) };
- function AtTop(val) { this.v = val };
-})();
-
-/* -----[ Exports ]----- */
-
-exports.ast_walker = ast_walker;
-exports.ast_mangle = ast_mangle;
-exports.ast_squeeze = ast_squeeze;
-exports.gen_code = gen_code;
-exports.ast_add_scope = ast_add_scope;
-exports.ast_squeeze_more = require("./squeeze-more").ast_squeeze_more;
-exports.set_logger = function(logger) { warn = logger };
-exports.make_string = make_string;
-exports.split_lines = split_lines;
\ No newline at end of file
diff --git a/build/lib/squeeze-more.js b/build/lib/squeeze-more.js
deleted file mode 100644
index 12380af..0000000
--- a/build/lib/squeeze-more.js
+++ /dev/null
@@ -1,22 +0,0 @@
-var jsp = require("./parse-js"),
- pro = require("./process"),
- slice = jsp.slice,
- member = jsp.member,
- PRECEDENCE = jsp.PRECEDENCE,
- OPERATORS = jsp.OPERATORS;
-
-function ast_squeeze_more(ast) {
- var w = pro.ast_walker(), walk = w.walk;
- return w.with_walkers({
- "call": function(expr, args) {
- if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) {
- // foo.toString() ==> foo+""
- return [ "binary", "+", expr[1], [ "string", "" ]];
- }
- }
- }, function() {
- return walk(ast);
- });
-};
-
-exports.ast_squeeze_more = ast_squeeze_more;
diff --git a/build/proton.js b/build/proton.js
index e759c9b..e718cef 100644
--- a/build/proton.js
+++ b/build/proton.js
@@ -1,4978 +1,5618 @@
-/*!
- * Proton v2.2.1
- * https://github.com/a-jie/Proton
- *
- * Copyright 2011-2017, A-JIE
- * Licensed under the MIT license
- * http://www.opensource.org/licenses/mit-license
- *
- */
-(function (root, factory) {
- if (typeof define === 'function' && define.amd) {
- define([], factory);
- } else if (typeof module !== 'undefined' && module.exports) {
- module.exports = factory();
- } else {
- root.Proton = factory();
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+ typeof define === 'function' && define.amd ? define(factory) :
+ (global.Proton = factory());
+}(this, (function () { 'use strict';
+
+var PI = 3.1415926;
+
+var MathUtils = {
+
+ PI: PI,
+ PIx2: PI * 2,
+ PI_2: PI / 2,
+ PI_180: PI / 180,
+ N180_PI: 180 / PI,
+
+ randomAToB: function randomAToB(a, b, INT) {
+ if (!INT) return a + Math.random() * (b - a);else return Math.floor(Math.random() * (b - a)) + a;
+ },
+ randomFloating: function randomFloating(center, f, INT) {
+ return this.randomAToB(center - f, center + f, INT);
+ },
+ randomZone: function randomZone(display) {},
+ degreeTransform: function degreeTransform(a) {
+ return a * PI / 180;
+ },
+ toColor16: function toColor16(num) {
+ return "#" + num.toString(16);
+ },
+ randomColor: function randomColor() {
+ return '#' + ('00000' + (Math.random() * 0x1000000 << 0).toString(16)).slice(-6);
}
-}(this, function () {
+};
+var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
+ return typeof obj;
+} : function (obj) {
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
+};
- //the max particle number in pool
- Proton.POOL_MAX = 1000;
- Proton.TIME_STEP = 60;
- Proton.USE_CLOCK = false;
-
- //1:100
- Proton.MEASURE = 100;
- Proton.EULER = 'euler';
- Proton.RK2 = 'runge-kutta2';
- Proton.VERLET = 'verlet';
-
- Proton.PARTICLE_CREATED = 'partilcleCreated';
- Proton.PARTICLE_UPDATE = 'partilcleUpdate';
- Proton.PARTICLE_SLEEP = 'particleSleep';
- Proton.PARTICLE_DEAD = 'partilcleDead';
- Proton.PROTON_UPDATE = 'protonUpdate';
- Proton.PROTON_UPDATE_AFTER = 'protonUpdateAfter';
- Proton.EMITTER_ADDED = 'emitterAdded';
- Proton.EMITTER_REMOVED = 'emitterRemoved';
-
- Proton.amendChangeTabsBug = true;
- Proton.TextureBuffer = {};
- Proton.TextureCanvasBuffer = {};
- /**
- * The constructor to add emitters
- *
- * @constructor Proton
- *
- * @todo proParticleCount is not in use
- * @todo add more documentation of the single properties and parameters
- *
- * @param {Number} [proParticleCount] not in use?
- * @param {Number} [integrationType=Proton.EULER]
- *
- * @property {String} [integrationType=Proton.EULER]
- * @property {Array} emitters All added emitter
- * @property {Array} renderers All added renderer
- * @property {Number} time The active time
- * @property {Number} oldtime The old time
- */
- function Proton(proParticleCount, integrationType) {
- this.integrationType = Proton.Util.initValue(integrationType, Proton.EULER);
- this.emitters = [];
- this.renderers = [];
- this.time = 0;
- this.oldTime = 0;
- Proton.pool = new Proton.Pool(100);
- Proton.integrator = new Proton.NumericalIntegration(this.integrationType);
- }
- Proton.prototype = {
- /**
- * add a type of Renderer
- *
- * @method addRender
- * @memberof Proton
- * @instance
- *
- * @param {Renderer} render
- */
- addRender: function(render) {
- render.proton = this;
- this.renderers.push(render.proton);
- },
- /**
- * add the Emitter
- *
- * @method addEmitter
- * @memberof Proton
- * @instance
- *
- * @param {Emitter} emitter
- */
- addEmitter: function(emitter) {
- this.emitters.push(emitter);
- emitter.parent = this;
- this.dispatchEvent(Proton.EMITTER_ADDED, emitter);
- },
- /**
- * Removes an Emitter
- *
- * @method removeEmitter
- * @memberof Proton
- * @instance
- *
- * @param {Proton.Emitter} emitter
- */
- removeEmitter: function(emitter) {
- var index = this.emitters.indexOf(emitter);
- this.emitters.splice(index, 1);
- emitter.parent = null;
- this.dispatchEvent(Proton.EMITTER_REMOVED, emitter);
- },
- /**
- * Updates all added emitters
- *
- * @method update
- * @memberof Proton
- * @instance
- */
- update: function() {
- this.dispatchEvent(Proton.PROTON_UPDATE);
-
- if (Proton.USE_CLOCK) {
- if (!this.oldTime)
- this.oldTime = new Date().getTime();
-
- var time = new Date().getTime();
- this.elapsed = (time - this.oldTime) / 1000;
- if (Proton.amendChangeTabsBug)
- this.amendChangeTabsBug();
- this.oldTime = time;
- } else {
- this.elapsed = 0.0167;
- }
-
- if (this.elapsed > 0) {
- for (var i = 0; i < this.emitters.length; i++) {
- this.emitters[i].update(this.elapsed);
- }
- }
-
- this.dispatchEvent(Proton.PROTON_UPDATE_AFTER);
- },
-
- /**
- * @todo add description
- *
- * @method amendChangeTabsBug
- * @memberof Proton
- * @instance
- */
- amendChangeTabsBug: function() {
- if (this.elapsed > .5) {
- this.oldTime = new Date().getTime();
- this.elapsed = 0;
- }
- },
- /**
- * Counts all particles from all emitters
- *
- * @method getCount
- * @memberof Proton
- * @instance
- */
- getCount: function() {
- var total = 0;
- var length = this.emitters.length;
- for (var i = 0; i < length; i++) {
- total += this.emitters[i].particles.length;
- }
- return total;
- },
-
- /**
- * Destroys everything related to this Proton instance. This includes all emitters, and all properties
- *
- * @method destroy
- * @memberof Proton
- * @instance
- */
- destroy: function() {
- var length = this.emitters.length;
- for (var i = 0; i < length; i++) {
- this.emitters[i].destroy();
- delete this.emitters[i];
- }
-
- this.emitters = [];
- this.time = 0;
- this.oldTime = 0;
- Proton.pool.release();
- }
- };
+var classCallCheck = function (instance, Constructor) {
+ if (!(instance instanceof Constructor)) {
+ throw new TypeError("Cannot call a class as a function");
+ }
+};
-
-
-
-/*
- * EventDispatcher
- * Visit http://createjs.com/ for documentation, updates and examples.
- *
- **/
-
-
- function EventDispatcher() {
- this.initialize();
- };
-
- EventDispatcher.initialize = function(target) {
- target.addEventListener = p.addEventListener;
- target.removeEventListener = p.removeEventListener;
- target.removeAllEventListeners = p.removeAllEventListeners;
- target.hasEventListener = p.hasEventListener;
- target.dispatchEvent = p.dispatchEvent;
- };
-
- var p = EventDispatcher.prototype;
-
- p._listeners = null;
-
- p.initialize = function() {};
- p.addEventListener = function(type, listener) {
- if (!this._listeners) {
- this._listeners = {};
- } else {
- this.removeEventListener(type, listener);
- }
-
- if (!this._listeners[type]) this._listeners[type] = []
- this._listeners[type].push(listener);
-
- return listener;
- };
-
- p.removeEventListener = function(type, listener) {
- if (!this._listeners) return;
- if (!this._listeners[type]) return;
-
- var arr = this._listeners[type];
- for (var i = 0, l = arr.length; i < l; i++) {
- if (arr[i] == listener) {
- if (l == 1) {
- delete(this._listeners[type]);
- }
- // allows for faster checks.
- else {
- arr.splice(i, 1);
- }
- break;
- }
- }
- };
-
- p.removeAllEventListeners = function(type) {
- if (!type)
- this._listeners = null;
- else if (this._listeners)
- delete(this._listeners[type]);
- };
-
- p.dispatchEvent = function(eventName, eventTarget) {
- var ret = false,
- listeners = this._listeners;
-
- if (eventName && listeners) {
- var arr = listeners[eventName];
- if (!arr) return ret;
-
- arr = arr.slice();
- // to avoid issues with items being removed or added during the dispatch
-
- var handler, i = arr.length;
- while (i--) {
- var handler = arr[i];
- ret = ret || handler(eventTarget);
- }
-
- }
+var createClass = function () {
+ function defineProperties(target, props) {
+ for (var i = 0; i < props.length; i++) {
+ var descriptor = props[i];
+ descriptor.enumerable = descriptor.enumerable || false;
+ descriptor.configurable = true;
+ if ("value" in descriptor) descriptor.writable = true;
+ Object.defineProperty(target, descriptor.key, descriptor);
+ }
+ }
- return !!ret;
- };
+ return function (Constructor, protoProps, staticProps) {
+ if (protoProps) defineProperties(Constructor.prototype, protoProps);
+ if (staticProps) defineProperties(Constructor, staticProps);
+ return Constructor;
+ };
+}();
- p.hasEventListener = function(type) {
- var listeners = this._listeners;
- return !!(listeners && listeners[type]);
- };
- EventDispatcher.initialize(Proton.prototype);
- Proton.EventDispatcher = EventDispatcher;
- /**
- * @namespace
- * @memberof! Proton#
- * @alias Proton.Util
- */
- var Util = Util || {
- /**
- * Returns the default if the value is null or undefined
- *
- * @memberof Proton#Proton.Util
- * @method initValue
- *
- * @param {Mixed} value a specific value, could be everything but null or undefined
- * @param {Mixed} defaults the default if the value is null or undefined
- */
- initValue: function(value, defaults) {
- var value = (value != null && value != undefined) ? value : defaults;
- return value;
- },
+var get = function get(object, property, receiver) {
+ if (object === null) object = Function.prototype;
+ var desc = Object.getOwnPropertyDescriptor(object, property);
- /**
- * Checks if the value is a valid array
- *
- * @memberof Proton#Proton.Util
- * @method isArray
- *
- * @param {Array} value Any array
- *
- * @returns {Boolean}
- */
- isArray: function(value) {
- return typeof value === 'object' && value.hasOwnProperty('length');
- },
-
- /**
- * Destroyes the given array
- *
- * @memberof Proton#Proton.Util
- * @method destroyArray
- *
- * @param {Array} array Any array
- */
- destroyArray: function(array) {
- array.length = 0;
- },
-
- /**
- * Destroyes the given object
- *
- * @memberof Proton#Proton.Util
- * @method destroyObject
- *
- * @param {Object} obj Any object
- */
- destroyObject: function(obj) {
- for (var o in obj)
- delete obj[o];
- },
-
- /**
- * Returns the Vector2D - or creates a new one
- *
- * @memberof Proton#Proton.Util
- * @method getVector2D
- *
- * @param {Proton.Vector2D | Number} postionOrX
- * @param {Number} [y] just valid if 'postionOrX' is not an object
- *
- * @return {Proton.Vector2D}
- */
- getVector2D: function(postionOrX, y) {
- if (typeof(postionOrX) == 'object') {
- return postionOrX;
- } else {
- var vector2d = new Proton.Vector2D(postionOrX, y);
- return vector2d;
- }
- },
+ if (desc === undefined) {
+ var parent = Object.getPrototypeOf(object);
- /**
- * Makes an instance of a class and binds the given array
- *
- * @memberof Proton#Proton.Util
- * @method classApply
- *
- * @param {Function} constructor A class to make an instance from
- * @param {Array} [argArray] Any array to bind it to the constructor
- *
- * @return {Object} The instance of constructor, optionally bind with argArray
- */
- classApply: function(constructor, argArray) {
- if (!argArray) return new constructor;
+ if (parent === null) {
+ return undefined;
+ } else {
+ return get(parent, property, receiver);
+ }
+ } else if ("value" in desc) {
+ return desc.value;
+ } else {
+ var getter = desc.get;
- var args = [null].concat(argArray);
- var factoryFunction = constructor.bind.apply(constructor, args);
- return new factoryFunction();
- },
+ if (getter === undefined) {
+ return undefined;
+ }
- /**
- * @memberof Proton#Proton.Util
- * @method judgeVector2D
- *
- * @todo add description for param `pOBJ`
- * @todo add description for function
- *
- * @param {Object} pOBJ
- *
- * @return {String} result
- */
- judgeVector2D: function(pOBJ) {
- var result = '';
- if (pOBJ.hasOwnProperty('x') || pOBJ.hasOwnProperty('y') || pOBJ.hasOwnProperty('p') || pOBJ.hasOwnProperty('position'))
- result += 'p';
- if (pOBJ.hasOwnProperty('vx') || pOBJ.hasOwnProperty('vx') || pOBJ.hasOwnProperty('v') || pOBJ.hasOwnProperty('velocity'))
- result += 'v';
- if (pOBJ.hasOwnProperty('ax') || pOBJ.hasOwnProperty('ax') || pOBJ.hasOwnProperty('a') || pOBJ.hasOwnProperty('accelerate'))
- result += 'a';
+ return getter.call(receiver);
+ }
+};
+
+var inherits = function (subClass, superClass) {
+ if (typeof superClass !== "function" && superClass !== null) {
+ throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
+ }
+
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
+ constructor: {
+ value: subClass,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
+};
- return result;
- },
- /**
- * @memberof Proton#Proton.Util
- * @method setVector2DByObject
- *
- * @todo add description for param `target`
- * @todo add description for param `pOBJ`
- * @todo add description for function
- *
- * @param {Object} target
- * @param {Object} pOBJ
- */
- setVector2DByObject: function(target, pOBJ) {
- if (pOBJ.hasOwnProperty('x'))
- target.p.x = pOBJ['x'];
- if (pOBJ.hasOwnProperty('y'))
- target.p.y = pOBJ['y'];
- if (pOBJ.hasOwnProperty('vx'))
- target.v.x = pOBJ['vx'];
- if (pOBJ.hasOwnProperty('vy'))
- target.v.y = pOBJ['vy'];
- if (pOBJ.hasOwnProperty('ax'))
- target.a.x = pOBJ['ax'];
- if (pOBJ.hasOwnProperty('ay'))
- target.a.y = pOBJ['ay'];
- if (pOBJ.hasOwnProperty('p'))
- particle.p.copy(pOBJ['p']);
- if (pOBJ.hasOwnProperty('v'))
- particle.v.copy(pOBJ['v']);
- if (pOBJ.hasOwnProperty('a'))
- particle.a.copy(pOBJ['a']);
- if (pOBJ.hasOwnProperty('position'))
- particle.p.copy(pOBJ['position']);
+var possibleConstructorReturn = function (self, call) {
+ if (!self) {
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
+ }
- if (pOBJ.hasOwnProperty('velocity'))
- particle.v.copy(pOBJ['velocity']);
+ return call && (typeof call === "object" || typeof call === "function") ? call : self;
+};
- if (pOBJ.hasOwnProperty('accelerate'))
- particle.a.copy(pOBJ['accelerate']);
- },
+var Vector2D = function () {
+ function Vector2D(x, y) {
+ classCallCheck(this, Vector2D);
- /**
- * 强行添加属性
- *
- * @memberof Proton#Proton.Util
- * @method addPrototypeByObject
- *
- * @todo add description for param `target`
- * @todo add description for param `filters`
- * @todo translate desription from chinese to english
- *
- * @param {Object} target
- * @param {Object} prototypeObject An object of single prototypes
- * @param {Object} filters
- *
- * @return {Object} target
- */
- addPrototypeByObject: function(target, prototypeObject, filters) {
- for (var singlePrototype in prototypeObject) {
- if (filters) {
- if (filters.indexOf(singlePrototype) < 0)
- target[singlePrototype] = Proton.Util.getSpanValue(prototypeObject[singlePrototype]);
- } else {
- target[singlePrototype] = Proton.Util.getSpanValue(prototypeObject[singlePrototype]);
- }
- }
+ this.x = x || 0;
+ this.y = y || 0;
+ }
- return target;
- },
+ createClass(Vector2D, [{
+ key: 'set',
+ value: function set$$1(x, y) {
+ this.x = x;
+ this.y = y;
+ return this;
+ }
+ }, {
+ key: 'setX',
+ value: function setX(x) {
+ this.x = x;
+ return this;
+ }
+ }, {
+ key: 'setY',
+ value: function setY(y) {
+ this.y = y;
+ return this;
+ }
+ }, {
+ key: 'getGradient',
+ value: function getGradient() {
+ if (this.x != 0) return Math.atan2(this.y, this.x);else if (this.y > 0) return MathUtils.PI_2;else if (this.y < 0) return -MathUtils.PI_2;
+ }
+ }, {
+ key: 'copy',
+ value: function copy(v) {
+ this.x = v.x;
+ this.y = v.y;
- /**
- * set the prototype in a given prototypeObject
- *
- * @memberof Proton#Proton.Util
- * @method setPrototypeByObject
- *
- * @todo add description for param `target`
- * @todo add description for param `filters`
- * @todo translate desription from chinese to english
- *
- * @param {Object} target
- * @param {Object} prototypeObject An object of single prototypes
- * @param {Object} filters
- *
- * @return {Object} target
- */
- setPrototypeByObject: function(target, prototypeObject, filters) {
- for (var singlePrototype in prototypeObject) {
- if (target.hasOwnProperty(singlePrototype)) {
- if (filters) {
- if (filters.indexOf(singlePrototype) < 0)
- target[singlePrototype] = Proton.Util.getSpanValue(prototypeObject[singlePrototype]);
- } else {
- target[singlePrototype] = Proton.Util.getSpanValue(prototypeObject[singlePrototype]);
- }
- }
+ return this;
+ }
+ }, {
+ key: 'add',
+ value: function add(v, w) {
+ if (w !== undefined) {
+ return this.addVectors(v, w);
}
- return target;
- },
+ this.x += v.x;
+ this.y += v.y;
- /**
- * Returns a new Proton.Span object
- *
- * @memberof Proton#Proton.Util
- * @method setSpanValue
- *
- * @todo a, b and c should be 'Mixed' or 'Number'?
- *
- * @param {Mixed | Proton.Span} a
- * @param {Mixed} b
- * @param {Mixed} c
- *
- * @return {Proton.Span}
- */
- setSpanValue: function(a, b, c) {
- if (a instanceof Proton.Span) {
- return a;
- } else {
- if (!b) {
- return new Proton.Span(a);
- } else {
- if (!c)
- return new Proton.Span(a, b);
- else
- return new Proton.Span(a, b, c);
- }
- }
- },
+ return this;
+ }
+ }, {
+ key: 'addXY',
+ value: function addXY(a, b) {
+ this.x += a;
+ this.y += b;
- /**
- * Returns the value from a Proton.Span, if the param is not a Proton.Span it will return the given parameter
- *
- * @memberof Proton#Proton.Util
- * @method getSpanValue
- *
- * @param {Mixed | Proton.Span} pan
- *
- * @return {Mixed} the value of Proton.Span OR the parameter if it is not a Proton.Span
- */
- getSpanValue: function(pan) {
- if (pan instanceof Proton.Span)
- return pan.getValue();
- else
- return pan;
- },
+ return this;
+ }
+ }, {
+ key: 'addVectors',
+ value: function addVectors(a, b) {
+ this.x = a.x + b.x;
+ this.y = a.y + b.y;
- /**
- * Inherits any class from the superclass. Acts like 'extends' in Java
- *
- * @memberof Proton#Proton.Util
- * @method inherits
- *
- * @param {Object} subClass the child class
- * @param {Object} superClass the parent/super class
- */
- inherits: function(subClass, superClass) {
- subClass._super_ = superClass;
- if (Object['create']) {
- //console.log(subClass,superClass);
- subClass.prototype = Object.create(superClass.prototype, {
- constructor: {
- value: subClass
- }
- });
- } else {
- var F = function() {};
- F.prototype = superClass.prototype;
- subClass.prototype = new F();
- subClass.prototype.constructor = subClass;
+ return this;
+ }
+ }, {
+ key: 'sub',
+ value: function sub(v, w) {
+ if (w !== undefined) {
+ return this.subVectors(v, w);
}
- },
- /**
- * This will get the image data. It could be necessary to create a Proton.Zone.
- *
- * @memberof Proton#Proton.Util
- * @method getImageData
- *
- * @param {HTMLCanvasElement} context any canvas, must be a 2dContext 'canvas.getContext('2d')'
- * @param {Object} image could be any dom image, e.g. document.getElementById('thisIsAnImgTag');
- * @param {Proton.Rectangle} rect
- */
- getImageData: function(context, image, rect) {
- context.drawImage(image, rect.x, rect.y);
- var imagedata = context.getImageData(rect.x, rect.y, rect.width, rect.height);
- context.clearRect(rect.x, rect.y, rect.width, rect.height);
- return imagedata;
- },
+ this.x -= v.x;
+ this.y -= v.y;
- /**
- * @memberof Proton#Proton.Util
- * @method getImage
- *
- * @todo add description
- * @todo describe fun
- *
- * @param {Mixed} img
- * @param {Proton.Particle} particle
- * @param {Boolean} drawCanvas set to true if a canvas should be saved into particle.transform.canvas
- * @param {Boolean} fun
- */
- getImage: function(img, particle, drawCanvas, fun) {
- if (typeof(img) == 'string') {
- this.loadAndSetImage(img, particle, drawCanvas, fun);
- } else if (typeof(img) == 'object') {
- this.loadAndSetImage(img.src, particle, drawCanvas, fun);
- } else if (img instanceof Image) {
- this.loadedImage(img.src, particle, drawCanvas, fun, img);
- }
- },
-
- /**
- * @memberof Proton#Proton.Util
- * @method loadedImage
- *
- * @todo add description
- * @todo describe fun
- * @todo describe target
- *
- * @param {String} src the src of an img-tag
- * @param {Proton.Particle} particle
- * @param {Boolean} drawCanvas set to true if a canvas should be saved into particle.transform.canvas
- * @param {Boolean} fun
- * @param {Object} target
- */
- loadedImage: function(src, particle, drawCanvas, fun, target) {
- particle.target = target;
- particle.transform.src = src;
- if (!Proton.TextureBuffer[src])
- Proton.TextureBuffer[src] = particle.target;
- if (drawCanvas) {
- if (Proton.TextureCanvasBuffer[src]) {
- particle.transform.canvas = Proton.TextureCanvasBuffer[src];
- } else {
- var _width = Proton.WebGLUtil.nhpot(particle.target.width);
- var _height = Proton.WebGLUtil.nhpot(particle.target.height);
- particle.transform.canvas = Proton.DomUtil.createCanvas('canvas' + src, _width, _height);
- var context = particle.transform.canvas.getContext('2d');
- context.drawImage(particle.target, 0, 0, particle.target.width, particle.target.height);
- Proton.TextureCanvasBuffer[src] = particle.transform.canvas;
- }
- }
- if (fun)
- fun(particle);
- },
+ return this;
+ }
+ }, {
+ key: 'subVectors',
+ value: function subVectors(a, b) {
+ this.x = a.x - b.x;
+ this.y = a.y - b.y;
- /**
- * @memberof Proton#Proton.Util
- * @method loadAndSetImage
- *
- * @todo add description
- * @todo describe fun
- *
- * @param {String} src the src of an img-tag
- * @param {Proton.Particle} particle
- * @param {Boolean} drawCanvas set to true if a canvas should be saved into particle.transform.canvas
- * @param {Boolean} fun
- */
- loadAndSetImage: function(src, particle, drawCanvas, fun) {
- if (Proton.TextureBuffer[src]) {
- this.loadedImage(src, particle, drawCanvas, fun, Proton.TextureBuffer[src]);
+ return this;
+ }
+ }, {
+ key: 'divideScalar',
+ value: function divideScalar(s) {
+ if (s !== 0) {
+ this.x /= s;
+ this.y /= s;
} else {
- var self = this;
- var myImage = new Image();
- myImage.onload = function(e) {
- self.loadedImage(src, particle, drawCanvas, fun, e.target);
- }
- myImage.src = src;
+ this.set(0, 0);
}
- },
- /**
- * @typedef {Object} rgbObject
- * @property {Number} r red value
- * @property {Number} g green value
- * @property {Number} b blue value
- */
- /**
- * converts a hex value to a rgb object
- *
- * @memberof Proton#Proton.Util
- * @method hexToRGB
- *
- * @param {String} h any hex value, e.g. #000000 or 000000 for black
- *
- * @return {rgbObject}
- */
- hexToRGB: function(h) {
- var hex16 = (h.charAt(0) == "#") ? h.substring(1, 7) : h;
- var r = parseInt(hex16.substring(0, 2), 16);
- var g = parseInt(hex16.substring(2, 4), 16);
- var b = parseInt(hex16.substring(4, 6), 16);
-
- return {
- r: r,
- g: g,
- b: b
- }
- },
-
- /**
- * converts a rgb value to a rgb string
- *
- * @memberof Proton#Proton.Util
- * @method rgbToHex
- *
- * @param {Object | Proton.hexToRGB} rgb a rgb object like in {@link Proton#Proton.Util.hexToRGB}
- *
- * @return {String} rgb()
- */
- rgbToHex: function(rbg) {
- return 'rgb(' + rbg.r + ', ' + rbg.g + ', ' + rbg.b + ')';
+ return this;
}
- };
+ }, {
+ key: 'multiplyScalar',
+ value: function multiplyScalar(s) {
+ this.x *= s;
+ this.y *= s;
- Proton.Util = Util;
-
-
-
-///bind
-if (!Function.prototype.bind) {
- Function.prototype.bind = function(oThis) {
- if (typeof this !== "function") {
- // closest thing possible to the ECMAScript 5
- // internal IsCallable function
- throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
+ return this;
}
+ }, {
+ key: 'negate',
+ value: function negate() {
+ return this.multiplyScalar(-1);
+ }
+ }, {
+ key: 'dot',
+ value: function dot(v) {
+ return this.x * v.x + this.y * v.y;
+ }
+ }, {
+ key: 'lengthSq',
+ value: function lengthSq() {
+ return this.x * this.x + this.y * this.y;
+ }
+ }, {
+ key: 'length',
+ value: function length() {
+ return Math.sqrt(this.x * this.x + this.y * this.y);
+ }
+ }, {
+ key: 'normalize',
+ value: function normalize() {
+ return this.divideScalar(this.length());
+ }
+ }, {
+ key: 'distanceTo',
+ value: function distanceTo(v) {
+ return Math.sqrt(this.distanceToSquared(v));
+ }
+ }, {
+ key: 'rotate',
+ value: function rotate(tha) {
+ var x = this.x;
+ var y = this.y;
- var aArgs = Array.prototype.slice.call(arguments, 1),
- fToBind = this,
- fNOP = function() {},
- fBound = function() {
- return fToBind.apply(this instanceof fNOP ? this : oThis || this,
- aArgs.concat(Array.prototype.slice.call(arguments)));
- };
-
- fNOP.prototype = this.prototype;
- fBound.prototype = new fNOP();
-
- return fBound;
- };
-}
-
-
+ this.x = x * Math.cos(tha) + y * Math.sin(tha);
+ this.y = -x * Math.sin(tha) + y * Math.cos(tha);
- /**
- * @namespace
- * @memberof! Proton#
- * @alias Proton.WebGLUtil
- */
- var WebGLUtil = WebGLUtil || {
-
- /**
- * @memberof Proton#Proton.WebGLUtil
- * @method ipot
- *
- * @todo add description
- * @todo add length description
- *
- * @param {Number} length
- *
- * @return {Boolean}
- */
- ipot : function(length) {
- return (length & (length - 1)) == 0;
- },
+ return this;
+ }
+ }, {
+ key: 'distanceToSquared',
+ value: function distanceToSquared(v) {
+ var dx = this.x - v.x;
+ var dy = this.y - v.y;
- /**
- * @memberof Proton#Proton.WebGLUtil
- * @method nhpot
- *
- * @todo add description
- * @todo add length description
- *
- * @param {Number} length
- *
- * @return {Number}
- */
- nhpot : function(length) {--length;
- for (var i = 1; i < 32; i <<= 1) {
- length = length | length >> i;
- }
- return length + 1;
- },
+ return dx * dx + dy * dy;
+ }
+ }, {
+ key: 'lerp',
+ value: function lerp(v, alpha) {
+ this.x += (v.x - this.x) * alpha;
+ this.y += (v.y - this.y) * alpha;
- /**
- * @memberof Proton#Proton.WebGLUtil
- * @method makeTranslation
- *
- * @todo add description
- * @todo add tx, ty description
- * @todo add return description
- *
- * @param {Number} tx either 0 or 1
- * @param {Number} ty either 0 or 1
- *
- * @return {Object}
- */
- makeTranslation : function(tx, ty) {
- return [1, 0, 0, 0, 1, 0, tx, ty, 1];
- },
+ return this;
+ }
+ }, {
+ key: 'equals',
+ value: function equals(v) {
+ return v.x === this.x && v.y === this.y;
+ }
+ }, {
+ key: 'clear',
+ value: function clear() {
+ this.x = 0.0;
+ this.y = 0.0;
+ return this;
+ }
+ }, {
+ key: 'clone',
+ value: function clone() {
+ return new Vector2D(this.x, this.y);
+ }
+ }]);
+ return Vector2D;
+}();
- /**
- * @memberof Proton#Proton.WebGLUtil
- * @method makeRotation
- *
- * @todo add description
- * @todo add return description
- *
- * @param {Number} angleInRadians
- *
- * @return {Object}
- */
- makeRotation : function(angleInRadians) {
- var c = Math.cos(angleInRadians);
- var s = Math.sin(angleInRadians);
- return [c, -s, 0, s, c, 0, 0, 0, 1];
- },
+var Span = function () {
+ function Span(a, b, center) {
+ classCallCheck(this, Span);
- /**
- * @memberof Proton#Proton.WebGLUtil
- * @method makeScale
- *
- * @todo add description
- * @todo add tx, ty description
- * @todo add return description
- *
- * @param {Number} sx either 0 or 1
- * @param {Number} sy either 0 or 1
- *
- * @return {Object}
- */
- makeScale : function(sx, sy) {
- return [sx, 0, 0, 0, sy, 0, 0, 0, 1];
- },
+ this.isArray = false;
- /**
- * @memberof Proton#Proton.WebGLUtil
- * @method matrixMultiply
- *
- * @todo add description
- * @todo add a, b description
- * @todo add return description
- *
- * @param {Object} a
- * @param {Object} b
- *
- * @return {Object}
- */
- matrixMultiply : function(a, b) {
- var a00 = a[0 * 3 + 0];
- var a01 = a[0 * 3 + 1];
- var a02 = a[0 * 3 + 2];
- var a10 = a[1 * 3 + 0];
- var a11 = a[1 * 3 + 1];
- var a12 = a[1 * 3 + 2];
- var a20 = a[2 * 3 + 0];
- var a21 = a[2 * 3 + 1];
- var a22 = a[2 * 3 + 2];
- var b00 = b[0 * 3 + 0];
- var b01 = b[0 * 3 + 1];
- var b02 = b[0 * 3 + 2];
- var b10 = b[1 * 3 + 0];
- var b11 = b[1 * 3 + 1];
- var b12 = b[1 * 3 + 2];
- var b20 = b[2 * 3 + 0];
- var b21 = b[2 * 3 + 1];
- var b22 = b[2 * 3 + 2];
- return [a00 * b00 + a01 * b10 + a02 * b20, a00 * b01 + a01 * b11 + a02 * b21, a00 * b02 + a01 * b12 + a02 * b22, a10 * b00 + a11 * b10 + a12 * b20, a10 * b01 + a11 * b11 + a12 * b21, a10 * b02 + a11 * b12 + a12 * b22, a20 * b00 + a21 * b10 + a22 * b20, a20 * b01 + a21 * b11 + a22 * b21, a20 * b02 + a21 * b12 + a22 * b22];
+ if (Util.isArray(a)) {
+ this.isArray = true;
+ this.a = a;
+ } else {
+ this.a = Util.initValue(a, 1);
+ this.b = Util.initValue(b, this.a);
+ this.center = Util.initValue(center, false);
}
}
- Proton.WebGLUtil = WebGLUtil;
-
-
-
-
- /**
- * @namespace
- * @memberof! Proton#
- * @alias Proton.DomUtil
- */
- var DomUtil = DomUtil || {
-
- /**
- * Creates and returns a new canvas. The opacity is by default set to 0
- *
- * @memberof Proton#Proton.DomUtil
- * @method createCanvas
- *
- * @param {String} $id the canvas' id
- * @param {Number} $width the canvas' width
- * @param {Number} $height the canvas' height
- * @param {String} [$position=absolute] the canvas' position, default is 'absolute'
- *
- * @return {Object}
- */
- createCanvas : function($id, $width, $height, $position) {
- var element = document.createElement("canvas");
- var position = $position ? $position : 'absolute';
- element.id = $id;
- element.width = $width;
- element.height = $height;
- element.style.position = position;
- element.style.opacity = 0;
- this.transformDom(element, -500, -500, 0, 0);
- return element;
- },
-
- /**
- * Adds a transform: translate(), scale(), rotate() to a given div element for all browsers
- *
- * @memberof Proton#Proton.DomUtil
- * @method transformDom
- *
- * @param {HTMLDivElement} $div
- * @param {Number} $x
- * @param {Number} $y
- * @param {Number} $scale
- * @param {Number} $rotate
- */
- transformDom : function($div, $x, $y, $scale, $rotate) {
- $div.style.WebkitTransform = 'translate(' + $x + 'px, ' + $y + 'px) ' + 'scale(' + $scale + ') ' + 'rotate(' + $rotate + 'deg)';
- $div.style.MozTransform = 'translate(' + $x + 'px, ' + $y + 'px) ' + 'scale(' + $scale + ') ' + 'rotate(' + $rotate + 'deg)';
- $div.style.OTransform = 'translate(' + $x + 'px, ' + $y + 'px) ' + 'scale(' + $scale + ') ' + 'rotate(' + $rotate + 'deg)';
- $div.style.msTransform = 'translate(' + $x + 'px, ' + $y + 'px) ' + 'scale(' + $scale + ') ' + 'rotate(' + $rotate + 'deg)';
- $div.style.transform = 'translate(' + $x + 'px, ' + $y + 'px) ' + 'scale(' + $scale + ') ' + 'rotate(' + $rotate + 'deg)';
+ createClass(Span, [{
+ key: 'getValue',
+ value: function getValue(INT) {
+ if (this.isArray) {
+ return this.a[Math.floor(this.a.length * Math.random())];
+ } else {
+ if (!this.center) return MathUtils.randomAToB(this.a, this.b, INT);else return MathUtils.randomFloating(this.a, this.b, INT);
+ }
}
- }
+ }]);
+ return Span;
+}();
- Proton.DomUtil = DomUtil;
+var WebGLUtil = {
+ /**
+ * @memberof Proton#Proton.WebGLUtil
+ * @method ipot
+ *
+ * @todo add description
+ * @todo add length description
+ *
+ * @param {Number} length
+ *
+ * @return {Boolean}
+ */
+ ipot: function ipot(length) {
+ return (length & length - 1) == 0;
+ },
- function MStack() {
- this.mats = [];
- this.size = 0;
- for (var i = 0; i < 20; i++)
- this.mats.push(Proton.Mat3.create([0, 0, 0, 0, 0, 0, 0, 0, 0]));
- }
-
-
- MStack.prototype.set = function(m, i) {
- if (i == 0)
- Proton.Mat3.set(m, this.mats[0]);
- else
- Proton.Mat3.multiply(this.mats[i - 1], m, this.mats[i]);
- this.size = Math.max(this.size, i + 1);
- }
+ /**
+ * @memberof Proton#Proton.WebGLUtil
+ * @method nhpot
+ *
+ * @todo add description
+ * @todo add length description
+ *
+ * @param {Number} length
+ *
+ * @return {Number}
+ */
+ nhpot: function nhpot(length) {
+ --length;
+ for (var i = 1; i < 32; i <<= 1) {
+ length = length | length >> i;
+ }
- MStack.prototype.push = function(m) {
- if (this.size == 0)
- Proton.Mat3.set(m, this.mats[0]);
- else
- Proton.Mat3.multiply(this.mats[this.size - 1], m, this.mats[this.size]);
- this.size++;
- }
+ return length + 1;
+ },
- MStack.prototype.pop = function() {
- if (this.size > 0)
- this.size--;
- }
- MStack.prototype.top = function() {
- return (this.mats[this.size - 1]);
- }
+ /**
+ * @memberof Proton#Proton.WebGLUtil
+ * @method makeTranslation
+ *
+ * @todo add description
+ * @todo add tx, ty description
+ * @todo add return description
+ *
+ * @param {Number} tx either 0 or 1
+ * @param {Number} ty either 0 or 1
+ *
+ * @return {Object}
+ */
+ makeTranslation: function makeTranslation(tx, ty) {
+ return [1, 0, 0, 0, 1, 0, tx, ty, 1];
+ },
- Proton.MStack = MStack;
+ /**
+ * @memberof Proton#Proton.WebGLUtil
+ * @method makeRotation
+ *
+ * @todo add description
+ * @todo add return description
+ *
+ * @param {Number} angleInRadians
+ *
+ * @return {Object}
+ */
+ makeRotation: function makeRotation(angleInRadians) {
+ var c = Math.cos(angleInRadians);
+ var s = Math.sin(angleInRadians);
+ return [c, -s, 0, s, c, 0, 0, 0, 1];
+ },
- Particle.ID = 0;
- /**
- * the Particle class
- *
- * @class Proton.Particle
- * @constructor
- * @param {Object} pObj the parameters object;
- * for example {life:3,dead:false}
- */
- function Particle(pOBJ) {
- /**
- * The particle's id;
- * @property id
- * @type {string}
- */
- this.id = 'particle_' + Particle.ID++;
- this.reset(true);
- Proton.Util.setPrototypeByObject(this, pOBJ);
- }
+ /**
+ * @memberof Proton#Proton.WebGLUtil
+ * @method makeScale
+ *
+ * @todo add description
+ * @todo add tx, ty description
+ * @todo add return description
+ *
+ * @param {Number} sx either 0 or 1
+ * @param {Number} sy either 0 or 1
+ *
+ * @return {Object}
+ */
+ makeScale: function makeScale(sx, sy) {
+ return [sx, 0, 0, 0, sy, 0, 0, 0, 1];
+ },
- Particle.prototype = {
- getDirection : function() {
- return Math.atan2(this.v.x, -this.v.y) * (180 / Math.PI);
- },
-
- reset : function(init) {
- this.life = Infinity;
- this.age = 0;
-
- //Energy loss
- this.energy = 1;
- this.dead = false;
- this.sleep = false;
- this.target = null;
- this.sprite = null;
- this.parent = null;
- this.mass = 1;
- this.radius = 10;
- this.alpha = 1;
- this.scale = 1;
- this.rotation = 0;
- this.color = null;
- this.easing = Proton.ease.setEasingByName(Proton.easeLinear);
-
- if (init) {
- this.transform = {}
- this.p = new Proton.Vector2D();
- this.v = new Proton.Vector2D();
- this.a = new Proton.Vector2D();
- this.old = {
- p : new Proton.Vector2D(),
- v : new Proton.Vector2D(),
- a : new Proton.Vector2D()
- };
- this.behaviours = [];
- } else {
- Proton.Util.destroyObject(this.transform);
- this.p.set(0, 0);
- this.v.set(0, 0);
- this.a.set(0, 0);
- this.old.p.set(0, 0);
- this.old.v.set(0, 0);
- this.old.a.set(0, 0);
-
- this.removeAllBehaviours();
- }
+ /**
+ * @memberof Proton#Proton.WebGLUtil
+ * @method matrixMultiply
+ *
+ * @todo add description
+ * @todo add a, b description
+ * @todo add return description
+ *
+ * @param {Object} a
+ * @param {Object} b
+ *
+ * @return {Object}
+ */
+ matrixMultiply: function matrixMultiply(a, b) {
+ var a00 = a[0 * 3 + 0];
+ var a01 = a[0 * 3 + 1];
+ var a02 = a[0 * 3 + 2];
+ var a10 = a[1 * 3 + 0];
+ var a11 = a[1 * 3 + 1];
+ var a12 = a[1 * 3 + 2];
+ var a20 = a[2 * 3 + 0];
+ var a21 = a[2 * 3 + 1];
+ var a22 = a[2 * 3 + 2];
+ var b00 = b[0 * 3 + 0];
+ var b01 = b[0 * 3 + 1];
+ var b02 = b[0 * 3 + 2];
+ var b10 = b[1 * 3 + 0];
+ var b11 = b[1 * 3 + 1];
+ var b12 = b[1 * 3 + 2];
+ var b20 = b[2 * 3 + 0];
+ var b21 = b[2 * 3 + 1];
+ var b22 = b[2 * 3 + 2];
+
+ return [a00 * b00 + a01 * b10 + a02 * b20, a00 * b01 + a01 * b11 + a02 * b21, a00 * b02 + a01 * b12 + a02 * b22, a10 * b00 + a11 * b10 + a12 * b20, a10 * b01 + a11 * b11 + a12 * b21, a10 * b02 + a11 * b12 + a12 * b22, a20 * b00 + a21 * b10 + a22 * b20, a20 * b01 + a21 * b11 + a22 * b21, a20 * b02 + a21 * b12 + a22 * b22];
+ }
+};
- this.transform.rgb = {
- r : 255,
- g : 255,
- b : 255
- }
+var DomUtil = {
- return this;
- },
+ /**
+ * Creates and returns a new canvas. The opacity is by default set to 0
+ *
+ * @memberof Proton#Proton.DomUtil
+ * @method createCanvas
+ *
+ * @param {String} $id the canvas' id
+ * @param {Number} $width the canvas' width
+ * @param {Number} $height the canvas' height
+ * @param {String} [$position=absolute] the canvas' position, default is 'absolute'
+ *
+ * @return {Object}
+ */
+ createCanvas: function createCanvas(id, width, height, position) {
+ var dom = document.createElement("canvas");
+ position = position || 'absolute';
- update : function(time, index) {
- if (!this.sleep) {
- this.age += time;
- var length = this.behaviours.length, i;
+ dom.id = id;
+ dom.width = width;
+ dom.height = height;
+ dom.style.opacity = 0;
+ dom.style.position = position;
- for ( i = 0; i < length; i++) {
- if (this.behaviours[i])
- this.behaviours[i].applyBehaviour(this, time, index)
- }
- } else {
+ this.transform(dom, -500, -500, 0, 0);
- }
+ return dom;
+ },
+ createDiv: function createDiv(id, width, height) {
+ var dom = document.createElement("div");
- if (this.age >= this.life) {
- this.destroy();
- } else {
- var scale = this.easing(this.age / this.life);
- this.energy = Math.max(1 - scale, 0);
- }
+ dom.id = id;
+ dom.style.position = 'absolute';
+ this.resize(dom, width, height);
- },
+ return dom;
+ },
+ resize: function resize(dom, width, height) {
+ dom.style.width = width + 'px';
+ dom.style.height = height + 'px';
+ dom.style.marginLeft = -width / 2 + 'px';
+ dom.style.marginTop = -height / 2 + 'px';
+ },
- addBehaviour : function(behaviour) {
- this.behaviours.push(behaviour);
- if (behaviour.hasOwnProperty('parents'))
- behaviour.parents.push(this);
- behaviour.initialize(this);
- },
+ /**
+ * Adds a transform: translate(), scale(), rotate() to a given div dom for all browsers
+ *
+ * @memberof Proton#Proton.DomUtil
+ * @method transform
+ *
+ * @param {HTMLDivElement} div
+ * @param {Number} $x
+ * @param {Number} $y
+ * @param {Number} $scale
+ * @param {Number} $rotate
+ */
+ transform: function transform(div, x, y, scale, rotate) {
+ var transform = "translate(" + x + "px, " + y + "px) scale(" + scale + ") rotate(" + rotate + "deg)";
+
+ div.style.willChange = 'transform';
+ this.css3(div, 'transform', transform);
+ },
+ transform3d: function transform3d(div, x, y, scale, rotate) {
+ var transform = "translate3d(" + x + "px, " + y + "px, 0) scale(" + scale + ") rotate(" + rotate + "deg)";
+
+ div.style.willChange = 'transform';
+ this.css3(div, 'backfaceVisibility', 'hidden');
+ this.css3(div, 'transform', transform);
+ },
+ css3: function css3(div, key, val) {
+ var bkey = key.charAt(0).toUpperCase() + key.substr(1);
+
+ div.style["Webkit" + bkey] = val;
+ div.style["Moz" + bkey] = val;
+ div.style["O" + bkey] = val;
+ div.style["ms" + bkey] = val;
+ div.style["" + key] = val;
+ }
+};
- addBehaviours : function(behaviours) {
- var length = behaviours.length, i;
+var IMG_CACHE = {};
+var CANVAS_CACHE = {};
+var canvasID = 0;
- for ( i = 0; i < length; i++) {
- this.addBehaviour(behaviours[i]);
- }
- },
+var ImgUtil = {
- removeBehaviour : function(behaviour) {
- var index = this.behaviours.indexOf(behaviour);
- if (index > -1) {
- var behaviour = this.behaviours.splice(index, 1);
- behaviour.parents = null;
- }
- },
+ /**
+ * This will get the image data. It could be necessary to create a Proton.Zone.
+ *
+ * @memberof Proton#Proton.Util
+ * @method getImageData
+ *
+ * @param {HTMLCanvasElement} context any canvas, must be a 2dContext 'canvas.getContext('2d')'
+ * @param {Object} image could be any dom image, e.g. document.getElementById('thisIsAnImgTag');
+ * @param {Proton.Rectangle} rect
+ */
+ getImageData: function getImageData(context, image, rect) {
+ context.drawImage(image, rect.x, rect.y);
+ var imagedata = context.getImageData(rect.x, rect.y, rect.width, rect.height);
+ context.clearRect(rect.x, rect.y, rect.width, rect.height);
- removeAllBehaviours : function() {
- Proton.Util.destroyArray(this.behaviours);
- },
-
- /**
- * Destory this particle
- * @method destroy
- */
- destroy : function() {
- this.removeAllBehaviours();
- this.energy = 0;
- this.dead = true;
- this.parent = null;
- }
- };
+ return imagedata;
+ },
- Proton.Particle = Particle;
+ /**
+ * @memberof Proton#Proton.Util
+ * @method getImgFromCache
+ *
+ * @todo add description
+ * @todo describe func
+ *
+ * @param {Mixed} img
+ * @param {Proton.Particle} particle
+ * @param {Boolean} drawCanvas set to true if a canvas should be saved into particle.transform.canvas
+ * @param {Boolean} func
+ */
+ getImgFromCache: function getImgFromCache(img, callback, param) {
+ var src = typeof img == 'string' ? img : img.src;
+ if (IMG_CACHE[src]) {
+ callback(IMG_CACHE[src], param);
+ } else {
+ var image = new Image();
+ image.onload = function (e) {
+ IMG_CACHE[src] = e.target;
+ callback(IMG_CACHE[src], param);
+ };
+ image.src = src;
+ }
+ },
+ getCanvasFromCache: function getCanvasFromCache(img, callback, param) {
+ var src = img.src;
- /**
- * @memberof! Proton#
- * @constructor
- * @alias Proton.Pool
- *
- * @todo add description
- * @todo add description of properties
- *
- * @property {Number} cID
- * @property {Object} list
- */
- function Pool() {
- this.cID = 0;
- this.list = {};
- }
-
- Pool.prototype = {
+ if (!CANVAS_CACHE[src]) {
+ var width = WebGLUtil.nhpot(img.width);
+ var height = WebGLUtil.nhpot(img.height);
- /**
- * Creates a new class instance
- *
- * @todo add more documentation
- *
- * @method create
- * @memberof Proton#Proton.Pool
- *
- * @param {Object|Function} obj any Object or Function
- * @param {Object} [params] just add if `obj` is a function
- *
- * @return {Object}
- */
- create: function(obj, params) {
- this.cID++;
-
- if (typeof obj == "function")
- return Proton.Util.classApply(obj, params);
- else
- return obj.clone();
- },
+ var canvas = DomUtil.createCanvas('canvas_cache_' + canvasID, width, height);
+ var context = canvas.getContext('2d');
+ context.drawImage(img, 0, 0, img.width, img.height);
- /**
- * @todo add description - what is in the list?
- *
- * @method getCount
- * @memberof Proton#Proton.Pool
- *
- * @return {Number}
- */
- getCount: function() {
- var count = 0;
- for (var id in this.list)
- count += this.list[id].length;
-
- return count++;;
- },
+ CANVAS_CACHE[src] = canvas;
+ }
- /**
- * @todo add description
- *
- * @method get
- * @memberof Proton#Proton.Pool
- *
- * @param {Object|Function} obj
- * @param {Object} [params] just add if `obj` is a function
- *
- * @return {Object}
- */
- get: function(obj, params) {
- var p, puid = obj.__puid || PUID.id(obj);
- if (this.list[puid] && this.list[puid].length > 0)
- p = this.list[puid].pop();
- else
- p = this.create(obj, params);
-
- p.__puid = obj.__puid || puid;
- return p;
- },
+ callback && callback(CANVAS_CACHE[src], param);
- /**
- * @todo add description
- *
- * @method set
- * @memberof Proton#Proton.Pool
- *
- * @param {Object} obj
- *
- * @return {Object}
- */
- set: function(obj) {
- return this._getList(obj.__puid).push(obj);
- },
+ return CANVAS_CACHE[src];
+ }
+};
- /**
- * Destroyes all items from Pool.list
- *
- * @method destroy
- * @memberof Proton#Proton.Pool
- */
- destroy: function() {
- for (var id in this.list) {
- this.list[id].length = 0;
- delete this.list[id];
- }
- },
+var Util = {
- /**
- * Returns Pool.list
- *
- * @method _getList
- * @memberof Proton#Proton.Pool
- * @private
- *
- * @param {Number} uid the unique id
- *
- * @return {Object}
- */
- _getList: function(uid) {
- uid = uid || "default";
- if (!this.list[uid]) this.list[uid] = [];
- return this.list[uid];
- }
- }
+ /**
+ * Returns the default if the value is null or undefined
+ *
+ * @memberof Proton#Proton.Util
+ * @method initValue
+ *
+ * @param {Mixed} value a specific value, could be everything but null or undefined
+ * @param {Mixed} defaults the default if the value is null or undefined
+ */
+ initValue: function initValue(value, defaults) {
+ value = value !== null && value !== undefined ? value : defaults;
+ return value;
+ },
- Proton.Pool = Pool;
- var PUID = {
- _id: 0,
- _uids: {},
- id: function(obj) {
- for (var id in this._uids) {
- if (this._uids[id] == obj) return id;
- }
+ /**
+ * Checks if the value is a valid array
+ *
+ * @memberof Proton#Proton.Util
+ * @method isArray
+ *
+ * @param {Array} value Any array
+ *
+ * @returns {Boolean}
+ */
+ isArray: function isArray(value) {
+ return Object.prototype.toString.call(value) === '[object Array]';
+ },
- var nid = "PUID_" + (this._id++);
- this._uids[nid] = obj;
- return nid;
- },
- hash: function(str) {
- return;
- }
- }
+ /**
+ * Destroyes the given array
+ *
+ * @memberof Proton#Proton.Util
+ * @method destroyArray
+ *
+ * @param {Array} array Any array
+ */
+ destroyArray: function destroyArray(array) {
+ if (array) array.length = 0;
+ },
+ /**
+ * Destroyes the given object
+ *
+ * @memberof Proton#Proton.Util
+ * @method destroyObject
+ *
+ * @param {Object} obj Any object
+ */
+ destroyObject: function destroyObject(obj, ignore) {
+ for (var o in obj) {
+ if (ignore && ignore.indexOf(o) > -1) continue;
+ delete obj[o];
+ }
+ },
- var MathUtils = {
- randomAToB : function(a, b, INT) {
- if (!INT)
- return a + Math.random() * (b - a );
- else
- return Math.floor(Math.random() * (b - a)) + a;
- },
- randomFloating : function(center, f, INT) {
- return MathUtils.randomAToB(center - f, center + f, INT);
- },
- randomZone : function(display) {
+ /**
+ * Makes an instance of a class and binds the given array
+ *
+ * @memberof Proton#Proton.Util
+ * @method classApply
+ *
+ * @param {Function} constructor A class to make an instance from
+ * @param {Array} [args] Any array to bind it to the constructor
+ *
+ * @return {Object} The instance of constructor, optionally bind with args
+ */
+ classApply: function classApply(constructor, args) {
+ if (!args) return new constructor();
- },
+ args = [null].concat(args);
+ var factoryFunction = constructor.bind.apply(constructor, args);
+ return new factoryFunction();
+ },
- degreeTransform : function(a) {
- return a * Math.PI / 180;
- },
- toColor16 : function getRGB(num) {
- return "#" + num.toString(16);
- },
-
- randomColor : function() {
- return '#' + ('00000' + (Math.random() * 0x1000000 << 0).toString(16)).slice(-6);
- }
- }
+ /**
+ * @memberof Proton#Proton.Util
+ * @method setVector2DByObject
+ *
+ * @todo add description for param `target`
+ * @todo add description for param `pOBJ`
+ * @todo add description for function
+ *
+ * @param {Object} target
+ * @param {Object} pOBJ
+ */
+ setVector2DByObject: function setVector2DByObject(target, pOBJ) {
+ if (this.hasProp(pOBJ, 'x')) target.p.x = pOBJ['x'];
+ if (this.hasProp(pOBJ, 'y')) target.p.y = pOBJ['y'];
- Proton.MathUtils = MathUtils;
+ if (this.hasProp(pOBJ, 'vx')) target.v.x = pOBJ['vx'];
+ if (this.hasProp(pOBJ, 'vy')) target.v.y = pOBJ['vy'];
+ if (this.hasProp(pOBJ, 'ax')) target.a.x = pOBJ['ax'];
+ if (this.hasProp(pOBJ, 'ay')) target.a.y = pOBJ['ay'];
-//数值积分
+ if (this.hasProp(pOBJ, 'p')) particle.p.copy(pOBJ['p']);
+ if (this.hasProp(pOBJ, 'v')) particle.v.copy(pOBJ['v']);
+ if (this.hasProp(pOBJ, 'a')) particle.a.copy(pOBJ['a']);
- var NumericalIntegration = function(type) {
- this.type = Proton.Util.initValue(type, Proton.EULER);
- }
+ if (this.hasProp(pOBJ, 'position')) particle.p.copy(pOBJ['position']);
+ if (this.hasProp(pOBJ, 'velocity')) particle.v.copy(pOBJ['velocity']);
+ if (this.hasProp(pOBJ, 'accelerate')) particle.a.copy(pOBJ['accelerate']);
+ },
+ hasProp: function hasProp(obj, key) {
+ if (!obj) return false;
+ return obj[key] !== undefined;
+ // return obj.hasOwnProperty(key);
+ },
- NumericalIntegration.prototype = {
- integrate : function(particles, time, damping) {
- this.eulerIntegrate(particles, time, damping);
- },
- eulerIntegrate : function(particle, time, damping) {
- if (!particle.sleep) {
- particle.old.p.copy(particle.p);
- particle.old.v.copy(particle.v);
- particle.a.multiplyScalar(1 / particle.mass);
- particle.v.add(particle.a.multiplyScalar(time));
- particle.p.add(particle.old.v.multiplyScalar(time));
- if (damping)
- particle.v.multiplyScalar(damping);
- particle.a.clear();
- }
- }
- }
+ /**
+ * set the prototype in a given prototypeObject
+ *
+ * @memberof Proton#Proton.Util
+ * @method setPrototypeByObject
+ *
+ * @todo add description for param `target`
+ * @todo add description for param `filters`
+ * @todo translate desription from chinese to english
+ *
+ * @param {Object} target
+ * @param {Object} prototypeObject An object of single prototypes
+ * @param {Object} filters
+ *
+ * @return {Object} target
+ */
+ setPrototypeByObject: function setPrototypeByObject(target, prototypeObject, filters) {
+ for (var singleProp in prototypeObject) {
+ if (target.hasOwnProperty(singleProp)) {
+ if (filters) {
+ if (filters.indexOf(singleProp) < 0) target[singleProp] = this.getSpanValue(prototypeObject[singleProp]);
+ } else {
+ target[singleProp] = this.getSpanValue(prototypeObject[singleProp]);
+ }
+ }
+ }
- Proton.NumericalIntegration = NumericalIntegration;
+ return target;
+ },
-//@author mrdoob / http://mrdoob.com/
+ /**
+ * Returns a new Span object
+ *
+ * @memberof Proton#Proton.Util
+ * @method setSpanValue
+ *
+ * @todo a, b and c should be 'Mixed' or 'Number'?
+ *
+ * @param {Mixed | Span} a
+ * @param {Mixed} b
+ * @param {Mixed} c
+ *
+ * @return {Span}
+ */
+ setSpanValue: function setSpanValue(a, b, c) {
+ if (a instanceof Span) {
+ return a;
+ } else {
+ if (!b) {
+ return new Span(a);
+ } else {
+ if (!c) return new Span(a, b);else return new Span(a, b, c);
+ }
+ }
+ },
- var Vector2D = function(x, y) {
- this.x = x || 0;
- this.y = y || 0;
- }
- Vector2D.prototype = {
- set : function(x, y) {
+ /**
+ * Returns the value from a Span, if the param is not a Span it will return the given parameter
+ *
+ * @memberof Proton#Proton.Util
+ * @method getSpanValue
+ *
+ * @param {Mixed | Span} pan
+ *
+ * @return {Mixed} the value of Span OR the parameter if it is not a Span
+ */
+ getSpanValue: function getSpanValue(pan) {
+ return pan instanceof Span ? pan.getValue() : pan;
+ },
- this.x = x;
- this.y = y;
- return this;
- },
+ /**
+ * This will get the image data. It could be necessary to create a Proton.Zone.
+ *
+ * @memberof Proton#Proton.Util
+ * @method getImageData
+ *
+ * @param {HTMLCanvasElement} context any canvas, must be a 2dContext 'canvas.getContext('2d')'
+ * @param {Object} image could be any dom image, e.g. document.getElementById('thisIsAnImgTag');
+ * @param {Proton.Rectangle} rect
+ */
+ getImageData: function getImageData(context, image, rect) {
+ return ImgUtil.getImageData(context, image, rect);
+ },
+ destroy: function destroy(arr, param) {
+ var i = arr.length;
+
+ while (i--) {
+ try {
+ arr[i].destroy(param);
+ } catch (e) {}
+ delete arr[i];
+ }
- setX : function(x) {
+ arr.length = 0;
+ }
+};
- this.x = x;
- return this;
+var PUID = {
+ id: 0,
+ cache: {},
- },
+ getID: function getID(target) {
+ var uid = this.getCacheID(target);
+ if (uid) return uid;
- setY : function(y) {
+ uid = 'PUID_' + this.id++;
+ this.cache[uid] = target;
- this.y = y;
+ return uid;
+ },
+ getCacheID: function getCacheID(target) {
+ var obj = void 0;
+ for (var id in this.cache) {
+ obj = this.cache[id];
- return this;
+ if (obj === target) return id;
- },
+ if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && obj.isInner && target.isInner) {
+ if (obj.src === target.src) return id;
+ }
+ }
- getGradient : function() {
- if (this.x != 0)
- return Math.atan2(this.y, this.x);
- else if (this.y > 0)
- return Math.PI / 2;
- else if (this.y < 0)
- return -Math.PI / 2;
- },
+ return null;
+ },
+ getTarget: function getTarget(uid) {
+ return this.cache[uid];
+ }
+};
+
+/**
+ * get -> PUID :: uid-> Body
+ * -> cache[abc]. -> cache[abc] .pop()
+ * -> create [new Body| clone]
+ * -> return p1: { __pid: abc }
+ *
+ * expire -> cache[abc]= [p0, p1];
+ *
+ */
+var Pool = function () {
- copy : function(v) {
+ /**
+ * @memberof! Proton#
+ * @constructor
+ * @alias Proton.Pool
+ *
+ * @todo add description
+ * @todo add description of properties
+ *
+ * @property {Number} total
+ * @property {Object} cache
+ */
+ function Pool(num) {
+ classCallCheck(this, Pool);
- this.x = v.x;
- this.y = v.y;
+ this.total = 0;
+ this.cache = {};
+ }
- return this;
+ /**
+ * @todo add description
+ *
+ * @method get
+ * @memberof Proton#Proton.Pool
+ *
+ * @param {Object|Function} target
+ * @param {Object} [params] just add if `target` is a function
+ *
+ * @return {Object}
+ */
- },
- add : function(v, w) {
+ createClass(Pool, [{
+ key: 'get',
+ value: function get$$1(target, params, uid) {
+ var p = void 0;
+ uid = uid || target.__puid || PUID.getID(target);
- if (w !== undefined) {
- return this.addVectors(v, w);
+ if (this.cache[uid] && this.cache[uid].length > 0) p = this.cache[uid].pop();else p = this.createOrClone(target, params);
- }
+ p.__puid = target.__puid || uid;
+ return p;
+ }
- this.x += v.x;
- this.y += v.y;
+ /**
+ * @todo add description
+ *
+ * @method set
+ * @memberof Proton#Proton.Pool
+ *
+ * @param {Object} target
+ *
+ * @return {Object}
+ */
- return this;
+ }, {
+ key: 'expire',
+ value: function expire(target) {
+ return this.getCache(target.__puid).push(target);
+ }
- },
+ /**
+ * Creates a new class instance
+ *
+ * @todo add more documentation
+ *
+ * @method create
+ * @memberof Proton#Proton.Pool
+ *
+ * @param {Object|Function} target any Object or Function
+ * @param {Object} [params] just add if `target` is a function
+ *
+ * @return {Object}
+ */
- addXY : function(a, b) {
+ }, {
+ key: 'createOrClone',
+ value: function createOrClone(target, params) {
+ this.total++;
- this.x += a;
- this.y += b;
+ if (this.create) {
+ return this.create(target, params);
+ } else if (typeof target == "function") {
+ return Util.classApply(target, params);
+ } else {
+ return target.clone();
+ }
+ }
- return this;
+ /**
+ * @todo add description - what is in the cache?
+ *
+ * @method getCount
+ * @memberof Proton#Proton.Pool
+ *
+ * @return {Number}
+ */
- },
+ }, {
+ key: 'getCount',
+ value: function getCount() {
+ var count = 0;
- addVectors : function(a, b) {
+ for (var id in this.cache) {
+ count += this.cache[id].length;
+ }return count++;
+ }
- this.x = a.x + b.x;
- this.y = a.y + b.y;
+ /**
+ * Destroyes all items from Pool.cache
+ *
+ * @method destroy
+ * @memberof Proton#Proton.Pool
+ */
- return this;
+ }, {
+ key: 'destroy',
+ value: function destroy() {
+ for (var id in this.cache) {
+ this.cache[id].length = 0;
+ delete this.cache[id];
+ }
+ }
- },
+ /**
+ * Returns Pool.cache
+ *
+ * @method getCache
+ * @memberof Proton#Proton.Pool
+ * @private
+ *
+ * @param {Number} uid the unique id
+ *
+ * @return {Object}
+ */
- addScalar : function(s) {
+ }, {
+ key: 'getCache',
+ value: function getCache(uid) {
+ uid = uid || "default";
- this.x += s;
- this.y += s;
+ if (!this.cache[uid]) this.cache[uid] = [];
+ return this.cache[uid];
+ }
+ }]);
+ return Pool;
+}();
- return this;
+var Stats = function () {
+ function Stats(proton) {
+ classCallCheck(this, Stats);
- },
+ this.proton = proton;
+ this.container = null;
+ this.type = 1;
- sub : function(v, w) {
+ this.emitterIndex = 0;
+ this.rendererIndex = 0;
+ }
- if (w !== undefined) {
- return this.subVectors(v, w);
+ createClass(Stats, [{
+ key: "update",
+ value: function update(style, body) {
+ this.add(style, body);
+
+ var emitter = this.getEmitter();
+ var renderer = this.getRenderer();
+ var str = "";
+
+ switch (this.type) {
+ case 2:
+ str += "emitter:" + this.proton.emitters.length + "
";
+ if (emitter) str += "em speed:" + emitter.emitSpeed + "
";
+ if (emitter) str += "pos:" + this.getEmitterPos(emitter);
+ break;
+
+ case 3:
+ if (emitter) str += "initializes:" + emitter.initializes.length + "
";
+ if (emitter) str += "" + this.concatArr(emitter.initializes) + "
";
+ if (emitter) str += "behaviours:" + emitter.behaviours.length + "
";
+ if (emitter) str += "" + this.concatArr(emitter.behaviours) + "
";
+ break;
+
+ case 4:
+ if (renderer) str += renderer.name + "
";
+ if (renderer) str += "body:" + this.getCreatedNumber(renderer) + "
";
+ break;
+
+ default:
+ str += "particles:" + this.proton.getCount() + "
";
+ str += "pool:" + this.proton.pool.getCount() + "
";
+ str += "total:" + this.proton.pool.total;
+ }
- }
+ this.container.innerHTML = str;
+ }
+ }, {
+ key: "add",
+ value: function add(style, body) {
+ var _this = this;
+
+ if (!this.container) {
+ this.type = 1;
+
+ this.container = document.createElement('div');
+ this.container.style.cssText = ['position:absolute;bottom:0px;left:0;cursor:pointer;', 'opacity:0.9;z-index:10000;padding:10px;font-size:12px;', 'width:120px;height:50px;background-color:#002;color:#0ff;'].join('');
+
+ this.container.addEventListener('click', function (e) {
+ _this.type++;
+ if (_this.type > 4) _this.type = 1;
+ }, false);
+
+ var bg = void 0,
+ color = void 0;
+ switch (style) {
+ case 2:
+ bg = "#201";
+ color = "#f08";
+ break;
+
+ case 3:
+ bg = "#020";
+ color = "#0f0";
+ break;
+
+ default:
+ bg = "#002";
+ color = "#0ff";
+ }
- this.x -= v.x;
- this.y -= v.y;
+ this.container.style["background-color"] = bg;
+ this.container.style["color"] = color;
+ }
- return this;
+ if (!this.container.parentNode) {
+ body = body || this.body || document.body;
+ body.appendChild(this.container);
+ }
+ }
+ }, {
+ key: "getEmitter",
+ value: function getEmitter() {
+ return this.proton.emitters[this.emitterIndex];
+ }
+ }, {
+ key: "getRenderer",
+ value: function getRenderer() {
+ return this.proton.renderers[this.rendererIndex];
+ }
+ }, {
+ key: "concatArr",
+ value: function concatArr(arr) {
+ var result = '';
+ if (!arr || !arr.length) return result;
- },
+ for (var i = 0; i < arr.length; i++) {
+ result += (arr[i].name || '').substr(0, 1) + '.';
+ }
- subVectors : function(a, b) {
+ return result;
+ }
+ }, {
+ key: "getCreatedNumber",
+ value: function getCreatedNumber(renderer) {
+ return renderer.pool.total || renderer.cpool && renderer.cpool.total || 0;
+ }
+ }, {
+ key: "getEmitterPos",
+ value: function getEmitterPos(e) {
+ return Math.round(e.p.x) + "," + Math.round(e.p.y);
+ }
+ }]);
+ return Stats;
+}();
- this.x = a.x - b.x;
- this.y = a.y - b.y;
+/*
+ * EventDispatcher
+ * This code reference since http://createjs.com/.
+ *
+ **/
- return this;
+var EventDispatcher = function () {
+ function EventDispatcher() {
+ classCallCheck(this, EventDispatcher);
- },
+ this._listeners = null;
+ }
- multiplyScalar : function(s) {
+ createClass(EventDispatcher, [{
+ key: "addEventListener",
+ value: function addEventListener(type, listener) {
+ if (!this._listeners) {
+ this._listeners = {};
+ } else {
+ this.removeEventListener(type, listener);
+ }
- this.x *= s;
- this.y *= s;
+ if (!this._listeners[type]) this._listeners[type] = [];
+ this._listeners[type].push(listener);
- return this;
+ return listener;
+ }
+ }, {
+ key: "removeEventListener",
+ value: function removeEventListener(type, listener) {
+ if (!this._listeners) return;
+ if (!this._listeners[type]) return;
- },
+ var arr = this._listeners[type];
+ var length = arr.length;
- divideScalar : function(s) {
+ for (var i = 0; i < length; i++) {
+ if (arr[i] == listener) {
+ if (length == 1) {
+ delete this._listeners[type];
+ }
- if (s !== 0) {
+ // allows for faster checks.
+ else {
+ arr.splice(i, 1);
+ }
- this.x /= s;
- this.y /= s;
+ break;
+ }
+ }
+ }
+ }, {
+ key: "removeAllEventListeners",
+ value: function removeAllEventListeners(type) {
+ if (!type) this._listeners = null;else if (this._listeners) delete this._listeners[type];
+ }
+ }, {
+ key: "dispatchEvent",
+ value: function dispatchEvent(type, args) {
+ var result = false;
+ var listeners = this._listeners;
+
+ if (type && listeners) {
+ var arr = listeners[type];
+ if (!arr) return result;
+
+ //arr = arr.slice();
+ // to avoid issues with items being removed or added during the dispatch
+
+ var handler = void 0;
+ var i = arr.length;
+ while (i--) {
+ handler = arr[i];
+ result = result || handler(args);
+ }
+ }
- } else {
+ return !!result;
+ }
+ }, {
+ key: "hasEventListener",
+ value: function hasEventListener(type) {
+ var listeners = this._listeners;
+ return !!(listeners && listeners[type]);
+ }
+ }], [{
+ key: "bind",
+ value: function bind(TargetClass) {
+ TargetClass.prototype.dispatchEvent = EventDispatcher.prototype.dispatchEvent;
+ TargetClass.prototype.hasEventListener = EventDispatcher.prototype.hasEventListener;
+ TargetClass.prototype.addEventListener = EventDispatcher.prototype.addEventListener;
+ TargetClass.prototype.removeEventListener = EventDispatcher.prototype.removeEventListener;
+ TargetClass.prototype.removeAllEventListeners = EventDispatcher.prototype.removeAllEventListeners;
+ }
+ }]);
+ return EventDispatcher;
+}();
- this.set(0, 0);
+var Integration = function () {
+ function Integration(type) {
+ classCallCheck(this, Integration);
- }
+ this.type = type;
+ }
- return this;
+ createClass(Integration, [{
+ key: 'calculate',
+ value: function calculate(particles, time, damping) {
+ this.eulerIntegrate(particles, time, damping);
+ }
- },
+ // Euler Integrate
- min : function(v) {
+ }, {
+ key: 'eulerIntegrate',
+ value: function eulerIntegrate(particle, time, damping) {
+ if (!particle.sleep) {
+ particle.old.p.copy(particle.p);
+ particle.old.v.copy(particle.v);
- if (this.x > v.x) {
+ particle.a.multiplyScalar(1 / particle.mass);
+ particle.v.add(particle.a.multiplyScalar(time));
+ particle.p.add(particle.old.v.multiplyScalar(time));
- this.x = v.x;
+ if (damping) particle.v.multiplyScalar(damping);
+ particle.a.clear();
}
+ }
+ }]);
+ return Integration;
+}();
- if (this.y > v.y) {
-
- this.y = v.y;
-
- }
+var Proton$1 = function () {
- return this;
+ /**
+ * The constructor to add emitters
+ *
+ * @constructor Proton
+ *
+ * @todo proParticleCount is not in use
+ * @todo add more documentation of the single properties and parameters
+ *
+ * @param {Number} [proParticleCount] not in use?
+ * @param {Number} [integrationType=Proton.EULER]
+ *
+ * @property {String} [integrationType=Proton.EULER]
+ * @property {Array} emitters All added emitter
+ * @property {Array} renderers All added renderer
+ * @property {Number} time The active time
+ * @property {Number} oldtime The old time
+ */
+ function Proton(integrationType) {
+ classCallCheck(this, Proton);
- },
- max : function(v) {
+ this.emitters = [];
+ this.renderers = [];
- if (this.x < v.x) {
+ this.time = 0;
+ this.oldTime = 0;
+ this.elapsed = 0;
- this.x = v.x;
+ this.stats = new Stats(this);
+ this.pool = new Pool(80);
- }
+ this.integrationType = Util.initValue(integrationType, Proton.EULER);
+ this.integrator = new Integration(this.integrationType);
+ }
- if (this.y < v.y) {
+ /**
+ * add a type of Renderer
+ *
+ * @method addRenderer
+ * @memberof Proton
+ * @instance
+ *
+ * @param {Renderer} render
+ */
- this.y = v.y;
- }
+ //1:100
- return this;
- },
+ createClass(Proton, [{
+ key: 'addRenderer',
+ value: function addRenderer(render) {
+ render.init(this);
+ this.renderers.push(render);
+ }
- negate : function() {
+ /**
+ * @name add a type of Renderer
+ *
+ * @method addRenderer
+ * @param {Renderer} render
+ */
+
+ }, {
+ key: 'removeRenderer',
+ value: function removeRenderer(render) {
+ var index = this.renderers.indexOf(render);
+ this.renderers.splice(index, 1);
+ render.remove(this);
+ }
- return this.multiplyScalar(-1);
+ /**
+ * add the Emitter
+ *
+ * @method addEmitter
+ * @memberof Proton
+ * @instance
+ *
+ * @param {Emitter} emitter
+ */
- },
+ }, {
+ key: 'addEmitter',
+ value: function addEmitter(emitter) {
+ this.emitters.push(emitter);
+ emitter.parent = this;
- dot : function(v) {
+ this.dispatchEvent(Proton.EMITTER_ADDED, emitter);
+ }
- return this.x * v.x + this.y * v.y;
+ /**
+ * Removes an Emitter
+ *
+ * @method removeEmitter
+ * @memberof Proton
+ * @instance
+ *
+ * @param {Proton.Emitter} emitter
+ */
- },
+ }, {
+ key: 'removeEmitter',
+ value: function removeEmitter(emitter) {
+ var index = this.emitters.indexOf(emitter);
+ this.emitters.splice(index, 1);
+ emitter.parent = null;
- lengthSq : function() {
+ this.dispatchEvent(Proton.EMITTER_REMOVED, emitter);
+ }
- return this.x * this.x + this.y * this.y;
+ /**
+ * Updates all added emitters
+ *
+ * @method update
+ * @memberof Proton
+ * @instance
+ */
- },
+ }, {
+ key: 'update',
+ value: function update() {
+ this.dispatchEvent(Proton.PROTON_UPDATE);
- length : function() {
+ if (Proton.USE_CLOCK) {
+ if (!this.oldTime) this.oldTime = new Date().getTime();
- return Math.sqrt(this.x * this.x + this.y * this.y);
+ var time = new Date().getTime();
+ this.elapsed = (time - this.oldTime) / 1000;
+ Proton.amendChangeTabsBug && this.amendChangeTabsBug();
- },
+ this.oldTime = time;
+ } else {
+ this.elapsed = 0.0167;
+ }
- normalize : function() {
+ // emitter update
+ if (this.elapsed > 0) this.emittersUpdate(this.elapsed);
- return this.divideScalar(this.length());
+ this.dispatchEvent(Proton.PROTON_UPDATE_AFTER);
+ }
+ }, {
+ key: 'emittersUpdate',
+ value: function emittersUpdate(elapsed) {
+ var i = this.emitters.length;
+ while (i--) {
+ this.emitters[i].update(elapsed);
+ }
+ }
- },
+ /**
+ * @todo add description
+ *
+ * @method amendChangeTabsBug
+ * @memberof Proton
+ * @instance
+ */
- distanceTo : function(v) {
+ }, {
+ key: 'amendChangeTabsBug',
+ value: function amendChangeTabsBug() {
+ if (this.elapsed > .5) {
+ this.oldTime = new Date().getTime();
+ this.elapsed = 0;
+ }
+ }
- return Math.sqrt(this.distanceToSquared(v));
+ /**
+ * Counts all particles from all emitters
+ *
+ * @method getCount
+ * @memberof Proton
+ * @instance
+ */
- },
+ }, {
+ key: 'getCount',
+ value: function getCount() {
+ var total = 0;
+ var i = this.emitters.length;
- rotate : function(tha) {
- var x = this.x;
- var y = this.y;
- this.x = x * Math.cos(tha) + y * Math.sin(tha);
- this.y = -x * Math.sin(tha) + y * Math.cos(tha);
- return this;
- },
+ while (i--) {
+ total += this.emitters[i].particles.length;
+ }return total;
+ }
+ }, {
+ key: 'getAllParticles',
+ value: function getAllParticles() {
+ var particles = [];
+ var i = this.emitters.length;
- distanceToSquared : function(v) {
+ while (i--) {
+ particles = particles.concat(this.emitters[i].particles);
+ }return particles;
+ }
- var dx = this.x - v.x, dy = this.y - v.y;
- return dx * dx + dy * dy;
+ /**
+ * Destroys everything related to this Proton instance. This includes all emitters, and all properties
+ *
+ * @method destroy
+ * @memberof Proton
+ * @instance
+ */
- },
+ }, {
+ key: 'destroy',
+ value: function destroy() {
+ Util.destroy(this.renderers, this.getAllParticles());
+ Util.destroy(this.emitters);
- setLength : function(l) {
+ this.time = 0;
+ this.oldTime = 0;
- var oldLength = this.length();
+ this.pool.destroy();
+ }
+ }]);
+ return Proton;
+}();
+
+Proton$1.USE_CLOCK = false;
+Proton$1.MEASURE = 100;
+Proton$1.EULER = 'euler';
+Proton$1.RK2 = 'runge-kutta2';
+Proton$1.PARTICLE_CREATED = 'PARTICLE_CREATED';
+Proton$1.PARTICLE_UPDATE = 'PARTICLE_UPDATE';
+Proton$1.PARTICLE_SLEEP = 'PARTICLE_SLEEP';
+Proton$1.PARTICLE_DEAD = 'PARTICLE_DEAD';
+Proton$1.PROTON_UPDATE = 'PROTON_UPDATE';
+Proton$1.PROTON_UPDATE_AFTER = 'PROTON_UPDATE_AFTER';
+Proton$1.EMITTER_ADDED = 'EMITTER_ADDED';
+Proton$1.EMITTER_REMOVED = 'EMITTER_REMOVED';
+Proton$1.amendChangeTabsBug = true;
+Proton$1.bindEmtterEvent = false;
+EventDispatcher.bind(Proton$1);
+
+var ease = {
+ easeLinear: function easeLinear(value) {
+ return value;
+ },
+ easeInQuad: function easeInQuad(value) {
+ return Math.pow(value, 2);
+ },
+ easeOutQuad: function easeOutQuad(value) {
+ return -(Math.pow(value - 1, 2) - 1);
+ },
+ easeInOutQuad: function easeInOutQuad(value) {
+ if ((value /= 0.5) < 1) return 0.5 * Math.pow(value, 2);
+
+ return -0.5 * ((value -= 2) * value - 2);
+ },
+ easeInCubic: function easeInCubic(value) {
+ return Math.pow(value, 3);
+ },
+ easeOutCubic: function easeOutCubic(value) {
+ return Math.pow(value - 1, 3) + 1;
+ },
+ easeInOutCubic: function easeInOutCubic(value) {
+ if ((value /= 0.5) < 1) return 0.5 * Math.pow(value, 3);
+
+ return 0.5 * (Math.pow(value - 2, 3) + 2);
+ },
+ easeInQuart: function easeInQuart(value) {
+ return Math.pow(value, 4);
+ },
+ easeOutQuart: function easeOutQuart(value) {
+ return -(Math.pow(value - 1, 4) - 1);
+ },
+ easeInOutQuart: function easeInOutQuart(value) {
+ if ((value /= 0.5) < 1) return 0.5 * Math.pow(value, 4);
+
+ return -0.5 * ((value -= 2) * Math.pow(value, 3) - 2);
+ },
+ easeInSine: function easeInSine(value) {
+ return -Math.cos(value * MathUtils.PI_2) + 1;
+ },
+ easeOutSine: function easeOutSine(value) {
+ return Math.sin(value * MathUtils.PI_2);
+ },
+ easeInOutSine: function easeInOutSine(value) {
+ return -0.5 * (Math.cos(MathUtils.PI * value) - 1);
+ },
+ easeInExpo: function easeInExpo(value) {
+ return value === 0 ? 0 : Math.pow(2, 10 * (value - 1));
+ },
+ easeOutExpo: function easeOutExpo(value) {
+ return value === 1 ? 1 : -Math.pow(2, -10 * value) + 1;
+ },
+ easeInOutExpo: function easeInOutExpo(value) {
+ if (value === 0) return 0;
+
+ if (value === 1) return 1;
+
+ if ((value /= 0.5) < 1) return 0.5 * Math.pow(2, 10 * (value - 1));
+
+ return 0.5 * (-Math.pow(2, -10 * --value) + 2);
+ },
+ easeInCirc: function easeInCirc(value) {
+ return -(Math.sqrt(1 - value * value) - 1);
+ },
+ easeOutCirc: function easeOutCirc(value) {
+ return Math.sqrt(1 - Math.pow(value - 1, 2));
+ },
+ easeInOutCirc: function easeInOutCirc(value) {
+ if ((value /= 0.5) < 1) return -0.5 * (Math.sqrt(1 - value * value) - 1);
+ return 0.5 * (Math.sqrt(1 - (value -= 2) * value) + 1);
+ },
+ easeInBack: function easeInBack(value) {
+ var s = 1.70158;
+ return value * value * ((s + 1) * value - s);
+ },
+ easeOutBack: function easeOutBack(value) {
+ var s = 1.70158;
+ return (value = value - 1) * value * ((s + 1) * value + s) + 1;
+ },
+ easeInOutBack: function easeInOutBack(value) {
+ var s = 1.70158;
+ if ((value /= 0.5) < 1) return 0.5 * (value * value * (((s *= 1.525) + 1) * value - s));
+ return 0.5 * ((value -= 2) * value * (((s *= 1.525) + 1) * value + s) + 2);
+ },
+ getEasing: function getEasing(ease) {
+ if (typeof ease === 'function') return ease;else return this[ease] || this.easeLinear;
+ }
+};
- if (oldLength !== 0 && l !== oldLength) {
+var Particle = function () {
- this.multiplyScalar(l / oldLength);
- }
+ /**
+ * the Particle class
+ *
+ * @class Proton.Particle
+ * @constructor
+ * @param {Object} pObj the parameters object;
+ * for example {life:3,dead:false}
+ */
+ function Particle(pOBJ) {
+ classCallCheck(this, Particle);
- return this;
+ /**
+ * The particle's id;
+ * @property id
+ * @type {string}
+ */
+ this.id = 'particle_' + Particle.ID++;
+ this.reset('init');
- },
+ pOBJ && Util.setPrototypeByObject(this, pOBJ);
+ }
- lerp : function(v, alpha) {
+ createClass(Particle, [{
+ key: 'getDirection',
+ value: function getDirection() {
+ return Math.atan2(this.v.x, -this.v.y) * MathUtils.N180_PI;
+ }
+ }, {
+ key: 'reset',
+ value: function reset(init) {
+ this.life = Infinity;
+ this.age = 0;
+
+ //Energy loss
+ this.energy = 1;
+ this.dead = false;
+ this.sleep = false;
+ this.body = null;
+ this.sprite = null;
+ this.parent = null;
+
+ this.mass = 1;
+ this.radius = 10;
+ this.alpha = 1;
+ this.scale = 1;
+ this.rotation = 0;
+ this.color = null;
+
+ this.easing = ease.easeLinear;
+
+ if (init == 'init') {
+ this.transform = {};
+ this.p = new Vector2D();
+ this.v = new Vector2D();
+ this.a = new Vector2D();
+
+ this.old = {
+ p: new Vector2D(),
+ v: new Vector2D(),
+ a: new Vector2D()
+ };
+
+ this.behaviours = [];
+ } else {
+ Util.destroyObject(this.transform, 'rgb');
- this.x += (v.x - this.x ) * alpha;
- this.y += (v.y - this.y ) * alpha;
+ this.p.set(0, 0);
+ this.v.set(0, 0);
+ this.a.set(0, 0);
- return this;
+ this.old.p.set(0, 0);
+ this.old.v.set(0, 0);
+ this.old.a.set(0, 0);
- },
+ this.removeAllBehaviours();
+ }
- equals : function(v) {
+ if (!this.transform.rgb) {
+ this.transform.rgb = { r: 255, g: 255, b: 255 };
+ } else {
+ this.transform.rgb.r = 255;
+ this.transform.rgb.g = 255;
+ this.transform.rgb.b = 255;
+ }
- return ((v.x === this.x ) && (v.y === this.y ) );
+ return this;
+ }
+ }, {
+ key: 'update',
+ value: function update(time, index) {
+ if (!this.sleep) {
+ this.age += time;
+ this.applyBehaviours(time, index);
+ }
- },
+ if (this.age < this.life) {
+ var scale = this.easing(this.age / this.life);
+ this.energy = Math.max(1 - scale, 0);
+ } else {
+ this.destroy();
+ }
+ }
+ }, {
+ key: 'applyBehaviours',
+ value: function applyBehaviours(time, index) {
+ var length = this.behaviours.length;
+ var i = void 0;
+
+ for (i = 0; i < length; i++) {
+ this.behaviours[i] && this.behaviours[i].applyBehaviour(this, time, index);
+ }
+ }
+ }, {
+ key: 'addBehaviour',
+ value: function addBehaviour(behaviour) {
+ this.behaviours.push(behaviour);
- toArray : function() {
+ if (behaviour.hasOwnProperty('parents')) behaviour.parents.push(this);
+ behaviour.initialize(this);
+ }
+ }, {
+ key: 'addBehaviours',
+ value: function addBehaviours(behaviours) {
+ var length = behaviours.length;
+ var i = void 0;
+
+ for (i = 0; i < length; i++) {
+ this.addBehaviour(behaviours[i]);
+ }
+ }
+ }, {
+ key: 'removeBehaviour',
+ value: function removeBehaviour(behaviour) {
+ var index = this.behaviours.indexOf(behaviour);
+
+ if (index > -1) {
+ var _behaviour = this.behaviours.splice(index, 1);
+ _behaviour.parents = null;
+ }
+ }
+ }, {
+ key: 'removeAllBehaviours',
+ value: function removeAllBehaviours() {
+ Util.destroyArray(this.behaviours);
+ }
- return [this.x, this.y];
+ /**
+ * Destory this particle
+ * @method destroy
+ */
- },
+ }, {
+ key: 'destroy',
+ value: function destroy() {
+ this.removeAllBehaviours();
+ this.energy = 0;
+ this.dead = true;
+ this.parent = null;
+ }
+ }]);
+ return Particle;
+}();
- clear : function() {
- this.x = 0.0;
- this.y = 0.0;
- return this;
- },
+Particle.ID = 0;
- clone : function() {
+var ColorUtil = {
- return new Proton.Vector2D(this.x, this.y);
+ /**
+ * @typedef {Object} rgbObject
+ * @property {Number} r red value
+ * @property {Number} g green value
+ * @property {Number} b blue value
+ */
+ /**
+ * converts a hex value to a rgb object
+ *
+ * @memberof Proton#Proton.Util
+ * @method hexToRGB
+ *
+ * @param {String} h any hex value, e.g. #000000 or 000000 for black
+ *
+ * @return {rgbObject}
+ */
+ hexToRGB: function hexToRGB(h) {
+ var hex16 = h.charAt(0) == "#" ? h.substring(1, 7) : h;
+ var r = parseInt(hex16.substring(0, 2), 16);
+ var g = parseInt(hex16.substring(2, 4), 16);
+ var b = parseInt(hex16.substring(4, 6), 16);
- }
- };
+ return { r: r, g: g, b: b };
+ },
- Proton.Vector2D = Vector2D;
+ /**
+ * converts a rgb value to a rgb string
+ *
+ * @memberof Proton#Proton.Util
+ * @method rgbToHex
+ *
+ * @param {Object | Proton.hexToRGB} rgb a rgb object like in {@link Proton#Proton.}
+ *
+ * @return {String} rgb()
+ */
+ rgbToHex: function rgbToHex(rbg) {
+ return "rgb(" + rbg.r + ", " + rbg.g + ", " + rbg.b + ")";
+ },
+ getHex16FromParticle: function getHex16FromParticle(p) {
+ return Number(p.transform.rgb.r) * 65536 + Number(p.transform.rgb.g) * 256 + Number(p.transform.rgb.b);
+ }
+};
+var Polar2D = function () {
+ function Polar2D(r, tha) {
+ classCallCheck(this, Polar2D);
- var Polar2D = function(r, tha) {
this.r = Math.abs(r) || 0;
this.tha = tha || 0;
}
- Polar2D.prototype = {
- set : function(r, tha) {
-
+ createClass(Polar2D, [{
+ key: 'set',
+ value: function set$$1(r, tha) {
this.r = r;
this.tha = tha;
return this;
-
- },
-
- setR : function(r) {
-
+ }
+ }, {
+ key: 'setR',
+ value: function setR(r) {
this.r = r;
return this;
-
- },
-
- setTha : function(tha) {
-
+ }
+ }, {
+ key: 'setTha',
+ value: function setTha(tha) {
this.tha = tha;
-
return this;
-
- },
-
- copy : function(p) {
-
+ }
+ }, {
+ key: 'copy',
+ value: function copy(p) {
this.r = p.r;
this.tha = p.tha;
-
return this;
-
- },
-
- toVector : function() {
- return new Proton.Vector2D(this.getX(), this.getY());
- },
-
- getX : function() {
+ }
+ }, {
+ key: 'toVector',
+ value: function toVector() {
+ return new Vector2D(this.getX(), this.getY());
+ }
+ }, {
+ key: 'getX',
+ value: function getX() {
return this.r * Math.sin(this.tha);
- },
-
- getY : function() {
+ }
+ }, {
+ key: 'getY',
+ value: function getY() {
return -this.r * Math.cos(this.tha);
- },
-
- normalize : function() {
-
+ }
+ }, {
+ key: 'normalize',
+ value: function normalize() {
this.r = 1;
return this;
- },
-
- equals : function(v) {
-
- return ((v.r === this.r ) && (v.tha === this.tha ) );
-
- },
-
- toArray : function() {
-
- return [this.r, this.tha];
-
- },
-
- clear : function() {
+ }
+ }, {
+ key: 'equals',
+ value: function equals(v) {
+ return v.r === this.r && v.tha === this.tha;
+ }
+ }, {
+ key: 'clear',
+ value: function clear() {
this.r = 0.0;
this.tha = 0.0;
return this;
- },
-
- clone : function() {
-
- return new Proton.Polar2D(this.r, this.tha);
-
- }
- };
-
- Proton.Polar2D = Polar2D;
-
-
-
- function Span(a, b, center) {
- this.isArray = false;
-
- if (Proton.Util.isArray(a)) {
- this.isArray = true;
- this.a = a;
- } else {
- this.a = Proton.Util.initValue(a, 1);
- this.b = Proton.Util.initValue(b, this.a);
- this.center = Proton.Util.initValue(center, false);
- }
- }
-
-
- Span.prototype = {
- getValue : function(INT) {
- if (this.isArray) {
- return this.a[Math.floor(this.a.length * Math.random())];
- } else {
- if (!this.center)
- return Proton.MathUtils.randomAToB(this.a, this.b, INT);
- else
- return Proton.MathUtils.randomFloating(this.a, this.b, INT);
- }
}
- }
-
- Proton.Span = Span;
- Proton.getSpan = function(a, b, center) {
- return new Proton.Span(a, b, center);
- }
-
-
-
- function ColorSpan(color) {
- if (Proton.Util.isArray(color)) {
- this.colorArr = color;
- } else {
- this.colorArr = [color];
+ }, {
+ key: 'clone',
+ value: function clone() {
+ return new Polar2D(this.r, this.tha);
}
- }
-
+ }]);
+ return Polar2D;
+}();
+
+var Mat3 = {
+ create: function create(mat3) {
+ var mat = new Float32Array(9);
+ if (mat3) this.set(mat3, mat);
+
+ return mat;
+ },
+ set: function set(mat1, mat2) {
+ for (var i = 0; i < 9; i++) {
+ mat2[i] = mat1[i];
+ }return mat2;
+ },
+ multiply: function multiply(mat, mat2, mat3) {
+ var a00 = mat[0],
+ a01 = mat[1],
+ a02 = mat[2],
+ a10 = mat[3],
+ a11 = mat[4],
+ a20 = mat[6],
+ a21 = mat[7],
+ b00 = mat2[0],
+ b01 = mat2[1],
+ b02 = mat2[2],
+ b10 = mat2[3],
+ b11 = mat2[4],
+ b20 = mat2[6],
+ b21 = mat2[7];
+
+ mat3[0] = b00 * a00 + b01 * a10;
+ mat3[1] = b00 * a01 + b01 * a11;
+ mat3[2] = a02 * b02;
+ mat3[3] = b10 * a00 + b11 * a10;
+ mat3[4] = b10 * a01 + b11 * a11;
+ mat3[6] = b20 * a00 + b21 * a10 + a20;
+ mat3[7] = b20 * a01 + b21 * a11 + a21;
+
+ return mat3;
+ },
+ inverse: function inverse(mat, mat3) {
+ var a00 = mat[0],
+ a01 = mat[1],
+ a10 = mat[3],
+ a11 = mat[4],
+ a20 = mat[6],
+ a21 = mat[7],
+ b01 = a11,
+ b11 = -a10,
+ b21 = a21 * a10 - a11 * a20,
+ d = a00 * b01 + a01 * b11,
+ id = void 0;
+
+ id = 1 / d;
+ mat3[0] = b01 * id;
+ mat3[1] = -a01 * id;
+ mat3[3] = b11 * id;
+ mat3[4] = a00 * id;
+ mat3[6] = b21 * id;
+ mat3[7] = (-a21 * a00 + a01 * a20) * id;
+
+ return mat3;
+ },
+ multiplyVec2: function multiplyVec2(m, vec, mat3) {
+ var x = vec[0],
+ y = vec[1];
+
+ mat3[0] = x * m[0] + y * m[3] + m[6];
+ mat3[1] = x * m[1] + y * m[4] + m[7];
+
+ return mat3;
+ }
+};
+
+var ArraySpan = function (_Span) {
+ inherits(ArraySpan, _Span);
+
+ function ArraySpan(color) {
+ classCallCheck(this, ArraySpan);
+
+ var _this = possibleConstructorReturn(this, (ArraySpan.__proto__ || Object.getPrototypeOf(ArraySpan)).call(this));
+
+ _this._arr = Util.isArray(color) ? color : [color];
+ return _this;
+ }
- Proton.Util.inherits(ColorSpan, Proton.Span);
- ColorSpan.prototype.getValue = function() {
- var color = this.colorArr[Math.floor(this.colorArr.length * Math.random())];
- if (color == 'random' || color == 'Random')
- return Proton.MathUtils.randomColor();
- else
- return color;
- }
+ createClass(ArraySpan, [{
+ key: 'getValue',
+ value: function getValue() {
+ var color = this._arr[Math.floor(this._arr.length * Math.random())];
+ return color === 'random' || color === 'Random' ? MathUtils.randomColor() : color;
+ }
- Proton.ColorSpan = ColorSpan;
+ /**
+ * Make sure that the color is an instance of Proton.ArraySpan, if not it makes a new instance
+ *
+ * @method setSpanValue
+ * @memberof Proton#Proton.Color
+ * @instance
+ *
+ * @param {Proton.Particle} particle
+ * @param {Number} the integrate time 1/ms
+ * @param {Int} the particle index
+ */
+ }], [{
+ key: 'createArraySpan',
+ value: function createArraySpan(arr) {
+ if (!arr) return null;
+ if (arr instanceof ArraySpan) return arr;else return new ArraySpan(arr);
+ }
+ }]);
+ return ArraySpan;
+}(Span);
+var Rectangle = function () {
function Rectangle(x, y, w, h) {
+ classCallCheck(this, Rectangle);
+
this.x = x;
this.y = y;
+
this.width = w;
this.height = h;
+
this.bottom = this.y + this.height;
this.right = this.x + this.width;
}
-
- Rectangle.prototype = {
- contains : function(x, y) {
- if (x <= this.right && x >= this.x && y <= this.bottom && y >= this.y)
- return true
- else
- return false
- }
- }
-
- Proton.Rectangle = Rectangle;
-
-
-
- var Mat3 = Mat3 || {
- create : function(mat3) {
- var mat = new Float32Array(9);
- if (mat3)
- this.set(mat3, mat);
- return mat;
- },
- set : function(mat1, mat2) {
- for (var i = 0; i < 9; i++)
- mat2[i] = mat1[i];
- return mat2;
- },
- multiply : function(mat, mat2, mat3) {
- var a00 = mat[0], a01 = mat[1], a02 = mat[2], a10 = mat[3], a11 = mat[4], a20 = mat[6], a21 = mat[7], b00 = mat2[0], b01 = mat2[1], b02 = mat2[2], b10 = mat2[3], b11 = mat2[4], b20 = mat2[6], b21 = mat2[7];
-
- mat3[0] = b00 * a00 + b01 * a10;
- mat3[1] = b00 * a01 + b01 * a11;
- mat3[2] = a02 * b02;
- mat3[3] = b10 * a00 + b11 * a10;
- mat3[4] = b10 * a01 + b11 * a11;
- mat3[6] = b20 * a00 + b21 * a10 + a20;
- mat3[7] = b20 * a01 + b21 * a11 + a21;
- return mat3;
- },
- inverse : function(mat, mat3) {
- var a00 = mat[0], a01 = mat[1], a10 = mat[3], a11 = mat[4], a20 = mat[6], a21 = mat[7], b01 = a11, b11 = -a10, b21 = a21 * a10 - a11 * a20, d = a00 * b01 + a01 * b11, id;
- id = 1 / d;
- mat3[0] = b01 * id;
- mat3[1] = (-a01 ) * id;
- mat3[3] = b11 * id;
- mat3[4] = a00 * id;
- mat3[6] = b21 * id;
- mat3[7] = (-a21 * a00 + a01 * a20) * id;
- return mat3;
- },
- multiplyVec2 : function(m, vec, mat3) {
- var x = vec[0], y = vec[1];
- mat3[0] = x * m[0] + y * m[3] + m[6];
- mat3[1] = x * m[1] + y * m[4] + m[7];
- return mat3;
+ createClass(Rectangle, [{
+ key: "contains",
+ value: function contains(x, y) {
+ if (x <= this.right && x >= this.x && y <= this.bottom && y >= this.y) return true;else return false;
}
- }
-
- Proton.Mat3 = Mat3;
-
+ }]);
+ return Rectangle;
+}();
-
- Behaviour.id = 0;
+var Rate = function () {
/**
- * The Behaviour class is the base for the other Behaviour
- *
- * @memberof! -
- * @interface
- * @alias Proton.Behaviour
- *
- * @param {Number} life the behaviours life
- * @param {String} easing The behaviour's decaying trend, for example Proton.easeOutQuart
- *
- * @property {String} id The behaviours id
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- * @property {Number} age=0 How long the particle should be 'alife'
- * @property {Number} energy=1
- * @property {Boolean} dead=false The particle is dead at first
- * @property {Array} parents The behaviour's parents array
- * @property {String} name The behaviour name
- */
- function Behaviour(life, easing) {
- this.id = 'Behaviour_' + Behaviour.id++;
- this.life = Proton.Util.initValue(life, Infinity);
- this.easing = Proton.ease.setEasingByName(easing);
- this.age = 0;
- this.energy = 1;
- this.dead = false;
- this.parents = [];
- this.name = 'Behaviour';
- }
-
-
- Behaviour.prototype = {
- /**
- * Reset this behaviour's parameters
- *
- * @method reset
- * @memberof Proton.Behaviour
- * @instance
- *
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=easeLinear] this behaviour's easing
- */
- reset : function(life, easing) {
- this.life = Proton.Util.initValue(life, Infinity);
- this.easing = Proton.Util.initValue(easing, Proton.ease.setEasingByName(Proton.easeLinear));
- },
- /**
- * Normalize a force by 1:100;
- *
- * @method normalizeForce
- * @memberof Proton.Behaviour
- * @instance
- *
- * @param {Proton.Vector2D} force
- */
- normalizeForce : function(force) {
- return force.multiplyScalar(Proton.MEASURE);
- },
-
- /**
- * Normalize a value by 1:100;
- *
- * @method normalizeValue
- * @memberof Proton.Behaviour
- * @instance
- *
- * @param {Number} value
- */
- normalizeValue : function(value) {
- return value * Proton.MEASURE;
- },
-
- /**
- * Initialize the behaviour's parameters for all particles
- *
- * @method initialize
- * @memberof Proton.Behaviour
- * @instance
- *
- * @param {Proton.Particle} particle
- */
- initialize : function(particle) {
- },
-
- /**
- * Apply this behaviour for all particles every time
- *
- * @method applyBehaviour
- * @memberof Proton.Behaviour
- * @instance
- *
- * @param {Proton.Particle} particle
- * @param {Number} time the integrate time 1/ms
- * @param {Int} index the particle index
- */
- applyBehaviour : function(particle, time, index) {
- this.age += time;
- if (this.age >= this.life || this.dead) {
- this.energy = 0;
- this.dead = true;
- this.destroy();
- } else {
- var scale = this.easing(particle.age / particle.life);
- this.energy = Math.max(1 - scale, 0);
- }
- },
-
- /**
- * Destory this behaviour
- *
- * @method destroy
- * @memberof Proton.Behaviour
- * @instance
- */
- destroy : function() {
- var index;
- var length = this.parents.length, i;
- for ( i = 0; i < length; i++) {
- this.parents[i].removeBehaviour(this);
- }
-
- this.parents = [];
- }
- };
-
- Proton.Behaviour = Behaviour;
-
+ * The number of particles per second emission (a [particle]/b [s]);
+ * @namespace
+ * @memberof! Proton#
+ * @constructor
+ * @alias Rate
+ *
+ * @param {Array | Number | Span} numpan the number of each emission;
+ * @param {Array | Number | Span} timepan the time of each emission;
+ * for example: new Rate(new Span(10, 20), new Span(.1, .25));
+ */
+ function Rate(numpan, timepan) {
+ classCallCheck(this, Rate);
+ this.numPan = Util.setSpanValue(Util.initValue(numpan, 1));
+ this.timePan = Util.setSpanValue(Util.initValue(timepan, 1));
- /**
- * The number of particles per second emission (a [particle]/b [s]);
- * @namespace
- * @memberof! Proton#
- * @constructor
- * @alias Proton.Rate
- *
- * @param {Array | Number | Proton.Span} numpan the number of each emission;
- * @param {Array | Number | Proton.Span} timepan the time of each emission;
- * for example: new Proton.Rate(new Proton.Span(10, 20), new Proton.Span(.1, .25));
- */
- function Rate(numpan, timepan) {
- this.numPan = Proton.Util.initValue(numpan, 1);
- this.timePan = Proton.Util.initValue(timepan, 1);
- this.numPan = Proton.Util.setSpanValue(this.numPan);
- this.timePan = Proton.Util.setSpanValue(this.timePan);
this.startTime = 0;
this.nextTime = 0;
this.init();
}
-
- Rate.prototype = {
- /**
- * @method init
- * @memberof Proton#Proton.Rate
- * @instance
- */
- init : function() {
+ createClass(Rate, [{
+ key: 'init',
+ value: function init() {
this.startTime = 0;
this.nextTime = this.timePan.getValue();
- },
-
- getValue : function(time) {
+ }
+ }, {
+ key: 'getValue',
+ value: function getValue(time) {
this.startTime += time;
+
if (this.startTime >= this.nextTime) {
this.startTime = 0;
this.nextTime = this.timePan.getValue();
+
if (this.numPan.b == 1) {
- if (this.numPan.getValue(false) > 0.5)
- return 1;
- else
- return 0;
+ if (this.numPan.getValue(false) > 0.5) return 1;else return 0;
} else {
return this.numPan.getValue(true);
}
}
+
return 0;
}
+ }]);
+ return Rate;
+}();
+
+var Initialize = function () {
+ function Initialize() {
+ classCallCheck(this, Initialize);
+ }
+
+ createClass(Initialize, [{
+ key: "reset",
+ value: function reset() {}
+ }, {
+ key: "init",
+ value: function init(emitter, particle) {
+ if (particle) {
+ this.initialize(particle);
+ } else {
+ this.initialize(emitter);
+ }
+ }
+ }, {
+ key: "initialize",
+
+
+ ///sub class init
+ value: function initialize(target) {}
+ }]);
+ return Initialize;
+}();
+
+var Life = function (_Initialize) {
+ inherits(Life, _Initialize);
+
+ function Life(a, b, c) {
+ classCallCheck(this, Life);
+
+ var _this = possibleConstructorReturn(this, (Life.__proto__ || Object.getPrototypeOf(Life)).call(this));
+
+ _this.lifePan = Util.setSpanValue(a, b, c);
+ _this.name = 'Life';
+ return _this;
+ }
+
+ createClass(Life, [{
+ key: 'initialize',
+ value: function initialize(target) {
+ if (this.lifePan.a == Infinity) target.life = Infinity;else target.life = this.lifePan.getValue();
+ }
+ }]);
+ return Life;
+}(Initialize);
+
+var Zone = function () {
+ function Zone() {
+ classCallCheck(this, Zone);
+
+ this.vector = new Vector2D(0, 0);
+ this.random = 0;
+ this.crossType = "dead";
+ this.alert = true;
}
- Proton.Rate = Rate;
+ createClass(Zone, [{
+ key: "getPosition",
+ value: function getPosition() {}
+ }, {
+ key: "crossing",
+ value: function crossing(particle) {}
+ }]);
+ return Zone;
+}();
+var PointZone = function (_Zone) {
+ inherits(PointZone, _Zone);
+ function PointZone(x, y) {
+ classCallCheck(this, PointZone);
- function Initialize() {
+ var _this = possibleConstructorReturn(this, (PointZone.__proto__ || Object.getPrototypeOf(PointZone)).call(this));
+ _this.x = x;
+ _this.y = y;
+ return _this;
}
+ createClass(PointZone, [{
+ key: 'getPosition',
+ value: function getPosition() {
+ this.vector.x = this.x;
+ this.vector.y = this.y;
- Initialize.prototype.reset = function() {
-
- }
+ return this.vector;
+ }
+ }, {
+ key: 'crossing',
+ value: function crossing(particle) {
- Initialize.prototype.init = function(emitter, particle) {
- if (particle) {
- this.initialize(particle);
- } else {
- this.initialize(emitter);
+ if (this.alert) {
+ alert('Sorry PointZone does not support crossing method');
+ this.alert = false;
+ }
}
- };
+ }]);
+ return PointZone;
+}(Zone);
- ///sub class init
- Initialize.prototype.initialize = function(target) {
- };
+var Position = function (_Initialize) {
+ inherits(Position, _Initialize);
- Proton.Initialize = Initialize;
+ function Position(zone) {
+ classCallCheck(this, Position);
+ var _this = possibleConstructorReturn(this, (Position.__proto__ || Object.getPrototypeOf(Position)).call(this));
+ _this.zone = Util.initValue(zone, new PointZone());
- var InitializeUtil = {
+ _this.name = 'Position';
+ return _this;
+ }
- initialize : function(emitter, particle, initializes) {
- var length = initializes.length, i;
- for ( i = 0; i < length; i++) {
- if (initializes[i] instanceof Proton.Initialize)
- initializes[i].init(emitter, particle);
- else
- Proton.InitializeUtil.init(emitter, particle, initializes[i]);
- }
+ createClass(Position, [{
+ key: 'reset',
+ value: function reset(zone) {
+ this.zone = Util.initValue(zone, new PointZone());
+ }
+ }, {
+ key: 'initialize',
+ value: function initialize(target) {
+ this.zone.getPosition();
- Proton.InitializeUtil.bindEmitter(emitter, particle);
- },
-
- //////////////////////init//////////////////////
- init : function(emitter, particle, initialize) {
- Proton.Util.setPrototypeByObject(particle, initialize);
- Proton.Util.setVector2DByObject(particle, initialize);
- },
-
- bindEmitter : function(emitter, particle) {
- if (emitter.bindEmitter) {
- particle.p.add(emitter.p);
- particle.v.add(emitter.v);
- particle.a.add(emitter.a);
- particle.v.rotate(Proton.MathUtils.degreeTransform(emitter.rotation));
- }
+ target.p.x = this.zone.vector.x;
+ target.p.y = this.zone.vector.y;
}
- //////////////////////init//////////////////////
- }
+ }]);
+ return Position;
+}(Initialize);
- Proton.InitializeUtil = InitializeUtil;
+var Velocity = function (_Initialize) {
+ inherits(Velocity, _Initialize);
+ function Velocity(rpan, thapan, type) {
+ classCallCheck(this, Velocity);
+ var _this = possibleConstructorReturn(this, (Velocity.__proto__ || Object.getPrototypeOf(Velocity)).call(this));
- function Life(a, b, c) {
- Life._super_.call(this);
- this.lifePan = Proton.Util.setSpanValue(a, b, c);
- }
+ _this.rPan = Util.setSpanValue(rpan);
+ _this.thaPan = Util.setSpanValue(thapan);
+ _this.type = Util.initValue(type, 'vector');
+ _this.name = 'Velocity';
+ return _this;
+ }
- Proton.Util.inherits(Life, Proton.Initialize);
- Life.prototype.initialize = function(target) {
- if (this.lifePan.a == Infinity)
- target.life = Infinity;
- else
- target.life = this.lifePan.getValue();
- };
+ createClass(Velocity, [{
+ key: 'reset',
+ value: function reset(rpan, thapan, type) {
+ this.rPan = Util.setSpanValue(rpan);
+ this.thaPan = Util.setSpanValue(thapan);
+ this.type = Util.initValue(type, 'vector');
+ }
+ }, {
+ key: 'normalizeVelocity',
+ value: function normalizeVelocity(vr) {
+ return vr * Proton$1.MEASURE;
+ }
+ }, {
+ key: 'initialize',
+ value: function initialize(target) {
+ if (this.type == 'p' || this.type == 'P' || this.type == 'polar') {
+ var polar2d = new Polar2D(this.normalizeVelocity(this.rPan.getValue()), this.thaPan.getValue() * MathUtils.PI_180);
+
+ target.v.x = polar2d.getX();
+ target.v.y = polar2d.getY();
+ } else {
+ target.v.x = this.normalizeVelocity(this.rPan.getValue());
+ target.v.y = this.normalizeVelocity(this.thaPan.getValue());
+ }
+ }
+ }]);
+ return Velocity;
+}(Initialize);
- Proton.Life = Life;
+var Mass = function (_Initialize) {
+ inherits(Mass, _Initialize);
+ function Mass(a, b, c) {
+ classCallCheck(this, Mass);
+ var _this = possibleConstructorReturn(this, (Mass.__proto__ || Object.getPrototypeOf(Mass)).call(this));
- function Position(zone) {
- Position._super_.call(this);
- this.zone = Proton.Util.initValue(zone, new Proton.PointZone());
+ _this.massPan = Util.setSpanValue(a, b, c);
+ _this.name = 'Mass';
+ return _this;
}
+ createClass(Mass, [{
+ key: 'initialize',
+ value: function initialize(target) {
+ target.mass = this.massPan.getValue();
+ }
+ }]);
+ return Mass;
+}(Initialize);
- Proton.Util.inherits(Position, Proton.Initialize);
- Position.prototype.reset = function(zone) {
- this.zone = Proton.Util.initValue(zone, new Proton.PointZone());
- };
-
- Position.prototype.initialize = function(target) {
- this.zone.getPosition();
- target.p.x = this.zone.vector.x;
- target.p.y = this.zone.vector.y;
- };
+var Radius = function (_Initialize) {
+ inherits(Radius, _Initialize);
- Proton.Position = Position;
- Proton.P = Position;
+ function Radius(a, b, c) {
+ classCallCheck(this, Radius);
+ var _this = possibleConstructorReturn(this, (Radius.__proto__ || Object.getPrototypeOf(Radius)).call(this));
+ _this.radius = Util.setSpanValue(a, b, c);
- //radius and tha
- function Velocity(rpan, thapan, type) {
- Velocity._super_.call(this);
- this.rPan = Proton.Util.setSpanValue(rpan);
- this.thaPan = Proton.Util.setSpanValue(thapan);
- this.type = Proton.Util.initValue(type, 'vector');
+ _this.name = 'Radius';
+ return _this;
}
+ createClass(Radius, [{
+ key: 'reset',
+ value: function reset(a, b, c) {
+ this.radius = Util.setSpanValue(a, b, c);
+ }
+ }, {
+ key: 'initialize',
+ value: function initialize(particle) {
+ particle.radius = this.radius.getValue();
+ particle.transform.oldRadius = particle.radius;
+ }
+ }]);
+ return Radius;
+}(Initialize);
+
+var Body = function (_Initialize) {
+ inherits(Body, _Initialize);
- Proton.Util.inherits(Velocity, Proton.Initialize);
+ function Body(image, w, h) {
+ classCallCheck(this, Body);
- Velocity.prototype.reset = function(rpan, thapan, type) {
- this.rPan = Proton.Util.setSpanValue(rpan);
- this.thaPan = Proton.Util.setSpanValue(thapan);
- this.type = Proton.Util.initValue(type, 'vector');
- };
+ var _this = possibleConstructorReturn(this, (Body.__proto__ || Object.getPrototypeOf(Body)).call(this));
- Velocity.prototype.normalizeVelocity = function(vr) {
- return vr * Proton.MEASURE;
- }
+ _this.image = _this.setSpanValue(image);
+ _this.w = Util.initValue(w, 20);
+ _this.h = Util.initValue(h, _this.w);
+ _this.name = 'Body';
+ return _this;
+ }
- Velocity.prototype.initialize = function(target) {
- if (this.type == 'p' || this.type == 'P' || this.type == 'polar') {
- var polar2d = new Proton.Polar2D(this.normalizeVelocity(this.rPan.getValue()), this.thaPan.getValue() * Math.PI / 180);
- target.v.x = polar2d.getX();
- target.v.y = polar2d.getY();
- } else {
- target.v.x = this.normalizeVelocity(this.rPan.getValue());
- target.v.y = this.normalizeVelocity(this.thaPan.getValue());
- }
- };
+ createClass(Body, [{
+ key: 'initialize',
+ value: function initialize(particle) {
+ var imagetarget = this.image.getValue();
- Proton.Velocity = Velocity;
- Proton.V = Velocity;
+ if (typeof imagetarget == 'string') {
+ particle.body = { width: this.w, height: this.h, src: imagetarget, isInner: true, inner: true };
+ } else {
+ particle.body = imagetarget;
+ }
+ }
+ }, {
+ key: 'setSpanValue',
+ value: function setSpanValue(color) {
+ return color instanceof ArraySpan ? color : new ArraySpan(color);
+ }
+ }]);
+ return Body;
+}(Initialize);
+var Behaviour = function () {
+ /**
+ * The Behaviour class is the base for the other Behaviour
+ *
+ * @memberof! -
+ * @interface
+ * @alias Proton.Behaviour
+ *
+ * @param {Number} life the behaviours life
+ * @param {String} easing The behaviour's decaying trend, for example ease.easeOutQuart
+ *
+ * @property {String} id The behaviours id
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ * @property {Number} age=0 How long the particle should be 'alife'
+ * @property {Number} energy=1
+ * @property {Boolean} dead=false The particle is dead at first
+ * @property {Array} parents The behaviour's parents array
+ * @property {String} name The behaviour name
+ */
+ function Behaviour(life, easing) {
+ classCallCheck(this, Behaviour);
- function Mass(a, b, c) {
- Mass._super_.call(this);
- this.massPan = Proton.Util.setSpanValue(a, b, c);
- }
+ this.life = Util.initValue(life, Infinity);
+ this.easing = ease.getEasing(easing);
- Proton.Util.inherits(Mass, Proton.Initialize);
- Mass.prototype.initialize = function(target) {
- target.mass = this.massPan.getValue();
- };
+ this.age = 0;
+ this.energy = 1;
+ this.dead = false;
+ this.parents = [];
- Proton.Mass = Mass;
+ this.id = 'Behaviour_' + Behaviour.id++;
+ this.name = 'Behaviour';
+ }
+ /**
+ * Reset this behaviour's parameters
+ *
+ * @method reset
+ * @memberof Proton.Behaviour
+ * @instance
+ *
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=easeLinear] this behaviour's easing
+ */
- function Radius(a, b, c) {
- Radius._super_.call(this);
- this.radius = Proton.Util.setSpanValue(a, b, c);
- }
+ createClass(Behaviour, [{
+ key: 'reset',
+ value: function reset(life, easing) {
+ this.life = Util.initValue(life, Infinity);
+ this.easing = ease.getEasing(easing);
+ }
+ /**
+ * Normalize a force by 1:100;
+ *
+ * @method normalizeForce
+ * @memberof Proton.Behaviour
+ * @instance
+ *
+ * @param {Proton.Vector2D} force
+ */
- Proton.Util.inherits(Radius, Proton.Initialize);
- Radius.prototype.reset = function(a, b, c) {
- this.radius = Proton.Util.setSpanValue(a, b, c);
- };
+ }, {
+ key: 'normalizeForce',
+ value: function normalizeForce(force) {
+ return force.multiplyScalar(Proton$1.MEASURE);
+ }
- Radius.prototype.initialize = function(particle) {
- particle.radius = this.radius.getValue();
- particle.transform.oldRadius = particle.radius;
- };
+ /**
+ * Normalize a value by 1:100;
+ *
+ * @method normalizeValue
+ * @memberof Proton.Behaviour
+ * @instance
+ *
+ * @param {Number} value
+ */
- Proton.Radius = Radius;
+ }, {
+ key: 'normalizeValue',
+ value: function normalizeValue(value) {
+ return value * Proton$1.MEASURE;
+ }
+ /**
+ * Initialize the behaviour's parameters for all particles
+ *
+ * @method initialize
+ * @memberof Proton.Behaviour
+ * @instance
+ *
+ * @param {Proton.Particle} particle
+ */
+ }, {
+ key: 'initialize',
+ value: function initialize(particle) {}
- function ImageTarget(image, w, h) {
- ImageTarget._super_.call(this);
- this.image = this.setSpanValue(image);
- this.w = Proton.Util.initValue(w, 20);
- this.h = Proton.Util.initValue(h, this.w);
- }
+ /**
+ * Apply this behaviour for all particles every time
+ *
+ * @method applyBehaviour
+ * @memberof Proton.Behaviour
+ * @instance
+ *
+ * @param {Proton.Particle} particle
+ * @param {Number} time the integrate time 1/ms
+ * @param {Int} index the particle index
+ */
+ }, {
+ key: 'calculate',
+ value: function calculate(particle, time, index) {
+ this.age += time;
- Proton.Util.inherits(ImageTarget, Proton.Initialize);
- ImageTarget.prototype.initialize = function(particle) {
- var imagetarget = this.image.getValue();
- if ( typeof (imagetarget) == 'string') {
- particle.target = {
- width : this.w,
- height : this.h,
- src : imagetarget
- }
- } else {
- particle.target = imagetarget;
- }
- };
+ if (this.age >= this.life || this.dead) {
+ this.energy = 0;
+ this.dead = true;
+ this.destroy();
+ } else {
+ var scale = this.easing(particle.age / particle.life);
+ this.energy = Math.max(1 - scale, 0);
+ }
+ }
- ImageTarget.prototype.setSpanValue = function(color) {
- if ( color instanceof Proton.ColorSpan) {
- return color;
- } else {
- return new Proton.ColorSpan(color);
- }
- }
+ /**
+ * Destory this behaviour
+ *
+ * @method destroy
+ * @memberof Proton.Behaviour
+ * @instance
+ */
- Proton.ImageTarget = ImageTarget;
+ }, {
+ key: 'destroy',
+ value: function destroy() {
+ var i = this.parents.length;
+ while (i--) {
+ this.parents[i].removeBehaviour(this);
+ }
+ this.parents.length = 0;
+ }
+ }]);
+ return Behaviour;
+}();
+Behaviour.id = 0;
+var Force = function (_Behaviour) {
+ inherits(Force, _Behaviour);
/**
- * @memberof! Proton#
- * @augments Proton.Behaviour
- * @constructor
- * @alias Proton.Force
- *
- * @param {Number} fx
- * @param {Number} fy
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- *
- * @property {String} name The Behaviour name
- */
+ * @memberof! Proton#
+ * @augments Proton.Behaviour
+ * @constructor
+ * @alias Proton.Force
+ *
+ * @param {Number} fx
+ * @param {Number} fy
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ *
+ * @property {String} name The Behaviour name
+ */
function Force(fx, fy, life, easing) {
- Force._super_.call(this, life, easing);
- this.force = this.normalizeForce(new Proton.Vector2D(fx, fy));
- this.name = "Force";
- }
+ classCallCheck(this, Force);
+ var _this = possibleConstructorReturn(this, (Force.__proto__ || Object.getPrototypeOf(Force)).call(this, life, easing));
- Proton.Util.inherits(Force, Proton.Behaviour);
-
- /**
- * Reset this behaviour's parameters
- *
- * @method reset
- * @memberof Proton#Proton.Force
- * @instance
- *
- * @param {Number} fx
- * @param {Number} fy
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- */
- Force.prototype.reset = function(fx, fy, life, easing) {
- this.force = this.normalizeForce(new Proton.Vector2D(fx, fy));
- if (life)
- Force._super_.prototype.reset.call(this, life, easing);
+ _this.force = _this.normalizeForce(new Vector2D(fx, fy));
+ _this.name = "Force";
+ return _this;
}
/**
- * Apply this behaviour for all particles every time
- *
- * @method applyBehaviour
- * @memberof Proton#Proton.Force
- * @instance
- *
- * @param {Proton.Particle} particle
- * @param {Number} the integrate time 1/ms
- * @param {Int} the particle index
- */
- Force.prototype.applyBehaviour = function(particle, time, index) {
- Force._super_.prototype.applyBehaviour.call(this, particle, time, index);
- particle.a.add(this.force);
- };
-
- Proton.Force = Force;
- Proton.F = Force;
+ * Reset this behaviour's parameters
+ *
+ * @method reset
+ * @memberof Proton#Proton.Force
+ * @instance
+ *
+ * @param {Number} fx
+ * @param {Number} fy
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ */
+
+
+ createClass(Force, [{
+ key: 'reset',
+ value: function reset(fx, fy, life, easing) {
+ this.force = this.normalizeForce(new Vector2D(fx, fy));
+
+ life && get(Force.prototype.__proto__ || Object.getPrototypeOf(Force.prototype), 'reset', this).call(this, life, easing);
+ }
+ /**
+ * Apply this behaviour for all particles every time
+ *
+ * @method applyBehaviour
+ * @memberof Proton#Proton.Force
+ * @instance
+ *
+ * @param {Proton.Particle} particle
+ * @param {Number} the integrate time 1/ms
+ * @param {Int} the particle index
+ */
+
+ }, {
+ key: 'applyBehaviour',
+ value: function applyBehaviour(particle, time, index) {
+ this.calculate(particle, time, index);
+ particle.a.add(this.force);
+ }
+ }]);
+ return Force;
+}(Behaviour);
+var Attraction = function (_Behaviour) {
+ inherits(Attraction, _Behaviour);
/**
- * This behaviour let the particles follow one specific Proton.Vector2D
- *
- * @memberof! Proton#
- * @augments Proton.Behaviour
- * @constructor
- * @alias Proton.Attraction
- *
- * @todo add description for 'force' and 'radius'
- *
- * @param {Proton.Vector2D} targetPosition the attraction point coordinates
- * @param {Number} [force=100]
- * @param {Number} [radius=1000]
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- *
- * @property {Proton.Vector2D} targetPosition
- * @property {Number} radius
- * @property {Number} force
- * @property {Number} radiusSq
- * @property {Proton.Vector2D} attractionForce
- * @property {Number} lengthSq
- * @property {String} name The Behaviour name
- */
+ * This behaviour let the particles follow one specific Proton.Vector2D
+ *
+ * @memberof! Proton#
+ * @augments Proton.Behaviour
+ * @constructor
+ * @alias Proton.Attraction
+ *
+ * @todo add description for 'force' and 'radius'
+ *
+ * @param {Proton.Vector2D} targetPosition the attraction point coordinates
+ * @param {Number} [force=100]
+ * @param {Number} [radius=1000]
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ *
+ * @property {Proton.Vector2D} targetPosition
+ * @property {Number} radius
+ * @property {Number} force
+ * @property {Number} radiusSq
+ * @property {Proton.Vector2D} attractionForce
+ * @property {Number} lengthSq
+ * @property {String} name The Behaviour name
+ */
function Attraction(targetPosition, force, radius, life, easing) {
- Attraction._super_.call(this, life, easing);
-
- this.targetPosition = Proton.Util.initValue(targetPosition, new Proton.Vector2D);
- this.radius = Proton.Util.initValue(radius, 1000);
- this.force = Proton.Util.initValue(this.normalizeValue(force), 100);
- this.radiusSq = this.radius * this.radius
- this.attractionForce = new Proton.Vector2D();
- this.lengthSq = 0;
- this.name = "Attraction";
- }
+ classCallCheck(this, Attraction);
+ var _this = possibleConstructorReturn(this, (Attraction.__proto__ || Object.getPrototypeOf(Attraction)).call(this, life, easing));
- Proton.Util.inherits(Attraction, Proton.Behaviour);
+ _this.targetPosition = Util.initValue(targetPosition, new Vector2D());
+ _this.radius = Util.initValue(radius, 1000);
+ _this.force = Util.initValue(_this.normalizeValue(force), 100);
- /**
- * Reset this behaviour's parameters
- *
- * @method reset
- * @memberof Proton#Proton.Attraction
- * @instance
- *
- * @todo add description for 'force' and 'radius'
- *
- * @param {Proton.Vector2D} targetPosition the attraction point coordinates
- * @param {Number} [force=100]
- * @param {Number} [radius=1000]
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- */
- Attraction.prototype.reset = function(targetPosition, force, radius, life, easing) {
- this.targetPosition = Proton.Util.initValue(targetPosition, new Proton.Vector2D);
- this.radius = Proton.Util.initValue(radius, 1000);
- this.force = Proton.Util.initValue(this.normalizeValue(force), 100);
- this.radiusSq = this.radius * this.radius
- this.attractionForce = new Proton.Vector2D();
- this.lengthSq = 0;
- if (life)
- Attraction._super_.prototype.reset.call(this, life, easing);
+ _this.radiusSq = _this.radius * _this.radius;
+ _this.attractionForce = new Vector2D();
+ _this.lengthSq = 0;
+
+ _this.name = "Attraction";
+ return _this;
}
/**
- * Apply this behaviour for all particles every time
- *
- * @memberof Proton#Proton.Attraction
- * @method applyBehaviour
- * @instance
- *
- * @param {Proton.Particle} particle
- * @param {Number} time the integrate time 1/ms
- * @param {Int} index the particle index
- */
- Attraction.prototype.applyBehaviour = function(particle, time, index) {
- Attraction._super_.prototype.applyBehaviour.call(this, particle, time, index);
- this.attractionForce.copy(this.targetPosition);
- this.attractionForce.sub(particle.p);
- this.lengthSq = this.attractionForce.lengthSq();
- if (this.lengthSq > 0.000004 && this.lengthSq < this.radiusSq) {
- this.attractionForce.normalize();
- this.attractionForce.multiplyScalar(1 - this.lengthSq / this.radiusSq);
- this.attractionForce.multiplyScalar(this.force);
- particle.a.add(this.attractionForce);
+ * Reset this behaviour's parameters
+ *
+ * @method reset
+ * @memberof Proton#Proton.Attraction
+ * @instance
+ *
+ * @todo add description for 'force' and 'radius'
+ *
+ * @param {Proton.Vector2D} targetPosition the attraction point coordinates
+ * @param {Number} [force=100]
+ * @param {Number} [radius=1000]
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ */
+
+
+ createClass(Attraction, [{
+ key: 'reset',
+ value: function reset(targetPosition, force, radius, life, easing) {
+ this.targetPosition = Util.initValue(targetPosition, new Vector2D());
+ this.radius = Util.initValue(radius, 1000);
+ this.force = Util.initValue(this.normalizeValue(force), 100);
+
+ this.radiusSq = this.radius * this.radius;
+ this.attractionForce = new Vector2D();
+ this.lengthSq = 0;
+
+ life && get(Attraction.prototype.__proto__ || Object.getPrototypeOf(Attraction.prototype), 'reset', this).call(this, life, easing);
}
- };
- Proton.Attraction = Attraction;
+ /**
+ * Apply this behaviour for all particles every time
+ *
+ * @memberof Proton#Proton.Attraction
+ * @method applyBehaviour
+ * @instance
+ *
+ * @param {Proton.Particle} particle
+ * @param {Number} time the integrate time 1/ms
+ * @param {Int} index the particle index
+ */
+
+ }, {
+ key: 'applyBehaviour',
+ value: function applyBehaviour(particle, time, index) {
+ this.calculate(particle, time, index);
+
+ this.attractionForce.copy(this.targetPosition);
+ this.attractionForce.sub(particle.p);
+ this.lengthSq = this.attractionForce.lengthSq();
+
+ if (this.lengthSq > 0.000004 && this.lengthSq < this.radiusSq) {
+ this.attractionForce.normalize();
+ this.attractionForce.multiplyScalar(1 - this.lengthSq / this.radiusSq);
+ this.attractionForce.multiplyScalar(this.force);
+
+ particle.a.add(this.attractionForce);
+ }
+ }
+ }]);
+ return Attraction;
+}(Behaviour);
+var RandomDrift = function (_Behaviour) {
+ inherits(RandomDrift, _Behaviour);
+ /**
+ * @memberof! Proton#
+ * @augments Behaviour
+ * @constructor
+ * @alias RandomDrift
+ *
+ * @param {Number} driftX X value of the new Vector2D
+ * @param {Number} driftY Y value of the new Vector2D
+ * @param {Number} delay How much delay the drift should have
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=easeLinear] this behaviour's easing
+ *
+ * @property {Number} time The time of the drift
+ * @property {String} name The Behaviour name
+ */
+ function RandomDrift(driftX, driftY, delay, life, easing) {
+ classCallCheck(this, RandomDrift);
+ var _this = possibleConstructorReturn(this, (RandomDrift.__proto__ || Object.getPrototypeOf(RandomDrift)).call(this, life, easing));
+ _this.reset(driftX, driftY, delay);
+ _this.time = 0;
+ _this.name = "RandomDrift";
+ return _this;
+ }
/**
- * @memberof! Proton#
- * @augments Proton.Behaviour
- * @constructor
- * @alias Proton.RandomDrift
- *
- * @param {Number} driftX X value of the new Proton.Vector2D
- * @param {Number} driftY Y value of the new Proton.Vector2D
- * @param {Number} delay How much delay the drift should have
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=easeLinear] this behaviour's easing
- *
- * @property {Number} time The time of the drift
- * @property {String} name The Behaviour name
- */
- function RandomDrift(driftX, driftY, delay, life, easing) {
- RandomDrift._super_.call(this, life, easing);
- this.reset(driftX, driftY, delay);
- this.time = 0;
- this.name = "RandomDrift";
- }
+ * Reset this behaviour's parameters
+ *
+ * @method reset
+ * @memberof Proton#RandomDrift
+ * @instance
+ *
+ * @param {Number} driftX X value of the new Vector2D
+ * @param {Number} driftY Y value of the new Vector2D
+ * @param {Number} delay How much delay the drift should have
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=easeLinear] this behaviour's easing
+ */
+
+
+ createClass(RandomDrift, [{
+ key: 'reset',
+ value: function reset(driftX, driftY, delay, life, easing) {
+ this.panFoce = new Vector2D(driftX, driftY);
+ this.panFoce = this.normalizeForce(this.panFoce);
+ this.delay = delay;
+
+ life && get(RandomDrift.prototype.__proto__ || Object.getPrototypeOf(RandomDrift.prototype), 'reset', this).call(this, life, easing);
+ }
+
+ /**
+ * Apply this behaviour for all particles every time
+ *
+ * @method applyBehaviour
+ * @memberof Proton#RandomDrift
+ * @instance
+ *
+ * @param {Particle} particle
+ * @param {Number} time the integrate time 1/ms
+ * @param {Int} index the particle index
+ */
+
+ }, {
+ key: 'applyBehaviour',
+ value: function applyBehaviour(particle, time, index) {
+ this.calculate(particle, time, index);
+ this.time += time;
+
+ if (this.time >= this.delay) {
+ particle.a.addXY(MathUtils.randomAToB(-this.panFoce.x, this.panFoce.x), MathUtils.randomAToB(-this.panFoce.y, this.panFoce.y));
+ this.time = 0;
+ }
+ }
+ }]);
+ return RandomDrift;
+}(Behaviour);
- Proton.Util.inherits(RandomDrift, Proton.Behaviour);
+var Gravity = function (_Force) {
+ inherits(Gravity, _Force);
/**
- * Reset this behaviour's parameters
- *
- * @method reset
- * @memberof Proton#Proton.RandomDrift
- * @instance
- *
- * @param {Number} driftX X value of the new Proton.Vector2D
- * @param {Number} driftY Y value of the new Proton.Vector2D
- * @param {Number} delay How much delay the drift should have
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=easeLinear] this behaviour's easing
- */
- RandomDrift.prototype.reset = function(driftX, driftY, delay, life, easing) {
- this.panFoce = new Proton.Vector2D(driftX, driftY);
- this.panFoce = this.normalizeForce(this.panFoce);
- this.delay = delay;
- if (life)
- RandomDrift._super_.prototype.reset.call(this, life, easing);
+ * @memberof! Proton#
+ * @augments Proton#Proton.Force
+ * @constructor
+ * @alias Proton.Gravity
+ *
+ * @param {Number} g Gravity
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ *
+ * @property {String} name The Behaviour name
+ */
+ function Gravity(g, life, easing) {
+ classCallCheck(this, Gravity);
+
+ var _this = possibleConstructorReturn(this, (Gravity.__proto__ || Object.getPrototypeOf(Gravity)).call(this, 0, g, life, easing));
+
+ _this.name = "Gravity";
+ return _this;
}
/**
- * Apply this behaviour for all particles every time
- *
- * @method applyBehaviour
- * @memberof Proton#Proton.RandomDrift
- * @instance
- *
- * @param {Proton.Particle} particle
- * @param {Number} time the integrate time 1/ms
- * @param {Int} index the particle index
- */
- RandomDrift.prototype.applyBehaviour = function(particle, time, index) {
- RandomDrift._super_.prototype.applyBehaviour.call(this, particle, time, index);
- this.time += time;
- if (this.time >= this.delay) {
-
- particle.a.addXY(Proton.MathUtils.randomAToB(-this.panFoce.x, this.panFoce.x), Proton.MathUtils.randomAToB(-this.panFoce.y, this.panFoce.y));
- this.time = 0;
- };
- };
+ * Reset this behaviour's parameters
+ *
+ * @method reset
+ * @memberof Proton#Proton.Gravity
+ * @instance
+ *
+ * @param {Number} g Gravity
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ */
+
+
+ createClass(Gravity, [{
+ key: 'reset',
+ value: function reset(g, life, easing) {
+ get(Gravity.prototype.__proto__ || Object.getPrototypeOf(Gravity.prototype), 'reset', this).call(this, 0, g, life, easing);
+ }
+ }]);
+ return Gravity;
+}(Force);
- Proton.RandomDrift = RandomDrift;
+//can use Collision(emitter,true,function(){}) or Collision();
+var Collision = function (_Behaviour) {
+ inherits(Collision, _Behaviour);
+ /**
+ * The callback after collision
+ *
+ * @callback Callback
+ *
+ * @param {Proton.Particle} particle
+ * @param {Proton.Paritcle} otherParticle
+ */
+ /**
+ * @memberof! Proton#
+ * @augments Proton.Behaviour
+ * @constructor
+ * @alias Proton.Collision
+ *
+ * @todo add description to mass
+ *
+ * @param {Proton.Emitter} [emitter=null] the attraction point coordinates
+ * @param {Boolean} [mass=true]
+ * @param {Callback} [callback=null] the callback after the collision
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ *
+ * @property {String} name The Behaviour name
+ */
+ function Collision(emitter, mass, callback, life, easing) {
+ classCallCheck(this, Collision);
+ var _this = possibleConstructorReturn(this, (Collision.__proto__ || Object.getPrototypeOf(Collision)).call(this, life, easing));
- /**
- * The oppisite of Proton.Attraction - turns the force
- *
- * @memberof! Proton#
- * @augments Proton#Proton.Attraction
- * @constructor
- * @alias Proton.Repulsion
- *
- * @todo add description for 'force' and 'radius'
- *
- * @param {Proton.Vector2D} targetPosition the attraction point coordinates
- * @param {Number} [force=100]
- * @param {Number} [radius=1000]
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- *
- * @property {Number} force
- * @property {String} name The Behaviour name
- */
- function Repulsion(targetPosition, force, radius, life, easing) {
- Repulsion._super_.call(this, targetPosition, force, radius, life, easing);
- this.force *= -1;
- this.name = "Repulsion";
+ _this.reset(emitter, mass, callback);
+ _this.name = "Collision";
+ return _this;
}
- Proton.Util.inherits(Repulsion, Proton.Attraction);
-
/**
- * Reset this behaviour's parameters
- *
- * @method reset
- * @memberof Proton#Proton.Repulsion
- * @instance
- *
- * @todo add description for 'force' and 'radius'
- *
- * @param {Proton.Vector2D} targetPosition the attraction point coordinates
- * @param {Number} [force=100]
- * @param {Number} [radius=1000]
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- */
- Repulsion.prototype.reset = function(targetPosition, force, radius, life, easing) {
- Repulsion._super_.prototype.reset.call(this, targetPosition, force, radius, life, easing);
- this.force *= -1;
- }
+ * Reset this behaviour's parameters
+ *
+ * @memberof Proton#Proton.Collision
+ * @method reset
+ * @instance
+ *
+ * @todo add description to mass
+ *
+ * @param {Proton.Emitter} [emitter=null] the attraction point coordinates
+ * @param {Boolean} [mass=true]
+ * @param {Callback} [callback=null] the callback after the collision
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ */
+
+
+ createClass(Collision, [{
+ key: 'reset',
+ value: function reset(emitter, mass, callback, life, easing) {
+ this.emitter = Util.initValue(emitter, null);
+ this.mass = Util.initValue(mass, true);
+ this.callback = Util.initValue(callback, null);
+
+ this.collisionPool = [];
+ this.delta = new Vector2D();
+
+ life && get(Collision.prototype.__proto__ || Object.getPrototypeOf(Collision.prototype), 'reset', this).call(this, life, easing);
+ }
- Proton.Repulsion = Repulsion;
+ /**
+ * Apply this behaviour for all particles every time
+ *
+ * @memberof Proton#Proton.Collision
+ * @method applyBehaviour
+ * @instance
+ *
+ * @param {Proton.Particle} particle
+ * @param {Number} time the integrate time 1/ms
+ * @param {Int} index the particle index
+ */
+
+ }, {
+ key: 'applyBehaviour',
+ value: function applyBehaviour(particle, time, index) {
+ var newPool = this.emitter ? this.emitter.particles.slice(index) : this.pool.slice(index);
+ var length = newPool.length;
+
+ var otherParticle = void 0;
+ var lengthSq = void 0;
+ var overlap = void 0;
+ var totalMass = void 0;
+ var averageMass1 = void 0,
+ averageMass2 = void 0;
+ var i = void 0;
+
+ for (i = 0; i < length; i++) {
+ otherParticle = newPool[i];
+
+ if (otherParticle !== particle) {
+ this.delta.copy(otherParticle.p);
+ this.delta.sub(particle.p);
+
+ lengthSq = this.delta.lengthSq();
+ var distance = particle.radius + otherParticle.radius;
+
+ if (lengthSq <= distance * distance) {
+ overlap = distance - Math.sqrt(lengthSq);
+ overlap += 0.5;
+
+ totalMass = particle.mass + otherParticle.mass;
+ averageMass1 = this.mass ? otherParticle.mass / totalMass : 0.5;
+ averageMass2 = this.mass ? particle.mass / totalMass : 0.5;
+
+ particle.p.add(this.delta.clone().normalize().multiplyScalar(overlap * -averageMass1));
+ otherParticle.p.add(this.delta.normalize().multiplyScalar(overlap * averageMass2));
+
+ this.callback && this.callback(particle, otherParticle);
+ }
+ }
+ }
+ }
+ }]);
+ return Collision;
+}(Behaviour);
+var CrossZone = function (_Behaviour) {
+ inherits(CrossZone, _Behaviour);
+ /**
+ * Defines what happens if the particles come to the end of the specified zone
+ *
+ * @memberof! Proton#
+ * @augments Proton.Behaviour
+ * @constructor
+ * @alias Proton.CrossZone
+ *
+ * @param {Proton.Zone} zone can be any Proton.Zone - e.g. Proton.RectZone()
+ * @param {String} [crossType=dead] what happens if the particles pass the zone - allowed strings: dead | bound | cross
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ *
+ * @property {String} name The Behaviour name
+ */
+ function CrossZone(zone, crossType, life, easing) {
+ classCallCheck(this, CrossZone);
+ var _this = possibleConstructorReturn(this, (CrossZone.__proto__ || Object.getPrototypeOf(CrossZone)).call(this, life, easing));
+ _this.reset(zone, crossType);
+ _this.name = "CrossZone";
+ return _this;
+ }
- /**
- * @memberof! Proton#
- * @augments Proton#Proton.Force
- * @constructor
- * @alias Proton.Gravity
- *
- * @param {Number} g Gravity
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- *
- * @property {String} name The Behaviour name
- */
- function Gravity(g, life, easing) {
- Gravity._super_.call(this, 0, g, life, easing);
- this.name = "Gravity";
- }
+ /**
+ * Reset this behaviour's parameters
+ *
+ * @method reset
+ * @memberof Proton#Proton.CrossZone
+ * @instance
+ *
+ * @param {Proton.Zone} zone can be any Proton.Zone - e.g. Proton.RectZone()
+ * @param {String} [crossType=dead] what happens if the particles pass the zone - allowed strings: dead | bound | cross
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=easeLinear] this behaviour's easing
+ */
- Proton.Util.inherits(Gravity, Proton.Force);
- /**
- * Reset this behaviour's parameters
- *
- * @method reset
- * @memberof Proton#Proton.Gravity
- * @instance
- *
- * @param {Number} g Gravity
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- */
- Gravity.prototype.reset = function(g, life, easing) {
- Gravity._super_.prototype.reset.call(this, 0, g, life, easing);
- }
+ createClass(CrossZone, [{
+ key: 'reset',
+ value: function reset(zone, crossType, life, easing) {
+ this.zone = zone;
+ this.zone.crossType = Util.initValue(crossType, "dead");
- Proton.Gravity = Gravity;
- Proton.G = Gravity;
+ life && get(CrossZone.prototype.__proto__ || Object.getPrototypeOf(CrossZone.prototype), 'reset', this).call(this, life, easing);
+ }
+ /**
+ * Apply this behaviour for all particles every time
+ *
+ * @method applyBehaviour
+ * @memberof Proton#Proton.CrossZone
+ * @instance
+ *
+ * @param {Proton.Particle} particle
+ * @param {Number} the integrate time 1/ms
+ * @param {Int} the particle index
+ */
+ }, {
+ key: 'applyBehaviour',
+ value: function applyBehaviour(particle, time, index) {
+ this.calculate(particle, time, index);
+ this.zone.crossing(particle);
+ }
+ }]);
+ return CrossZone;
+}(Behaviour);
- //can use Collision(emitter,true,function(){}) or Collision();
+var Alpha = function (_Behaviour) {
+ inherits(Alpha, _Behaviour);
/**
- * The callback after collision
- *
- * @callback Callback
- *
- * @param {Proton.Particle} particle
- * @param {Proton.Paritcle} otherParticle
- */
- /**
- * @memberof! Proton#
- * @augments Proton.Behaviour
- * @constructor
- * @alias Proton.Collision
- *
- * @todo add description to mass
- *
- * @param {Proton.Emitter} [emitter=null] the attraction point coordinates
- * @param {Boolean} [mass=true]
- * @param {Callback} [callback=null] the callback after the collision
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- *
- * @property {String} name The Behaviour name
- */
- function Collision(emitter, mass, callback, life, easing) {
- Collision._super_.call(this, life, easing);
- this.reset(emitter, mass, callback);
- this.name = "Collision";
+ * @memberof! Proton#
+ * @augments Proton.Behaviour
+ * @constructor
+ * @alias Proton.Alpha
+ *
+ * @todo add description for 'a' and 'b'
+ *
+ * @param {Number} a
+ * @param {String} b
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ *
+ * @property {String} name The Behaviour name
+ */
+ function Alpha(a, b, life, easing) {
+ classCallCheck(this, Alpha);
+
+ var _this = possibleConstructorReturn(this, (Alpha.__proto__ || Object.getPrototypeOf(Alpha)).call(this, life, easing));
+
+ _this.reset(a, b);
+ _this.name = "Alpha";
+ return _this;
}
+ /**
+ * Reset this behaviour's parameters
+ *
+ * @method reset
+ * @memberof Proton#Proton.Alpha
+ * @instance
+ *
+ * @todo add description for 'a' and 'b'
+ *
+ * @param {Number} a
+ * @param {String} b
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ */
+
+
+ createClass(Alpha, [{
+ key: 'reset',
+ value: function reset(a, b, life, easing) {
+ this.same = b === null || b === undefined ? true : false;
+ this.a = Util.setSpanValue(Util.initValue(a, 1));
+ this.b = Util.setSpanValue(b);
+
+ life && get(Alpha.prototype.__proto__ || Object.getPrototypeOf(Alpha.prototype), 'reset', this).call(this, life, easing);
+ }
+
+ /**
+ * Sets the new alpha value of the particle
+ *
+ * @method initialize
+ * @memberof Proton#Proton.Alpha
+ * @instance
+ *
+ * @param {Proton.Particle} particle A single Proton generated particle
+ */
+
+ }, {
+ key: 'initialize',
+ value: function initialize(particle) {
+ particle.transform.alphaA = this.a.getValue();
+
+ if (this.same) particle.transform.alphaB = particle.transform.alphaA;else particle.transform.alphaB = this.b.getValue();
+ }
+
+ /**
+ * @method applyBehaviour
+ * @memberof Proton#Proton.Alpha
+ * @instance
+ *
+ * @param {Proton.Particle} particle
+ * @param {Number} time the integrate time 1/ms
+ * @param {Int} index the particle index
+ */
+
+ }, {
+ key: 'applyBehaviour',
+ value: function applyBehaviour(particle, time, index) {
+ this.calculate(particle, time, index);
+
+ particle.alpha = particle.transform.alphaB + (particle.transform.alphaA - particle.transform.alphaB) * this.energy;
+ if (particle.alpha < 0.001) particle.alpha = 0;
+ }
+ }]);
+ return Alpha;
+}(Behaviour);
- Proton.Util.inherits(Collision, Proton.Behaviour);
+var Scale = function (_Behaviour) {
+ inherits(Scale, _Behaviour);
/**
- * Reset this behaviour's parameters
- *
- * @memberof Proton#Proton.Collision
- * @method reset
- * @instance
- *
- * @todo add description to mass
- *
- * @param {Proton.Emitter} [emitter=null] the attraction point coordinates
- * @param {Boolean} [mass=true]
- * @param {Callback} [callback=null] the callback after the collision
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- */
- Collision.prototype.reset = function(emitter, mass, callback, life, easing) {
- this.emitter = Proton.Util.initValue(emitter, null);
- this.mass = Proton.Util.initValue(mass, true);
- this.callback = Proton.Util.initValue(callback, null);
- this.collisionPool = [];
- this.delta = new Proton.Vector2D();
- if (life)
- Collision._super_.prototype.reset.call(this, life, easing);
+ * @memberof! Proton#
+ * @augments Proton.Behaviour
+ * @constructor
+ * @alias Proton.Scale
+ *
+ * @todo add description for 'a' and 'b'
+ *
+ * @param {Number} a
+ * @param {String} b
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ *
+ * @property {String} name The Behaviour name
+ */
+ function Scale(a, b, life, easing) {
+ classCallCheck(this, Scale);
+
+ var _this = possibleConstructorReturn(this, (Scale.__proto__ || Object.getPrototypeOf(Scale)).call(this, life, easing));
+
+ _this.reset(a, b);
+ _this.name = "Scale";
+ return _this;
}
/**
- * Apply this behaviour for all particles every time
- *
- * @memberof Proton#Proton.Collision
- * @method applyBehaviour
- * @instance
- *
- * @param {Proton.Particle} particle
- * @param {Number} time the integrate time 1/ms
- * @param {Int} index the particle index
- */
- Collision.prototype.applyBehaviour = function(particle, time, index) {
- var newPool = this.emitter ? this.emitter.particles.slice(index) : this.pool.slice(index);
- var otherParticle;
- var lengthSq;
- var overlap;
- var averageMass1, averageMass2;
- var length = newPool.length;
- for (var i = 0; i < length; i++) {
- otherParticle = newPool[i];
- if (otherParticle !== particle) {
- this.delta.copy(otherParticle.p);
- this.delta.sub(particle.p);
- lengthSq = this.delta.lengthSq();
- distance = particle.radius + otherParticle.radius;
-
- if (lengthSq <= distance * distance) {
- overlap = distance - Math.sqrt(lengthSq);
- overlap += 0.5;
- totalMass = particle.mass + otherParticle.mass;
- averageMass1 = this.mass ? otherParticle.mass / totalMass : 0.5;
- averageMass2 = this.mass ? particle.mass / totalMass : 0.5;
- particle.p.add(this.delta.clone().normalize().multiplyScalar(overlap * -averageMass1));
- otherParticle.p.add(this.delta.normalize().multiplyScalar(overlap * averageMass2));
- if (this.callback)
- this.callback(particle, otherParticle);
- }
- }
+ * Reset this behaviour's parameters
+ *
+ * @method reset
+ * @memberof Proton#Proton.Scale
+ * @instance
+ *
+ * @param {Number} a
+ * @param {String} b
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ */
+
+
+ createClass(Scale, [{
+ key: 'reset',
+ value: function reset(a, b, life, easing) {
+ this.same = b === null || b === undefined ? true : false;
+ this.a = Util.setSpanValue(Util.initValue(a, 1));
+ this.b = Util.setSpanValue(b);
+
+ life && get(Scale.prototype.__proto__ || Object.getPrototypeOf(Scale.prototype), 'reset', this).call(this, life, easing);
}
- };
-
- Proton.Collision = Collision;
+ /**
+ * Initialize the behaviour's parameters for all particles
+ *
+ * @method initialize
+ * @memberof Proton#Proton.Scale
+ * @instance
+ *
+ * @param {Proton.Particle} particle
+ */
+
+ }, {
+ key: 'initialize',
+ value: function initialize(particle) {
+ particle.transform.scaleA = this.a.getValue();
+ particle.transform.oldRadius = particle.radius;
+ particle.transform.scaleB = this.same ? particle.transform.scaleA : this.b.getValue();
+ }
+ }, {
+ key: 'applyBehaviour',
+ /**
+ * Apply this behaviour for all particles every time
+ *
+ * @method applyBehaviour
+ * @memberof Proton#Proton.Scale
+ * @instance
+ *
+ * @param {Proton.Particle} particle
+ * @param {Number} time the integrate time 1/ms
+ * @param {Int} index the particle index
+ */
+ value: function applyBehaviour(particle, time, index) {
+ this.calculate(particle, time, index);
+ particle.scale = particle.transform.scaleB + (particle.transform.scaleA - particle.transform.scaleB) * this.energy;
+
+ if (particle.scale < 0.0001) particle.scale = 0;
+ particle.radius = particle.transform.oldRadius * particle.scale;
+ }
+ }]);
+ return Scale;
+}(Behaviour);
+var Rotate = function (_Behaviour) {
+ inherits(Rotate, _Behaviour);
/**
- * Defines what happens if the particles come to the end of the specified zone
- *
- * @memberof! Proton#
- * @augments Proton.Behaviour
- * @constructor
- * @alias Proton.CrossZone
- *
- * @param {Proton.Zone} zone can be any Proton.Zone - e.g. Proton.RectZone()
- * @param {String} [crossType=dead] what happens if the particles pass the zone - allowed strings: dead | bound | cross
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- *
- * @property {String} name The Behaviour name
- */
- function CrossZone(zone, crossType, life, easing) {
- CrossZone._super_.call(this, life, easing);
- this.reset(zone, crossType);
- this.name = "CrossZone";
- }
+ * @memberof! Proton#
+ * @augments Proton.Behaviour
+ * @constructor
+ * @alias Proton.Rotate
+ *
+ * @todo add description for 'a', 'b' and 'style'
+ *
+ * @param {Number} a
+ * @param {String} b
+ * @param {String} [style=to]
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ *
+ * @property {String} name The Behaviour name
+ */
+ function Rotate(a, b, style, life, easing) {
+ classCallCheck(this, Rotate);
- Proton.Util.inherits(CrossZone, Proton.Behaviour);
+ var _this = possibleConstructorReturn(this, (Rotate.__proto__ || Object.getPrototypeOf(Rotate)).call(this, life, easing));
- /**
- * Reset this behaviour's parameters
- *
- * @method reset
- * @memberof Proton#Proton.CrossZone
- * @instance
- *
- * @param {Proton.Zone} zone can be any Proton.Zone - e.g. Proton.RectZone()
- * @param {String} [crossType=dead] what happens if the particles pass the zone - allowed strings: dead | bound | cross
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=easeLinear] this behaviour's easing
- */
- CrossZone.prototype.reset = function(zone, crossType, life, easing) {
- this.zone = zone;
- this.zone.crossType = Proton.Util.initValue(crossType, "dead");
- if (life)
- CrossZone._super_.prototype.reset.call(this, life, easing);
+ _this.reset(a, b, style);
+ _this.name = "Rotate";
+ return _this;
}
/**
- * Apply this behaviour for all particles every time
- *
- * @method applyBehaviour
- * @memberof Proton#Proton.CrossZone
- * @instance
- *
- * @param {Proton.Particle} particle
- * @param {Number} the integrate time 1/ms
- * @param {Int} the particle index
- */
- CrossZone.prototype.applyBehaviour = function(particle, time, index) {
- CrossZone._super_.prototype.applyBehaviour.call(this, particle, time, index);
- this.zone.crossing(particle);
- };
+ * Reset this behaviour's parameters
+ *
+ * @method reset
+ * @memberof Proton#Proton.Rotate
+ * @instance
+ *
+ * @todo add description for 'a', 'b' and 'style'
+ *
+ * @param {Number} a
+ * @param {String} b
+ * @param {String} [style=to]
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ */
+
+
+ createClass(Rotate, [{
+ key: 'reset',
+ value: function reset(a, b, style, life, easing) {
+ this.same = b === null || b === undefined ? true : false;
+
+ this.a = Util.setSpanValue(Util.initValue(a, "Velocity"));
+ this.b = Util.setSpanValue(Util.initValue(b, 0));
+ this.style = Util.initValue(style, 'to');
+
+ life && get(Rotate.prototype.__proto__ || Object.getPrototypeOf(Rotate.prototype), 'reset', this).call(this, life, easing);
+ }
- Proton.CrossZone = CrossZone;
+ /**
+ * Initialize the behaviour's parameters for all particles
+ *
+ * @method initialize
+ * @memberof Proton#Proton.Rotate
+ * @instance
+ *
+ * @param {Proton.Particle} particle
+ */
+
+ }, {
+ key: 'initialize',
+ value: function initialize(particle) {
+ particle.rotation = this.a.getValue();
+ particle.transform.rotationA = this.a.getValue();
+
+ if (!this.same) particle.transform.rotationB = this.b.getValue();
+ }
+ }, {
+ key: 'applyBehaviour',
+ /**
+ * Apply this behaviour for all particles every time
+ *
+ * @method applyBehaviour
+ * @memberof Proton#Proton.Rotate
+ * @instance
+ *
+ * @param {Proton.Particle} particle
+ * @param {Number} time the integrate time 1/ms
+ * @param {Int} index the particle index
+ */
+ value: function applyBehaviour(particle, time, index) {
+ this.calculate(particle, time, index);
+
+ if (!this.same) {
+ if (this.style == 'to' || this.style == 'TO' || this.style == '_') {
+ particle.rotation += particle.transform.rotationB + (particle.transform.rotationA - particle.transform.rotationB) * this.energy;
+ } else {
+ particle.rotation += particle.transform.rotationB;
+ }
+ } else if (this.a.a == "V" || this.a.a == "Velocity" || this.a.a == "v") {
+ //beta...
+ particle.rotation = particle.getDirection();
+ }
+ }
+ }]);
+ return Rotate;
+}(Behaviour);
+var Color = function (_Behaviour) {
+ inherits(Color, _Behaviour);
- /**
- * @memberof! Proton#
- * @augments Proton.Behaviour
- * @constructor
- * @alias Proton.Alpha
- *
- * @todo add description for 'a' and 'b'
- *
- * @param {Number} a
- * @param {String} b
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- *
- * @property {String} name The Behaviour name
- */
- function Alpha(a, b, life, easing) {
- Alpha._super_.call(this, life, easing);
- this.reset(a, b);
- this.name = "Alpha";
- }
+ /**
+ * @memberof! Proton#
+ * @augments Proton.Behaviour
+ * @constructor
+ * @alias Proton.Color
+ *
+ * @param {Proton.ArraySpan | String} a the string should be a hex e.g. #000000 for black
+ * @param {Proton.ArraySpan | String} b the string should be a hex e.g. #000000 for black
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=easeLinear] this behaviour's easing
+ *
+ * @property {String} name The Behaviour name
+ */
+ function Color(a, b, life, easing) {
+ classCallCheck(this, Color);
+ var _this = possibleConstructorReturn(this, (Color.__proto__ || Object.getPrototypeOf(Color)).call(this, life, easing));
- Proton.Util.inherits(Alpha, Proton.Behaviour);
+ _this.reset(a, b);
+ _this.name = "Color";
+ return _this;
+ }
- /**
- * Reset this behaviour's parameters
- *
- * @method reset
- * @memberof Proton#Proton.Alpha
- * @instance
- *
- * @todo add description for 'a' and 'b'
- *
- * @param {Number} a
- * @param {String} b
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- */
- Alpha.prototype.reset = function(a, b, life, easing) {
- if (b == null || b == undefined)
- this.same = true;
- else
- this.same = false;
- this.a = Proton.Util.setSpanValue(Proton.Util.initValue(a, 1));
- this.b = Proton.Util.setSpanValue(b);
- if (life)
- Alpha._super_.prototype.reset.call(this, life, easing);
- }
+ /**
+ * Reset this behaviour's parameters
+ *
+ * @method reset
+ * @memberof Proton#Proton.Color
+ * @instance
+ *
+ * @param {Proton.ArraySpan | String} a the string should be a hex e.g. #000000 for black
+ * @param {Proton.ArraySpan | String} b the string should be a hex e.g. #000000 for black
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=easeLinear] this behaviour's easing
+ */
- /**
- * Sets the new alpha value of the particle
- *
- * @method initialize
- * @memberof Proton#Proton.Alpha
- * @instance
- *
- * @param {Proton.Particle} particle A single Proton generated particle
- */
- Alpha.prototype.initialize = function(particle) {
- particle.transform.alphaA = this.a.getValue();
- if (this.same)
- particle.transform.alphaB = particle.transform.alphaA;
- else
- particle.transform.alphaB = this.b.getValue();
- };
- /**
- * @method applyBehaviour
- * @memberof Proton#Proton.Alpha
- * @instance
- *
- * @param {Proton.Particle} particle
- * @param {Number} time the integrate time 1/ms
- * @param {Int} index the particle index
- */
- Alpha.prototype.applyBehaviour = function(particle, time, index) {
- Alpha._super_.prototype.applyBehaviour.call(this, particle, time, index);
- particle.alpha = particle.transform.alphaB + (particle.transform.alphaA - particle.transform.alphaB) * this.energy;
- if (particle.alpha < 0.001)
- particle.alpha = 0;
- };
+ createClass(Color, [{
+ key: 'reset',
+ value: function reset(a, b, life, easing) {
+ this.a = ArraySpan.createArraySpan(a);
+ this.b = ArraySpan.createArraySpan(b);
- Proton.Alpha = Alpha;
+ life && get(Color.prototype.__proto__ || Object.getPrototypeOf(Color.prototype), 'reset', this).call(this, life, easing);
+ }
+ /**
+ * Initialize the behaviour's parameters for all particles
+ *
+ * @method initialize
+ * @memberof Proton#Proton.Color
+ * @instance
+ *
+ * @param {Proton.Particle} particle
+ */
+ }, {
+ key: 'initialize',
+ value: function initialize(particle) {
+ particle.color = this.a.getValue();
+ particle.transform.colorA = ColorUtil.hexToRGB(particle.color);
+ if (this.b) particle.transform.colorB = ColorUtil.hexToRGB(this.b.getValue());
+ }
+ }, {
+ key: 'applyBehaviour',
- /**
- * @memberof! Proton#
- * @augments Proton.Behaviour
- * @constructor
- * @alias Proton.Scale
- *
- * @todo add description for 'a' and 'b'
- *
- * @param {Number} a
- * @param {String} b
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- *
- * @property {String} name The Behaviour name
- */
- function Scale(a, b, life, easing) {
- Scale._super_.call(this, life, easing);
- this.reset(a, b);
- this.name = "Scale";
- }
+ /**
+ * Apply this behaviour for all particles every time
+ *
+ * @method applyBehaviour
+ * @memberof Proton#Proton.Color
+ * @instance
+ *
+ * @param {Proton.Particle} particle
+ * @param {Number} the integrate time 1/ms
+ * @param {Int} the particle index
+ */
+ value: function applyBehaviour(particle, time, index) {
+ if (this.b) {
+ this.calculate(particle, time, index);
+
+ particle.transform.rgb.r = particle.transform.colorB.r + (particle.transform.colorA.r - particle.transform.colorB.r) * this.energy;
+ particle.transform.rgb.g = particle.transform.colorB.g + (particle.transform.colorA.g - particle.transform.colorB.g) * this.energy;
+ particle.transform.rgb.b = particle.transform.colorB.b + (particle.transform.colorA.b - particle.transform.colorB.b) * this.energy;
+
+ particle.transform.rgb.r = Math.floor(particle.transform.rgb.r);
+ particle.transform.rgb.g = Math.floor(particle.transform.rgb.g);
+ particle.transform.rgb.b = Math.floor(particle.transform.rgb.b);
+ } else {
+ particle.transform.rgb.r = particle.transform.colorA.r;
+ particle.transform.rgb.g = particle.transform.colorA.g;
+ particle.transform.rgb.b = particle.transform.colorA.b;
+ }
+ }
+ }]);
+ return Color;
+}(Behaviour);
+
+var Repulsion = function (_Attraction) {
+ inherits(Repulsion, _Attraction);
+
+ /**
+ * The oppisite of Proton.Attraction - turns the force
+ *
+ * @memberof! Proton#
+ * @augments Proton#Proton.Attraction
+ * @constructor
+ * @alias Proton.Repulsion
+ *
+ * @todo add description for 'force' and 'radius'
+ *
+ * @param {Proton.Vector2D} targetPosition the attraction point coordinates
+ * @param {Number} [force=100]
+ * @param {Number} [radius=1000]
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ *
+ * @property {Number} force
+ * @property {String} name The Behaviour name
+ */
+ function Repulsion(targetPosition, force, radius, life, easing) {
+ classCallCheck(this, Repulsion);
- Proton.Util.inherits(Scale, Proton.Behaviour);
+ var _this = possibleConstructorReturn(this, (Repulsion.__proto__ || Object.getPrototypeOf(Repulsion)).call(this, targetPosition, force, radius, life, easing));
- /**
- * Reset this behaviour's parameters
- *
- * @method reset
- * @memberof Proton#Proton.Scale
- * @instance
- *
- * @param {Number} a
- * @param {String} b
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- */
- Scale.prototype.reset = function(a, b, life, easing) {
- if (b == null || b == undefined)
- this.same = true;
- else
- this.same = false;
- this.a = Proton.Util.setSpanValue(Proton.Util.initValue(a, 1));
- this.b = Proton.Util.setSpanValue(b);
- if (life)
- Scale._super_.prototype.reset.call(this, life, easing);
+ _this.force *= -1;
+ _this.name = "Repulsion";
+ return _this;
}
/**
- * Initialize the behaviour's parameters for all particles
- *
- * @method initialize
- * @memberof Proton#Proton.Scale
- * @instance
- *
- * @param {Proton.Particle} particle
- */
- Scale.prototype.initialize = function(particle) {
- particle.transform.scaleA = this.a.getValue();
- particle.transform.oldRadius = particle.radius;
- if (this.same)
- particle.transform.scaleB = particle.transform.scaleA;
- else
- particle.transform.scaleB = this.b.getValue();
+ * Reset this behaviour's parameters
+ *
+ * @method reset
+ * @memberof Proton#Proton.Repulsion
+ * @instance
+ *
+ * @todo add description for 'force' and 'radius'
+ *
+ * @param {Proton.Vector2D} targetPosition the attraction point coordinates
+ * @param {Number} [force=100]
+ * @param {Number} [radius=1000]
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=ease.easeLinear] this behaviour's easing
+ */
+
+
+ createClass(Repulsion, [{
+ key: 'reset',
+ value: function reset(targetPosition, force, radius, life, easing) {
+ get(Repulsion.prototype.__proto__ || Object.getPrototypeOf(Repulsion.prototype), 'reset', this).call(this, targetPosition, force, radius, life, easing);
+ this.force *= -1;
+ }
+ }]);
+ return Repulsion;
+}(Attraction);
- };
+var GravityWell = function (_Behaviour) {
+ inherits(GravityWell, _Behaviour);
/**
- * Apply this behaviour for all particles every time
- *
- * @method applyBehaviour
- * @memberof Proton#Proton.Scale
- * @instance
- *
- * @param {Proton.Particle} particle
- * @param {Number} time the integrate time 1/ms
- * @param {Int} index the particle index
- */
- Scale.prototype.applyBehaviour = function(particle, time, index) {
- Scale._super_.prototype.applyBehaviour.call(this, particle, time, index);
- particle.scale = particle.transform.scaleB + (particle.transform.scaleA - particle.transform.scaleB) * this.energy;
- if (particle.scale < 0.0001)
- particle.scale = 0;
- particle.radius = particle.transform.oldRadius * particle.scale;
- };
-
- Proton.Scale = Scale;
+ * @memberof! Proton#
+ * @augments Behaviour
+ * @constructor
+ * @alias GravityWell
+ *
+ * @param {Vector2D} [centerPoint=new Vector2D] The point in the center
+ * @param {Number} [force=100] The force
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=easeLinear] this behaviour's easing
+ *
+ * @property {String} name The Behaviour name
+ */
+ function GravityWell(centerPoint, force, life, easing) {
+ classCallCheck(this, GravityWell);
+ var _this = possibleConstructorReturn(this, (GravityWell.__proto__ || Object.getPrototypeOf(GravityWell)).call(this, life, easing));
+ _this.distanceVec = new Vector2D();
+ _this.centerPoint = Util.initValue(centerPoint, new Vector2D());
+ _this.force = Util.initValue(_this.normalizeValue(force), 100);
+ _this.name = "GravityWell";
+ return _this;
+ }
/**
- * @memberof! Proton#
- * @augments Proton.Behaviour
- * @constructor
- * @alias Proton.Rotate
- *
- * @todo add description for 'a', 'b' and 'style'
- *
- * @param {Number} a
- * @param {String} b
- * @param {String} [style=to]
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- *
- * @property {String} name The Behaviour name
- */
- function Rotate(a, b, style, life, easing) {
- Rotate._super_.call(this, life, easing);
- this.reset(a, b, style);
- this.name = "Rotate";
- }
+ * Reset this behaviour's parameters
+ *
+ * @method reset
+ * @memberof Proton#GravityWell
+ * @instance
+ *
+ * @param {Vector2D} [centerPoint=new Vector2D] The point in the center
+ * @param {Number} [force=100] The force
+ * @param {Number} [life=Infinity] this behaviour's life
+ * @param {String} [easing=easeLinear] this behaviour's easing
+ */
+
+
+ createClass(GravityWell, [{
+ key: 'reset',
+ value: function reset(centerPoint, force, life, easing) {
+ this.distanceVec = new Vector2D();
+ this.centerPoint = Util.initValue(centerPoint, new Vector2D());
+ this.force = Util.initValue(this.normalizeValue(force), 100);
+
+ life && get(GravityWell.prototype.__proto__ || Object.getPrototypeOf(GravityWell.prototype), 'reset', this).call(this, life, easing);
+ }
+ }, {
+ key: 'initialize',
- Proton.Util.inherits(Rotate, Proton.Behaviour);
- /**
- * Reset this behaviour's parameters
- *
- * @method reset
- * @memberof Proton#Proton.Rotate
- * @instance
- *
- * @todo add description for 'a', 'b' and 'style'
- *
- * @param {Number} a
- * @param {String} b
- * @param {String} [style=to]
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- */
- Rotate.prototype.reset = function(a, b, style, life, easing) {
- if (b == null || b == undefined)
- this.same = true;
- else
- this.same = false;
- this.a = Proton.Util.setSpanValue(Proton.Util.initValue(a, "Velocity"));
- this.b = Proton.Util.setSpanValue(Proton.Util.initValue(b, 0));
- this.style = Proton.Util.initValue(style, 'to');
- if (life)
- Rotate._super_.prototype.reset.call(this, life, easing);
- }
+ /**
+ * @inheritdoc
+ */
+ value: function initialize(particle) {}
+ }, {
+ key: 'applyBehaviour',
- /**
- * Initialize the behaviour's parameters for all particles
- *
- * @method initialize
- * @memberof Proton#Proton.Rotate
- * @instance
- *
- * @param {Proton.Particle} particle
- */
- Rotate.prototype.initialize = function(particle) {
- particle.rotation = this.a.getValue();
- particle.transform.rotationA = this.a.getValue();
- if (!this.same)
- particle.transform.rotationB = this.b.getValue();
- };
- /**
- * Apply this behaviour for all particles every time
- *
- * @method applyBehaviour
- * @memberof Proton#Proton.Rotate
- * @instance
- *
- * @param {Proton.Particle} particle
- * @param {Number} time the integrate time 1/ms
- * @param {Int} index the particle index
- */
- Rotate.prototype.applyBehaviour = function(particle, time, index) {
- Rotate._super_.prototype.applyBehaviour.call(this, particle, time, index);
- if (!this.same) {
- if (this.style == 'to' || this.style == 'TO' || this.style == '_') {
- particle.rotation += particle.transform.rotationB + (particle.transform.rotationA - particle.transform.rotationB) * this.energy
- } else {
- particle.rotation += particle.transform.rotationB;
+ /**
+ * Apply this behaviour for all particles every time
+ *
+ * @method applyBehaviour
+ * @memberof Proton#GravityWell
+ * @instance
+ *
+ * @param {Particle} particle
+ * @param {Number} the integrate time 1/ms
+ * @param {Int} the particle index
+ */
+ value: function applyBehaviour(particle, time, index) {
+ this.distanceVec.set(this.centerPoint.x - particle.p.x, this.centerPoint.y - particle.p.y);
+ var distanceSq = this.distanceVec.lengthSq();
+
+ if (distanceSq != 0) {
+ var distance = this.distanceVec.length();
+ var factor = this.force * time / (distanceSq * distance);
+
+ particle.v.x += factor * this.distanceVec.x;
+ particle.v.y += factor * this.distanceVec.y;
}
- } else if (this.a.a == "V" || this.a.a == "Velocity" || this.a.a == "v") {
- //beta...
- particle.rotation = particle.getDirection();
}
- };
-
- Proton.Rotate = Rotate;
-
+ }]);
+ return GravityWell;
+}(Behaviour);
+var InitializeUtil = {
+ initialize: function initialize(emitter, particle, initializes) {
+ var length = initializes.length;
+ var i = void 0;
+ for (i = 0; i < length; i++) {
+ if (initializes[i] instanceof Proton.Initialize) initializes[i].init(emitter, particle);else this.init(emitter, particle, initializes[i]);
+ }
- /**
- * @memberof! Proton#
- * @augments Proton.Behaviour
- * @constructor
- * @alias Proton.Color
- *
- * @param {Proton.ColorSpan | String} color1 the string should be a hex e.g. #000000 for black
- * @param {Proton.ColorSpan | String} color2 the string should be a hex e.g. #000000 for black
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=easeLinear] this behaviour's easing
- *
- * @property {String} name The Behaviour name
- */
- function Color(color1, color2, life, easing) {
- Color._super_.call(this, life, easing);
- this.reset(color1, color2);
- this.name = "Color";
- }
+ this.bindEmitter(emitter, particle);
+ },
- Proton.Util.inherits(Color, Proton.Behaviour);
+ //////////////////////init//////////////////////
+ init: function init(emitter, particle, initialize) {
+ Util.setPrototypeByObject(particle, initialize);
+ Util.setVector2DByObject(particle, initialize);
+ },
+ bindEmitter: function bindEmitter(emitter, particle) {
+ if (emitter.bindEmitter) {
+ particle.p.add(emitter.p);
+ particle.v.add(emitter.v);
+ particle.a.add(emitter.a);
- /**
- * Reset this behaviour's parameters
- *
- * @method reset
- * @memberof Proton#Proton.Color
- * @instance
- *
- * @param {Proton.ColorSpan | String} color1 the string should be a hex e.g. #000000 for black
- * @param {Proton.ColorSpan | String} color2 the string should be a hex e.g. #000000 for black
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=easeLinear] this behaviour's easing
- */
- Color.prototype.reset = function(color1, color2, life, easing) {
- this.color1 = this.setSpanValue(color1);
- this.color2 = this.setSpanValue(color2);
- if (life)
- Color._super_.prototype.reset.call(this, life, easing);
+ particle.v.rotate(MathUtils.degreeTransform(emitter.rotation));
+ }
}
+};
- /**
- * Initialize the behaviour's parameters for all particles
- *
- * @method initialize
- * @memberof Proton#Proton.Color
- * @instance
- *
- * @param {Proton.Particle} particle
- */
- Color.prototype.initialize = function(particle) {
- particle.color = this.color1.getValue();
- particle.transform.beginRGB = Proton.Util.hexToRGB(particle.color);
-
- if (this.color2)
- particle.transform.endRGB = Proton.Util.hexToRGB(this.color2.getValue());
- };
+var Emitter = function (_Particle) {
+ inherits(Emitter, _Particle);
/**
- * Apply this behaviour for all particles every time
- *
- * @method applyBehaviour
- * @memberof Proton#Proton.Color
- * @instance
- *
- * @param {Proton.Particle} particle
- * @param {Number} the integrate time 1/ms
- * @param {Int} the particle index
- */
- Color.prototype.applyBehaviour = function(particle, time, index) {
- if (this.color2) {
- Color._super_.prototype.applyBehaviour.call(this, particle, time, index);
- particle.transform.rgb.r = particle.transform.endRGB.r + (particle.transform.beginRGB.r - particle.transform.endRGB.r) * this.energy;
- particle.transform.rgb.g = particle.transform.endRGB.g + (particle.transform.beginRGB.g - particle.transform.endRGB.g) * this.energy;
- particle.transform.rgb.b = particle.transform.endRGB.b + (particle.transform.beginRGB.b - particle.transform.endRGB.b) * this.energy;
- particle.transform.rgb.r = parseInt(particle.transform.rgb.r, 10);
- particle.transform.rgb.g = parseInt(particle.transform.rgb.g, 10);
- particle.transform.rgb.b = parseInt(particle.transform.rgb.b, 10);
- } else {
- particle.transform.rgb.r = particle.transform.beginRGB.r;
- particle.transform.rgb.g = particle.transform.beginRGB.g;
- particle.transform.rgb.b = particle.transform.beginRGB.b;
+ * You can use this emit particles.
+ *
+ * It will dispatch follow events:
+ * PARTICLE_CREATED
+ * PARTICLE_UPDATA
+ * PARTICLE_DEAD
+ *
+ * @class Emitter
+ * @constructor
+ * @param {Object} pObj the parameters object;
+ * for example {damping:0.01,bindEmitter:false}
+ */
+ function Emitter(pObj) {
+ classCallCheck(this, Emitter);
- }
- };
+ var _this = possibleConstructorReturn(this, (Emitter.__proto__ || Object.getPrototypeOf(Emitter)).call(this, pObj));
- /**
- * Make sure that the color is an instance of Proton.ColorSpan, if not it makes a new instance
- *
- * @method setSpanValue
- * @memberof Proton#Proton.Color
- * @instance
- *
- * @param {Proton.Particle} particle
- * @param {Number} the integrate time 1/ms
- * @param {Int} the particle index
- */
- Color.prototype.setSpanValue = function(color) {
- if (color) {
- if ( color instanceof Proton.ColorSpan) {
- return color;
- } else {
- return new Proton.ColorSpan(color);
- }
- } else {
- return null;
- }
- }
+ _this.initializes = [];
+ _this.particles = [];
+ _this.behaviours = [];
- Proton.Color = Color;
+ _this.emitSpeed = 0;
+ _this.currentEmitTime = 0;
+ _this.totalEmitTimes = -1;
+ /**
+ * The friction coefficient for all particle emit by This;
+ * @property damping
+ * @type {Number}
+ * @default 0.006
+ */
+ _this.damping = .006;
+ /**
+ * If bindEmitter the particles can bind this emitter's property;
+ * @property bindEmitter
+ * @type {Boolean}
+ * @default true
+ */
+ _this.bindEmitter = true;
+ /**
+ * The number of particles per second emit (a [particle]/b [s]);
+ * @property rate
+ * @type {Rate}
+ * @default Rate(1, .1)
+ */
+ _this.rate = new Rate(1, .1);
- /**
- * @memberof! Proton#
- * @augments Proton.Behaviour
- * @constructor
- * @alias Proton.GravityWell
- *
- * @param {Proton.Vector2D} [centerPoint=new Proton.Vector2D] The point in the center
- * @param {Number} [force=100] The force
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- *
- * @property {String} name The Behaviour name
- */
- function GravityWell(centerPoint, force, life, easing) {
- GravityWell._super_.call(this, life, easing);
- this.distanceVec = new Proton.Vector2D();
- this.centerPoint = Proton.Util.initValue(centerPoint, new Proton.Vector2D);
- this.force = Proton.Util.initValue(this.normalizeValue(force), 100);
- this.name = "GravityWell";
+ _this.id = 'emitter_' + Emitter.ID++;
+ _this.name = 'Emitter';
+ return _this;
}
- Proton.Util.inherits(GravityWell, Proton.Behaviour);
-
/**
- * Reset this behaviour's parameters
- *
- * @method reset
- * @memberof Proton#Proton.GravityWell
- * @instance
- *
- * @param {Proton.Vector2D} [centerPoint=new Proton.Vector2D] The point in the center
- * @param {Number} [force=100] The force
- * @param {Number} [life=Infinity] this behaviour's life
- * @param {String} [easing=Proton.easeLinear] this behaviour's easing
- */
- GravityWell.prototype.reset = function(centerPoint, force, life, easing) {
- this.distanceVec = new Proton.Vector2D();
- this.centerPoint = Proton.Util.initValue(centerPoint, new Proton.Vector2D);
- this.force = Proton.Util.initValue(this.normalizeValue(force), 100);
- if (life)
- GravityWell._super_.prototype.reset.call(this, life, easing);
- };
+ * start emit particle
+ * @method emit
+ * @param {Number} currentEmitTime begin emit time;
+ * @param {String} life the life of this emitter
+ */
+
+
+ createClass(Emitter, [{
+ key: 'emit',
+ value: function emit(totalEmitTimes, life) {
+ this.stoped = false;
+ this.currentEmitTime = 0;
+ this.totalEmitTimes = Util.initValue(totalEmitTimes, Infinity);
+
+ if (life == true || life == 'life' || life == 'destroy') {
+ this.life = totalEmitTimes == 'once' ? 1 : this.totalEmitTimes;
+ } else if (!isNaN(life)) {
+ this.life = life;
+ }
- /**
- * @inheritdoc
- */
- GravityWell.prototype.initialize = function(particle) {
+ this.rate.init();
+ }
- };
+ /**
+ * stop emiting
+ * @method stop
+ */
+
+ }, {
+ key: 'stop',
+ value: function stop() {
+ this.totalEmitTimes = -1;
+ this.currentEmitTime = 0;
+ this.stoped = true;
+ }
- /**
- * Apply this behaviour for all particles every time
- *
- * @method applyBehaviour
- * @memberof Proton#Proton.GravityWell
- * @instance
- *
- * @param {Proton.Particle} particle
- * @param {Number} the integrate time 1/ms
- * @param {Int} the particle index
- */
- GravityWell.prototype.applyBehaviour = function(particle, time, index) {
- this.distanceVec.set(this.centerPoint.x - particle.p.x, this.centerPoint.y - particle.p.y);
- var distanceSq = this.distanceVec.lengthSq();
- if (distanceSq != 0) {
- var distance = this.distanceVec.length();
- var factor = (this.force * time ) / (distanceSq * distance );
- particle.v.x += factor * this.distanceVec.x;
- particle.v.y += factor * this.distanceVec.y;
+ /**
+ * remove current all particles
+ * @method removeAllParticles
+ */
+
+ }, {
+ key: 'removeAllParticles',
+ value: function removeAllParticles() {
+ var i = this.particles.length;
+ while (i--) {
+ this.particles[i].dead = true;
+ }
}
- }
- Proton.GravityWell = GravityWell;
+ /**
+ * add initialize to this emitter
+ * @method addSelfInitialize
+ */
+
+ }, {
+ key: 'addSelfInitialize',
+ value: function addSelfInitialize(pObj) {
+ if (pObj['init']) {
+ pObj.init(this);
+ } else {
+ this.initAll();
+ }
+ }
+ /**
+ * add the Initialize to particles;
+ *
+ * you can use initializes array:for example emitter.addInitialize(initialize1,initialize2,initialize3);
+ * @method addInitialize
+ * @param {Initialize} initialize like this new Radius(1, 12)
+ */
+
+ }, {
+ key: 'addInitialize',
+ value: function addInitialize() {
+ for (var _len = arguments.length, rest = Array(_len), _key = 0; _key < _len; _key++) {
+ rest[_key] = arguments[_key];
+ }
+ var i = rest.length;
+ while (i--) {
+ this.initializes.push(rest[i]);
+ }
+ }
- Emitter.ID = 0;
- /**
- * You can use this emit particles.
- *
- * It will dispatch follow events:
- * Proton.PARTICLE_CREATED
- * Proton.PARTICLE_UPDATA
- * Proton.PARTICLE_DEAD
- *
- * @class Proton.Emitter
- * @constructor
- * @param {Object} pObj the parameters object;
- * for example {damping:0.01,bindEmitter:false}
- */
- function Emitter(pObj) {
- this.initializes = [];
- this.particles = [];
- this.behaviours = [];
- this.emitTime = 0;
- this.emitTotalTimes = -1;
- /**
- * The friction coefficient for all particle emit by This;
- * @property damping
- * @type {Number}
- * @default 0.006
- */
- this.damping = .006;
/**
- * If bindEmitter the particles can bind this emitter's property;
- * @property bindEmitter
- * @type {Boolean}
- * @default true
- */
- this.bindEmitter = true;
+ * remove the Initialize
+ * @method removeInitialize
+ * @param {Initialize} initialize a initialize
+ */
+
+ }, {
+ key: 'removeInitialize',
+ value: function removeInitialize(initializer) {
+ var index = this.initializes.indexOf(initializer);
+ if (index > -1) this.initializes.splice(index, 1);
+ }
+
/**
- * The number of particles per second emit (a [particle]/b [s]);
- * @property rate
- * @type {Proton.Rate}
- * @default Proton.Rate(1, .1)
- */
- this.rate = new Proton.Rate(1, .1);
- Emitter._super_.call(this, pObj);
+ * remove all Initializes
+ * @method removeInitializers
+ */
+
+ }, {
+ key: 'removeAllInitializers',
+ value: function removeAllInitializers() {
+ Util.destroyArray(this.initializes);
+ }
+
/**
- * The emitter's id;
- * @property id
- * @type {string}
- */
- this.id = 'emitter_' + Emitter.ID++;
- };
+ * add the Behaviour to particles;
+ *
+ * you can use Behaviours array:emitter.addBehaviour(Behaviour1,Behaviour2,Behaviour3);
+ * @method addBehaviour
+ * @param {Behaviour} behaviour like this new Color('random')
+ */
+
+ }, {
+ key: 'addBehaviour',
+ value: function addBehaviour() {
+ for (var _len2 = arguments.length, rest = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
+ rest[_key2] = arguments[_key2];
+ }
- Proton.Util.inherits(Emitter, Proton.Particle);
- Proton.EventDispatcher.initialize(Emitter.prototype);
- /**
- * start emit particle
- * @method emit
- * @param {Number} emitTime begin emit time;
- * @param {String} life the life of this emitter
- */
- Emitter.prototype.emit = function(emitTime, life) {
- this.emitTime = 0;
- this.emitTotalTimes = Proton.Util.initValue(emitTime, Infinity);
-
- if (life == true || life == 'life' || life == 'destroy') {
- if (emitTime == 'once')
- this.life = 1;
- else
- this.life = this.emitTotalTimes;
-
- } else if (!isNaN(life)) {
- this.life = life;
+ var i = arguments.length;
+ while (i--) {
+ var behaviour = rest[i];
+ this.behaviours.push(behaviour);
+ if (behaviour.parents) behaviour.parents.push(this);
+ }
}
- this.rate.init();
- };
+ /**
+ * remove the Behaviour
+ * @method removeBehaviour
+ * @param {Behaviour} behaviour a behaviour
+ */
+
+ }, {
+ key: 'removeBehaviour',
+ value: function removeBehaviour(behaviour) {
+ var index = this.behaviours.indexOf(behaviour);
+ this.behaviours.splice(index, 1);
- /**
- * stop emiting
- * @method stopEmit
- */
- Emitter.prototype.stopEmit = function() {
- this.emitTotalTimes = -1;
- this.emitTime = 0;
- };
+ if (behaviour.parents) {
+ index = behaviour.parents.indexOf(behaviour);
+ behaviour.parents.splice(index, 1);
+ }
- /**
- * remove current all particles
- * @method removeAllParticles
- */
- Emitter.prototype.removeAllParticles = function() {
- for (var i = 0; i < this.particles.length; i++)
- this.particles[i].dead = true;
- };
- /**
- * create single particle;
- *
- * can use emit({x:10},new Gravity(10),{'particleUpdate',fun}) or emit([{x:10},new Initialize],new Gravity(10),{'particleUpdate',fun})
- * @method removeAllParticles
- */
- Emitter.prototype.createParticle = function(initialize, behaviour) {
- var particle = Proton.pool.get(Proton.Particle);
- this.setupParticle(particle, initialize, behaviour);
- this.dispatchEvent(Proton.PARTICLE_CREATED, particle);
-
- return particle;
- };
- /**
- * add initialize to this emitter
- * @method addSelfInitialize
- */
- Emitter.prototype.addSelfInitialize = function(pObj) {
- if (pObj['init']) {
- pObj.init(this);
- } else {
- this.initAll();
- }
- };
- /**
- * add the Initialize to particles;
- *
- * you can use initializes array:for example emitter.addInitialize(initialize1,initialize2,initialize3);
- * @method addInitialize
- * @param {Proton.Initialize} initialize like this new Proton.Radius(1, 12)
- */
- Emitter.prototype.addInitialize = function() {
- var length = arguments.length, i;
- for ( i = 0; i < length; i++) {
- this.initializes.push(arguments[i]);
- }
- };
- /**
- * remove the Initialize
- * @method removeInitialize
- * @param {Proton.Initialize} initialize a initialize
- */
- Emitter.prototype.removeInitialize = function(initializer) {
- var index = this.initializes.indexOf(initializer);
- if (index > -1) {
- this.initializes.splice(index, 1);
+ return index;
}
- };
- /**
- * remove all Initializes
- * @method removeInitializers
- */
- Emitter.prototype.removeInitializers = function() {
- Proton.Util.destroyArray(this.initializes);
- };
- /**
- * add the Behaviour to particles;
- *
- * you can use Behaviours array:emitter.addBehaviour(Behaviour1,Behaviour2,Behaviour3);
- * @method addBehaviour
- * @param {Proton.Behaviour} behaviour like this new Proton.Color('random')
- */
- Emitter.prototype.addBehaviour = function() {
- var length = arguments.length, i;
- for ( i = 0; i < length; i++) {
- this.behaviours.push(arguments[i]);
- if (arguments[i].hasOwnProperty("parents"))
- arguments[i].parents.push(this);
+ /**
+ * remove all behaviours
+ * @method removeAllBehaviours
+ */
+
+ }, {
+ key: 'removeAllBehaviours',
+ value: function removeAllBehaviours() {
+ Util.destroyArray(this.behaviours);
}
- };
- /**
- * remove the Behaviour
- * @method removeBehaviour
- * @param {Proton.Behaviour} behaviour a behaviour
- */
- Emitter.prototype.removeBehaviour = function(behaviour) {
- var index = this.behaviours.indexOf(behaviour);
- if (index > -1)
- this.behaviours.splice(index, 1);
- };
- /**
- * remove all behaviours
- * @method removeAllBehaviours
- */
- Emitter.prototype.removeAllBehaviours = function() {
- Proton.Util.destroyArray(this.behaviours);
- };
- Emitter.prototype.integrate = function(time) {
- var damping = 1 - this.damping;
- Proton.integrator.integrate(this, time, damping);
- var length = this.particles.length, i;
- for ( i = 0; i < length; i++) {
- var particle = this.particles[i];
- particle.update(time, i);
- Proton.integrator.integrate(particle, time, damping);
+ // emitter update
- this.dispatchEvent(Proton.PARTICLE_UPDATE, particle);
+ }, {
+ key: 'update',
+ value: function update(time) {
+ this.age += time;
+ if (this.age >= this.life || this.dead) this.destroy();
+
+ this.emitting(time);
+ this.integrate(time);
}
- };
+ }, {
+ key: 'integrate',
+ value: function integrate(time) {
+ if (!this.parent) return;
- Emitter.prototype.emitting = function(time) {
- if (this.emitTotalTimes == 'once') {
- var length = this.rate.getValue(99999), i;
- for ( i = 0; i < length; i++) {
- this.createParticle();
- }
+ var damping = 1 - this.damping;
+ this.parent.integrator.calculate(this, time, damping);
+
+ var length = this.particles.length;
+ var i = void 0,
+ particle = void 0;
+
+ for (i = length - 1; i >= 0; i--) {
+ particle = this.particles[i];
+
+ // particle update
+ particle.update(time, i);
+ this.parent.integrator.calculate(particle, time, damping);
+ this.dispatch("PARTICLE_UPDATE", particle);
+
+ // check dead
+ if (particle.dead) {
+ this.dispatch("PARTICLE_DEAD", particle);
- this.emitTotalTimes = 'none';
- } else if (!isNaN(this.emitTotalTimes)) {
- this.emitTime += time;
- if (this.emitTime < this.emitTotalTimes) {
- var length = this.rate.getValue(time), i;
- for ( i = 0; i < length; i++) {
+ this.parent.pool.expire(particle);
+ this.particles.splice(i, 1);
+ }
+ }
+ }
+ }, {
+ key: 'dispatch',
+ value: function dispatch(event, target) {
+ this.parent && this.parent.dispatchEvent(event, target);
+ Proton.bindEmtterEvent && this.dispatchEvent(event, target);
+ }
+ }, {
+ key: 'emitting',
+ value: function emitting(time) {
+ if (this.totalEmitTimes == 'once') {
+ var i = void 0;
+ var length = this.rate.getValue(99999);
+
+ if (length > 0) this.emitSpeed = length;
+ for (i = 0; i < length; i++) {
this.createParticle();
+ }this.totalEmitTimes = 'none';
+ } else {
+ this.currentEmitTime += time;
+
+ if (this.currentEmitTime < this.totalEmitTimes) {
+ var _length = this.rate.getValue(time);
+ var _i = void 0;
+
+ if (_length > 0) this.emitSpeed = _length;
+ for (_i = 0; _i < _length; _i++) {
+ this.createParticle();
+ }
}
}
}
- }
- Emitter.prototype.update = function(time) {
- this.age += time;
- if (this.age >= this.life || this.dead) {
- this.destroy();
+ /**
+ * create single particle;
+ *
+ * can use emit({x:10},new Gravity(10),{'particleUpdate',fun}) or emit([{x:10},new Initialize],new Gravity(10),{'particleUpdate',fun})
+ * @method removeAllParticles
+ */
+
+ }, {
+ key: 'createParticle',
+ value: function createParticle(initialize, behaviour) {
+ var particle = this.parent.pool.get(Particle);
+ this.setupParticle(particle, initialize, behaviour);
+ this.dispatch("PARTICLE_CREATED", particle);
+
+ return particle;
}
+ }, {
+ key: 'setupParticle',
+ value: function setupParticle(particle, initialize, behaviour) {
+ var initializes = this.initializes;
+ var behaviours = this.behaviours;
+
+ if (initialize) {
+ initializes = Util.isArray(initialize) ? initialize : [initialize];
+ }
- this.emitting(time);
- this.integrate(time);
- var particle;
- var length = this.particles.length, k;
- for ( k = length - 1; k >= 0; k--) {
- particle = this.particles[k];
- if (particle.dead) {
- this.dispatchEvent(Proton.PARTICLE_DEAD , particle);
-
- Proton.pool.set(particle);
- this.particles.splice(k, 1);
+ if (behaviour) {
+ behaviour = Util.isArray(behaviour) ? behaviour : [behaviour];
}
- }
- };
- Emitter.prototype.setupParticle = function(particle, initialize, behaviour) {
- var initializes = this.initializes;
- var behaviours = this.behaviours;
+ particle.reset();
+ InitializeUtil.initialize(this, particle, initializes);
+ particle.addBehaviours(behaviours);
+ particle.parent = this;
- if (initialize) {
- if ( initialize instanceof Array)
- initializes = initialize;
- else
- initializes = [initialize];
+ this.particles.push(particle);
+ }
+ }, {
+ key: 'remove',
+ value: function remove() {
+ this.stop();
+ Util.destroy(this.particles);
}
- if (behaviour) {
- if ( behaviour instanceof Array)
- behaviours = behaviour;
- else
- behaviours = [behaviour];
+ /**
+ * Destory this Emitter
+ * @method destroy
+ */
+
+ }, {
+ key: 'destroy',
+ value: function destroy(slow) {
+ this.dead = true;
+ this.remove();
+ this.removeAllInitializers();
+ this.removeAllBehaviours();
+ this.parent && this.parent.removeEmitter(this);
}
+ }]);
+ return Emitter;
+}(Particle);
- particle.reset();
- Proton.InitializeUtil.initialize(this, particle, initializes);
- particle.addBehaviours(behaviours);
- particle.parent = this;
- this.particles.push(particle);
- };
+Emitter.ID = 0;
+EventDispatcher.bind(Emitter);
+
+var BehaviourEmitter = function (_Emitter) {
+ inherits(BehaviourEmitter, _Emitter);
/**
- * Destory this Emitter
- * @method destroy
- */
- Emitter.prototype.destroy = function() {
- this.dead = true;
- this.emitTotalTimes = -1;
- if (this.particles.length == 0) {
- this.removeInitializers();
- this.removeAllBehaviours();
+ * The BehaviourEmitter class inherits from Proton.Emitter
+ *
+ * use the BehaviourEmitter you can add behaviours to self;
+ * @class Proton.BehaviourEmitter
+ * @constructor
+ * @param {Object} pObj the parameters object;
+ */
+ function BehaviourEmitter(pObj) {
+ classCallCheck(this, BehaviourEmitter);
- if (this.parent)
- this.parent.removeEmitter(this);
- }
+ var _this = possibleConstructorReturn(this, (BehaviourEmitter.__proto__ || Object.getPrototypeOf(BehaviourEmitter)).call(this, pObj));
+
+ _this.selfBehaviours = [];
+ return _this;
}
- Proton.Emitter = Emitter;
+ createClass(BehaviourEmitter, [{
+ key: 'addSelfBehaviour',
+ /**
+ * add the Behaviour to emitter;
+ *
+ * you can use Behaviours array:emitter.addSelfBehaviour(Behaviour1,Behaviour2,Behaviour3);
+ * @method addSelfBehaviour
+ * @param {Proton.Behaviour} behaviour like this new Proton.Color('random')
+ */
+ value: function addSelfBehaviour() {
+ for (var _len = arguments.length, rest = Array(_len), _key = 0; _key < _len; _key++) {
+ rest[_key] = arguments[_key];
+ }
- /**
- * The BehaviourEmitter class inherits from Proton.Emitter
- *
- * use the BehaviourEmitter you can add behaviours to self;
- * @class Proton.BehaviourEmitter
- * @constructor
- * @param {Object} pObj the parameters object;
- */
- function BehaviourEmitter(pObj) {
- this.selfBehaviours = [];
- BehaviourEmitter._super_.call(this, pObj);
- };
+ var length = rest.length;
+ var i = void 0;
- Proton.Util.inherits(BehaviourEmitter, Proton.Emitter);
- /**
- * add the Behaviour to emitter;
- *
- * you can use Behaviours array:emitter.addSelfBehaviour(Behaviour1,Behaviour2,Behaviour3);
- * @method addSelfBehaviour
- * @param {Proton.Behaviour} behaviour like this new Proton.Color('random')
- */
- BehaviourEmitter.prototype.addSelfBehaviour = function() {
- var length = arguments.length, i;
- for ( i = 0; i < length; i++) {
- this.selfBehaviours.push(arguments[i]);
+ for (i = 0; i < length; i++) {
+ this.selfBehaviours.push(rest[i]);
+ }
}
- };
- /**
- * remove the Behaviour for self
- * @method removeSelfBehaviour
- * @param {Proton.Behaviour} behaviour a behaviour
- */
- BehaviourEmitter.prototype.removeSelfBehaviour = function(behaviour) {
- var index = this.selfBehaviours.indexOf(behaviour);
- if (index > -1)
- this.selfBehaviours.splice(index, 1);
- };
+ }, {
+ key: 'removeSelfBehaviour',
- BehaviourEmitter.prototype.update = function(time) {
- BehaviourEmitter._super_.prototype.update.call(this, time);
- if (!this.sleep) {
- var length = this.selfBehaviours.length, i;
- for ( i = 0; i < length; i++) {
- this.selfBehaviours[i].applyBehaviour(this, time, i)
- }
+ /**
+ * remove the Behaviour for self
+ * @method removeSelfBehaviour
+ * @param {Proton.Behaviour} behaviour a behaviour
+ */
+ value: function removeSelfBehaviour(behaviour) {
+ var index = this.selfBehaviours.indexOf(behaviour);
+ if (index > -1) this.selfBehaviours.splice(index, 1);
}
- }
+ }, {
+ key: 'update',
+ value: function update(time) {
+ get(BehaviourEmitter.prototype.__proto__ || Object.getPrototypeOf(BehaviourEmitter.prototype), 'update', this).call(this, time);
- Proton.BehaviourEmitter = BehaviourEmitter;
+ if (!this.sleep) {
+ var length = this.selfBehaviours.length;
+ var i = void 0;
+ for (i = 0; i < length; i++) {
+ this.selfBehaviours[i].applyBehaviour(this, time, i);
+ }
+ }
+ }
+ }]);
+ return BehaviourEmitter;
+}(Emitter);
+var FollowEmitter = function (_Emitter) {
+ inherits(FollowEmitter, _Emitter);
/**
- * The FollowEmitter class inherits from Proton.Emitter
- *
- * use the FollowEmitter will emit particle when mousemoving
- *
- * @class Proton.FollowEmitter
- * @constructor
- * @param {Element} mouseTarget mouseevent's target;
- * @param {Number} ease the easing of following speed;
- * @default 0.7
- * @param {Object} pObj the parameters object;
- */
+ * The FollowEmitter class inherits from Proton.Emitter
+ *
+ * use the FollowEmitter will emit particle when mousemoving
+ *
+ * @class Proton.FollowEmitter
+ * @constructor
+ * @param {Element} mouseTarget mouseevent's target;
+ * @param {Number} ease the easing of following speed;
+ * @default 0.7
+ * @param {Object} pObj the parameters object;
+ */
function FollowEmitter(mouseTarget, ease, pObj) {
- this.mouseTarget = Proton.Util.initValue(mouseTarget, window);
- this.ease = Proton.Util.initValue(ease, .7);
- this._allowEmitting = false;
- this.initEventHandler();
- FollowEmitter._super_.call(this, pObj);
- };
+ classCallCheck(this, FollowEmitter);
- Proton.Util.inherits(FollowEmitter, Proton.Emitter);
- FollowEmitter.prototype.initEventHandler = function() {
- var self = this;
- this.mousemoveHandler = function(e) {
- self.mousemove.call(self, e);
- };
-
- this.mousedownHandler = function(e) {
- self.mousedown.call(self, e);
- };
-
- this.mouseupHandler = function(e) {
- self.mouseup.call(self, e);
- };
- this.mouseTarget.addEventListener('mousemove', this.mousemoveHandler, false);
- }
- /**
- * start emit particle
- * @method emit
- */
- FollowEmitter.prototype.emit = function() {
- this._allowEmitting = true;
- }
- /**
- * stop emiting
- * @method stopEmit
- */
- FollowEmitter.prototype.stopEmit = function() {
- this._allowEmitting = false;
- }
+ var _this = possibleConstructorReturn(this, (FollowEmitter.__proto__ || Object.getPrototypeOf(FollowEmitter)).call(this, pObj));
- FollowEmitter.prototype.mousemove = function(e) {
- if (e.layerX || e.layerX == 0) {
- this.p.x += (e.layerX - this.p.x) * this.ease;
- this.p.y += (e.layerY - this.p.y) * this.ease;
- } else if (e.offsetX || e.offsetX == 0) {
- this.p.x += (e.offsetX - this.p.x) * this.ease;
- this.p.y += (e.offsetY - this.p.y) * this.ease;
- }
- if (this._allowEmitting)
- FollowEmitter._super_.prototype.emit.call(this, 'once');
- };
- /**
- * Destory this Emitter
- * @method destroy
- */
- FollowEmitter.prototype.destroy = function() {
- FollowEmitter._super_.prototype.destroy.call(this);
- this.mouseTarget.removeEventListener('mousemove', this.mousemoveHandler, false);
- }
+ _this.mouseTarget = Util.initValue(mouseTarget, window);
+ _this.ease = Util.initValue(ease, .7);
- Proton.FollowEmitter = FollowEmitter;
-
-
-
- var ease = ease || {
- easeLinear : function(value) {
- return value;
- },
-
- easeInQuad : function(value) {
- return Math.pow(value, 2);
- },
-
- easeOutQuad : function(value) {
- return -(Math.pow((value - 1), 2) - 1);
- },
-
- easeInOutQuad : function(value) {
- if ((value /= 0.5) < 1)
- return 0.5 * Math.pow(value, 2);
- return -0.5 * ((value -= 2) * value - 2);
- },
-
- easeInCubic : function(value) {
- return Math.pow(value, 3);
- },
-
- easeOutCubic : function(value) {
- return (Math.pow((value - 1), 3) + 1);
- },
-
- easeInOutCubic : function(value) {
- if ((value /= 0.5) < 1)
- return 0.5 * Math.pow(value, 3);
- return 0.5 * (Math.pow((value - 2), 3) + 2);
- },
-
- easeInQuart : function(value) {
- return Math.pow(value, 4);
- },
-
- easeOutQuart : function(value) {
- return -(Math.pow((value - 1), 4) - 1);
- },
-
- easeInOutQuart : function(value) {
- if ((value /= 0.5) < 1)
- return 0.5 * Math.pow(value, 4);
- return -0.5 * ((value -= 2) * Math.pow(value, 3) - 2);
- },
-
- easeInSine : function(value) {
- return -Math.cos(value * (Math.PI / 2)) + 1;
- },
-
- easeOutSine : function(value) {
- return Math.sin(value * (Math.PI / 2));
- },
-
- easeInOutSine : function(value) {
- return (-0.5 * (Math.cos(Math.PI * value) - 1));
- },
-
- easeInExpo : function(value) {
- return (value === 0) ? 0 : Math.pow(2, 10 * (value - 1));
- },
-
- easeOutExpo : function(value) {
- return (value === 1) ? 1 : -Math.pow(2, -10 * value) + 1;
- },
-
- easeInOutExpo : function(value) {
- if (value === 0)
- return 0;
- if (value === 1)
- return 1;
- if ((value /= 0.5) < 1)
- return 0.5 * Math.pow(2, 10 * (value - 1));
- return 0.5 * (-Math.pow(2, -10 * --value) + 2);
- },
-
- easeInCirc : function(value) {
- return -(Math.sqrt(1 - (value * value)) - 1);
- },
-
- easeOutCirc : function(value) {
- return Math.sqrt(1 - Math.pow((value - 1), 2));
- },
-
- easeInOutCirc : function(value) {
- if ((value /= 0.5) < 1)
- return -0.5 * (Math.sqrt(1 - value * value) - 1);
- return 0.5 * (Math.sqrt(1 - (value -= 2) * value) + 1);
- },
-
- easeInBack : function(value) {
- var s = 1.70158;
- return (value) * value * ((s + 1) * value - s);
- },
-
- easeOutBack : function(value) {
- var s = 1.70158;
- return ( value = value - 1) * value * ((s + 1) * value + s) + 1;
- },
-
- easeInOutBack : function(value) {
- var s = 1.70158;
- if ((value /= 0.5) < 1)
- return 0.5 * (value * value * (((s *= (1.525)) + 1) * value - s));
- return 0.5 * ((value -= 2) * value * (((s *= (1.525)) + 1) * value + s) + 2);
- },
-
- setEasingByName: function(easeName) {
- if (!!ease[easeName])
- return ease[easeName];
- else
- return ease.easeLinear;
- }
+ _this._allowEmitting = false;
+ _this.initEventHandler();
+ return _this;
}
- for (var key in ease) {
- if (key != "setEasingByName") Proton[key] = ease[key];
- }
+ createClass(FollowEmitter, [{
+ key: 'initEventHandler',
+ value: function initEventHandler() {
+ var _this2 = this;
+
+ this.mousemoveHandler = function (e) {
+ return _this2.mousemove.call(_this2, e);
+ };
+ this.mousedownHandler = function (e) {
+ return _this2.mousedown.call(_this2, e);
+ };
+ this.mouseupHandler = function (e) {
+ return _this2.mouseup.call(_this2, e);
+ };
- Proton.ease = ease;
-
+ this.mouseTarget.addEventListener('mousemove', this.mousemoveHandler, false);
+ }
+ /**
+ * start emit particle
+ * @method emit
+ */
+
+ }, {
+ key: 'emit',
+ value: function emit() {
+ this._allowEmitting = true;
+ }
-//the own renderer
+ /**
+ * stop emiting
+ * @method stop
+ */
+
+ }, {
+ key: 'stop',
+ value: function stop() {
+ this._allowEmitting = false;
+ }
+ }, {
+ key: 'mousemove',
+ value: function mousemove(e) {
+ if (e.layerX || e.layerX == 0) {
+ this.p.x += (e.layerX - this.p.x) * this.ease;
+ this.p.y += (e.layerY - this.p.y) * this.ease;
+ } else if (e.offsetX || e.offsetX == 0) {
+ this.p.x += (e.offsetX - this.p.x) * this.ease;
+ this.p.y += (e.offsetY - this.p.y) * this.ease;
+ }
- function Renderer(type, proton, element) {
- ///element dom/div canvas/canvas easeljs/cantainer(or stage)
- this.element = element;
- this.type = Proton.Util.initValue(type, 'canvas');
- this.proton = proton;
- this.renderer = this.getRenderer();
- }
+ if (this._allowEmitting) get(FollowEmitter.prototype.__proto__ || Object.getPrototypeOf(FollowEmitter.prototype), 'emit', this).call(this, 'once');
+ }
+ }, {
+ key: 'destroy',
- Renderer.prototype = {
- start : function() {
- this.addEventHandler();
- this.renderer.start();
- },
- stop : function() {
- this.renderer.stop();
- },
-
- resize : function(width, height) {
- this.renderer.resize(width, height);
- },
- setStroke : function(color, thinkness) {
- if (this.renderer.hasOwnProperty('stroke'))
- this.renderer.setStroke(color, thinkness);
- else
- alert('Sorry this renderer do not suppest stroke method!');
- },
- createImageData : function(data) {
- if (this.renderer instanceof Proton.PixelRender)
- this.renderer.createImageData(data);
- },
- setMaxRadius : function(radius) {
- if (this.renderer instanceof Proton.WebGLRender)
- this.renderer.setMaxRadius(radius);
- },
- blendEquation : function(A) {
- if (this.renderer instanceof Proton.WebGLRender)
- this.renderer.blendEquation(A);
- },
- blendFunc : function(A, B) {
- if (this.renderer instanceof Proton.WebGLRender)
- this.renderer.blendFunc(A, B);
- },
- setType : function(type) {
- this.type = type;
- this.renderer = this.getRenderer();
- },
- getRenderer : function() {
- switch(this.type) {
- case 'pixi':
- return new Proton.PixiRender(this.proton, this.element);
- break;
-
- case 'dom':
- return new Proton.DomRender(this.proton, this.element);
- break;
-
- case 'canvas':
- return new Proton.CanvasRender(this.proton, this.element);
- break;
-
- case 'webgl':
- return new Proton.WebGLRender(this.proton, this.element);
- break;
-
- case 'easel':
- return new Proton.EaselRender(this.proton, this.element);
- break;
-
- case 'easeljs':
- return new Proton.EaselRender(this.proton, this.element);
- break;
-
- case 'pixel':
- return new Proton.PixelRender(this.proton, this.element);
- break;
-
- default:
- return new Proton.BaseRender(this.proton, this.element);
- }
- },
- render : function(callback) {
- this.renderer.render(callback);
- },
- addEventHandler : function() {
- if (this.onProtonUpdate)
- this.renderer.onProtonUpdate = this.onProtonUpdate;
-
- if (this.onParticleCreated)
- this.renderer.onParticleCreated = this.onParticleCreated;
-
- if (this.onParticleUpdate)
- this.renderer.onParticleUpdate = this.onParticleUpdate;
-
- if (this.onParticleDead)
- this.renderer.onParticleDead = this.onParticleDead;
+ /**
+ * Destory this Emitter
+ * @method destroy
+ */
+ value: function destroy() {
+ get(FollowEmitter.prototype.__proto__ || Object.getPrototypeOf(FollowEmitter.prototype), 'destroy', this).call(this);
+ this.mouseTarget.removeEventListener('mousemove', this.mousemoveHandler, false);
}
- }
+ }]);
+ return FollowEmitter;
+}(Emitter);
- Proton.Renderer = Renderer;
+var BaseRenderer = function () {
+ function BaseRenderer(element, stroke) {
+ classCallCheck(this, BaseRenderer);
+ this.element = element;
+ this.stroke = stroke;
+ this.initHandler();
- function BaseRender(proton, element, stroke) {
- this.proton = proton;
- this.element = element;
- this.stroke = stroke;
- this.pool = new Proton.Pool();
- }
+ this.circleConf = { isCircle: true };
+ this.pool = new Pool();
+ this.name = 'BaseRenderer';
+ }
+
+ createClass(BaseRenderer, [{
+ key: 'setStroke',
+ value: function setStroke(color, thinkness) {
+ color = Util.initValue(color, '#000000');
+ thinkness = Util.initValue(thinkness, 1);
+
+ this.stroke = { color: color, thinkness: thinkness };
+ }
+ }, {
+ key: 'initHandler',
+ value: function initHandler() {
+ var _this = this;
+
+ this._protonUpdateHandler = function () {
+ _this.onProtonUpdate.call(_this);
+ };
+ this._protonUpdateAfterHandler = function () {
+ _this.onProtonUpdateAfter.call(_this);
+ };
+ this._emitterAddedHandler = function (emitter) {
+ _this.onEmitterAdded.call(_this, emitter);
+ };
+ this._emitterRemovedHandler = function (emitter) {
+ _this.onEmitterRemoved.call(_this, emitter);
+ };
+ this._particleCreatedHandler = function (particle) {
+ _this.onParticleCreated.call(_this, particle);
+ };
+ this._particleUpdateHandler = function (particle) {
+ _this.onParticleUpdate.call(_this, particle);
+ };
+ this._particleDeadHandler = function (particle) {
+ _this.onParticleDead.call(_this, particle);
+ };
+ }
+ }, {
+ key: 'init',
+ value: function init(proton) {
+ this.parent = proton;
+ proton.addEventListener(Proton.PROTON_UPDATE, this._protonUpdateHandler);
+ proton.addEventListener(Proton.PROTON_UPDATE_AFTER, this._protonUpdateAfterHandler);
- BaseRender.prototype = {
- start : function() {
- var self = this;
- this.proton.addEventListener(Proton.PROTON_UPDATE, function() {
- self.onProtonUpdate.call(self);
- });
+ proton.addEventListener(Proton.EMITTER_ADDED, this._emitterAddedHandler);
+ proton.addEventListener(Proton.EMITTER_REMOVED, this._emitterRemovedHandler);
- this.proton.addEventListener(Proton.PROTON_UPDATE_AFTER, function() {
- self.onProtonUpdateAfter.call(self);
- });
+ proton.addEventListener(Proton.PARTICLE_CREATED, this._particleCreatedHandler);
+ proton.addEventListener(Proton.PARTICLE_UPDATE, this._particleUpdateHandler);
+ proton.addEventListener(Proton.PARTICLE_DEAD, this._particleDeadHandler);
+ }
+ }, {
+ key: 'resize',
+ value: function resize(width, height) {}
+ }, {
+ key: 'remove',
+ value: function remove(proton) {
+ this.parent.removeEventListener(Proton.PROTON_UPDATE, this._protonUpdateHandler);
+ this.parent.removeEventListener(Proton.PROTON_UPDATE_AFTER, this._protonUpdateAfterHandler);
+
+ this.parent.removeEventListener(Proton.EMITTER_ADDED, this._emitterAddedHandler);
+ this.parent.removeEventListener(Proton.EMITTER_REMOVED, this._emitterRemovedHandler);
+
+ this.parent.removeEventListener(Proton.PARTICLE_CREATED, this._particleCreatedHandler);
+ this.parent.removeEventListener(Proton.PARTICLE_UPDATE, this._particleUpdateHandler);
+ this.parent.removeEventListener(Proton.PARTICLE_DEAD, this._particleDeadHandler);
+
+ this.parent = null;
+ }
+ }, {
+ key: 'destroy',
+ value: function destroy() {
+ this.remove();
+ }
+ }, {
+ key: 'onProtonUpdate',
+ value: function onProtonUpdate() {}
+ }, {
+ key: 'onProtonUpdateAfter',
+ value: function onProtonUpdateAfter() {}
+ }, {
+ key: 'onEmitterAdded',
+ value: function onEmitterAdded(emitter) {}
+ }, {
+ key: 'onEmitterRemoved',
+ value: function onEmitterRemoved(emitter) {}
+ }, {
+ key: 'onParticleCreated',
+ value: function onParticleCreated(particle) {}
+ }, {
+ key: 'onParticleUpdate',
+ value: function onParticleUpdate(particle) {}
+ }, {
+ key: 'onParticleDead',
+ value: function onParticleDead(particle) {}
+ }]);
+ return BaseRenderer;
+}();
+
+var CanvasRenderer = function (_BaseRenderer) {
+ inherits(CanvasRenderer, _BaseRenderer);
+
+ function CanvasRenderer(element) {
+ classCallCheck(this, CanvasRenderer);
+
+ var _this = possibleConstructorReturn(this, (CanvasRenderer.__proto__ || Object.getPrototypeOf(CanvasRenderer)).call(this, element));
+
+ _this.stroke = null;
+ _this.context = _this.element.getContext("2d");
+ _this.bufferCache = {};
+
+ _this.name = 'CanvasRenderer';
+ return _this;
+ }
- this.proton.addEventListener(Proton.EMITTER_ADDED, function(emitter) {
- self.onEmitterAdded.call(self, emitter);
- });
+ createClass(CanvasRenderer, [{
+ key: 'resize',
+ value: function resize(width, height) {
+ this.element.width = width;
+ this.element.height = height;
+ }
+ }, {
+ key: 'onProtonUpdate',
+ value: function onProtonUpdate() {
+ this.context.clearRect(0, 0, this.element.width, this.element.height);
+ }
+ }, {
+ key: 'onParticleCreated',
+ value: function onParticleCreated(particle) {
+ if (particle.body) ImgUtil.getImgFromCache(particle.body, this.addImg2Body, particle);else particle.color = particle.color || '#ff0000';
+ }
+ }, {
+ key: 'onParticleUpdate',
+ value: function onParticleUpdate(particle) {
+ if (particle.body) {
+ if (particle.body instanceof Image) this.drawImage(particle);
+ } else {
+ this.drawCircle(particle);
+ }
+ }
+ }, {
+ key: 'onParticleDead',
+ value: function onParticleDead(particle) {
+ particle.body = null;
+ }
- this.proton.addEventListener(Proton.EMITTER_REMOVED, function(emitter) {
- self.onEmitterRemoved.call(self, emitter);
- });
+ // private
- var length = this.proton.emitters.length, i;
- for ( i = 0; i < length; i++) {
- var emitter = this.proton.emitters[i];
- this.addEmitterListener(emitter);
- }
- },
-
- resize : function(width, height) {
- },
-
- addEmitterListener : function(emitter) {
- var self = this;
- emitter.addEventListener(Proton.PARTICLE_CREATED, function(particle) {
- self.onParticleCreated.call(self, particle);
- });
- emitter.addEventListener(Proton.PARTICLE_UPDATE, function(particle) {
- self.onParticleUpdate.call(self, particle);
- });
- emitter.addEventListener(Proton.PARTICLE_DEAD, function(particle) {
- self.onParticleDead.call(self, particle);
- });
- },
-
- stop : function() {
- var length = this.proton.emitters.length, i;
- this.proton.removeAllEventListeners();
- for ( i = 0; i < length; i++) {
- var emitter = this.proton.emitters[i];
- emitter.removeAllEventListeners();
- }
- },
+ }, {
+ key: 'addImg2Body',
+ value: function addImg2Body(img, particle) {
+ particle.body = img;
+ }
- onEmitterAdded : function(emitter) {
- this.addEmitterListener(emitter);
- },
+ // private drawCircle --
- onEmitterRemoved : function(emitter) {
- emitter.removeAllEventListeners();
- },
+ }, {
+ key: 'drawImage',
+ value: function drawImage(particle) {
+ var w = particle.body.width * particle.scale | 0;
+ var h = particle.body.height * particle.scale | 0;
+ var x = particle.p.x - w / 2;
+ var y = particle.p.y - h / 2;
- onProtonUpdate : function() {
+ if (!!particle.color) {
+ if (!particle.transform["buffer"]) particle.transform.buffer = this.createBuffer(particle.body);
- },
+ var bufferContext = particle.transform.buffer.getContext('2d');
+ bufferContext.clearRect(0, 0, particle.transform.buffer.width, particle.transform.buffer.height);
+ bufferContext.globalAlpha = particle.alpha;
+ bufferContext.drawImage(particle.body, 0, 0);
- onProtonUpdateAfter : function() {
+ bufferContext.globalCompositeOperation = "source-atop";
+ bufferContext.fillStyle = ColorUtil.rgbToHex(particle.transform.rgb);
+ bufferContext.fillRect(0, 0, particle.transform.buffer.width, particle.transform.buffer.height);
+ bufferContext.globalCompositeOperation = "source-over";
+ bufferContext.globalAlpha = 1;
- },
+ this.context.drawImage(particle.transform.buffer, 0, 0, particle.transform.buffer.width, particle.transform.buffer.height, x, y, w, h);
+ } else {
+ this.context.save();
- onParticleCreated : function(particle) {
+ this.context.globalAlpha = particle.alpha;
+ this.context.translate(particle.p.x, particle.p.y);
+ this.context.rotate(MathUtils.degreeTransform(particle.rotation));
+ this.context.translate(-particle.p.x, -particle.p.y);
+ this.context.drawImage(particle.body, 0, 0, particle.body.width, particle.body.height, x, y, w, h);
- },
+ this.context.globalAlpha = 1;
+ this.context.restore();
+ }
+ }
- onParticleUpdate : function(particle) {
+ // private drawCircle --
- },
+ }, {
+ key: 'drawCircle',
+ value: function drawCircle(particle) {
+ if (particle.transform["rgb"]) this.context.fillStyle = 'rgba(' + particle.transform.rgb.r + ',' + particle.transform.rgb.g + ',' + particle.transform.rgb.b + ',' + particle.alpha + ')';else this.context.fillStyle = particle.color;
- onParticleDead : function(particle) {
+ // draw circle
+ this.context.beginPath();
+ this.context.arc(particle.p.x, particle.p.y, particle.radius, 0, Math.PI * 2, true);
- }
- }
+ if (this.stroke) {
+ this.context.strokeStyle = this.stroke.color;
+ this.context.lineWidth = this.stroke.thinkness;
+ this.context.stroke();
+ }
- Proton.BaseRender = BaseRender;
+ this.context.closePath();
+ this.context.fill();
+ }
+ // private createBuffer --
+ }, {
+ key: 'createBuffer',
+ value: function createBuffer(image) {
+ if (image instanceof Image) {
+ var size = image.width + '_' + image.height;
+ var canvas = this.bufferCache[size];
- function DomRender(proton, element) {
- DomRender._super_.call(this, proton, element);
- this.stroke = null;
- }
+ if (!canvas) {
+ canvas = document.createElement('canvas');
+ canvas.width = image.width;
+ canvas.height = image.height;
+ this.bufferCache[size] = canvas;
+ }
+ return canvas;
+ }
+ }
+ }]);
+ return CanvasRenderer;
+}(BaseRenderer);
- Proton.Util.inherits(DomRender, Proton.BaseRender);
+var DomRenderer = function (_BaseRenderer) {
+ inherits(DomRenderer, _BaseRenderer);
- DomRender.prototype.start = function() {
- DomRender._super_.prototype.start.call(this);
- }
+ function DomRenderer(element) {
+ classCallCheck(this, DomRenderer);
- DomRender.prototype.setStroke = function(color, thinkness) {
- color = Proton.Util.initValue(color, '#000000');
- thinkness = Proton.Util.initValue(thinkness, 1);
- this.stroke = {
- color : color,
- thinkness : thinkness
- };
- }
+ var _this = possibleConstructorReturn(this, (DomRenderer.__proto__ || Object.getPrototypeOf(DomRenderer)).call(this, element));
- DomRender.prototype.onProtonUpdate = function() {
- }
+ _this.stroke = null;
+ _this.pool.create = function (body, particle) {
+ return _this.createBody(body, particle);
+ };
+ _this.addImg2Body = _this.addImg2Body.bind(_this);
- DomRender.prototype.onParticleCreated = function(particle) {
- if (particle.target) {
- var self = this;
- Proton.Util.getImage(particle.target, particle, false, function(particle) {
- self.setImgInDIV.call(self, particle);
- });
- } else {
- particle.transform.canvas = Proton.DomUtil.createCanvas(particle.id + '_canvas', particle.radius + 1, particle.radius + 1, 'absolute');
- particle.transform.bakOldRadius = particle.radius;
+ _this.transform3d = false;
- if (this.stroke) {
- particle.transform.canvas.width = 2 * particle.radius + this.stroke.thinkness * 2;
- particle.transform.canvas.height = 2 * particle.radius + this.stroke.thinkness * 2;
- } else {
- particle.transform.canvas.width = 2 * particle.radius + 1;
- particle.transform.canvas.height = 2 * particle.radius + 1;
- }
+ _this.name = 'DomRenderer';
+ return _this;
+ }
- particle.transform.context = particle.transform.canvas.getContext('2d');
- particle.transform.context.fillStyle = particle.color;
- particle.transform.context.beginPath();
- particle.transform.context.arc(particle.radius, particle.radius, particle.radius, 0, Math.PI * 2, true);
+ createClass(DomRenderer, [{
+ key: 'onParticleCreated',
+ value: function onParticleCreated(particle) {
+ if (particle.body) {
+ ImgUtil.getImgFromCache(particle.body, this.addImg2Body, particle);
+ } else {
+ particle.body = this.pool.get(this.circleConf, particle);
+ this.element.appendChild(particle.body);
+ }
+ }
+ }, {
+ key: 'onParticleUpdate',
+ value: function onParticleUpdate(particle) {
+ if (this.bodyReady(particle)) {
+ if (this.transform3d) DomUtil.transform3d(particle.body, particle.p.x, particle.p.y, particle.scale, particle.rotation);else DomUtil.transform(particle.body, particle.p.x, particle.p.y, particle.scale, particle.rotation);
+
+ particle.body.style.opacity = particle.alpha;
+ if (particle.body.isCircle) {
+ particle.body.style.backgroundColor = particle.color || '#ff0000';
+ }
+ }
+ }
+ }, {
+ key: 'onParticleDead',
+ value: function onParticleDead(particle) {
+ if (this.bodyReady(particle)) {
+ this.element.removeChild(particle.body);
+ this.pool.expire(particle.body);
+ particle.body = null;
+ }
+ }
+ }, {
+ key: 'bodyReady',
+ value: function bodyReady(particle) {
+ return _typeof(particle.body) === 'object' && particle.body && !particle.body.isInner;
+ }
- if (this.stroke) {
- particle.transform.context.strokeStyle = this.stroke.color;
- particle.transform.context.lineWidth = this.stroke.thinkness;
- particle.transform.context.stroke();
- }
+ // private
- particle.transform.context.closePath();
- particle.transform.context.fill();
- this.element.appendChild(particle.transform.canvas);
- }
+ }, {
+ key: 'addImg2Body',
+ value: function addImg2Body(img, particle) {
+ if (particle.dead) return;
+ particle.body = this.pool.get(img, particle);
+ DomUtil.resize(particle.body, img.width, img.height);
- }
+ this.element.appendChild(particle.body);
+ }
+ }, {
+ key: 'createBody',
+ value: function createBody(body, particle) {
+ if (body.isCircle) return this.createCircle(particle);else return this.createSprite(body, particle);
+ }
- DomRender.prototype.onParticleUpdate = function(particle) {
- if (particle.target) {
- if (particle.target instanceof Image) {
- particle.transform.canvas.style.opacity = particle.alpha;
- Proton.DomUtil.transformDom(particle.transform.canvas, particle.p.x - particle.target.width / 2, particle.p.y - particle.target.height / 2, particle.scale, particle.rotation);
- }
- } else {
- particle.transform.canvas.style.opacity = particle.alpha;
- if (particle.transform['oldRadius'])
- Proton.DomUtil.transformDom(particle.transform.canvas, particle.p.x - particle.transform.oldRadius, particle.p.y - particle.transform.oldRadius, particle.scale, particle.rotation);
- else
- Proton.DomUtil.transformDom(particle.transform.canvas, particle.p.x - particle.transform.bakOldRadius, particle.p.y - particle.transform.bakOldRadius, particle.scale, particle.rotation);
- }
- }
+ // private --
- DomRender.prototype.onParticleDead = function(particle) {
- if (particle.transform.canvas)
- this.element.removeChild(particle.transform.canvas);
- }
+ }, {
+ key: 'createCircle',
+ value: function createCircle(particle) {
+ var dom = DomUtil.createDiv(particle.id + '_dom', 2 * particle.radius, 2 * particle.radius);
+ dom.style.borderRadius = particle.radius + 'px';
- DomRender.prototype.setImgInDIV = function(particle) {
- particle.transform.canvas = Proton.DomUtil.createCanvas(particle.id + '_canvas', particle.target.width + 1, particle.target.height + 1, 'absolute', particle.p.x - particle.radius, particle.p.y - particle.radius);
- particle.transform.context = particle.transform.canvas.getContext('2d');
- particle.transform.context.drawImage(particle.target, 0, 0, particle.target.width, particle.target.height);
- this.element.appendChild(particle.transform.canvas);
- }
+ if (this.stroke) {
+ dom.style.borderColor = this.stroke.color;
+ dom.style.borderWidth = this.stroke.thinkness + 'px';
+ }
+ dom.isCircle = true;
+
+ return dom;
+ }
+ }, {
+ key: 'createSprite',
+ value: function createSprite(body, particle) {
+ var url = typeof body === 'string' ? body : body.src;
+ var dom = DomUtil.createDiv(particle.id + '_dom', body.width, body.height);
+ dom.style.backgroundImage = 'url(' + url + ')';
+
+ return dom;
+ }
+ }]);
+ return DomRenderer;
+}(BaseRenderer);
- Proton.DomRender = DomRender;
+var EaselRenderer = function (_BaseRenderer) {
+ inherits(EaselRenderer, _BaseRenderer);
+ function EaselRenderer(element, stroke) {
+ classCallCheck(this, EaselRenderer);
+ var _this = possibleConstructorReturn(this, (EaselRenderer.__proto__ || Object.getPrototypeOf(EaselRenderer)).call(this, element));
- function EaselRender(proton, element, stroke) {
- EaselRender._super_.call(this, proton, element);
- this.stroke = stroke;
+ _this.stroke = stroke;
+ _this.name = 'EaselRenderer';
+ return _this;
}
+ createClass(EaselRenderer, [{
+ key: 'onParticleCreated',
+ value: function onParticleCreated(particle) {
+ if (particle.body) {
+ this.createSprite(particle);
+ } else {
+ this.createCircle(particle);
+ }
- Proton.Util.inherits(EaselRender, Proton.BaseRender);
- EaselRender.prototype.resize = function(width, height) {
+ this.element.addChild(particle.body);
+ }
+ }, {
+ key: 'onParticleUpdate',
+ value: function onParticleUpdate(particle) {
+ if (particle.body) {
+ particle.body.x = particle.p.x;
+ particle.body.y = particle.p.y;
+
+ particle.body.alpha = particle.alpha;
+ particle.body.scaleX = particle.body.scaleY = particle.scale;
+ particle.body.rotation = particle.rotation;
+ }
+ }
+ }, {
+ key: 'onParticleDead',
+ value: function onParticleDead(particle) {
+ if (particle.body) {
+ particle.body.parent && particle.body.parent.removeChild(particle.body);
+ this.pool.expire(particle.body);
+ particle.body = null;
+ }
- }
- EaselRender.prototype.start = function() {
- EaselRender._super_.prototype.start.call(this);
- };
+ if (particle.graphics) this.pool.expire(particle.graphics);
+ }
- EaselRender.prototype.onProtonUpdate = function() {
+ // private
- }
+ }, {
+ key: 'createSprite',
+ value: function createSprite(particle) {
+ particle.body = this.pool.get(particle.body);
- EaselRender.prototype.onParticleCreated = function(particle) {
- if (particle.target) {
- particle.target = this.pool.get(particle.target);
- if (!particle.target.parent) {
- if (!!particle.target['image']) {
- particle.target.regX = particle.target.image.width / 2;
- particle.target.regY = particle.target.image.height / 2;
- }
- this.element.addChild(particle.target);
+ if (particle.body.parent) return;
+ if (particle.body['image']) {
+ particle.body.regX = particle.body.image.width / 2;
+ particle.body.regY = particle.body.image.height / 2;
}
- } else {
+ }
+ }, {
+ key: 'createCircle',
+ value: function createCircle(particle) {
var graphics = this.pool.get(createjs.Graphics);
+
if (this.stroke) {
- if (this.stroke == true) {
- graphics.beginStroke('#000000');
- } else if (this.stroke instanceof String) {
- graphics.beginStroke(this.stroke);
- }
+ if (this.stroke instanceof String) graphics.beginStroke(this.stroke);else graphics.beginStroke('#000000');
}
+ graphics.beginFill(particle.color || '#ff0000').drawCircle(0, 0, particle.radius);
- graphics.beginFill(particle.color).drawCircle(0, 0, particle.radius);
- var shape = new createjs.Shape(graphics);
- particle.target = shape;
- this.element.addChild(particle.target);
- }
- }
+ var shape = this.pool.get(createjs.Shape, [graphics]);
- EaselRender.prototype.onParticleUpdate = function(particle) {
- if (particle.target) {
- particle.target.x = particle.p.x;
- particle.target.y = particle.p.y;
- particle.target.alpha = particle.alpha;
- particle.target.scaleX = particle.target.scaleY = particle.scale;
- particle.target.rotation = particle.rotation;
+ particle.body = shape;
+ particle.graphics = graphics;
}
- }
+ }]);
+ return EaselRenderer;
+}(BaseRenderer);
- EaselRender.prototype.onParticleDead = function(particle) {
- if (particle.target) {
- particle.target.parent && particle.target.parent.removeChild(particle.target);
- this.pool.set(particle.target);
- particle.target = null;
- }
- }
+var PixelRenderer = function (_BaseRenderer) {
+ inherits(PixelRenderer, _BaseRenderer);
- Proton.EaselRender = EaselRender;
+ function PixelRenderer(element, rectangle) {
+ classCallCheck(this, PixelRenderer);
+ var _this = possibleConstructorReturn(this, (PixelRenderer.__proto__ || Object.getPrototypeOf(PixelRenderer)).call(this, element));
+ _this.context = _this.element.getContext('2d');
+ _this.imageData = null;
+ _this.rectangle = null;
+ _this.rectangle = rectangle;
+ _this.createImageData(rectangle);
- function CanvasRender(proton, element) {
- CanvasRender._super_.call(this, proton, element);
- this.stroke = null;
- this.context = this.element.getContext("2d");
- this.bufferCache = {};
- }
+ _this.name = 'PixelRenderer';
+ return _this;
+ }
+ createClass(PixelRenderer, [{
+ key: 'resize',
+ value: function resize(width, height) {
+ this.element.width = width;
+ this.element.height = height;
+ }
+ }, {
+ key: 'createImageData',
+ value: function createImageData(rectangle) {
+ this.rectangle = rectangle ? rectangle : new Rectangle(0, 0, this.element.width, this.element.height);
+ this.imageData = this.context.createImageData(this.rectangle.width, this.rectangle.height);
+ this.context.putImageData(this.imageData, this.rectangle.x, this.rectangle.y);
+ }
+ }, {
+ key: 'onProtonUpdate',
+ value: function onProtonUpdate() {
+ this.context.clearRect(this.rectangle.x, this.rectangle.y, this.rectangle.width, this.rectangle.height);
+ this.imageData = this.context.getImageData(this.rectangle.x, this.rectangle.y, this.rectangle.width, this.rectangle.height);
+ }
+ }, {
+ key: 'onProtonUpdateAfter',
+ value: function onProtonUpdateAfter() {
+ this.context.putImageData(this.imageData, this.rectangle.x, this.rectangle.y);
+ }
+ }, {
+ key: 'onParticleCreated',
+ value: function onParticleCreated(particle) {}
+ }, {
+ key: 'onParticleUpdate',
+ value: function onParticleUpdate(particle) {
+ if (this.imageData) {
+ this.setPixel(this.imageData, Math.floor(particle.p.x - this.rectangle.x), Math.floor(particle.p.y - this.rectangle.y), particle);
+ }
+ }
+ }, {
+ key: 'setPixel',
+ value: function setPixel(imagedata, x, y, particle) {
+ var rgb = particle.transform.rgb;
- Proton.Util.inherits(CanvasRender, Proton.BaseRender);
- CanvasRender.prototype.resize = function(width, height) {
- this.element.width = width;
- this.element.height = height;
- }
- CanvasRender.prototype.start = function() {
- CanvasRender._super_.prototype.start.call(this);
- }
+ if (x < 0 || x > this.element.width || y < 0 || y > this.elementwidth) return;
- CanvasRender.prototype.setStroke = function(color, thinkness) {
- color = Proton.Util.initValue(color, '#000000');
- thinkness = Proton.Util.initValue(thinkness, 1);
- this.stroke = {
- color : color,
- thinkness : thinkness
- };
- }
+ var i = ((y >> 0) * imagedata.width + (x >> 0)) * 4;
- CanvasRender.prototype.onProtonUpdate = function() {
- this.context.clearRect(0, 0, this.element.width, this.element.height);
- }
+ imagedata.data[i] = rgb.r;
+ imagedata.data[i + 1] = rgb.g;
+ imagedata.data[i + 2] = rgb.b;
+ imagedata.data[i + 3] = particle.alpha * 255;
+ }
+ }, {
+ key: 'onParticleDead',
+ value: function onParticleDead(particle) {}
+ }]);
+ return PixelRenderer;
+}(BaseRenderer);
+
+var PixiRenderer = function (_BaseRenderer) {
+ inherits(PixiRenderer, _BaseRenderer);
+
+ function PixiRenderer(element, stroke) {
+ classCallCheck(this, PixiRenderer);
+
+ var _this = possibleConstructorReturn(this, (PixiRenderer.__proto__ || Object.getPrototypeOf(PixiRenderer)).call(this, element));
+
+ _this.stroke = stroke;
+ _this.setColor = false;
+ _this.pool.create = function (body, particle) {
+ return _this.createBody(body, particle);
+ };
+ _this.name = 'PixiRenderer';
+ return _this;
+ }
- CanvasRender.prototype.onParticleCreated = function(particle) {
- if (particle.target)
- Proton.Util.getImage(particle.target, particle, false);
- else
- particle.color = particle.color ? particle.color : '#ff0000';
- }
+ createClass(PixiRenderer, [{
+ key: 'onProtonUpdate',
+ value: function onProtonUpdate() {}
- CanvasRender.prototype.onParticleUpdate = function(particle) {
- if (particle.target) {
- if (particle.target instanceof Image) {
- var w = particle.target.width * particle.scale | 0;
- var h = particle.target.height * particle.scale | 0;
- var x = particle.p.x - w / 2;
- var y = particle.p.y - h / 2;
-
- if (!!particle.color) {
- if (!particle.transform["buffer"])
- particle.transform.buffer = this.getBuffer(particle.target);
- var bufferContext = particle.transform.buffer.getContext('2d');
- bufferContext.clearRect(0, 0, particle.transform.buffer.width, particle.transform.buffer.height);
- bufferContext.globalAlpha = particle.alpha;
- bufferContext.drawImage(particle.target, 0, 0);
- bufferContext.globalCompositeOperation = "source-atop";
- bufferContext.fillStyle = Proton.Util.rgbToHex(particle.transform.rgb);
- bufferContext.fillRect(0, 0, particle.transform.buffer.width, particle.transform.buffer.height);
- bufferContext.globalCompositeOperation = "source-over";
- bufferContext.globalAlpha = 1;
- this.context.drawImage(particle.transform.buffer, 0, 0, particle.transform.buffer.width, particle.transform.buffer.height, x, y, w, h);
- } else {
- this.context.save();
- this.context.globalAlpha = particle.alpha;
- this.context.translate(particle.p.x, particle.p.y);
- this.context.rotate(Proton.MathUtils.degreeTransform(particle.rotation));
- this.context.translate(-particle.p.x, -particle.p.y);
- this.context.drawImage(particle.target, 0, 0, particle.target.width, particle.target.height, x, y, w, h);
- this.context.globalAlpha = 1;
- this.context.restore();
- }
- }
- } else {
- if (particle.transform["rgb"])
- this.context.fillStyle = 'rgba(' + particle.transform.rgb.r + ',' + particle.transform.rgb.g + ',' + particle.transform.rgb.b + ',' + particle.alpha + ')';
- else
- this.context.fillStyle = particle.color;
- this.context.beginPath();
- this.context.arc(particle.p.x, particle.p.y, particle.radius, 0, Math.PI * 2, true);
- if (this.stroke) {
- this.context.strokeStyle = this.stroke.color;
- this.context.lineWidth = this.stroke.thinkness;
- this.context.stroke();
- }
+ /**
+ * @param particle
+ */
- this.context.closePath();
- this.context.fill();
- }
- }
+ }, {
+ key: 'onParticleCreated',
+ value: function onParticleCreated(particle) {
+ if (particle.body) {
+ particle.body = this.pool.get(particle.body, particle);
+ } else {
+ particle.body = this.pool.get(this.circleConf, particle);
+ }
- CanvasRender.prototype.onParticleDead = function(particle) {
+ this.element.addChild(particle.body);
+ }
- }
+ /**
+ * @param particle
+ */
- CanvasRender.prototype.getBuffer = function(image) {
- if ( image instanceof Image) {
- var size = image.width + '_' + image.height;
- var canvas = this.bufferCache[size];
- if (!canvas) {
- canvas = document.createElement('canvas');
- canvas.width = image.width;
- canvas.height = image.height;
- this.bufferCache[size] = canvas;
- }
- return canvas;
- }
- }
+ }, {
+ key: 'onParticleUpdate',
+ value: function onParticleUpdate(particle) {
+ this.transform(particle, particle.body);
+ if (this.setColor) particle.body.tint = ColorUtil.getHex16FromParticle(particle);
+ }
- Proton.CanvasRender = CanvasRender;
+ /**
+ * @param particle
+ */
+ }, {
+ key: 'onParticleDead',
+ value: function onParticleDead(particle) {
+ this.element.removeChild(particle.body);
+ this.pool.expire(particle.body);
+ particle.body = null;
+ }
+ }, {
+ key: 'destroy',
+ value: function destroy(particles) {
+ get(PixiRenderer.prototype.__proto__ || Object.getPrototypeOf(PixiRenderer.prototype), 'destroy', this).call(this);
+ this.pool.destroy();
+ var i = particles.length;
+ while (i--) {
+ var particle = particles[i];
+ if (particle.body) {
+ this.element.removeChild(particle.body);
+ }
+ }
+ }
+ }, {
+ key: 'transform',
+ value: function transform(particle, target) {
+ target.x = particle.p.x;
+ target.y = particle.p.y;
- function PixelRender(proton, element, rectangle) {
- PixelRender._super_.call(this, proton, element);
- this.context = this.element.getContext('2d');
- this.imageData = null;
- this.rectangle = null;
- this.rectangle = rectangle;
- this.createImageData(rectangle);
- }
+ target.alpha = particle.alpha;
+ target.scale.x = particle.scale;
+ target.scale.y = particle.scale;
- Proton.Util.inherits(PixelRender, Proton.BaseRender);
- PixelRender.prototype.resize = function(width, height) {
- this.element.width = width;
- this.element.height = height;
- }
- PixelRender.prototype.createImageData = function(rectangle) {
- if (!rectangle)
- this.rectangle = new Proton.Rectangle(0, 0, this.element.width, this.element.height);
- else
- this.rectangle = rectangle;
- this.imageData = this.context.createImageData(this.rectangle.width, this.rectangle.height);
- this.context.putImageData(this.imageData, this.rectangle.x, this.rectangle.y);
- }
+ // using cached version of MathUtils.PI_180 for slight performance increase.
+ target.rotation = particle.rotation * MathUtils.PI_180; // MathUtils.PI_180;
+ }
+ }, {
+ key: 'createBody',
+ value: function createBody(body, particle) {
+ if (body.isCircle) return this.createCircle(particle);else return this.createSprite(body);
+ }
+ }, {
+ key: 'createSprite',
+ value: function createSprite(body) {
+ var sprite = body.isInner ? PIXI.Sprite.fromImage(body.src) : new PIXI.Sprite(body);
+ sprite.anchor.x = 0.5;
+ sprite.anchor.y = 0.5;
+
+ return sprite;
+ }
+ }, {
+ key: 'createCircle',
+ value: function createCircle(particle) {
+ var graphics = new PIXI.Graphics();
- PixelRender.prototype.start = function() {
- PixelRender._super_.prototype.start.call(this);
- };
+ if (this.stroke) {
+ var stroke = this.stroke instanceof String ? this.stroke : 0x000000;
+ graphics.beginStroke(this.stroke);
+ }
- PixelRender.prototype.onProtonUpdate = function() {
- this.context.clearRect(this.rectangle.x, this.rectangle.y, this.rectangle.width, this.rectangle.height);
- this.imageData = this.context.getImageData(this.rectangle.x, this.rectangle.y, this.rectangle.width, this.rectangle.height);
- }
+ graphics.beginFill(particle.color || 0x008ced);
+ graphics.drawCircle(0, 0, particle.radius);
+ graphics.endFill();
- PixelRender.prototype.onProtonUpdateAfter = function() {
- this.context.putImageData(this.imageData, this.rectangle.x, this.rectangle.y);
- }
+ return graphics;
+ }
+ }]);
+ return PixiRenderer;
+}(BaseRenderer);
- PixelRender.prototype.onParticleCreated = function(particle) {
+var MStack = function () {
+ function MStack() {
+ classCallCheck(this, MStack);
- }
+ this.mats = [];
+ this.size = 0;
- PixelRender.prototype.onParticleUpdate = function(particle) {
- if (this.imageData) {
- this.setPixel(this.imageData, Math.floor(particle.p.x - this.rectangle.x), Math.floor(particle.p.y - this.rectangle.y), particle);
+ for (var i = 0; i < 20; i++) {
+ this.mats.push(Mat3.create([0, 0, 0, 0, 0, 0, 0, 0, 0]));
}
}
- PixelRender.prototype.setPixel = function(imagedata, x, y, particle) {
- var rgb = particle.transform.rgb;
- if ((x < 0) || (x > this.element.width) || (y < 0) || (y > this.elementwidth))
- return;
+ createClass(MStack, [{
+ key: 'set',
+ value: function set$$1(m, i) {
+ if (i == 0) Mat3.set(m, this.mats[0]);else Mat3.multiply(this.mats[i - 1], m, this.mats[i]);
- var i = ((y >> 0) * imagedata.width + (x >> 0)) * 4;
+ this.size = Math.max(this.size, i + 1);
+ }
+ }, {
+ key: 'push',
+ value: function push(m) {
+ if (this.size == 0) Mat3.set(m, this.mats[0]);else Mat3.multiply(this.mats[this.size - 1], m, this.mats[this.size]);
- imagedata.data[i] = rgb.r;
- imagedata.data[i + 1] = rgb.g;
- imagedata.data[i + 2] = rgb.b;
- imagedata.data[i + 3] = particle.alpha * 255;
- }
+ this.size++;
+ }
+ }, {
+ key: 'pop',
+ value: function pop() {
+ if (this.size > 0) this.size--;
+ }
+ }, {
+ key: 'top',
+ value: function top() {
+ return this.mats[this.size - 1];
+ }
+ }]);
+ return MStack;
+}();
- PixelRender.prototype.onParticleDead = function(particle) {
+var WebGLRenderer = function (_BaseRenderer) {
+ inherits(WebGLRenderer, _BaseRenderer);
- }
+ function WebGLRenderer(element) {
+ classCallCheck(this, WebGLRenderer);
- Proton.PixelRender = PixelRender;
+ var _this = possibleConstructorReturn(this, (WebGLRenderer.__proto__ || Object.getPrototypeOf(WebGLRenderer)).call(this, element));
+ _this.gl = _this.element.getContext('experimental-webgl', { antialias: true, stencil: false, depth: false });
+ if (!_this.gl) alert("Sorry your browser do not suppest WebGL!");
+ _this.initVar();
+ _this.setMaxRadius();
+ _this.initShaders();
+ _this.initBuffers();
- function WebGLRender(proton, element) {
- WebGLRender._super_.call(this, proton, element);
- this.gl = this.element.getContext('experimental-webgl', {
- antialias : true,
- stencil : false,
- depth : false
- });
- if (!this.gl)
- alert("Sorry your browser do not suppest WebGL!");
- this.initVar();
- this.setMaxRadius();
- this.initShaders();
- this.initBuffers();
- this.gl.blendEquation(this.gl.FUNC_ADD);
- this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA);
- this.gl.enable(this.gl.BLEND);
- }
+ _this.gl.blendEquation(_this.gl.FUNC_ADD);
+ _this.gl.blendFunc(_this.gl.SRC_ALPHA, _this.gl.ONE_MINUS_SRC_ALPHA);
+ _this.gl.enable(_this.gl.BLEND);
+ _this.addImg2Body = _this.addImg2Body.bind(_this);
- Proton.Util.inherits(WebGLRender, Proton.BaseRender);
- WebGLRender.prototype.resize = function(width, height) {
- this.umat[4] = -2;
- this.umat[7] = 1;
- this.smat[0] = 1 / width;
- this.smat[4] = 1 / height;
- this.mstack.set(this.umat, 0);
- this.mstack.set(this.smat, 1);
- this.gl.viewport(0, 0, width, height);
- this.element.width = width;
- this.element.height = height;
- }
+ _this.name = 'WebGLRenderer';
+ return _this;
+ }
- WebGLRender.prototype.setMaxRadius = function(radius) {
- this.circleCanvasURL = this.createCircle(radius);
- }
+ createClass(WebGLRenderer, [{
+ key: 'init',
+ value: function init(proton) {
+ get(WebGLRenderer.prototype.__proto__ || Object.getPrototypeOf(WebGLRenderer.prototype), 'init', this).call(this, proton);
+ this.resize(this.element.width, this.element.height);
+ }
+ }, {
+ key: 'resize',
+ value: function resize(width, height) {
+ this.umat[4] = -2;
+ this.umat[7] = 1;
- WebGLRender.prototype.getVertexShader = function() {
- var vsSource = ["uniform vec2 viewport;", "attribute vec2 aVertexPosition;", "attribute vec2 aTextureCoord;", "uniform mat3 tMat;", "varying vec2 vTextureCoord;", "varying float alpha;", "void main() {", "vec3 v = tMat * vec3(aVertexPosition, 1.0);", "gl_Position = vec4(v.x, v.y, 0, 1);", "vTextureCoord = aTextureCoord;", "alpha = tMat[0][2];", "}"].join("\n");
- return vsSource;
- }
+ this.smat[0] = 1 / width;
+ this.smat[4] = 1 / height;
- WebGLRender.prototype.getFragmentShader = function() {
- var fsSource = ["precision mediump float;", "varying vec2 vTextureCoord;", "varying float alpha;", "uniform sampler2D uSampler;", "uniform vec4 color;", "uniform bool useTexture;", "uniform vec3 uColor;", "void main() {", "vec4 textureColor = texture2D(uSampler, vTextureCoord);", "gl_FragColor = textureColor * vec4(uColor, 1.0);", "gl_FragColor.w *= alpha;", "}"].join("\n");
- return fsSource;
- }
+ this.mstack.set(this.umat, 0);
+ this.mstack.set(this.smat, 1);
- WebGLRender.prototype.initVar = function() {
- this.mstack = new Proton.MStack();
- this.umat = Proton.Mat3.create([2, 0, 1, 0, -2, 0, -1, 1, 1]);
- this.smat = Proton.Mat3.create([1 / 100, 0, 1, 0, 1 / 100, 0, 0, 0, 1]);
- this.texturebuffers = {};
- }
+ this.gl.viewport(0, 0, width, height);
+ this.element.width = width;
+ this.element.height = height;
+ }
+ }, {
+ key: 'setMaxRadius',
+ value: function setMaxRadius(radius) {
+ this.circleCanvasURL = this.createCircle(radius);
+ }
+ }, {
+ key: 'getVertexShader',
+ value: function getVertexShader() {
+ var vsSource = ["uniform vec2 viewport;", "attribute vec2 aVertexPosition;", "attribute vec2 aTextureCoord;", "uniform mat3 tMat;", "varying vec2 vTextureCoord;", "varying float alpha;", "void main() {", "vec3 v = tMat * vec3(aVertexPosition, 1.0);", "gl_Position = vec4(v.x, v.y, 0, 1);", "vTextureCoord = aTextureCoord;", "alpha = tMat[0][2];", "}"].join("\n");
+ return vsSource;
+ }
+ }, {
+ key: 'getFragmentShader',
+ value: function getFragmentShader() {
+ var fsSource = ["precision mediump float;", "varying vec2 vTextureCoord;", "varying float alpha;", "uniform sampler2D uSampler;", "uniform vec4 color;", "uniform bool useTexture;", "uniform vec3 uColor;", "void main() {", "vec4 textureColor = texture2D(uSampler, vTextureCoord);", "gl_FragColor = textureColor * vec4(uColor, 1.0);", "gl_FragColor.w *= alpha;", "}"].join("\n");
+ return fsSource;
+ }
+ }, {
+ key: 'initVar',
+ value: function initVar() {
+ this.mstack = new MStack();
+ this.umat = Mat3.create([2, 0, 1, 0, -2, 0, -1, 1, 1]);
+ this.smat = Mat3.create([1 / 100, 0, 1, 0, 1 / 100, 0, 0, 0, 1]);
+ this.texturebuffers = {};
+ }
+ }, {
+ key: 'blendEquation',
+ value: function blendEquation(A) {
+ this.gl.blendEquation(this.gl[A]);
+ }
+ }, {
+ key: 'blendFunc',
+ value: function blendFunc(A, B) {
+ this.gl.blendFunc(this.gl[A], this.gl[B]);
+ }
+ }, {
+ key: 'getShader',
+ value: function getShader(gl, str, fs) {
+ var shader = fs ? gl.createShader(gl.FRAGMENT_SHADER) : gl.createShader(gl.VERTEX_SHADER);
- WebGLRender.prototype.start = function() {
- WebGLRender._super_.prototype.start.call(this);
- this.resize(this.element.width, this.element.height);
- }
+ gl.shaderSource(shader, str);
+ gl.compileShader(shader);
- WebGLRender.prototype.blendEquation = function(A) {
- this.gl.blendEquation(this.gl[A]);
- }
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
+ alert(gl.getShaderInfoLog(shader));
+ return null;
+ }
- WebGLRender.prototype.blendFunc = function(A, B) {
- this.gl.blendFunc(this.gl[A], this.gl[B]);
- }
+ return shader;
+ }
+ }, {
+ key: 'initShaders',
+ value: function initShaders() {
+ var fragmentShader = this.getShader(this.gl, this.getFragmentShader(), true);
+ var vertexShader = this.getShader(this.gl, this.getVertexShader(), false);
+
+ this.sprogram = this.gl.createProgram();
+ this.gl.attachShader(this.sprogram, vertexShader);
+ this.gl.attachShader(this.sprogram, fragmentShader);
+ this.gl.linkProgram(this.sprogram);
+
+ if (!this.gl.getProgramParameter(this.sprogram, this.gl.LINK_STATUS)) alert("Could not initialise shaders");
+
+ this.gl.useProgram(this.sprogram);
+ this.sprogram.vpa = this.gl.getAttribLocation(this.sprogram, "aVertexPosition");
+ this.sprogram.tca = this.gl.getAttribLocation(this.sprogram, "aTextureCoord");
+ this.gl.enableVertexAttribArray(this.sprogram.tca);
+ this.gl.enableVertexAttribArray(this.sprogram.vpa);
+
+ this.sprogram.tMatUniform = this.gl.getUniformLocation(this.sprogram, "tMat");
+ this.sprogram.samplerUniform = this.gl.getUniformLocation(this.sprogram, "uSampler");
+ this.sprogram.useTex = this.gl.getUniformLocation(this.sprogram, "useTexture");
+ this.sprogram.color = this.gl.getUniformLocation(this.sprogram, "uColor");
+ this.gl.uniform1i(this.sprogram.useTex, 1);
+ }
+ }, {
+ key: 'initBuffers',
+ value: function initBuffers() {
+ var vs = [0, 3, 1, 0, 2, 3];
+ var idx = void 0;
+
+ this.unitIBuffer = this.gl.createBuffer();
+ this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.unitIBuffer);
+ this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(vs), this.gl.STATIC_DRAW);
+
+ var i = void 0;
+ var ids = [];
+ for (i = 0; i < 100; i++) {
+ ids.push(i);
+ }idx = new Uint16Array(ids);
+
+ this.unitI33 = this.gl.createBuffer();
+ this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.unitI33);
+ this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, idx, this.gl.STATIC_DRAW);
+
+ ids = [];
+ for (i = 0; i < 100; i++) {
+ ids.push(i, i + 1, i + 2);
+ }idx = new Uint16Array(ids);
+
+ this.stripBuffer = this.gl.createBuffer();
+ this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.stripBuffer);
+ this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, idx, this.gl.STATIC_DRAW);
+ }
+ }, {
+ key: 'createCircle',
+ value: function createCircle(raidus) {
+ this.circleCanvasRadius = WebGLUtil.nhpot(Util.initValue(raidus, 32));
+ var canvas = DomUtil.createCanvas('circle_canvas', this.circleCanvasRadius * 2, this.circleCanvasRadius * 2);
+ var context = canvas.getContext('2d');
+
+ context.beginPath();
+ context.arc(this.circleCanvasRadius, this.circleCanvasRadius, this.circleCanvasRadius, 0, Math.PI * 2, true);
+ context.closePath();
+ context.fillStyle = '#FFF';
+ context.fill();
+
+ return canvas.toDataURL();
+ }
+ }, {
+ key: 'drawImg2Canvas',
+ value: function drawImg2Canvas(particle) {
+ var _w = particle.body.width;
+ var _h = particle.body.height;
- WebGLRender.prototype.getShader = function(gl, str, fs) {
- var shader;
- if (fs)
- shader = gl.createShader(gl.FRAGMENT_SHADER);
- else
- shader = gl.createShader(gl.VERTEX_SHADER);
- gl.shaderSource(shader, str);
- gl.compileShader(shader);
-
- if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
- alert(gl.getShaderInfoLog(shader));
- return null;
- }
- return shader;
- }
+ var _width = WebGLUtil.nhpot(particle.body.width);
+ var _height = WebGLUtil.nhpot(particle.body.height);
- WebGLRender.prototype.initShaders = function() {
- var fragmentShader = this.getShader(this.gl, this.getFragmentShader(), true);
- var vertexShader = this.getShader(this.gl, this.getVertexShader(), false);
-
- this.sprogram = this.gl.createProgram();
- this.gl.attachShader(this.sprogram, vertexShader);
- this.gl.attachShader(this.sprogram, fragmentShader);
- this.gl.linkProgram(this.sprogram);
- if (!this.gl.getProgramParameter(this.sprogram, this.gl.LINK_STATUS))
- alert("Could not initialise shaders");
-
- this.gl.useProgram(this.sprogram);
- this.sprogram.vpa = this.gl.getAttribLocation(this.sprogram, "aVertexPosition");
- this.sprogram.tca = this.gl.getAttribLocation(this.sprogram, "aTextureCoord");
- this.gl.enableVertexAttribArray(this.sprogram.tca);
- this.gl.enableVertexAttribArray(this.sprogram.vpa);
-
- this.sprogram.tMatUniform = this.gl.getUniformLocation(this.sprogram, "tMat");
- this.sprogram.samplerUniform = this.gl.getUniformLocation(this.sprogram, "uSampler");
- this.sprogram.useTex = this.gl.getUniformLocation(this.sprogram, "useTexture");
- this.sprogram.color = this.gl.getUniformLocation(this.sprogram, "uColor");
- this.gl.uniform1i(this.sprogram.useTex, 1);
- };
+ var _scaleX = particle.body.width / _width;
+ var _scaleY = particle.body.height / _height;
- WebGLRender.prototype.initBuffers = function() {
- this.unitIBuffer = this.gl.createBuffer();
- this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.unitIBuffer);
- var vs = [0, 3, 1, 0, 2, 3];
- this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(vs), this.gl.STATIC_DRAW);
-
- var ids = [];
- for (var i = 0; i < 100; i++)
- ids.push(i);
-
- idx = new Uint16Array(ids);
- this.unitI33 = this.gl.createBuffer();
- this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.unitI33);
- this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, idx, this.gl.STATIC_DRAW);
-
- ids = [];
- for ( i = 0; i < 100; i++)
- ids.push(i, i + 1, i + 2);
-
- idx = new Uint16Array(ids);
- this.stripBuffer = this.gl.createBuffer();
- this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.stripBuffer);
- this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, idx, this.gl.STATIC_DRAW);
- };
+ if (!this.texturebuffers[particle.transform.src]) this.texturebuffers[particle.transform.src] = [this.gl.createTexture(), this.gl.createBuffer(), this.gl.createBuffer()];
- WebGLRender.prototype.createCircle = function(raidus) {
- this.circleCanvasRadius = Proton.WebGLUtil.nhpot(Proton.Util.initValue(raidus, 32));
- var canvas = Proton.DomUtil.createCanvas('circle_canvas', this.circleCanvasRadius * 2, this.circleCanvasRadius * 2);
- var context = canvas.getContext('2d');
- context.beginPath();
- context.arc(this.circleCanvasRadius, this.circleCanvasRadius, this.circleCanvasRadius, 0, Math.PI * 2, true);
- context.closePath();
- context.fillStyle = '#FFF';
- context.fill();
- return canvas.toDataURL();
- };
+ particle.transform.texture = this.texturebuffers[particle.transform.src][0];
+ particle.transform.vcBuffer = this.texturebuffers[particle.transform.src][1];
+ particle.transform.tcBuffer = this.texturebuffers[particle.transform.src][2];
- WebGLRender.prototype.setImgInCanvas = function(particle) {
- var _w = particle.target.width;
- var _h = particle.target.height;
- var _width = Proton.WebGLUtil.nhpot(particle.target.width);
- var _height = Proton.WebGLUtil.nhpot(particle.target.height);
- var _scaleX = particle.target.width / _width;
- var _scaleY = particle.target.height / _height;
-
- if (!this.texturebuffers[particle.transform.src])
- this.texturebuffers[particle.transform.src] = [this.gl.createTexture(), this.gl.createBuffer(), this.gl.createBuffer()];
- particle.transform.texture = this.texturebuffers[particle.transform.src][0];
- particle.transform.vcBuffer = this.texturebuffers[particle.transform.src][1];
- particle.transform.tcBuffer = this.texturebuffers[particle.transform.src][2];
- this.gl.bindBuffer(this.gl.ARRAY_BUFFER, particle.transform.tcBuffer);
- this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([0.0, 0.0, _scaleX, 0.0, 0.0, _scaleY, _scaleY, _scaleY]), this.gl.STATIC_DRAW);
- this.gl.bindBuffer(this.gl.ARRAY_BUFFER, particle.transform.vcBuffer);
- this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([0.0, 0.0, _w, 0.0, 0.0, _h, _w, _h]), this.gl.STATIC_DRAW);
-
- var context = particle.transform.canvas.getContext('2d');
- var data = context.getImageData(0, 0, _width, _height);
-
- this.gl.bindTexture(this.gl.TEXTURE_2D, particle.transform.texture);
- this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, this.gl.RGBA, this.gl.UNSIGNED_BYTE, data);
- this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR);
- this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR_MIPMAP_NEAREST);
- this.gl.generateMipmap(this.gl.TEXTURE_2D);
- particle.transform.textureLoaded = true;
- particle.transform.textureWidth = _w;
- particle.transform.textureHeight = _h;
- }
+ this.gl.bindBuffer(this.gl.ARRAY_BUFFER, particle.transform.tcBuffer);
+ this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([0.0, 0.0, _scaleX, 0.0, 0.0, _scaleY, _scaleY, _scaleY]), this.gl.STATIC_DRAW);
+ this.gl.bindBuffer(this.gl.ARRAY_BUFFER, particle.transform.vcBuffer);
+ this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([0.0, 0.0, _w, 0.0, 0.0, _h, _w, _h]), this.gl.STATIC_DRAW);
- WebGLRender.prototype.setStroke = function(color, thinkness) {
+ var context = particle.transform.canvas.getContext('2d');
+ var data = context.getImageData(0, 0, _width, _height);
- }
+ this.gl.bindTexture(this.gl.TEXTURE_2D, particle.transform.texture);
+ this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, this.gl.RGBA, this.gl.UNSIGNED_BYTE, data);
+ this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR);
+ this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR_MIPMAP_NEAREST);
+ this.gl.generateMipmap(this.gl.TEXTURE_2D);
- WebGLRender.prototype.onProtonUpdate = function() {
- //this.gl.clearColor(0, 0, 0, 1);
- //this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
- }
+ particle.transform.textureLoaded = true;
+ particle.transform.textureWidth = _w;
+ particle.transform.textureHeight = _h;
+ }
+ }, {
+ key: 'onProtonUpdate',
+ value: function onProtonUpdate() {
+ //this.gl.clearColor(0, 0, 0, 1);
+ //this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
+ }
+ }, {
+ key: 'onParticleCreated',
+ value: function onParticleCreated(particle) {
+ particle.transform.textureLoaded = false;
+ particle.transform.tmat = Mat3.create();
+ particle.transform.tmat[8] = 1;
+ particle.transform.imat = Mat3.create();
+ particle.transform.imat[8] = 1;
+
+ if (particle.body) {
+ ImgUtil.getImgFromCache(particle.body, this.addImg2Body, particle);
+ } else {
+ ImgUtil.getImgFromCache(this.circleCanvasURL, this.addImg2Body, particle);
+ particle.transform.oldScale = particle.radius / this.circleCanvasRadius;
+ }
+ }
- WebGLRender.prototype.onParticleCreated = function(particle) {
- var self = this;
- particle.transform.textureLoaded = false;
- particle.transform.tmat = Proton.Mat3.create();
- particle.transform.tmat[8] = 1;
- particle.transform.imat = Proton.Mat3.create();
- particle.transform.imat[8] = 1;
- if (particle.target) {
- Proton.Util.getImage(particle.target, particle, true, function(particle) {
- self.setImgInCanvas.call(self, particle);
- particle.transform.oldScale = 1;
- });
- } else {
- Proton.Util.getImage(this.circleCanvasURL, particle, true, function(particle) {
- self.setImgInCanvas.call(self, particle);
- particle.transform.oldScale = particle.radius / self.circleCanvasRadius;
- });
- }
- }
+ // private
- WebGLRender.prototype.onParticleUpdate = function(particle) {
- if (particle.transform.textureLoaded) {
- this.updateMatrix(particle);
- this.gl.uniform3f(this.sprogram.color, particle.transform.rgb.r / 255, particle.transform.rgb.g / 255, particle.transform.rgb.b / 255);
- this.gl.uniformMatrix3fv(this.sprogram.tMatUniform, false, this.mstack.top());
- this.gl.bindBuffer(this.gl.ARRAY_BUFFER, particle.transform.vcBuffer);
- this.gl.vertexAttribPointer(this.sprogram.vpa, 2, this.gl.FLOAT, false, 0, 0);
- this.gl.bindBuffer(this.gl.ARRAY_BUFFER, particle.transform.tcBuffer);
- this.gl.vertexAttribPointer(this.sprogram.tca, 2, this.gl.FLOAT, false, 0, 0);
- this.gl.bindTexture(this.gl.TEXTURE_2D, particle.transform.texture);
- this.gl.uniform1i(this.sprogram.samplerUniform, 0);
- this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.unitIBuffer);
- this.gl.drawElements(this.gl.TRIANGLES, 6, this.gl.UNSIGNED_SHORT, 0);
- this.mstack.pop();
- }
- }
+ }, {
+ key: 'addImg2Body',
+ value: function addImg2Body(img, particle) {
+ if (particle.dead) return;
- WebGLRender.prototype.onParticleDead = function(particle) {
-
- }
+ particle.body = img;
+ particle.transform.src = img.src;
+ particle.transform.canvas = ImgUtil.getCanvasFromCache(img);
+ particle.transform.oldScale = 1;
- WebGLRender.prototype.updateMatrix = function(particle) {
- var moveOriginMatrix = Proton.WebGLUtil.makeTranslation(-particle.transform.textureWidth / 2, -particle.transform.textureHeight / 2);
- var translationMatrix = Proton.WebGLUtil.makeTranslation(particle.p.x, particle.p.y);
- var angel = particle.rotation * (Math.PI / 180);
- var rotationMatrix = Proton.WebGLUtil.makeRotation(angel);
- var scale = particle.scale * particle.transform.oldScale;
- var scaleMatrix = Proton.WebGLUtil.makeScale(scale, scale);
-
- var matrix = Proton.WebGLUtil.matrixMultiply(moveOriginMatrix, scaleMatrix);
- matrix = Proton.WebGLUtil.matrixMultiply(matrix, rotationMatrix);
- matrix = Proton.WebGLUtil.matrixMultiply(matrix, translationMatrix);
-
- Proton.Mat3.inverse(matrix, particle.transform.imat);
- matrix[2] = particle.alpha;
- this.mstack.push(matrix);
- }
+ this.drawImg2Canvas(particle);
+ }
+ }, {
+ key: 'onParticleUpdate',
+ value: function onParticleUpdate(particle) {
+ if (particle.transform.textureLoaded) {
+ this.updateMatrix(particle);
+
+ this.gl.uniform3f(this.sprogram.color, particle.transform.rgb.r / 255, particle.transform.rgb.g / 255, particle.transform.rgb.b / 255);
+ this.gl.uniformMatrix3fv(this.sprogram.tMatUniform, false, this.mstack.top());
+
+ this.gl.bindBuffer(this.gl.ARRAY_BUFFER, particle.transform.vcBuffer);
+ this.gl.vertexAttribPointer(this.sprogram.vpa, 2, this.gl.FLOAT, false, 0, 0);
+ this.gl.bindBuffer(this.gl.ARRAY_BUFFER, particle.transform.tcBuffer);
+ this.gl.vertexAttribPointer(this.sprogram.tca, 2, this.gl.FLOAT, false, 0, 0);
+ this.gl.bindTexture(this.gl.TEXTURE_2D, particle.transform.texture);
+ this.gl.uniform1i(this.sprogram.samplerUniform, 0);
+ this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.unitIBuffer);
+
+ this.gl.drawElements(this.gl.TRIANGLES, 6, this.gl.UNSIGNED_SHORT, 0);
+
+ this.mstack.pop();
+ }
+ }
+ }, {
+ key: 'onParticleDead',
+ value: function onParticleDead(particle) {}
+ }, {
+ key: 'updateMatrix',
+ value: function updateMatrix(particle) {
+ var moveOriginMatrix = WebGLUtil.makeTranslation(-particle.transform.textureWidth / 2, -particle.transform.textureHeight / 2);
+ var translationMatrix = WebGLUtil.makeTranslation(particle.p.x, particle.p.y);
- Proton.WebGLRender = WebGLRender;
+ var angel = particle.rotation * MathUtils.PI_180;
+ var rotationMatrix = WebGLUtil.makeRotation(angel);
+ var scale = particle.scale * particle.transform.oldScale;
+ var scaleMatrix = WebGLUtil.makeScale(scale, scale);
+ var matrix = WebGLUtil.matrixMultiply(moveOriginMatrix, scaleMatrix);
+ matrix = WebGLUtil.matrixMultiply(matrix, rotationMatrix);
+ matrix = WebGLUtil.matrixMultiply(matrix, translationMatrix);
- function Zone() {
- this.vector = new Proton.Vector2D(0, 0);
- this.random = 0;
- this.crossType = "dead";
- this.alert = true;
- }
+ Mat3.inverse(matrix, particle.transform.imat);
+ matrix[2] = particle.alpha;
+ this.mstack.push(matrix);
+ }
+ }]);
+ return WebGLRenderer;
+}(BaseRenderer);
- Zone.prototype = {
- getPosition : function() {
+var CustomRenderer = function (_BaseRenderer) {
+ inherits(CustomRenderer, _BaseRenderer);
- },
+ function CustomRenderer(element) {
+ classCallCheck(this, CustomRenderer);
- crossing : function(particle) {
+ var _this = possibleConstructorReturn(this, (CustomRenderer.__proto__ || Object.getPrototypeOf(CustomRenderer)).call(this, element));
- }
- };
+ _this.name = 'CustomRenderer';
+ return _this;
+ }
+
+ return CustomRenderer;
+}(BaseRenderer);
- Proton.Zone = Zone;
+var CircleZone = function (_Zone) {
+ inherits(CircleZone, _Zone);
+ function CircleZone(x1, y1, x2, y2, direction) {
+ classCallCheck(this, CircleZone);
+ var _this = possibleConstructorReturn(this, (CircleZone.__proto__ || Object.getPrototypeOf(CircleZone)).call(this));
- function LineZone(x1, y1, x2, y2, direction) {
- LineZone._super_.call(this);
if (x2 - x1 >= 0) {
- this.x1 = x1;
- this.y1 = y1;
- this.x2 = x2;
- this.y2 = y2;
+ _this.x1 = x1;
+ _this.y1 = y1;
+ _this.x2 = x2;
+ _this.y2 = y2;
} else {
- this.x1 = x2;
- this.y1 = y2;
- this.x2 = x1;
- this.y2 = y1;
+ _this.x1 = x2;
+ _this.y1 = y2;
+ _this.x2 = x1;
+ _this.y2 = y1;
}
- this.dx = this.x2 - this.x1;
- this.dy = this.y2 - this.y1;
- this.minx = Math.min(this.x1, this.x2);
- this.miny = Math.min(this.y1, this.y2);
- this.maxx = Math.max(this.x1, this.x2);
- this.maxy = Math.max(this.y1, this.y2);
- this.dot = this.x2 * this.y1 - this.x1 * this.y2;
- this.xxyy = this.dx * this.dx + this.dy * this.dy;
- this.gradient = this.getGradient();
- this.length = this.getLength();
- this.direction = Proton.Util.initValue(direction, '>');
- }
-
- Proton.Util.inherits(LineZone, Proton.Zone);
- LineZone.prototype.getPosition = function() {
- this.random = Math.random();
- this.vector.x = this.x1 + this.random * this.length * Math.cos(this.gradient);
- this.vector.y = this.y1 + this.random * this.length * Math.sin(this.gradient);
- return this.vector;
- }
+ _this.dx = _this.x2 - _this.x1;
+ _this.dy = _this.y2 - _this.y1;
- LineZone.prototype.getDirection = function(x, y) {
- var A = this.dy;
- var B = -this.dx;
- var C = this.dot;
- var D = B == 0 ? 1 : B;
- if ((A * x + B * y + C) * D > 0)
- return true
- else
- return false;
- }
+ _this.minx = Math.min(_this.x1, _this.x2);
+ _this.miny = Math.min(_this.y1, _this.y2);
+ _this.maxx = Math.max(_this.x1, _this.x2);
+ _this.maxy = Math.max(_this.y1, _this.y2);
- LineZone.prototype.getDistance = function(x, y) {
- var A = this.dy;
- var B = -this.dx;
- var C = this.dot;
- var D = (A * x + B * y + C);
- return D / Math.sqrt(this.xxyy);
- }
+ _this.dot = _this.x2 * _this.y1 - _this.x1 * _this.y2;
+ _this.xxyy = _this.dx * _this.dx + _this.dy * _this.dy;
- LineZone.prototype.getSymmetric = function(v) {
- var tha2 = v.getGradient();
- var tha1 = this.getGradient();
- var tha = 2 * (tha1 - tha2);
- var oldx = v.x;
- var oldy = v.y;
- v.x = oldx * Math.cos(tha) - oldy * Math.sin(tha);
- v.y = oldx * Math.sin(tha) + oldy * Math.cos(tha);
- return v;
+ _this.gradient = _this.getGradient();
+ _this.length = _this.getLength();
+ _this.direction = Util.initValue(direction, '>');
+ return _this;
}
- LineZone.prototype.getGradient = function() {
- return Math.atan2(this.dy, this.dx);
- }
+ createClass(CircleZone, [{
+ key: 'getPosition',
+ value: function getPosition() {
+ this.random = Math.random();
+ this.vector.x = this.x1 + this.random * this.length * Math.cos(this.gradient);
+ this.vector.y = this.y1 + this.random * this.length * Math.sin(this.gradient);
- LineZone.prototype.getRange = function(particle, fun) {
- var angle = Math.abs(this.getGradient());
- if (angle <= Math.PI / 4) {
- if (particle.p.x < this.maxx && particle.p.x > this.minx) {
- fun();
- }
- } else {
- if (particle.p.y < this.maxy && particle.p.y > this.miny) {
- fun();
- }
+ return this.vector;
}
- }
+ }, {
+ key: 'getDirection',
+ value: function getDirection(x, y) {
+ var A = this.dy;
+ var B = -this.dx;
+ var C = this.dot;
+ var D = B == 0 ? 1 : B;
+
+ if ((A * x + B * y + C) * D > 0) return true;else return false;
+ }
+ }, {
+ key: 'getDistance',
+ value: function getDistance(x, y) {
+ var A = this.dy;
+ var B = -this.dx;
+ var C = this.dot;
+ var D = A * x + B * y + C;
+
+ return D / Math.sqrt(this.xxyy);
+ }
+ }, {
+ key: 'getSymmetric',
+ value: function getSymmetric(v) {
+ var tha2 = v.getGradient();
+ var tha1 = this.getGradient();
+ var tha = 2 * (tha1 - tha2);
- LineZone.prototype.getLength = function() {
- return Math.sqrt(this.dx * this.dx + this.dy * this.dy)
- }
+ var oldx = v.x;
+ var oldy = v.y;
- LineZone.prototype.crossing = function(particle) {
- var self = this;
- if (this.crossType == "dead") {
- if (this.direction == ">" || this.direction == "R" || this.direction == "right" || this.direction == "down") {
- this.getRange(particle, function() {
- if (self.getDirection(particle.p.x, particle.p.y))
- particle.dead = true;
- })
+ v.x = oldx * Math.cos(tha) - oldy * Math.sin(tha);
+ v.y = oldx * Math.sin(tha) + oldy * Math.cos(tha);
+
+ return v;
+ }
+ }, {
+ key: 'getGradient',
+ value: function getGradient() {
+ return Math.atan2(this.dy, this.dx);
+ }
+ }, {
+ key: 'rangeOut',
+ value: function rangeOut(particle) {
+ var angle = Math.abs(this.getGradient());
+
+ if (angle <= MathUtils.PI / 4) {
+ if (particle.p.x <= this.maxx && particle.p.x >= this.minx) return true;
} else {
- this.getRange(particle, function() {
- if (!self.getDirection(particle.p.x, particle.p.y))
- particle.dead = true;
- })
+ if (particle.p.y <= this.maxy && particle.p.y >= this.miny) return true;
}
- } else if (this.crossType == "bound") {
- this.getRange(particle, function() {
- if (self.getDistance(particle.p.x, particle.p.y) <= particle.radius) {
- if (self.dx == 0) {
+
+ return false;
+ }
+ }, {
+ key: 'getLength',
+ value: function getLength() {
+ return Math.sqrt(this.dx * this.dx + this.dy * this.dy);
+ }
+ }, {
+ key: 'crossing',
+ value: function crossing(particle) {
+ if (this.crossType == "dead") {
+ if (this.direction == ">" || this.direction == "R" || this.direction == "right" || this.direction == "down") {
+ if (!this.rangeOut(particle)) return;
+ if (this.getDirection(particle.p.x, particle.p.y)) particle.dead = true;
+ } else {
+ if (!this.rangeOut(particle)) return;
+ if (!this.getDirection(particle.p.x, particle.p.y)) particle.dead = true;
+ }
+ } else if (this.crossType == "bound") {
+ if (!this.rangeOut(particle)) return;
+
+ if (this.getDistance(particle.p.x, particle.p.y) <= particle.radius) {
+ if (this.dx == 0) {
particle.v.x *= -1;
- } else if (self.dy == 0) {
+ } else if (this.dy == 0) {
particle.v.y *= -1;
} else {
- self.getSymmetric(particle.v);
+ this.getSymmetric(particle.v);
}
}
- });
- } else if (this.crossType == "cross") {
- if (this.alert) {
- alert('Sorry lineZone does not support cross method');
- this.alert = false;
+ } else if (this.crossType == "cross") {
+ if (this.alert) {
+ console.error('Sorry lineZone does not support cross method');
+ this.alert = false;
+ }
}
}
- }
-
- Proton.LineZone = LineZone;
+ }]);
+ return CircleZone;
+}(Zone);
+var CircleZone$1 = function (_Zone) {
+ inherits(CircleZone, _Zone);
+ function CircleZone(x, y, radius) {
+ classCallCheck(this, CircleZone);
- function CircleZone(x, y, radius) {
- CircleZone._super_.call(this);
- this.x = x;
- this.y = y;
- this.radius = radius;
- this.angle = 0;
- this.center = {
- x : this.x,
- y : this.y
- };
- }
-
+ var _this = possibleConstructorReturn(this, (CircleZone.__proto__ || Object.getPrototypeOf(CircleZone)).call(this));
- Proton.Util.inherits(CircleZone, Proton.Zone);
- CircleZone.prototype.getPosition = function() {
- this.random = Math.random();
- this.angle = Math.PI * 2 * Math.random();
- this.vector.x = this.x + this.random * this.radius * Math.cos(this.angle);
- this.vector.y = this.y + this.random * this.radius * Math.sin(this.angle);
- return this.vector;
- }
+ _this.x = x;
+ _this.y = y;
+ _this.radius = radius;
- CircleZone.prototype.setCenter = function(x, y) {
- this.center.x = x;
- this.center.y = y;
- }
+ _this.angle = 0;
+ _this.center = { x: x, y: y };
+ return _this;
+ }
- CircleZone.prototype.crossing = function(particle) {
- var d = particle.p.distanceTo(this.center);
- if (this.crossType == "dead") {
- if (d - particle.radius > this.radius)
- particle.dead = true;
- } else if (this.crossType == "bound") {
- if (d + particle.radius >= this.radius)
- this.getSymmetric(particle);
- } else if (this.crossType == "cross") {
- if (this.alert) {
- alert('Sorry CircleZone does not support cross method');
- this.alert = false;
- }
- }
- }
+ createClass(CircleZone, [{
+ key: 'getPosition',
+ value: function getPosition() {
+ this.random = Math.random();
+ this.angle = MathUtils.PIx2 * Math.random();
- CircleZone.prototype.getSymmetric = function(particle) {
- var tha2 = particle.v.getGradient();
- var tha1 = this.getGradient(particle);
- var tha = 2 * (tha1 - tha2);
- var oldx = particle.v.x;
- var oldy = particle.v.y;
- particle.v.x = oldx * Math.cos(tha) - oldy * Math.sin(tha);
- particle.v.y = oldx * Math.sin(tha) + oldy * Math.cos(tha);
- }
+ this.vector.x = this.x + this.random * this.radius * Math.cos(this.angle);
+ this.vector.y = this.y + this.random * this.radius * Math.sin(this.angle);
- CircleZone.prototype.getGradient = function(particle) {
- return -Math.PI / 2 + Math.atan2(particle.p.y - this.center.y, particle.p.x - this.center.x);
- }
+ return this.vector;
+ }
+ }, {
+ key: 'setCenter',
+ value: function setCenter(x, y) {
+ this.center.x = x;
+ this.center.y = y;
+ }
+ }, {
+ key: 'crossing',
+ value: function crossing(particle) {
+ var d = particle.p.distanceTo(this.center);
+
+ if (this.crossType == "dead") {
+ if (d - particle.radius > this.radius) particle.dead = true;
+ } else if (this.crossType == "bound") {
+ if (d + particle.radius >= this.radius) this.getSymmetric(particle);
+ } else if (this.crossType == "cross") {
+ if (this.alert) {
+ alert('Sorry CircleZone does not support cross method');
+ this.alert = false;
+ }
+ }
+ }
+ }, {
+ key: 'getSymmetric',
+ value: function getSymmetric(particle) {
+ var tha2 = particle.v.getGradient();
+ var tha1 = this.getGradient(particle);
+
+ var tha = 2 * (tha1 - tha2);
+ var oldx = particle.v.x;
+ var oldy = particle.v.y;
+
+ particle.v.x = oldx * Math.cos(tha) - oldy * Math.sin(tha);
+ particle.v.y = oldx * Math.sin(tha) + oldy * Math.cos(tha);
+ }
+ }, {
+ key: 'getGradient',
+ value: function getGradient(particle) {
+ return -MathUtils.PI_2 + Math.atan2(particle.p.y - this.center.y, particle.p.x - this.center.x);
+ }
+ }]);
+ return CircleZone;
+}(Zone);
- Proton.CircleZone = CircleZone;
+var PointZoneRectZone = function (_Zone) {
+ inherits(PointZoneRectZone, _Zone);
+ function PointZoneRectZone(x, y, width, height) {
+ classCallCheck(this, PointZoneRectZone);
+ var _this = possibleConstructorReturn(this, (PointZoneRectZone.__proto__ || Object.getPrototypeOf(PointZoneRectZone)).call(this));
- function PointZone(x, y) {
- PointZone._super_.call(this);
- this.x = x;
- this.y = y;
+ _this.x = x;
+ _this.y = y;
+ _this.width = width;
+ _this.height = height;
+ return _this;
}
+ createClass(PointZoneRectZone, [{
+ key: "getPosition",
+ value: function getPosition() {
+ this.vector.x = this.x + Math.random() * this.width;
+ this.vector.y = this.y + Math.random() * this.height;
- Proton.Util.inherits(PointZone, Proton.Zone);
- PointZone.prototype.getPosition = function() {
- this.vector.x = this.x;
- this.vector.y = this.y;
- return this.vector;
- }
-
- PointZone.prototype.crossing = function(particle) {
- if (this.alert) {
- alert('Sorry PointZone does not support crossing method');
- this.alert = false;
+ return this.vector;
}
- }
-
- Proton.PointZone = PointZone;
-
-
-
- function RectZone(x, y, width, height) {
- RectZone._super_.call(this);
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
- }
-
+ }, {
+ key: "crossing",
+ value: function crossing(particle) {
+ if (this.crossType == "dead") {
+ if (particle.p.x + particle.radius < this.x) particle.dead = true;else if (particle.p.x - particle.radius > this.x + this.width) particle.dead = true;
+
+ if (particle.p.y + particle.radius < this.y) particle.dead = true;else if (particle.p.y - particle.radius > this.y + this.height) particle.dead = true;
+ } else if (this.crossType == "bound") {
+ if (particle.p.x - particle.radius < this.x) {
+ particle.p.x = this.x + particle.radius;
+ particle.v.x *= -1;
+ } else if (particle.p.x + particle.radius > this.x + this.width) {
+ particle.p.x = this.x + this.width - particle.radius;
+ particle.v.x *= -1;
+ }
- Proton.Util.inherits(RectZone, Proton.Zone);
- RectZone.prototype.getPosition = function() {
- this.vector.x = this.x + Math.random() * this.width;
- this.vector.y = this.y + Math.random() * this.height;
- return this.vector;
- }
+ if (particle.p.y - particle.radius < this.y) {
+ particle.p.y = this.y + particle.radius;
+ particle.v.y *= -1;
+ } else if (particle.p.y + particle.radius > this.y + this.height) {
+ particle.p.y = this.y + this.height - particle.radius;
+ particle.v.y *= -1;
+ }
+ } else if (this.crossType == "cross") {
+ if (particle.p.x + particle.radius < this.x && particle.v.x <= 0) particle.p.x = this.x + this.width + particle.radius;else if (particle.p.x - particle.radius > this.x + this.width && particle.v.x >= 0) particle.p.x = this.x - particle.radius;
- RectZone.prototype.crossing = function(particle) {
- if (this.crossType == "dead") {
- if (particle.p.x + particle.radius < this.x)
- particle.dead = true;
- else if (particle.p.x - particle.radius > this.x + this.width)
- particle.dead = true;
-
- if (particle.p.y + particle.radius < this.y)
- particle.dead = true;
- else if (particle.p.y - particle.radius > this.y + this.height)
- particle.dead = true;
- } else if (this.crossType == "bound") {
- if (particle.p.x - particle.radius < this.x) {
- particle.p.x = this.x + particle.radius;
- particle.v.x *= -1;
- } else if (particle.p.x + particle.radius > this.x + this.width) {
- particle.p.x = this.x + this.width - particle.radius;
- particle.v.x *= -1;
+ if (particle.p.y + particle.radius < this.y && particle.v.y <= 0) particle.p.y = this.y + this.height + particle.radius;else if (particle.p.y - particle.radius > this.y + this.height && particle.v.y >= 0) particle.p.y = this.y - particle.radius;
}
-
- if (particle.p.y - particle.radius < this.y) {
- particle.p.y = this.y + particle.radius;
- particle.v.y *= -1;
- } else if (particle.p.y + particle.radius > this.y + this.height) {
- particle.p.y = this.y + this.height - particle.radius;
- particle.v.y *= -1;
- }
- } else if (this.crossType == "cross") {
- if (particle.p.x + particle.radius < this.x && particle.v.x <= 0)
- particle.p.x = this.x + this.width + particle.radius;
- else if (particle.p.x - particle.radius > this.x + this.width && particle.v.x >= 0)
- particle.p.x = this.x - particle.radius;
-
- if (particle.p.y + particle.radius < this.y && particle.v.y <= 0)
- particle.p.y = this.y + this.height + particle.radius;
- else if (particle.p.y - particle.radius > this.y + this.height && particle.v.y >= 0)
- particle.p.y = this.y - particle.radius;
}
- }
-
- Proton.RectZone = RectZone;
-
+ }]);
+ return PointZoneRectZone;
+}(Zone);
+var ImageZone = function (_Zone) {
+ inherits(ImageZone, _Zone);
function ImageZone(imageData, x, y, d) {
- ImageZone._super_.call(this);
- this.reset(imageData, x, y, d);
- }
+ classCallCheck(this, ImageZone);
+ var _this = possibleConstructorReturn(this, (ImageZone.__proto__ || Object.getPrototypeOf(ImageZone)).call(this));
- Proton.Util.inherits(ImageZone, Proton.Zone);
- ImageZone.prototype.reset = function(imageData, x, y, d) {
- this.imageData = imageData;
- this.x = Proton.Util.initValue(x, 0);
- this.y = Proton.Util.initValue(y, 0);
- this.d = Proton.Util.initValue(d, 2);
- this.vectors = [];
- this.setVectors();
+ _this.reset(imageData, x, y, d);
+ return _this;
}
- ImageZone.prototype.setVectors = function() {
- var i, j;
- var length1 = this.imageData.width;
- var length2 = this.imageData.height;
- for ( i = 0; i < length1; i += this.d) {
- for ( j = 0; j < length2; j += this.d) {
- var index = ((j >> 0) * length1 + (i >> 0)) * 4;
- if (this.imageData.data[index + 3] > 0) {
- this.vectors.push({
- x : i + this.x,
- y : j + this.y
- });
+ createClass(ImageZone, [{
+ key: 'reset',
+ value: function reset(imageData, x, y, d) {
+ this.imageData = imageData;
+ this.x = Util.initValue(x, 0);
+ this.y = Util.initValue(y, 0);
+ this.d = Util.initValue(d, 2);
+
+ this.vectors = [];
+ this.setVectors();
+ }
+ }, {
+ key: 'setVectors',
+ value: function setVectors() {
+ var i = void 0,
+ j = void 0;
+ var length1 = this.imageData.width;
+ var length2 = this.imageData.height;
+
+ for (i = 0; i < length1; i += this.d) {
+ for (j = 0; j < length2; j += this.d) {
+ var index = ((j >> 0) * length1 + (i >> 0)) * 4;
+
+ if (this.imageData.data[index + 3] > 0) {
+ this.vectors.push({ x: i + this.x, y: j + this.y });
+ }
}
}
- }
- return this.vector;
- }
- ImageZone.prototype.getBound = function(x, y) {
- var index = ((y >> 0) * this.imageData.width + (x >> 0)) * 4;
- if (this.imageData.data[index + 3] > 0)
- return true;
- else
- return false;
- }
-
- ImageZone.prototype.getPosition = function() {
- return this.vector.copy(this.vectors[Math.floor(Math.random() * this.vectors.length)]);
- }
-
- ImageZone.prototype.getColor = function(x, y) {
- x -= this.x;
- y -= this.y;
- var i = ((y >> 0) * this.imageData.width + (x >> 0)) * 4;
- return {
- r : this.imageData.data[i],
- g : this.imageData.data[i + 1],
- b : this.imageData.data[i + 2],
- a : this.imageData.data[i + 3]
- };
- }
-
- ImageZone.prototype.crossing = function(particle) {
- if (this.crossType == "dead") {
- if (this.getBound(particle.p.x - this.x, particle.p.y - this.y))
- particle.dead = true;
- else
- particle.dead = false;
- } else if (this.crossType == "bound") {
- if (!this.getBound(particle.p.x - this.x, particle.p.y - this.y))
- particle.v.negate();
+ return this.vector;
}
- }
-
- Proton.ImageZone = ImageZone;
-
-
-
- var Debug = Debug || {
- addEventListener : function(proton, fun) {
- proton.addEventListener(Proton.PROTON_UPDATE, function() {
- fun();
- });
- },
-
- setStyle : function(c) {
- var color = c || '#ff0000';
- var rgb = Proton.Util.hexToRGB(color);
- var style = 'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + 0.5 + ')';
-
- return style;
- },
-
- drawZone : function(proton, canvas, zone, clear) {
- var context = canvas.getContext('2d');
- var style = this.setStyle();
-
- this.addEventListener(proton, function() {
- if (clear)
- context.clearRect(0, 0, canvas.width, canvas.height);
-
- if ( zone instanceof Proton.PointZone) {
- context.beginPath();
- context.fillStyle = style;
- context.arc(zone.x, zone.y, 10, 0, Math.PI * 2, true);
- context.fill();
- context.closePath();
- } else if ( zone instanceof Proton.LineZone) {
- context.beginPath();
- context.strokeStyle = style;
- context.moveTo(zone.x1, zone.y1);
- context.lineTo(zone.x2, zone.y2);
- context.stroke();
- context.closePath();
- } else if ( zone instanceof Proton.RectZone) {
- context.beginPath();
- context.strokeStyle = style;
- context.drawRect(zone.x, zone.y, zone.width, zone.height);
- context.stroke();
- context.closePath();
- } else if ( zone instanceof Proton.CircleZone) {
- context.beginPath();
- context.strokeStyle = style;
- context.arc(zone.x, zone.y, zone.radius, 0, Math.PI * 2, true);
- context.stroke();
- context.closePath();
- }
- });
- },
+ }, {
+ key: 'getBound',
+ value: function getBound(x, y) {
+ var index = ((y >> 0) * this.imageData.width + (x >> 0)) * 4;
+ if (this.imageData.data[index + 3] > 0) return true;else return false;
+ }
+ }, {
+ key: 'getPosition',
+ value: function getPosition() {
+ return this.vector.copy(this.vectors[Math.floor(Math.random() * this.vectors.length)]);
+ }
+ }, {
+ key: 'getColor',
+ value: function getColor(x, y) {
+ x -= this.x;
+ y -= this.y;
+ var i = ((y >> 0) * this.imageData.width + (x >> 0)) * 4;
+
+ return {
+ r: this.imageData.data[i],
+ g: this.imageData.data[i + 1],
+ b: this.imageData.data[i + 2],
+ a: this.imageData.data[i + 3]
+ };
+ }
+ }, {
+ key: 'crossing',
+ value: function crossing(particle) {
+ if (this.crossType == "dead") {
+ if (this.getBound(particle.p.x - this.x, particle.p.y - this.y)) particle.dead = true;else particle.dead = false;
+ } else if (this.crossType == "bound") {
+ if (!this.getBound(particle.p.x - this.x, particle.p.y - this.y)) particle.v.negate();
+ }
+ }
+ }]);
+ return ImageZone;
+}(Zone);
+
+var Debug = {
+ addEventListener: function addEventListener(proton, fun) {
+ proton.addEventListener("PROTON_UPDATE_AFTER", function () {
+ return fun();
+ });
+ },
+ getStyle: function getStyle(color) {
+ var rgb = ColorUtil.hexToRGB(color || '#ff0000');
+ return 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', 0.5)';
+ },
+ drawZone: function drawZone(proton, canvas, zone, clear) {
+ var context = canvas.getContext('2d');
+ var style = this.getStyle();
- drawEmitter : function(proton, canvas, emitter, clear) {
- var context = canvas.getContext('2d');
- var style = this.setStyle();
- this.addEventListener(proton, function() {
- if (clear)
- context.clearRect(0, 0, canvas.width, canvas.height);
+ this.addEventListener(proton, function () {
+ if (clear) context.clearRect(0, 0, canvas.width, canvas.height);
+ if (zone instanceof PointZone) {
context.beginPath();
context.fillStyle = style;
- context.arc(emitter.p.x, emitter.p.y, 10, 0, Math.PI * 2, true);
+ context.arc(zone.x, zone.y, 10, 0, Math.PI * 2, true);
context.fill();
context.closePath();
- });
- },
-
- test : {},
+ } else if (zone instanceof CircleZone) {
+ context.beginPath();
+ context.strokeStyle = style;
+ context.moveTo(zone.x1, zone.y1);
+ context.lineTo(zone.x2, zone.y2);
+ context.stroke();
+ context.closePath();
+ } else if (zone instanceof PointZoneRectZone) {
+ context.beginPath();
+ context.strokeStyle = style;
+ context.drawRect(zone.x, zone.y, zone.width, zone.height);
+ context.stroke();
+ context.closePath();
+ } else if (zone instanceof CircleZone$1) {
+ context.beginPath();
+ context.strokeStyle = style;
+ context.arc(zone.x, zone.y, zone.radius, 0, Math.PI * 2, true);
+ context.stroke();
+ context.closePath();
+ }
+ });
+ },
+ drawEmitter: function drawEmitter(proton, canvas, emitter, clear) {
+ var context = canvas.getContext('2d');
+ var style = this.getStyle();
- setTest : function(id, value) {
- this.test[id] = value;
- },
+ this.addEventListener(proton, function () {
+ if (clear) context.clearRect(0, 0, canvas.width, canvas.height);
- getTest : function(id) {
- if (this.test.hasOwnProperty(id))
- return this.test[id];
- else
- return false;
- }
+ context.beginPath();
+ context.fillStyle = style;
+ context.arc(emitter.p.x, emitter.p.y, 10, 0, Math.PI * 2, true);
+ context.fill();
+ context.closePath();
+ });
}
-
- Proton.Debug = Debug;
-
+};
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
-( function() {
- var lastTime = 0;
- var vendors = ['ms', 'moz', 'webkit', 'o'];
- for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
- window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
- window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
- }
-
- if (!window.requestAnimationFrame)
- window.requestAnimationFrame = function(callback, element) {
- var currTime = new Date().getTime();
- var timeToCall = Math.max(0, 16 - (currTime - lastTime));
- var id = window.setTimeout(function() {
- callback(currTime + timeToCall);
- }, timeToCall);
- lastTime = currTime + timeToCall;
- return id;
- };
-
- if (!window.cancelAnimationFrame)
- window.cancelAnimationFrame = function(id) {
- clearTimeout(id);
- };
- }());
+(function () {
+ var lastTime = 0;
+ var vendors = ['ms', 'moz', 'webkit', 'o'];
+ for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
+ window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
+ window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
+ }
+
+ if (!window.requestAnimationFrame) window.requestAnimationFrame = function (callback, element) {
+ var currTime = new Date().getTime();
+ var timeToCall = Math.max(0, 16 - (currTime - lastTime));
+ var id = window.setTimeout(function () {
+ callback(currTime + timeToCall);
+ }, timeToCall);
+ lastTime = currTime + timeToCall;
+ return id;
+ };
- return Proton;
-}));
\ No newline at end of file
+ if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function (id) {
+ clearTimeout(id);
+ };
+})();
+
+// import
+// namespace
+Proton$1.Particle = Proton$1.P = Particle;
+Proton$1.Pool = Pool;
+
+Proton$1.Util = Util;
+Proton$1.ColorUtil = ColorUtil;
+Proton$1.MathUtils = MathUtils;
+Proton$1.Vector2D = Proton$1.Vector = Vector2D;
+Proton$1.Polar2D = Proton$1.Polar = Polar2D;
+Proton$1.ArraySpan = ArraySpan;
+Proton$1.Rectangle = Rectangle;
+Proton$1.Rate = Rate;
+Proton$1.ease = ease;
+Proton$1.Span = Span;
+Proton$1.Mat3 = Mat3;
+Proton$1.getSpan = function (a, b, center) {
+ return new Span(a, b, center);
+};
+Proton$1.createArraySpan = ArraySpan.createArraySpan;
+
+Proton$1.Initialize = Proton$1.Init = Initialize;
+Proton$1.Life = Proton$1.L = Life;
+Proton$1.Position = Proton$1.P = Position;
+Proton$1.Velocity = Proton$1.V = Velocity;
+Proton$1.Mass = Proton$1.M = Mass;
+Proton$1.Radius = Proton$1.R = Radius;
+Proton$1.Body = Proton$1.B = Body;
+
+Proton$1.Behaviour = Behaviour;
+Proton$1.Force = Proton$1.F = Force;
+Proton$1.Attraction = Proton$1.A = Attraction;
+Proton$1.RandomDrift = Proton$1.RD = RandomDrift;
+Proton$1.Gravity = Proton$1.G = Gravity;
+Proton$1.Collision = Collision;
+Proton$1.CrossZone = CrossZone;
+Proton$1.Alpha = Proton$1.A = Alpha;
+Proton$1.Scale = Proton$1.S = Scale;
+Proton$1.Rotate = Rotate;
+Proton$1.Color = Color;
+Proton$1.Repulsion = Repulsion;
+Proton$1.GravityWell = GravityWell;
+
+Proton$1.Emitter = Emitter;
+Proton$1.BehaviourEmitter = BehaviourEmitter;
+Proton$1.FollowEmitter = FollowEmitter;
+
+Proton$1.Zone = Zone;
+Proton$1.LineZone = CircleZone;
+Proton$1.CircleZone = CircleZone$1;
+Proton$1.PointZone = PointZone;
+Proton$1.RectZone = PointZoneRectZone;
+Proton$1.ImageZone = ImageZone;
+
+Proton$1.CanvasRenderer = CanvasRenderer;
+Proton$1.DomRenderer = DomRenderer;
+Proton$1.EaselRenderer = EaselRenderer;
+Proton$1.PixiRenderer = PixiRenderer;
+Proton$1.PixelRenderer = PixelRenderer;
+Proton$1.WebGLRenderer = Proton$1.WebGlRenderer = WebGLRenderer;
+Proton$1.CustomRenderer = CustomRenderer;
+
+Proton$1.Debug = Debug;
+
+Object.assign(Proton$1, ease);
+
+return Proton$1;
+
+})));
+//# sourceMappingURL=proton.js.map
diff --git a/build/proton.js.map b/build/proton.js.map
new file mode 100644
index 0000000..941f38f
--- /dev/null
+++ b/build/proton.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"proton.js","sources":["../src/math/MathUtils.js","../src/math/Vector2D.js","../src/math/Span.js","../src/utils/WebGLUtil.js","../src/utils/DomUtil.js","../src/utils/ImgUtil.js","../src/utils/Util.js","../src/utils/PUID.js","../src/core/Pool.js","../src/debug/Stats.js","../src/events/EventDispatcher.js","../src/math/Integration.js","../src/core/Proton.js","../src/math/ease.js","../src/core/Particle.js","../src/utils/ColorUtil.js","../src/math/Polar2D.js","../src/math/Mat3.js","../src/math/ArraySpan.js","../src/math/Rectangle.js","../src/initialize/Rate.js","../src/initialize/Initialize.js","../src/initialize/Life.js","../src/zone/Zone.js","../src/zone/PointZone.js","../src/initialize/Position.js","../src/initialize/Velocity.js","../src/initialize/Mass.js","../src/initialize/Radius.js","../src/initialize/Body.js","../src/behaviour/Behaviour.js","../src/behaviour/Force.js","../src/behaviour/Attraction.js","../src/behaviour/RandomDrift.js","../src/behaviour/Gravity.js","../src/behaviour/Collision.js","../src/behaviour/CrossZone.js","../src/behaviour/Alpha.js","../src/behaviour/Scale.js","../src/behaviour/Rotate.js","../src/behaviour/Color.js","../src/behaviour/Repulsion.js","../src/behaviour/GravityWell.js","../src/initialize/InitializeUtil.js","../src/emitter/Emitter.js","../src/emitter/BehaviourEmitter.js","../src/emitter/FollowEmitter.js","../src/render/BaseRenderer.js","../src/render/CanvasRenderer.js","../src/render/DomRenderer.js","../src/render/EaselRenderer.js","../src/render/PixelRenderer.js","../src/render/PixiRenderer.js","../src/utils/MStack.js","../src/render/WebGLRenderer.js","../src/render/CustomRenderer.js","../src/zone/LineZone.js","../src/zone/CircleZone.js","../src/zone/RectZone.js","../src/zone/ImageZone.js","../src/debug/Debug.js","../src/polyfill/requestAnimationFrame.js","../src/index.js"],"sourcesContent":["const PI = 3.1415926;\n\nconst MathUtils = {\n\n PI: PI,\n PIx2: PI * 2,\n PI_2: PI / 2,\n PI_180: PI / 180,\n N180_PI: 180 / PI,\n\n randomAToB(a, b, INT) {\n if (!INT)\n return a + Math.random() * (b - a);\n else\n return Math.floor(Math.random() * (b - a)) + a;\n },\n\n randomFloating(center, f, INT) {\n return this.randomAToB(center - f, center + f, INT);\n },\n\n randomZone(display) {},\n\n degreeTransform(a) {\n return a * PI / 180;\n },\n\n toColor16(num) {\n return \"#\" + num.toString(16);\n },\n\n randomColor() {\n return '#' + ('00000' + (Math.random() * 0x1000000 << 0).toString(16)).slice(-6);\n }\n}\n\nexport default MathUtils;","import MathUtils from '../math/MathUtils';\n\nexport default class Vector2D {\n\n constructor(x, y) {\n this.x = x || 0;\n this.y = y || 0;\n }\n\n set(x, y) {\n this.x = x;\n this.y = y;\n return this;\n }\n\n setX(x) {\n this.x = x;\n return this;\n }\n\n setY(y) {\n this.y = y;\n return this;\n }\n\n getGradient() {\n if (this.x != 0)\n return Math.atan2(this.y, this.x);\n else if (this.y > 0)\n return MathUtils.PI_2;\n else if (this.y < 0)\n return -MathUtils.PI_2;\n }\n\n copy(v) {\n this.x = v.x;\n this.y = v.y;\n\n return this;\n }\n\n add(v, w) {\n if (w !== undefined) {\n return this.addVectors(v, w);\n }\n\n this.x += v.x;\n this.y += v.y;\n\n return this;\n }\n\n addXY(a, b) {\n this.x += a;\n this.y += b;\n\n return this;\n }\n\n addVectors(a, b) {\n this.x = a.x + b.x;\n this.y = a.y + b.y;\n\n return this;\n }\n\n sub(v, w) {\n if (w !== undefined) {\n return this.subVectors(v, w);\n }\n\n this.x -= v.x;\n this.y -= v.y;\n\n return this;\n }\n\n subVectors(a, b) {\n this.x = a.x - b.x;\n this.y = a.y - b.y;\n\n return this;\n }\n\n divideScalar(s) {\n if (s !== 0) {\n this.x /= s;\n this.y /= s;\n } else {\n this.set(0, 0);\n }\n\n return this;\n }\n\n multiplyScalar(s) {\n this.x *= s;\n this.y *= s;\n\n return this;\n }\n\n negate() {\n return this.multiplyScalar(-1);\n }\n\n dot(v) {\n return this.x * v.x + this.y * v.y;\n }\n\n lengthSq() {\n return this.x * this.x + this.y * this.y;\n }\n\n length() {\n return Math.sqrt(this.x * this.x + this.y * this.y);\n }\n\n normalize() {\n return this.divideScalar(this.length());\n }\n\n distanceTo(v) {\n return Math.sqrt(this.distanceToSquared(v));\n }\n\n rotate(tha) {\n const x = this.x;\n const y = this.y;\n\n this.x = x * Math.cos(tha) + y * Math.sin(tha);\n this.y = -x * Math.sin(tha) + y * Math.cos(tha);\n\n return this;\n }\n\n distanceToSquared(v) {\n const dx = this.x - v.x;\n const dy = this.y - v.y;\n\n return dx * dx + dy * dy;\n }\n\n lerp(v, alpha) {\n this.x += (v.x - this.x) * alpha;\n this.y += (v.y - this.y) * alpha;\n\n return this;\n }\n\n equals(v) {\n return ((v.x === this.x) && (v.y === this.y));\n }\n\n clear() {\n this.x = 0.0;\n this.y = 0.0;\n return this;\n }\n\n clone() {\n return new Vector2D(this.x, this.y);\n }\n}","import Util from '../utils/Util';\nimport MathUtils from '../math/MathUtils';\n\nexport default class Span {\n\n\tconstructor(a, b, center) {\n\t\tthis.isArray = false;\n\n\t\tif (Util.isArray(a)) {\n\t\t\tthis.isArray = true;\n\t\t\tthis.a = a;\n\t\t} else {\n\t\t\tthis.a = Util.initValue(a, 1);\n\t\t\tthis.b = Util.initValue(b, this.a);\n\t\t\tthis.center = Util.initValue(center, false);\n\t\t}\n\n\t}\n\n\tgetValue(INT) {\n\t\tif (this.isArray) {\n\t\t\treturn this.a[Math.floor(this.a.length * Math.random())];\n\t\t} else {\n\t\t\tif (!this.center)\n\t\t\t\treturn MathUtils.randomAToB(this.a, this.b, INT);\n\t\t\telse\n\t\t\t\treturn MathUtils.randomFloating(this.a, this.b, INT);\n\t\t}\n\t}\n}","export default {\n\n /**\n * @memberof Proton#Proton.WebGLUtil\n * @method ipot\n *\n * @todo add description\n * @todo add length description\n *\n * @param {Number} length\n *\n * @return {Boolean}\n */\n ipot(length) {\n return (length & (length - 1)) == 0;\n },\n\n /**\n * @memberof Proton#Proton.WebGLUtil\n * @method nhpot\n *\n * @todo add description\n * @todo add length description\n *\n * @param {Number} length\n *\n * @return {Number}\n */\n nhpot(length) {\n --length;\n for (let i = 1; i < 32; i <<= 1) {\n length = length | length >> i;\n }\n\n return length + 1;\n },\n\n /**\n * @memberof Proton#Proton.WebGLUtil\n * @method makeTranslation\n *\n * @todo add description\n * @todo add tx, ty description\n * @todo add return description\n *\n * @param {Number} tx either 0 or 1\n * @param {Number} ty either 0 or 1\n *\n * @return {Object}\n */\n makeTranslation(tx, ty) {\n return [1, 0, 0, 0, 1, 0, tx, ty, 1];\n },\n\n /**\n * @memberof Proton#Proton.WebGLUtil\n * @method makeRotation\n *\n * @todo add description\n * @todo add return description\n *\n * @param {Number} angleInRadians\n *\n * @return {Object}\n */\n makeRotation(angleInRadians) {\n let c = Math.cos(angleInRadians);\n let s = Math.sin(angleInRadians);\n\n return [c, -s, 0, s, c, 0, 0, 0, 1];\n },\n\n /**\n * @memberof Proton#Proton.WebGLUtil\n * @method makeScale\n *\n * @todo add description\n * @todo add tx, ty description\n * @todo add return description\n *\n * @param {Number} sx either 0 or 1\n * @param {Number} sy either 0 or 1\n *\n * @return {Object}\n */\n makeScale(sx, sy) {\n return [sx, 0, 0, 0, sy, 0, 0, 0, 1];\n },\n\n /**\n * @memberof Proton#Proton.WebGLUtil\n * @method matrixMultiply\n *\n * @todo add description\n * @todo add a, b description\n * @todo add return description\n *\n * @param {Object} a\n * @param {Object} b\n *\n * @return {Object}\n */\n matrixMultiply(a, b) {\n let a00 = a[0 * 3 + 0];\n let a01 = a[0 * 3 + 1];\n let a02 = a[0 * 3 + 2];\n let a10 = a[1 * 3 + 0];\n let a11 = a[1 * 3 + 1];\n let a12 = a[1 * 3 + 2];\n let a20 = a[2 * 3 + 0];\n let a21 = a[2 * 3 + 1];\n let a22 = a[2 * 3 + 2];\n let b00 = b[0 * 3 + 0];\n let b01 = b[0 * 3 + 1];\n let b02 = b[0 * 3 + 2];\n let b10 = b[1 * 3 + 0];\n let b11 = b[1 * 3 + 1];\n let b12 = b[1 * 3 + 2];\n let b20 = b[2 * 3 + 0];\n let b21 = b[2 * 3 + 1];\n let b22 = b[2 * 3 + 2];\n\n return [\n a00 * b00 + a01 * b10 + a02 * b20,\n a00 * b01 + a01 * b11 + a02 * b21,\n a00 * b02 + a01 * b12 + a02 * b22,\n a10 * b00 + a11 * b10 + a12 * b20,\n a10 * b01 + a11 * b11 + a12 * b21,\n a10 * b02 + a11 * b12 + a12 * b22,\n a20 * b00 + a21 * b10 + a22 * b20,\n a20 * b01 + a21 * b11 + a22 * b21,\n a20 * b02 + a21 * b12 + a22 * b22\n ];\n }\n}","export default {\n\n /**\n * Creates and returns a new canvas. The opacity is by default set to 0\n *\n * @memberof Proton#Proton.DomUtil\n * @method createCanvas\n *\n * @param {String} $id the canvas' id\n * @param {Number} $width the canvas' width\n * @param {Number} $height the canvas' height\n * @param {String} [$position=absolute] the canvas' position, default is 'absolute' \n *\n * @return {Object}\n */\n createCanvas(id, width, height, position) {\n const dom = document.createElement(\"canvas\");\n position = position || 'absolute';\n\n dom.id = id;\n dom.width = width;\n dom.height = height;\n dom.style.opacity = 0;\n dom.style.position = position;\n\n this.transform(dom, -500, -500, 0, 0);\n\n return dom;\n },\n\n createDiv(id, width, height) {\n const dom = document.createElement(\"div\");\n\n dom.id = id;\n dom.style.position = 'absolute';\n this.resize(dom, width, height);\n\n return dom;\n },\n\n resize(dom, width, height) {\n dom.style.width = width + 'px';\n dom.style.height = height + 'px';\n dom.style.marginLeft = -width / 2 + 'px';\n dom.style.marginTop = -height / 2 + 'px';\n },\n\n /**\n * Adds a transform: translate(), scale(), rotate() to a given div dom for all browsers\n *\n * @memberof Proton#Proton.DomUtil\n * @method transform\n *\n * @param {HTMLDivElement} div \n * @param {Number} $x \n * @param {Number} $y \n * @param {Number} $scale \n * @param {Number} $rotate \n */\n transform(div, x, y, scale, rotate) {\n const transform = `translate(${x}px, ${y}px) scale(${scale}) rotate(${rotate}deg)`;\n\n div.style.willChange = 'transform';\n this.css3(div, 'transform', transform);\n },\n\n transform3d(div, x, y, scale, rotate) {\n const transform = `translate3d(${x}px, ${y}px, 0) scale(${scale}) rotate(${rotate}deg)`;\n\n div.style.willChange = 'transform';\n this.css3(div, 'backfaceVisibility', 'hidden');\n this.css3(div, 'transform', transform);\n },\n\n css3(div, key, val) {\n const bkey = key.charAt(0).toUpperCase() + key.substr(1);\n\n div.style[`Webkit${bkey}`] = val;\n div.style[`Moz${bkey}`] = val;\n div.style[`O${bkey}`] = val;\n div.style[`ms${bkey}`] = val;\n div.style[`${key}`] = val;\n }\n}","import WebGLUtil from './WebGLUtil';\nimport DomUtil from './DomUtil';\n\nconst IMG_CACHE = {};\nconst CANVAS_CACHE = {};\nlet canvasID = 0;\n\nexport default {\n\n /**\n * This will get the image data. It could be necessary to create a Proton.Zone.\n *\n * @memberof Proton#Proton.Util\n * @method getImageData\n *\n * @param {HTMLCanvasElement} context any canvas, must be a 2dContext 'canvas.getContext('2d')'\n * @param {Object} image could be any dom image, e.g. document.getElementById('thisIsAnImgTag');\n * @param {Proton.Rectangle} rect\n */\n getImageData(context, image, rect) {\n context.drawImage(image, rect.x, rect.y);\n const imagedata = context.getImageData(rect.x, rect.y, rect.width, rect.height);\n context.clearRect(rect.x, rect.y, rect.width, rect.height);\n\n return imagedata;\n },\n\n /**\n * @memberof Proton#Proton.Util\n * @method getImgFromCache\n *\n * @todo add description\n * @todo describe func\n *\n * @param {Mixed} img\n * @param {Proton.Particle} particle\n * @param {Boolean} drawCanvas set to true if a canvas should be saved into particle.transform.canvas\n * @param {Boolean} func\n */\n getImgFromCache(img, callback, param) {\n const src = typeof (img) == 'string' ? img : img.src;\n\n if (IMG_CACHE[src]) {\n callback(IMG_CACHE[src], param);\n } else {\n const image = new Image();\n image.onload = e => {\n IMG_CACHE[src] = e.target;\n callback(IMG_CACHE[src], param);\n }\n\n image.src = src;\n }\n },\n\n getCanvasFromCache(img, callback, param) {\n const src = img.src;\n\n if (!CANVAS_CACHE[src]) {\n const width = WebGLUtil.nhpot(img.width);\n const height = WebGLUtil.nhpot(img.height);\n\n const canvas = DomUtil.createCanvas(`canvas_cache_${canvasID}`, width, height);\n const context = canvas.getContext('2d');\n context.drawImage(img, 0, 0, img.width, img.height);\n\n CANVAS_CACHE[src] = canvas;\n }\n\n callback && callback(CANVAS_CACHE[src], param);\n\n return CANVAS_CACHE[src];\n }\n}","import Vector2D from '../math/Vector2D';\nimport Span from '../math/Span';\nimport ImgUtil from './ImgUtil';\nimport DomUtil from './DomUtil';\n\nexport default {\n\n /**\n * Returns the default if the value is null or undefined\n *\n * @memberof Proton#Proton.Util\n * @method initValue\n *\n * @param {Mixed} value a specific value, could be everything but null or undefined\n * @param {Mixed} defaults the default if the value is null or undefined\n */\n initValue(value, defaults) {\n value = (value !== null && value !== undefined) ? value : defaults;\n return value;\n },\n\n /**\n * Checks if the value is a valid array\n *\n * @memberof Proton#Proton.Util\n * @method isArray\n *\n * @param {Array} value Any array\n *\n * @returns {Boolean} \n */\n isArray(value) {\n return Object.prototype.toString.call(value) === '[object Array]';\n },\n\n /**\n * Destroyes the given array\n *\n * @memberof Proton#Proton.Util\n * @method destroyArray\n *\n * @param {Array} array Any array\n */\n destroyArray(array) {\n if (array) array.length = 0;\n },\n\n /**\n * Destroyes the given object\n *\n * @memberof Proton#Proton.Util\n * @method destroyObject\n *\n * @param {Object} obj Any object\n */\n destroyObject(obj, ignore) {\n for (let o in obj) {\n if (ignore && ignore.indexOf(o) > -1) continue;\n delete obj[o];\n }\n },\n\n /**\n * Makes an instance of a class and binds the given array\n *\n * @memberof Proton#Proton.Util\n * @method classApply\n *\n * @param {Function} constructor A class to make an instance from\n * @param {Array} [args] Any array to bind it to the constructor\n *\n * @return {Object} The instance of constructor, optionally bind with args\n */\n classApply(constructor, args) {\n if (!args) return new constructor;\n\n args = [null].concat(args);\n const factoryFunction = constructor.bind.apply(constructor, args);\n return new factoryFunction();\n },\n\n /**\n * @memberof Proton#Proton.Util\n * @method setVector2DByObject\n *\n * @todo add description for param `target`\n * @todo add description for param `pOBJ`\n * @todo add description for function\n *\n * @param {Object} target\n * @param {Object} pOBJ\n */\n setVector2DByObject(target, pOBJ) {\n if (this.hasProp(pOBJ, 'x')) target.p.x = pOBJ['x'];\n if (this.hasProp(pOBJ, 'y')) target.p.y = pOBJ['y'];\n\n if (this.hasProp(pOBJ, 'vx')) target.v.x = pOBJ['vx'];\n if (this.hasProp(pOBJ, 'vy')) target.v.y = pOBJ['vy'];\n\n if (this.hasProp(pOBJ, 'ax')) target.a.x = pOBJ['ax'];\n if (this.hasProp(pOBJ, 'ay')) target.a.y = pOBJ['ay'];\n\n if (this.hasProp(pOBJ, 'p')) particle.p.copy(pOBJ['p']);\n if (this.hasProp(pOBJ, 'v')) particle.v.copy(pOBJ['v']);\n if (this.hasProp(pOBJ, 'a')) particle.a.copy(pOBJ['a']);\n\n if (this.hasProp(pOBJ, 'position')) particle.p.copy(pOBJ['position']);\n if (this.hasProp(pOBJ, 'velocity')) particle.v.copy(pOBJ['velocity']);\n if (this.hasProp(pOBJ, 'accelerate')) particle.a.copy(pOBJ['accelerate']);\n },\n\n hasProp(obj, key) {\n if (!obj) return false;\n return obj[key] !== undefined;\n // return obj.hasOwnProperty(key);\n },\n\n /**\n * set the prototype in a given prototypeObject\n *\n * @memberof Proton#Proton.Util\n * @method setPrototypeByObject\n *\n * @todo add description for param `target`\n * @todo add description for param `filters`\n * @todo translate desription from chinese to english\n *\n * @param {Object} target\n * @param {Object} prototypeObject An object of single prototypes\n * @param {Object} filters\n *\n * @return {Object} target\n */\n setPrototypeByObject(target, prototypeObject, filters) {\n for (let singleProp in prototypeObject) {\n if (target.hasOwnProperty(singleProp)) {\n if (filters) {\n if (filters.indexOf(singleProp) < 0)\n target[singleProp] = this.getSpanValue(prototypeObject[singleProp]);\n } else {\n target[singleProp] = this.getSpanValue(prototypeObject[singleProp]);\n }\n }\n }\n\n return target;\n },\n\n /**\n * Returns a new Span object\n *\n * @memberof Proton#Proton.Util\n * @method setSpanValue\n *\n * @todo a, b and c should be 'Mixed' or 'Number'?\n *\n * @param {Mixed | Span} a\n * @param {Mixed} b\n * @param {Mixed} c\n *\n * @return {Span}\n */\n setSpanValue(a, b, c) {\n if (a instanceof Span) {\n return a;\n } else {\n if (!b) {\n return new Span(a);\n } else {\n if (!c)\n return new Span(a, b);\n else\n return new Span(a, b, c);\n }\n }\n },\n\n /**\n * Returns the value from a Span, if the param is not a Span it will return the given parameter\n *\n * @memberof Proton#Proton.Util\n * @method getSpanValue\n *\n * @param {Mixed | Span} pan\n *\n * @return {Mixed} the value of Span OR the parameter if it is not a Span\n */\n getSpanValue(pan) {\n return pan instanceof Span ? pan.getValue() : pan;\n },\n\n /**\n * This will get the image data. It could be necessary to create a Proton.Zone.\n *\n * @memberof Proton#Proton.Util\n * @method getImageData\n *\n * @param {HTMLCanvasElement} context any canvas, must be a 2dContext 'canvas.getContext('2d')'\n * @param {Object} image could be any dom image, e.g. document.getElementById('thisIsAnImgTag');\n * @param {Proton.Rectangle} rect\n */\n getImageData(context, image, rect) {\n return ImgUtil.getImageData(context, image, rect);\n },\n\n destroy(arr, param) {\n let i = arr.length;\n\n while (i--) {\n try { arr[i].destroy(param); } catch (e) { }\n delete arr[i];\n }\n\n arr.length = 0;\n }\n\n}","export default {\n id: 0,\n cache: {},\n\n getID(target) {\n let uid = this.getCacheID(target);\n if (uid) return uid;\n\n uid = `PUID_${this.id++}`;\n this.cache[uid] = target;\n\n return uid;\n },\n\n getCacheID(target) {\n let obj;\n for (let id in this.cache) {\n obj = this.cache[id];\n\n if (obj === target) return id;\n \n if (typeof obj === 'object' && typeof target === 'object' && obj.isInner && target.isInner) {\n if (obj.src === target.src)\n return id;\n }\n }\n\n return null;\n },\n\n getTarget(uid) {\n return this.cache[uid];\n }\n}","/**\n * get -> PUID :: uid-> Body\n * -> cache[abc]. -> cache[abc] .pop()\n * -> create [new Body| clone]\n * -> return p1: { __pid: abc }\n * \n * expire -> cache[abc]= [p0, p1];\n * \n */\nimport Util from '../utils/Util';\nimport PUID from '../utils/PUID';\n\nexport default class Pool {\n\n /**\n * @memberof! Proton#\n * @constructor\n * @alias Proton.Pool\n *\n * @todo add description\n * @todo add description of properties\n *\n * @property {Number} total\n * @property {Object} cache\n */\n constructor(num) {\n this.total = 0;\n this.cache = {};\n }\n\n /**\n * @todo add description\n *\n * @method get\n * @memberof Proton#Proton.Pool\n *\n * @param {Object|Function} target\n * @param {Object} [params] just add if `target` is a function\n *\n * @return {Object}\n */\n get(target, params, uid) {\n let p;\n uid = uid || target.__puid || PUID.getID(target);\n\n if (this.cache[uid] && this.cache[uid].length > 0)\n p = this.cache[uid].pop();\n else\n p = this.createOrClone(target, params);\n\n p.__puid = target.__puid || uid;\n return p;\n }\n\n /**\n * @todo add description\n *\n * @method set\n * @memberof Proton#Proton.Pool\n *\n * @param {Object} target\n *\n * @return {Object}\n */\n expire(target) {\n return this.getCache(target.__puid).push(target);\n }\n\n /**\n * Creates a new class instance\n *\n * @todo add more documentation \n *\n * @method create\n * @memberof Proton#Proton.Pool\n *\n * @param {Object|Function} target any Object or Function\n * @param {Object} [params] just add if `target` is a function\n *\n * @return {Object}\n */\n createOrClone(target, params) {\n this.total++;\n\n if (this.create) {\n return this.create(target, params);\n } else if (typeof target == \"function\") {\n return Util.classApply(target, params);\n } else {\n return target.clone();\n }\n }\n\n /**\n * @todo add description - what is in the cache?\n *\n * @method getCount\n * @memberof Proton#Proton.Pool\n *\n * @return {Number}\n */\n getCount() {\n let count = 0;\n\n for (let id in this.cache)\n count += this.cache[id].length;\n\n return count++;;\n }\n\n /**\n * Destroyes all items from Pool.cache\n *\n * @method destroy\n * @memberof Proton#Proton.Pool\n */\n destroy() {\n for (let id in this.cache) {\n this.cache[id].length = 0;\n delete this.cache[id];\n }\n }\n\n /**\n * Returns Pool.cache\n *\n * @method getCache\n * @memberof Proton#Proton.Pool\n * @private\n *\n * @param {Number} uid the unique id\n *\n * @return {Object}\n */\n getCache(uid) {\n uid = uid || \"default\";\n\n if (!this.cache[uid]) this.cache[uid] = [];\n return this.cache[uid];\n }\n}","export default class Stats {\n\n constructor(proton) {\n this.proton = proton;\n this.container = null;\n this.type = 1;\n\n this.emitterIndex = 0;\n this.rendererIndex = 0;\n }\n\n update(style, body) {\n this.add(style, body);\n\n const emitter = this.getEmitter();\n const renderer = this.getRenderer();\n let str = \"\";\n\n switch (this.type) {\n case 2:\n str += \"emitter:\" + this.proton.emitters.length + \"
\";\n if (emitter) str += \"em speed:\" + emitter.emitSpeed + \"
\";\n if (emitter) str += \"pos:\" + this.getEmitterPos(emitter);\n break;\n\n case 3:\n if (emitter) str += \"initializes:\" + emitter.initializes.length + \"
\";\n if (emitter) str += \"\" + this.concatArr(emitter.initializes) + \"
\";\n if (emitter) str += \"behaviours:\" + emitter.behaviours.length + \"
\";\n if (emitter) str += \"\" + this.concatArr(emitter.behaviours) + \"
\";\n break;\n\n case 4:\n if (renderer) str += renderer.name + \"
\";\n if (renderer) str += \"body:\" + this.getCreatedNumber(renderer) + \"
\";\n break;\n\n default:\n str += \"particles:\" + this.proton.getCount() + \"
\";\n str += \"pool:\" + this.proton.pool.getCount() + \"
\";\n str += \"total:\" + this.proton.pool.total;\n }\n\n this.container.innerHTML = str;\n }\n\n add(style, body) {\n if (!this.container) {\n this.type = 1;\n\n this.container = document.createElement('div');\n this.container.style.cssText = [\n 'position:absolute;bottom:0px;left:0;cursor:pointer;',\n 'opacity:0.9;z-index:10000;padding:10px;font-size:12px;',\n 'width:120px;height:50px;background-color:#002;color:#0ff;'\n ].join('');\n\n this.container.addEventListener('click', e => {\n this.type++;\n if (this.type > 4) this.type = 1;\n }, false);\n\n let bg, color;\n switch (style) {\n case 2:\n bg = \"#201\";\n color = \"#f08\";\n break;\n\n case 3:\n bg = \"#020\";\n color = \"#0f0\";\n break;\n\n default:\n bg = \"#002\";\n color = \"#0ff\";\n }\n\n this.container.style[\"background-color\"] = bg;\n this.container.style[\"color\"] = color;\n }\n\n if (!this.container.parentNode) {\n body = body || this.body || document.body;\n body.appendChild(this.container);\n }\n }\n\n getEmitter() {\n return this.proton.emitters[this.emitterIndex];\n }\n\n getRenderer() {\n return this.proton.renderers[this.rendererIndex];\n }\n\n concatArr(arr) {\n let result = '';\n if (!arr || !arr.length) return result;\n\n for (let i = 0; i < arr.length; i++) {\n result += (arr[i].name || '').substr(0, 1) + '.';\n }\n\n return result;\n }\n\n getCreatedNumber(renderer) {\n return renderer.pool.total || (renderer.cpool && renderer.cpool.total) || 0;\n }\n\n getEmitterPos(e) {\n return Math.round(e.p.x) + \",\" + Math.round(e.p.y);\n }\n}","/*\n * EventDispatcher\n * This code reference since http://createjs.com/.\n *\n **/\n\nexport default class EventDispatcher {\n\n constructor() {\n this._listeners = null;\n }\n\n static bind(TargetClass){\n TargetClass.prototype.dispatchEvent = EventDispatcher.prototype.dispatchEvent;\n TargetClass.prototype.hasEventListener = EventDispatcher.prototype.hasEventListener;\n TargetClass.prototype.addEventListener = EventDispatcher.prototype.addEventListener;\n TargetClass.prototype.removeEventListener = EventDispatcher.prototype.removeEventListener;\n TargetClass.prototype.removeAllEventListeners = EventDispatcher.prototype.removeAllEventListeners;\n }\n\n addEventListener(type, listener) {\n if (!this._listeners) {\n this._listeners = {};\n } else {\n this.removeEventListener(type, listener);\n }\n\n if (!this._listeners[type]) this._listeners[type] = [];\n this._listeners[type].push(listener);\n\n return listener;\n }\n\n removeEventListener(type, listener) {\n if (!this._listeners) return;\n if (!this._listeners[type]) return;\n\n const arr = this._listeners[type];\n const length = arr.length;\n\n for (let i = 0;i < length; i++) {\n if (arr[i] == listener) {\n if (length == 1) {\n delete (this._listeners[type]);\n }\n\n // allows for faster checks.\n else {\n arr.splice(i, 1);\n }\n\n break;\n }\n }\n }\n\n removeAllEventListeners(type) {\n if (!type)\n this._listeners = null;\n else if (this._listeners)\n delete (this._listeners[type]);\n }\n\n dispatchEvent(type, args) {\n let result = false;\n const listeners = this._listeners;\n\n if (type && listeners) {\n let arr = listeners[type];\n if (!arr) return result;\n\n //arr = arr.slice();\n // to avoid issues with items being removed or added during the dispatch\n\n let handler;\n let i = arr.length;\n while (i--) {\n handler = arr[i];\n result = result || handler(args);\n }\n\n }\n\n return !!result;\n }\n\n hasEventListener(type) {\n const listeners = this._listeners;\n return !!(listeners && listeners[type]);\n }\n\n}","import Util from '../utils/Util';\n\nexport default class Integration {\n\n\tconstructor(type) {\n\t\tthis.type = type;\n\t}\n\n\tcalculate(particles, time, damping) {\n\t\tthis.eulerIntegrate(particles, time, damping);\n\t}\n\n\t// Euler Integrate\n\teulerIntegrate(particle, time, damping) {\n\t\tif (!particle.sleep) {\n\t\t\tparticle.old.p.copy(particle.p);\n\t\t\tparticle.old.v.copy(particle.v);\n\n\t\t\tparticle.a.multiplyScalar(1 / particle.mass);\n\t\t\tparticle.v.add(particle.a.multiplyScalar(time));\n\t\t\tparticle.p.add(particle.old.v.multiplyScalar(time));\n\n\t\t\tif (damping) particle.v.multiplyScalar(damping);\n\n\t\t\tparticle.a.clear();\n\t\t}\n\t}\n}","import Pool from './Pool';\nimport Util from '../utils/Util';\nimport Stats from '../debug/Stats';\nimport EventDispatcher from '../events/EventDispatcher';\nimport Integration from '../math/Integration';\n\nexport default class Proton {\n\n static USE_CLOCK = false;\n\n //1:100\n static MEASURE = 100;\n static EULER = 'euler';\n static RK2 = 'runge-kutta2';\n\n static PARTICLE_CREATED = 'PARTICLE_CREATED';\n static PARTICLE_UPDATE = 'PARTICLE_UPDATE';\n static PARTICLE_SLEEP = 'PARTICLE_SLEEP';\n static PARTICLE_DEAD = 'PARTICLE_DEAD';\n static PROTON_UPDATE = 'PROTON_UPDATE';\n static PROTON_UPDATE_AFTER = 'PROTON_UPDATE_AFTER';\n static EMITTER_ADDED = 'EMITTER_ADDED';\n static EMITTER_REMOVED = 'EMITTER_REMOVED';\n\n static amendChangeTabsBug = true;\n static bindEmtterEvent = false;\n\n /**\n * The constructor to add emitters\n *\n * @constructor Proton\n *\n * @todo proParticleCount is not in use\n * @todo add more documentation of the single properties and parameters\n *\n * @param {Number} [proParticleCount] not in use?\n * @param {Number} [integrationType=Proton.EULER]\n *\n * @property {String} [integrationType=Proton.EULER]\n * @property {Array} emitters All added emitter\n * @property {Array} renderers All added renderer\n * @property {Number} time The active time\n * @property {Number} oldtime The old time\n */\n constructor(integrationType) {\n\n this.emitters = [];\n this.renderers = [];\n\n this.time = 0;\n this.oldTime = 0;\n this.elapsed = 0;\n\n this.stats = new Stats(this);\n this.pool = new Pool(80);\n\n this.integrationType = Util.initValue(integrationType, Proton.EULER);\n this.integrator = new Integration(this.integrationType);\n }\n\n /**\n * add a type of Renderer\n *\n * @method addRenderer\n * @memberof Proton\n * @instance\n *\n * @param {Renderer} render\n */\n addRenderer(render) {\n render.init(this);\n this.renderers.push(render);\n }\n\n /**\n * @name add a type of Renderer\n *\n * @method addRenderer\n * @param {Renderer} render\n */\n removeRenderer(render) {\n const index = this.renderers.indexOf(render);\n this.renderers.splice(index, 1);\n render.remove(this);\n }\n\n /**\n * add the Emitter\n *\n * @method addEmitter\n * @memberof Proton\n * @instance\n *\n * @param {Emitter} emitter\n */\n addEmitter(emitter) {\n this.emitters.push(emitter);\n emitter.parent = this;\n\n this.dispatchEvent(Proton.EMITTER_ADDED, emitter);\n }\n\n /**\n * Removes an Emitter\n *\n * @method removeEmitter\n * @memberof Proton\n * @instance\n *\n * @param {Proton.Emitter} emitter\n */\n removeEmitter(emitter) {\n const index = this.emitters.indexOf(emitter);\n this.emitters.splice(index, 1);\n emitter.parent = null;\n\n this.dispatchEvent(Proton.EMITTER_REMOVED, emitter);\n }\n\n /**\n * Updates all added emitters\n *\n * @method update\n * @memberof Proton\n * @instance\n */\n update() {\n this.dispatchEvent(Proton.PROTON_UPDATE);\n\n if (Proton.USE_CLOCK) {\n if (!this.oldTime) this.oldTime = (new Date()).getTime();\n\n let time = new Date().getTime();\n this.elapsed = (time - this.oldTime) / 1000;\n Proton.amendChangeTabsBug && this.amendChangeTabsBug();\n\n this.oldTime = time;\n } else {\n this.elapsed = 0.0167;\n }\n\n // emitter update\n if (this.elapsed > 0) this.emittersUpdate(this.elapsed);\n\n this.dispatchEvent(Proton.PROTON_UPDATE_AFTER);\n }\n\n emittersUpdate(elapsed) {\n let i = this.emitters.length;\n while (i--) this.emitters[i].update(elapsed);\n }\n\n /**\n * @todo add description\n *\n * @method amendChangeTabsBug\n * @memberof Proton\n * @instance\n */\n amendChangeTabsBug() {\n if (this.elapsed > .5) {\n this.oldTime = (new Date()).getTime();\n this.elapsed = 0;\n }\n }\n\n /**\n * Counts all particles from all emitters\n *\n * @method getCount\n * @memberof Proton\n * @instance\n */\n getCount() {\n let total = 0;\n let i = this.emitters.length;\n\n while (i--) total += this.emitters[i].particles.length;\n return total;\n }\n\n getAllParticles() {\n let particles = [];\n let i = this.emitters.length;\n\n while (i--) particles = particles.concat(this.emitters[i].particles);\n return particles;\n }\n\n /**\n * Destroys everything related to this Proton instance. This includes all emitters, and all properties\n *\n * @method destroy\n * @memberof Proton\n * @instance\n */\n destroy() {\n Util.destroy(this.renderers, this.getAllParticles());\n Util.destroy(this.emitters);\n\n this.time = 0;\n this.oldTime = 0;\n\n this.pool.destroy();\n }\n}\n\nEventDispatcher.bind(Proton);","import MathUtils from './MathUtils';\n\nexport default {\n\n easeLinear(value) {\n return value;\n },\n\n easeInQuad(value) {\n return Math.pow(value, 2);\n },\n\n easeOutQuad(value) {\n return -(Math.pow((value - 1), 2) - 1);\n },\n\n easeInOutQuad(value) {\n if ((value /= 0.5) < 1)\n return 0.5 * Math.pow(value, 2);\n\n return -0.5 * ((value -= 2) * value - 2);\n },\n\n easeInCubic(value) {\n return Math.pow(value, 3);\n },\n\n easeOutCubic(value) {\n return (Math.pow((value - 1), 3) + 1);\n },\n\n easeInOutCubic(value) {\n if ((value /= 0.5) < 1)\n return 0.5 * Math.pow(value, 3);\n\n return 0.5 * (Math.pow((value - 2), 3) + 2);\n },\n\n easeInQuart(value) {\n return Math.pow(value, 4);\n },\n\n easeOutQuart(value) {\n return -(Math.pow((value - 1), 4) - 1);\n },\n\n easeInOutQuart(value) {\n if ((value /= 0.5) < 1)\n return 0.5 * Math.pow(value, 4);\n\n return -0.5 * ((value -= 2) * Math.pow(value, 3) - 2);\n },\n\n easeInSine(value) {\n return -Math.cos(value * (MathUtils.PI_2)) + 1;\n },\n\n easeOutSine(value) {\n return Math.sin(value * (MathUtils.PI_2));\n },\n\n easeInOutSine(value) {\n return (-0.5 * (Math.cos(MathUtils.PI * value) - 1));\n },\n\n easeInExpo(value) {\n return (value === 0) ? 0 : Math.pow(2, 10 * (value - 1));\n },\n\n easeOutExpo(value) {\n return (value === 1) ? 1 : -Math.pow(2, -10 * value) + 1;\n },\n\n easeInOutExpo(value) {\n if (value === 0)\n return 0;\n\n if (value === 1)\n return 1;\n\n if ((value /= 0.5) < 1)\n return 0.5 * Math.pow(2, 10 * (value - 1));\n\n return 0.5 * (-Math.pow(2, -10 * --value) + 2);\n },\n\n easeInCirc(value) {\n return -(Math.sqrt(1 - (value * value)) - 1);\n },\n\n easeOutCirc(value) {\n return Math.sqrt(1 - Math.pow((value - 1), 2));\n },\n\n easeInOutCirc(value) {\n if ((value /= 0.5) < 1)\n return -0.5 * (Math.sqrt(1 - value * value) - 1);\n return 0.5 * (Math.sqrt(1 - (value -= 2) * value) + 1);\n },\n\n easeInBack(value) {\n let s = 1.70158;\n return (value) * value * ((s + 1) * value - s);\n },\n\n easeOutBack(value) {\n let s = 1.70158;\n return (value = value - 1) * value * ((s + 1) * value + s) + 1;\n },\n\n easeInOutBack(value) {\n let s = 1.70158;\n if ((value /= 0.5) < 1)\n return 0.5 * (value * value * (((s *= (1.525)) + 1) * value - s));\n return 0.5 * ((value -= 2) * value * (((s *= (1.525)) + 1) * value + s) + 2);\n },\n\n getEasing(ease) {\n if (typeof ease === 'function')\n return ease;\n else\n return this[ease] || this.easeLinear;\n }\n};","import Util from '../utils/Util';\nimport ease from '../math/ease';\nimport Vector2D from '../math/Vector2D';\nimport MathUtils from '../math/MathUtils';\n\nexport default class Particle {\n\n static ID = 0;\n\n /**\n * the Particle class\n *\n * @class Proton.Particle\n * @constructor\n * @param {Object} pObj the parameters object;\n * for example {life:3,dead:false}\n */\n constructor(pOBJ) {\n /**\n * The particle's id;\n * @property id\n * @type {string}\n */\n this.id = `particle_${Particle.ID++}`;\n this.reset('init');\n\n pOBJ && Util.setPrototypeByObject(this, pOBJ);\n }\n\n getDirection() {\n return Math.atan2(this.v.x, -this.v.y) * MathUtils.N180_PI;\n }\n\n reset(init) {\n this.life = Infinity;\n this.age = 0;\n\n //Energy loss\n this.energy = 1;\n this.dead = false;\n this.sleep = false;\n this.body = null;\n this.sprite = null;\n this.parent = null;\n\n this.mass = 1;\n this.radius = 10;\n this.alpha = 1;\n this.scale = 1;\n this.rotation = 0;\n this.color = null;\n\n this.easing = ease.easeLinear;\n\n if (init == 'init') {\n this.transform = {};\n this.p = new Vector2D();\n this.v = new Vector2D();\n this.a = new Vector2D();\n\n this.old = {\n p: new Vector2D(),\n v: new Vector2D(),\n a: new Vector2D()\n };\n\n this.behaviours = [];\n } else {\n Util.destroyObject(this.transform, 'rgb');\n\n this.p.set(0, 0);\n this.v.set(0, 0);\n this.a.set(0, 0);\n\n this.old.p.set(0, 0);\n this.old.v.set(0, 0);\n this.old.a.set(0, 0);\n\n this.removeAllBehaviours();\n }\n\n if (!this.transform.rgb) {\n this.transform.rgb = { r: 255, g: 255, b: 255 };\n } else {\n this.transform.rgb.r = 255;\n this.transform.rgb.g = 255;\n this.transform.rgb.b = 255;\n }\n\n return this;\n }\n\n update(time, index) {\n if (!this.sleep) {\n this.age += time;\n this.applyBehaviours(time, index);\n }\n\n if (this.age < this.life) {\n const scale = this.easing(this.age / this.life);\n this.energy = Math.max(1 - scale, 0);\n } else {\n this.destroy();\n }\n }\n\n applyBehaviours(time, index) {\n const length = this.behaviours.length;\n let i;\n\n for (i = 0; i < length; i++) {\n this.behaviours[i] && this.behaviours[i].applyBehaviour(this, time, index)\n }\n }\n\n addBehaviour(behaviour) {\n this.behaviours.push(behaviour);\n\n if (behaviour.hasOwnProperty('parents')) behaviour.parents.push(this);\n behaviour.initialize(this);\n }\n\n addBehaviours(behaviours) {\n const length = behaviours.length;\n let i;\n\n for (i = 0; i < length; i++) {\n this.addBehaviour(behaviours[i]);\n }\n }\n\n removeBehaviour(behaviour) {\n const index = this.behaviours.indexOf(behaviour);\n\n if (index > -1) {\n const behaviour = this.behaviours.splice(index, 1);\n behaviour.parents = null;\n }\n }\n\n removeAllBehaviours() {\n Util.destroyArray(this.behaviours);\n }\n\n /**\n * Destory this particle\n * @method destroy\n */\n destroy() {\n this.removeAllBehaviours();\n this.energy = 0;\n this.dead = true;\n this.parent = null;\n }\n\n}","export default {\n\n /**\n * @typedef {Object} rgbObject\n * @property {Number} r red value\n * @property {Number} g green value\n * @property {Number} b blue value\n */\n /**\n * converts a hex value to a rgb object\n *\n * @memberof Proton#Proton.Util\n * @method hexToRGB\n *\n * @param {String} h any hex value, e.g. #000000 or 000000 for black\n *\n * @return {rgbObject}\n */\n hexToRGB(h) {\n const hex16 = (h.charAt(0) == \"#\") ? h.substring(1, 7) : h;\n const r = parseInt(hex16.substring(0, 2), 16);\n const g = parseInt(hex16.substring(2, 4), 16);\n const b = parseInt(hex16.substring(4, 6), 16);\n\n return { r, g, b };\n },\n\n /**\n * converts a rgb value to a rgb string\n *\n * @memberof Proton#Proton.Util\n * @method rgbToHex\n *\n * @param {Object | Proton.hexToRGB} rgb a rgb object like in {@link Proton#Proton.}\n *\n * @return {String} rgb()\n */\n rgbToHex(rbg) {\n return `rgb(${rbg.r}, ${rbg.g}, ${rbg.b})`;\n },\n\n getHex16FromParticle(p) {\n return Number(p.transform.rgb.r) * 65536 + Number(p.transform.rgb.g) * 256 + Number(p.transform.rgb.b);\n }\n}","import Vector2D from './Vector2D';\n\nexport default class Polar2D {\n\n\tconstructor(r, tha) {\n\t\tthis.r = Math.abs(r) || 0;\n\t\tthis.tha = tha || 0;\n\t}\n\n\tset(r, tha) {\n\t\tthis.r = r;\n\t\tthis.tha = tha;\n\t\treturn this;\n\t}\n\n\tsetR(r) {\n\t\tthis.r = r;\n\t\treturn this;\n\t}\n\n\tsetTha(tha) {\n\t\tthis.tha = tha;\n\t\treturn this;\n\t}\n\n\tcopy(p) {\n\t\tthis.r = p.r;\n\t\tthis.tha = p.tha;\n\t\treturn this;\n\t}\n\n\ttoVector() {\n\t\treturn new Vector2D(this.getX(), this.getY());\n\t}\n\n\tgetX() {\n\t\treturn this.r * Math.sin(this.tha);\n\t}\n\n\tgetY() {\n\t\treturn -this.r * Math.cos(this.tha);\n\t}\n\n\tnormalize() {\n\t\tthis.r = 1;\n\t\treturn this;\n\t}\n\n\tequals(v) {\n\t\treturn ((v.r === this.r) && (v.tha === this.tha));\n\t}\n\n\tclear() {\n\t\tthis.r = 0.0;\n\t\tthis.tha = 0.0;\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\treturn new Polar2D(this.r, this.tha);\n\t}\n}","export default {\n\tcreate(mat3) {\n\t\tconst mat = new Float32Array(9);\n\t\tif (mat3) this.set(mat3, mat);\n\n\t\treturn mat;\n\t},\n\n\tset(mat1, mat2) {\n\t\tfor (let i = 0; i < 9; i++)\n\t\t\tmat2[i] = mat1[i];\n\n\t\treturn mat2;\n\t},\n\n\tmultiply(mat, mat2, mat3) {\n\t\tlet a00 = mat[0], a01 = mat[1], a02 = mat[2], a10 = mat[3], a11 = mat[4], a20 = mat[6], a21 = mat[7], b00 = mat2[0], b01 = mat2[1], b02 = mat2[2], b10 = mat2[3], b11 = mat2[4], b20 = mat2[6], b21 = mat2[7];\n\n\t\tmat3[0] = b00 * a00 + b01 * a10;\n\t\tmat3[1] = b00 * a01 + b01 * a11;\n\t\tmat3[2] = a02 * b02;\n\t\tmat3[3] = b10 * a00 + b11 * a10;\n\t\tmat3[4] = b10 * a01 + b11 * a11;\n\t\tmat3[6] = b20 * a00 + b21 * a10 + a20;\n\t\tmat3[7] = b20 * a01 + b21 * a11 + a21;\n\n\t\treturn mat3;\n\t},\n\n\tinverse(mat, mat3) {\n\t\tlet a00 = mat[0], a01 = mat[1], a10 = mat[3], a11 = mat[4], a20 = mat[6], a21 = mat[7], b01 = a11, b11 = -a10, b21 = a21 * a10 - a11 * a20, d = a00 * b01 + a01 * b11, id;\n\n\t\tid = 1 / d;\n\t\tmat3[0] = b01 * id;\n\t\tmat3[1] = (-a01) * id;\n\t\tmat3[3] = b11 * id;\n\t\tmat3[4] = a00 * id;\n\t\tmat3[6] = b21 * id;\n\t\tmat3[7] = (-a21 * a00 + a01 * a20) * id;\n\n\t\treturn mat3;\n\t},\n\n\tmultiplyVec2(m, vec, mat3) {\n\t\tlet x = vec[0], y = vec[1];\n\n\t\tmat3[0] = x * m[0] + y * m[3] + m[6];\n\t\tmat3[1] = x * m[1] + y * m[4] + m[7];\n\n\t\treturn mat3;\n\t}\n}","import Span from './Span';\nimport Util from '../utils/Util';\nimport MathUtils from './MathUtils';\n\nexport default class ArraySpan extends Span {\n\n constructor(color) {\n super();\n this._arr = Util.isArray(color) ? color : [color];\n }\n\n getValue() {\n const color = this._arr[Math.floor(this._arr.length * Math.random())];\n return color === 'random' || color === 'Random' ? MathUtils.randomColor() : color;\n }\n\n /**\n * Make sure that the color is an instance of Proton.ArraySpan, if not it makes a new instance\n *\n * @method setSpanValue\n * @memberof Proton#Proton.Color\n * @instance\n *\n * @param {Proton.Particle} particle\n * @param {Number} the integrate time 1/ms\n * @param {Int} the particle index\n */\n static createArraySpan(arr) {\n if (!arr) return null;\n\n if (arr instanceof ArraySpan)\n return arr;\n else\n return new ArraySpan(arr);\n }\n\n}","export default class Rectangle {\n\n\tconstructor(x, y, w, h) {\n\t\tthis.x = x;\n\t\tthis.y = y;\n\n\t\tthis.width = w;\n\t\tthis.height = h;\n\n\t\tthis.bottom = this.y + this.height;\n\t\tthis.right = this.x + this.width;\n\t}\n\n\tcontains(x, y) {\n\t\tif (x <= this.right && x >= this.x && y <= this.bottom && y >= this.y)\n\t\t\treturn true;\n\t\telse\n\t\t\treturn false;\n\t}\n}\n","import Util from '../utils/Util';\n\nexport default class Rate {\n\n\t/**\n\t * The number of particles per second emission (a [particle]/b [s]);\n\t * @namespace\n\t * @memberof! Proton#\n\t * @constructor\n\t * @alias Rate\n\t *\n\t * @param {Array | Number | Span} numpan the number of each emission;\n\t * @param {Array | Number | Span} timepan the time of each emission;\n\t * for example: new Rate(new Span(10, 20), new Span(.1, .25));\n\t */\n\tconstructor(numpan, timepan) {\n\t\tthis.numPan = Util.setSpanValue(Util.initValue(numpan, 1));\n\t\tthis.timePan = Util.setSpanValue(Util.initValue(timepan, 1));\n\n\t\tthis.startTime = 0;\n\t\tthis.nextTime = 0;\n\t\tthis.init();\n\t}\n\n\tinit() {\n\t\tthis.startTime = 0;\n\t\tthis.nextTime = this.timePan.getValue();\n\t}\n\n\tgetValue(time) {\n\t\tthis.startTime += time;\n\n\t\tif (this.startTime >= this.nextTime) {\n\t\t\tthis.startTime = 0;\n\t\t\tthis.nextTime = this.timePan.getValue();\n\n\t\t\tif (this.numPan.b == 1) {\n\t\t\t\tif (this.numPan.getValue(false) > 0.5)\n\t\t\t\t\treturn 1;\n\t\t\t\telse\n\t\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn this.numPan.getValue(true);\n\t\t\t}\n\t\t}\n\n\t\treturn 0;\n\t}\n}","export default class Initialize {\n\t\n\treset() {\n\t}\n\n\tinit(emitter, particle) {\n\t\tif (particle) {\n\t\t\tthis.initialize(particle);\n\t\t} else {\n\t\t\tthis.initialize(emitter);\n\t\t}\n\t};\n\n\t///sub class init\n\tinitialize(target) {\n\t};\n}","import Util from '../utils/Util';\nimport Initialize from './Initialize';\n\nexport default class Life extends Initialize {\n\n\tconstructor(a, b, c) {\n\t\tsuper();\n\n\t\tthis.lifePan = Util.setSpanValue(a, b, c);\n\t\tthis.name = 'Life';\n\t}\n\n\tinitialize(target) {\n\t\tif (this.lifePan.a == Infinity)\n\t\t\ttarget.life = Infinity;\n\t\telse\n\t\t\ttarget.life = this.lifePan.getValue();\n\t}\n}\n","import Vector2D from '../math/Vector2D';\n\nexport default class Zone {\n\tconstructor() {\n\t\tthis.vector = new Vector2D(0, 0);\n\t\tthis.random = 0;\n\t\tthis.crossType = \"dead\";\n\t\tthis.alert = true;\n\t}\n\n\tgetPosition() {\n\t}\n\n\tcrossing(particle) {\n\t}\n}","import Zone from './Zone';\n\nexport default class PointZone extends Zone {\n\n\tconstructor(x, y) {\n\t\tsuper();\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t}\n\n\tgetPosition() {\n\t\tthis.vector.x = this.x;\n\t\tthis.vector.y = this.y;\n\n\t\treturn this.vector;\n\t}\n\n\tcrossing(particle) {\n\t\t\n\t\tif (this.alert) {\n\t\t\talert('Sorry PointZone does not support crossing method');\n\t\t\tthis.alert = false;\n\t\t}\n\t}\n}","import Util from '../utils/Util';\nimport PointZone from '../zone/PointZone';\nimport Initialize from './Initialize';\n\nexport default class Position extends Initialize {\n\n\tconstructor(zone) {\n\t\tsuper();\n\t\tthis.zone = Util.initValue(zone, new PointZone());\n\n\t\tthis.name = 'Position';\n\t}\n\n\treset(zone) {\n\t\tthis.zone = Util.initValue(zone, new PointZone());\n\t}\n\n\tinitialize(target) {\n\t\tthis.zone.getPosition();\n\n\t\ttarget.p.x = this.zone.vector.x;\n\t\ttarget.p.y = this.zone.vector.y;\n\t};\n\n}\n","import Proton from '../core/Proton';\nimport Util from '../utils/Util';\nimport Polar2D from '../math/Polar2D';\nimport MathUtils from '../math/MathUtils';\nimport Initialize from './Initialize';\n\nexport default class Velocity extends Initialize {\n\n constructor(rpan, thapan, type) {\n super();\n\n this.rPan = Util.setSpanValue(rpan);\n this.thaPan = Util.setSpanValue(thapan);\n this.type = Util.initValue(type, 'vector');\n\n this.name = 'Velocity';\n }\n\n reset(rpan, thapan, type) {\n this.rPan = Util.setSpanValue(rpan);\n this.thaPan = Util.setSpanValue(thapan);\n this.type = Util.initValue(type, 'vector');\n };\n\n normalizeVelocity(vr) {\n return vr * Proton.MEASURE;\n }\n\n initialize(target) {\n if (this.type == 'p' || this.type == 'P' || this.type == 'polar') {\n const polar2d = new Polar2D(this.normalizeVelocity(this.rPan.getValue()), this.thaPan.getValue() * MathUtils.PI_180);\n\n target.v.x = polar2d.getX();\n target.v.y = polar2d.getY();\n } else {\n target.v.x = this.normalizeVelocity(this.rPan.getValue());\n target.v.y = this.normalizeVelocity(this.thaPan.getValue());\n }\n };\n}","import Util from '../utils/Util';\nimport Initialize from './Initialize';\n\nexport default class Mass extends Initialize {\n\n\tconstructor(a, b, c) {\n\t\tsuper();\n\t\tthis.massPan = Util.setSpanValue(a, b, c);\n\t\tthis.name = 'Mass';\n\t}\n\n\tinitialize(target) {\n\t\ttarget.mass = this.massPan.getValue();\n\t}\n}","import Util from '../utils/Util';\nimport Initialize from './Initialize';\n\nexport default class Radius extends Initialize {\n\n\tconstructor(a, b, c) {\n\t\tsuper();\n\t\tthis.radius = Util.setSpanValue(a, b, c);\n\n\t\tthis.name = 'Radius';\n\t}\n\n\treset(a, b, c) {\n\t\tthis.radius = Util.setSpanValue(a, b, c);\n\t};\n\n\tinitialize(particle) {\n\t\tparticle.radius = this.radius.getValue();\n\t\tparticle.transform.oldRadius = particle.radius;\n\t};\n}","import Util from '../utils/Util';\nimport ArraySpan from '../math/ArraySpan';\nimport Initialize from './Initialize';\n\nexport default class Body extends Initialize {\n\n constructor(image, w, h) {\n super();\n\n this.image = this.setSpanValue(image);\n this.w = Util.initValue(w, 20);\n this.h = Util.initValue(h, this.w);\n this.name = 'Body';\n }\n\n initialize(particle) {\n const imagetarget = this.image.getValue();\n\n if (typeof(imagetarget) == 'string') {\n particle.body = { width: this.w, height: this.h, src: imagetarget , isInner: true, inner: true };\n } else {\n particle.body = imagetarget;\n }\n };\n\n setSpanValue(color) {\n return color instanceof ArraySpan ? color : new ArraySpan(color);\n }\n}","import Proton from '../core/Proton';\nimport Util from '../utils/Util';\nimport ease from '../math/ease';\n\nexport default class Behaviour {\n static id = 0;\n\n /**\n * The Behaviour class is the base for the other Behaviour\n *\n * @memberof! -\n * @interface\n * @alias Proton.Behaviour\n *\n * @param {Number} life \tthe behaviours life\n * @param {String} easing \tThe behaviour's decaying trend, for example ease.easeOutQuart\n *\n * @property {String} id \t\tThe behaviours id\n * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n * @property {Number} age=0 \tHow long the particle should be 'alife'\n * @property {Number} energy=1\n * @property {Boolean} dead=false The particle is dead at first\n * @property {Array} parents \tThe behaviour's parents array\n * @property {String} name \tThe behaviour name\n */\n constructor(life, easing) {\n\n this.life = Util.initValue(life, Infinity);\n this.easing = ease.getEasing(easing);\n\n this.age = 0;\n this.energy = 1;\n this.dead = false;\n this.parents = [];\n\n this.id = `Behaviour_${Behaviour.id++}`;\n this.name = 'Behaviour';\n }\n\n /**\n * Reset this behaviour's parameters\n *\n * @method reset\n * @memberof Proton.Behaviour\n * @instance\n *\n * @param {Number} [life=Infinity] \t\tthis behaviour's life\n * @param {String} [easing=easeLinear] \tthis behaviour's easing\n */\n reset(life, easing) {\n this.life = Util.initValue(life, Infinity);\n this.easing = ease.getEasing(easing);\n }\n\n /**\n * Normalize a force by 1:100;\n *\n * @method normalizeForce\n * @memberof Proton.Behaviour\n * @instance\n *\n * @param {Proton.Vector2D} force \n */\n normalizeForce(force) {\n return force.multiplyScalar(Proton.MEASURE);\n }\n\n /**\n * Normalize a value by 1:100;\n *\n * @method normalizeValue\n * @memberof Proton.Behaviour\n * @instance\n *\n * @param {Number} value\n */\n normalizeValue(value) {\n return value * Proton.MEASURE;\n }\n\n /**\n * Initialize the behaviour's parameters for all particles\n *\n * @method initialize\n * @memberof Proton.Behaviour\n * @instance\n *\n * @param {Proton.Particle} particle\n */\n initialize(particle) {}\n\n /**\n * Apply this behaviour for all particles every time\n *\n * @method applyBehaviour\n * @memberof Proton.Behaviour\n * @instance\n *\n * @param {Proton.Particle} particle\n * @param {Number} \t\t\ttime the integrate time 1/ms\n * @param {Int} \t\t\tindex the particle index\n */\n calculate(particle, time, index) {\n this.age += time;\n\n if (this.age >= this.life || this.dead) {\n this.energy = 0;\n this.dead = true;\n this.destroy();\n } else {\n const scale = this.easing(particle.age / particle.life);\n this.energy = Math.max(1 - scale, 0);\n }\n }\n\n /**\n * Destory this behaviour\n *\n * @method destroy\n * @memberof Proton.Behaviour\n * @instance\n */\n destroy() {\n let i = this.parents.length;\n while (i--) {\n this.parents[i].removeBehaviour(this);\n }\n\n this.parents.length = 0;\n }\n}","import Util from '../utils/Util';\nimport Vector2D from '../math/Vector2D';\nimport Behaviour from './Behaviour';\n\nexport default class Force extends Behaviour {\n\n\t/**\n\t * @memberof! Proton#\n\t * @augments Proton.Behaviour\n\t * @constructor\n\t * @alias Proton.Force\n\t *\n\t * @param {Number} fx\n\t * @param {Number} fy\n\t * @param {Number} [life=Infinity] \t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(fx, fy, life, easing) {\n\t\tsuper(life, easing);\n\n\t\tthis.force = this.normalizeForce(new Vector2D(fx, fy));\n\t\tthis.name = \"Force\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#Proton.Force\n\t * @instance\n\t *\n\t * @param {Number} fx\n\t * @param {Number} fy\n\t * @param {Number} [life=Infinity] \t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t */\n\treset(fx, fy, life, easing) {\n\t\tthis.force = this.normalizeForce(new Vector2D(fx, fy));\n\n\t\tlife && super.reset(life, easing);\n\t}\n\n\t/**\n\t * Apply this behaviour for all particles every time\n\t *\n\t * @method applyBehaviour\n\t * @memberof Proton#Proton.Force\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle\n\t * @param {Number} the integrate time 1/ms\n\t * @param {Int} the particle index\n\t */\n\tapplyBehaviour(particle, time, index) {\n\t\tthis.calculate(particle, time, index);\n\t\tparticle.a.add(this.force);\n\t}\n}","import Util from '../utils/Util';\nimport Vector2D from '../math/Vector2D';\nimport Behaviour from './Behaviour';\n\nexport default class Attraction extends Behaviour {\n\n\t/**\n\t * This behaviour let the particles follow one specific Proton.Vector2D\n\t *\n\t * @memberof! Proton#\n\t * @augments Proton.Behaviour\n\t * @constructor\n\t * @alias Proton.Attraction\n\t *\n\t * @todo add description for 'force' and 'radius'\n\t *\n\t * @param {Proton.Vector2D} targetPosition the attraction point coordinates\n\t * @param {Number} [force=100]\n\t * @param {Number} [radius=1000]\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {Proton.Vector2D} targetPosition\n\t * @property {Number} radius\n\t * @property {Number} force\n\t * @property {Number} radiusSq\n\t * @property {Proton.Vector2D} attractionForce\n\t * @property {Number} lengthSq\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(targetPosition, force, radius, life, easing) {\n\t\tsuper(life, easing);\n\n\t\tthis.targetPosition = Util.initValue(targetPosition, new Vector2D);\n\t\tthis.radius = Util.initValue(radius, 1000);\n\t\tthis.force = Util.initValue(this.normalizeValue(force), 100);\n\n\t\tthis.radiusSq = this.radius * this.radius\n\t\tthis.attractionForce = new Vector2D();\n\t\tthis.lengthSq = 0;\n\n\t\tthis.name = \"Attraction\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#Proton.Attraction\n\t * @instance\n\t *\n\t * @todo add description for 'force' and 'radius'\n\t *\n\t * @param {Proton.Vector2D} targetPosition the attraction point coordinates\n\t * @param {Number} [force=100]\n\t * @param {Number} [radius=1000]\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t */\n\treset(targetPosition, force, radius, life, easing) {\n\t\tthis.targetPosition = Util.initValue(targetPosition, new Vector2D);\n\t\tthis.radius = Util.initValue(radius, 1000);\n\t\tthis.force = Util.initValue(this.normalizeValue(force), 100);\n\n\t\tthis.radiusSq = this.radius * this.radius\n\t\tthis.attractionForce = new Vector2D();\n\t\tthis.lengthSq = 0;\n\n\t\tlife && super.reset(life, easing);\n\t}\n\n\t/**\n\t * Apply this behaviour for all particles every time\n\t *\n\t * @memberof Proton#Proton.Attraction\n\t * @method applyBehaviour\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle\n\t * @param {Number} \t\t\ttime the integrate time 1/ms\n\t * @param {Int} \t\t\tindex the particle index\n\t */\n\tapplyBehaviour(particle, time, index) {\n\t\tthis.calculate(particle, time, index);\n\n\t\tthis.attractionForce.copy(this.targetPosition);\n\t\tthis.attractionForce.sub(particle.p);\n\t\tthis.lengthSq = this.attractionForce.lengthSq();\n\n\t\tif (this.lengthSq > 0.000004 && this.lengthSq < this.radiusSq) {\n\t\t\tthis.attractionForce.normalize();\n\t\t\tthis.attractionForce.multiplyScalar(1 - this.lengthSq / this.radiusSq);\n\t\t\tthis.attractionForce.multiplyScalar(this.force);\n\n\t\t\tparticle.a.add(this.attractionForce);\n\t\t}\n\t}\n}\n\n","import Util from '../utils/Util';\nimport Vector2D from '../math/Vector2D';\nimport MathUtils from '../math/MathUtils';\nimport Behaviour from './Behaviour';\n\nexport default class RandomDrift extends Behaviour {\n\n\t/**\n\t * @memberof! Proton#\n\t * @augments Behaviour\n\t * @constructor\n\t * @alias RandomDrift\n\t *\n\t * @param {Number} driftX \t\t\t\tX value of the new Vector2D\n\t * @param {Number} driftY \t\t\t\tY value of the new Vector2D\n\t * @param {Number} delay \t\t\t\tHow much delay the drift should have\n\t * @param {Number} [life=Infinity] \t\tthis behaviour's life\n\t * @param {String} [easing=easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {Number} time The time of the drift\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(driftX, driftY, delay, life, easing) {\n\t\tsuper(life, easing);\n\n\t\tthis.reset(driftX, driftY, delay);\n\t\tthis.time = 0;\n\t\tthis.name = \"RandomDrift\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#RandomDrift\n\t * @instance\n\t *\n\t * @param {Number} driftX \t\t\t\tX value of the new Vector2D\n\t * @param {Number} driftY \t\t\t\tY value of the new Vector2D\n\t * @param {Number} delay \t\t\t\tHow much delay the drift should have\n\t * @param {Number} [life=Infinity] \t\tthis behaviour's life\n\t * @param {String} [easing=easeLinear] \tthis behaviour's easing\n\t */\n\treset(driftX, driftY, delay, life, easing) {\n\t\tthis.panFoce = new Vector2D(driftX, driftY);\n\t\tthis.panFoce = this.normalizeForce(this.panFoce);\n\t\tthis.delay = delay;\n\n\t\tlife && super.reset(life, easing);\n\t}\n\n\t/**\n\t * Apply this behaviour for all particles every time\n\t *\n\t * @method applyBehaviour\n\t * @memberof Proton#RandomDrift\n\t * @instance\n\t *\n\t * @param {Particle} particle\n\t * @param {Number} \t\t\ttime the integrate time 1/ms\n\t * @param {Int} \t\t\tindex the particle index\n\t */\n\tapplyBehaviour(particle, time, index) {\n\t\tthis.calculate(particle, time, index);\n\t\tthis.time += time;\n\n\t\tif (this.time >= this.delay) {\n\t\t\tparticle.a.addXY(MathUtils.randomAToB(-this.panFoce.x, this.panFoce.x), MathUtils.randomAToB(-this.panFoce.y, this.panFoce.y));\n\t\t\tthis.time = 0;\n\t\t};\n\t}\n}\n","import Util from '../utils/Util';\nimport Vector2D from '../math/Vector2D';\nimport Force from './Force';\n\nexport default class Gravity extends Force {\n\n\t/**\n\t * @memberof! Proton#\n\t * @augments Proton#Proton.Force\n\t * @constructor\n\t * @alias Proton.Gravity\n\t *\n\t * @param {Number} g \t\t\t\t\t\t\tGravity\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(g, life, easing) {\n\t\tsuper(0, g, life, easing);\n\t\tthis.name = \"Gravity\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#Proton.Gravity\n\t * @instance\n\t *\n\t * @param {Number} g \t\t\t\t\t\t\tGravity\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t */\n\treset(g, life, easing) {\n\t\tsuper.reset(0, g, life, easing);\n\t}\n}","import Util from '../utils/Util';\nimport Vector2D from '../math/Vector2D';\nimport Behaviour from './Behaviour';\n\n//can use Collision(emitter,true,function(){}) or Collision();\nexport default class Collision extends Behaviour {\n\n\t/**\n\t * The callback after collision\n\t *\n\t * @callback Callback\n\t *\n\t * @param {Proton.Particle} particle\n\t * @param {Proton.Paritcle} otherParticle\n\t */\n\t/**\n\t * @memberof! Proton#\n\t * @augments Proton.Behaviour\n\t * @constructor\n\t * @alias Proton.Collision\n\t *\n\t * @todo add description to mass\n\t *\n\t * @param {Proton.Emitter} \t[emitter=null] \t\tthe attraction point coordinates\n\t * @param {Boolean} \t\t[mass=true]\t\t\t\n\t * @param {Callback}\t \t[callback=null]\t\tthe callback after the collision\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(emitter, mass, callback, life, easing) {\n\t\tsuper(life, easing);\n\n\t\tthis.reset(emitter, mass, callback);\n\t\tthis.name = \"Collision\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @memberof Proton#Proton.Collision\n\t * @method reset\n\t * @instance\n\t *\n\t * @todo add description to mass\n\t *\n\t * @param {Proton.Emitter} \t[emitter=null] \t\tthe attraction point coordinates\n\t * @param {Boolean} \t\t[mass=true]\t\t\t\n\t * @param {Callback}\t \t[callback=null]\t\tthe callback after the collision\n\t * @param {Number} \t\t\t[life=Infinity] \tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t */\n\treset(emitter, mass, callback, life, easing) {\n\t\tthis.emitter = Util.initValue(emitter, null);\n\t\tthis.mass = Util.initValue(mass, true);\n\t\tthis.callback = Util.initValue(callback, null);\n\n\t\tthis.collisionPool = [];\n\t\tthis.delta = new Vector2D();\n\n\t\tlife && super.reset(life, easing);\n\t}\n\n\t/**\n\t * Apply this behaviour for all particles every time\n\t *\n\t * @memberof Proton#Proton.Collision\n\t * @method applyBehaviour\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle\n\t * @param {Number} \t\t\ttime the integrate time 1/ms\n\t * @param {Int} \t\t\tindex the particle index\n\t */\n\tapplyBehaviour(particle, time, index) {\n\t\tconst newPool = this.emitter ? this.emitter.particles.slice(index) : this.pool.slice(index);\n\t\tconst length = newPool.length;\n\n\t\tlet otherParticle;\n\t\tlet lengthSq;\n\t\tlet overlap;\n\t\tlet totalMass;\n\t\tlet averageMass1, averageMass2;\n\t\tlet i;\n\n\t\tfor (i = 0; i < length; i++) {\n\t\t\totherParticle = newPool[i];\n\n\t\t\tif (otherParticle !== particle) {\n\t\t\t\tthis.delta.copy(otherParticle.p);\n\t\t\t\tthis.delta.sub(particle.p);\n\n\t\t\t\tlengthSq = this.delta.lengthSq();\n\t\t\t\tconst distance = particle.radius + otherParticle.radius;\n\n\t\t\t\tif (lengthSq <= distance * distance) {\n\t\t\t\t\toverlap = distance - Math.sqrt(lengthSq);\n\t\t\t\t\toverlap += 0.5;\n\n\t\t\t\t\ttotalMass = particle.mass + otherParticle.mass;\n\t\t\t\t\taverageMass1 = this.mass ? otherParticle.mass / totalMass : 0.5;\n\t\t\t\t\taverageMass2 = this.mass ? particle.mass / totalMass : 0.5;\n\t\t\t\t\t\n\t\t\t\t\tparticle.p.add(this.delta.clone().normalize().multiplyScalar(overlap * -averageMass1));\n\t\t\t\t\totherParticle.p.add(this.delta.normalize().multiplyScalar(overlap * averageMass2));\n\n\t\t\t\t\tthis.callback && this.callback(particle, otherParticle);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n","import Util from '../utils/Util';\nimport Behaviour from './Behaviour';\n\nexport default class CrossZone extends Behaviour {\n\n /**\n * Defines what happens if the particles come to the end of the specified zone\n *\n * @memberof! Proton#\n * @augments Proton.Behaviour\n * @constructor\n * @alias Proton.CrossZone\n *\n * @param {Proton.Zone} zone \t\t\t\t\t\tcan be any Proton.Zone - e.g. Proton.RectZone()\n * @param {String} \t\t[crossType=dead] \t\t\twhat happens if the particles pass the zone - allowed strings: dead | bound | cross\n * @param {Number} \t\t[life=Infinity] \t\t\tthis behaviour's life\n * @param {String} \t\t[easing=ease.easeLinear] \tthis behaviour's easing\n *\n * @property {String} name The Behaviour name\n */\n constructor(zone, crossType, life, easing) {\n super(life, easing);\n\n this.reset(zone, crossType);\n this.name = \"CrossZone\";\n }\n\n /**\n * Reset this behaviour's parameters\n *\n * @method reset\n * @memberof Proton#Proton.CrossZone\n * @instance\n *\n * @param {Proton.Zone} zone \t\t\t\tcan be any Proton.Zone - e.g. Proton.RectZone()\n * @param {String} \t\t[crossType=dead] \twhat happens if the particles pass the zone - allowed strings: dead | bound | cross\n * @param {Number} \t\t[life=Infinity] \tthis behaviour's life\n * @param {String} \t\t[easing=easeLinear]\tthis behaviour's easing\n */\n reset(zone, crossType, life, easing) {\n this.zone = zone;\n this.zone.crossType = Util.initValue(crossType, \"dead\");\n\n life && super.reset(life, easing);\n }\n\n /**\n * Apply this behaviour for all particles every time\n *\n * @method applyBehaviour\n * @memberof Proton#Proton.CrossZone\n * @instance\n *\n * @param {Proton.Particle} particle\n * @param {Number} the integrate time 1/ms\n * @param {Int} the particle index\n */\n applyBehaviour(particle, time, index) {\n this.calculate(particle, time, index);\n this.zone.crossing(particle);\n };\n}","import Util from '../utils/Util';\nimport Behaviour from './Behaviour';\n\nexport default class Alpha extends Behaviour {\n\n\t/**\n\t * @memberof! Proton#\n\t * @augments Proton.Behaviour\n\t * @constructor\n\t * @alias Proton.Alpha\n\t *\n\t * @todo add description for 'a' and 'b'\n\t *\n\t * @param {Number} a\n\t * @param {String} b\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(a, b, life, easing) {\n\t\tsuper(life, easing);\n\n\t\tthis.reset(a, b);\n\t\tthis.name = \"Alpha\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#Proton.Alpha\n\t * @instance\n\t *\n\t * @todo add description for 'a' and 'b'\n\t *\n\t * @param {Number} a\n\t * @param {String} b\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t */\n\treset(a, b, life, easing) {\n\t\tthis.same = b === null || b === undefined ? true : false;\n\t\tthis.a = Util.setSpanValue(Util.initValue(a, 1));\n\t\tthis.b = Util.setSpanValue(b);\n\n\t\tlife && super.reset(life, easing);\n\t}\n\t\n\t/**\n\t * Sets the new alpha value of the particle\n\t *\n\t * @method initialize\n\t * @memberof Proton#Proton.Alpha\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle A single Proton generated particle\n\t */\n\tinitialize(particle) {\n\t\tparticle.transform.alphaA = this.a.getValue();\n\n\t\tif (this.same)\n\t\t\tparticle.transform.alphaB = particle.transform.alphaA;\n\t\telse\n\t\t\tparticle.transform.alphaB = this.b.getValue();\n\t}\n\n\t/**\n\t * @method applyBehaviour\n\t * @memberof Proton#Proton.Alpha\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle\n\t * @param {Number} \t\t\ttime the integrate time 1/ms\n\t * @param {Int} \t\t\tindex the particle index\n \t */\n\tapplyBehaviour(particle, time, index) {\n\t\tthis.calculate(particle, time, index);\n\t\t\n\t\tparticle.alpha = particle.transform.alphaB + (particle.transform.alphaA - particle.transform.alphaB) * this.energy;\n\t\tif (particle.alpha < 0.001) particle.alpha = 0;\n\t}\n}\n","import Util from '../utils/Util';\nimport Behaviour from './Behaviour';\n\nexport default class Scale extends Behaviour {\n\n\t/**\n\t * @memberof! Proton#\n\t * @augments Proton.Behaviour\n\t * @constructor\n\t * @alias Proton.Scale\n\t *\n\t * @todo add description for 'a' and 'b'\n\t *\n\t * @param {Number} a\n\t * @param {String} b\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(a, b, life, easing) {\n\t\tsuper(life, easing);\n\n\t\tthis.reset(a, b);\n\t\tthis.name = \"Scale\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#Proton.Scale\n\t * @instance\n\t *\n\t * @param {Number} a\n\t * @param {String} b\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t */\n\treset(a, b, life, easing) {\n\t\tthis.same = b === null || b === undefined ? true : false;\n\t\tthis.a = Util.setSpanValue(Util.initValue(a, 1));\n\t\tthis.b = Util.setSpanValue(b);\n\n\t\tlife && super.reset(life, easing);\n\t}\n\n\t/**\n\t * Initialize the behaviour's parameters for all particles\n\t *\n\t * @method initialize\n\t * @memberof Proton#Proton.Scale\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle\n\t */\n\tinitialize(particle) {\n\t\tparticle.transform.scaleA = this.a.getValue();\n\t\tparticle.transform.oldRadius = particle.radius;\n\t\tparticle.transform.scaleB = this.same ? particle.transform.scaleA : this.b.getValue();\n\t};\n\n\t/**\n\t * Apply this behaviour for all particles every time\n\t *\n\t * @method applyBehaviour\n\t * @memberof Proton#Proton.Scale\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle\n\t * @param {Number} \t\t\ttime the integrate time 1/ms\n\t * @param {Int} \t\t\tindex the particle index\n\t */\n\tapplyBehaviour(particle, time, index) {\n\t\tthis.calculate(particle, time, index);\n\t\tparticle.scale = particle.transform.scaleB + (particle.transform.scaleA - particle.transform.scaleB) * this.energy;\n\n\t\tif (particle.scale < 0.0001) particle.scale = 0;\n\t\tparticle.radius = particle.transform.oldRadius * particle.scale;\n\t}\n}","import Util from '../utils/Util';\nimport Behaviour from './Behaviour';\n\nexport default class Rotate extends Behaviour {\n\n\t/**\n\t * @memberof! Proton#\n\t * @augments Proton.Behaviour\n\t * @constructor\n\t * @alias Proton.Rotate\n\t *\n\t * @todo add description for 'a', 'b' and 'style'\n\t *\n\t * @param {Number} a\n\t * @param {String} b\n\t * @param {String} [style=to]\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(a, b, style, life, easing) {\n\t\tsuper(life, easing);\n\n\t\tthis.reset(a, b, style);\n\t\tthis.name = \"Rotate\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#Proton.Rotate\n\t * @instance\n\t *\n\t * @todo add description for 'a', 'b' and 'style'\n\t *\n\t * @param {Number} a\n\t * @param {String} b\n\t * @param {String} [style=to]\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t */\n\treset(a, b, style, life, easing) {\n\t\tthis.same = b === null || b === undefined ? true : false;\n\n\t\tthis.a = Util.setSpanValue(Util.initValue(a, \"Velocity\"));\n\t\tthis.b = Util.setSpanValue(Util.initValue(b, 0));\n\t\tthis.style = Util.initValue(style, 'to');\n\n\t\tlife && super.reset(life, easing);\n\t}\n\n\t/**\n\t * Initialize the behaviour's parameters for all particles\n\t *\n\t * @method initialize\n\t * @memberof Proton#Proton.Rotate\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle\n\t */\n\tinitialize(particle) {\n\t\tparticle.rotation = this.a.getValue();\n\t\tparticle.transform.rotationA = this.a.getValue();\n\n\t\tif (!this.same) particle.transform.rotationB = this.b.getValue();\n\t};\n\n\t/**\n\t * Apply this behaviour for all particles every time\n\t *\n\t * @method applyBehaviour\n\t * @memberof Proton#Proton.Rotate\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle\n\t * @param {Number} \t\t\ttime the integrate time 1/ms\n\t * @param {Int} \t\t\tindex the particle index\n\t */\n\tapplyBehaviour(particle, time, index) {\n\t\tthis.calculate(particle, time, index);\n\n\t\tif (!this.same) {\n\t\t\tif (this.style == 'to' || this.style == 'TO' || this.style == '_') {\n\t\t\t\tparticle.rotation += particle.transform.rotationB + (particle.transform.rotationA - particle.transform.rotationB) * this.energy\n\t\t\t} else {\n\t\t\t\tparticle.rotation += particle.transform.rotationB;\n\t\t\t}\n\t\t} else if (this.a.a == \"V\" || this.a.a == \"Velocity\" || this.a.a == \"v\") {\n\t\t\t//beta...\n\t\t\tparticle.rotation = particle.getDirection();\n\t\t}\n\t}\n\n}","import Util from '../utils/Util';\nimport ColorUtil from '../utils/ColorUtil';\nimport ArraySpan from '../math/ArraySpan';\nimport Behaviour from './Behaviour';\n\nexport default class Color extends Behaviour {\n\n /**\n * @memberof! Proton#\n * @augments Proton.Behaviour\n * @constructor\n * @alias Proton.Color\n *\n * @param {Proton.ArraySpan | String} a the string should be a hex e.g. #000000 for black\n * @param {Proton.ArraySpan | String} b the string should be a hex e.g. #000000 for black\n * @param {Number} [life=Infinity] \tthis behaviour's life\n * @param {String} [easing=easeLinear] \tthis behaviour's easing\n *\n * @property {String} name The Behaviour name\n */\n constructor(a, b, life, easing) {\n super(life, easing);\n\n this.reset(a, b);\n this.name = \"Color\";\n }\n\n /**\n * Reset this behaviour's parameters\n *\n * @method reset\n * @memberof Proton#Proton.Color\n * @instance\n *\n * @param {Proton.ArraySpan | String} a the string should be a hex e.g. #000000 for black\n * @param {Proton.ArraySpan | String} b the string should be a hex e.g. #000000 for black\n * @param {Number} [life=Infinity] \tthis behaviour's life\n * @param {String} [easing=easeLinear] \tthis behaviour's easing\n */\n reset(a, b, life, easing) {\n this.a = ArraySpan.createArraySpan(a);\n this.b = ArraySpan.createArraySpan(b);\n\n life && super.reset(life, easing);\n }\n\n /**\n * Initialize the behaviour's parameters for all particles\n *\n * @method initialize\n * @memberof Proton#Proton.Color\n * @instance\n *\n * @param {Proton.Particle} particle\n */\n initialize(particle) {\n particle.color = this.a.getValue();\n particle.transform.colorA = ColorUtil.hexToRGB(particle.color);\n\n if (this.b)\n particle.transform.colorB = ColorUtil.hexToRGB(this.b.getValue());\n };\n\n /**\n * Apply this behaviour for all particles every time\n *\n * @method applyBehaviour\n * @memberof Proton#Proton.Color\n * @instance\n *\n * @param {Proton.Particle} particle\n * @param {Number} the integrate time 1/ms\n * @param {Int} the particle index\n */\n applyBehaviour(particle, time, index) {\n if (this.b) {\n this.calculate(particle, time, index);\n\n particle.transform.rgb.r = particle.transform.colorB.r + (particle.transform.colorA.r - particle.transform.colorB.r) * this.energy;\n particle.transform.rgb.g = particle.transform.colorB.g + (particle.transform.colorA.g - particle.transform.colorB.g) * this.energy;\n particle.transform.rgb.b = particle.transform.colorB.b + (particle.transform.colorA.b - particle.transform.colorB.b) * this.energy;\n\n particle.transform.rgb.r = Math.floor(particle.transform.rgb.r);\n particle.transform.rgb.g = Math.floor(particle.transform.rgb.g);\n particle.transform.rgb.b = Math.floor(particle.transform.rgb.b);\n\n } else {\n particle.transform.rgb.r = particle.transform.colorA.r;\n particle.transform.rgb.g = particle.transform.colorA.g;\n particle.transform.rgb.b = particle.transform.colorA.b;\n }\n };\n\n}","import Util from '../utils/Util';\nimport Attraction from './Attraction';\n\nexport default class Repulsion extends Attraction {\n\n\t/**\n\t * The oppisite of Proton.Attraction - turns the force\n\t *\n\t * @memberof! Proton#\n\t * @augments Proton#Proton.Attraction\n\t * @constructor\n\t * @alias Proton.Repulsion\n\t *\n\t * @todo add description for 'force' and 'radius'\n\t *\n\t * @param {Proton.Vector2D} targetPosition the attraction point coordinates\n\t * @param {Number} [force=100]\n\t * @param {Number} [radius=1000]\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {Number} force\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(targetPosition, force, radius, life, easing) {\n\t\tsuper(targetPosition, force, radius, life, easing);\n\n\t\tthis.force *= -1;\n\t\tthis.name = \"Repulsion\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#Proton.Repulsion\n\t * @instance\n\t *\n\t * @todo add description for 'force' and 'radius'\n\t *\n\t * @param {Proton.Vector2D} targetPosition the attraction point coordinates\n\t * @param {Number} [force=100]\n\t * @param {Number} [radius=1000]\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t */\n\treset(targetPosition, force, radius, life, easing) {\n\t\tsuper.reset(targetPosition, force, radius, life, easing);\n\t\tthis.force *= -1;\n\t}\n}\n","import Util from '../utils/Util';\nimport Vector2D from '../math/Vector2D';\nimport Behaviour from './Behaviour';\n\nexport default class GravityWell extends Behaviour {\n\n\t/**\n\t * @memberof! Proton#\n\t * @augments Behaviour\n\t * @constructor\n\t * @alias GravityWell\n\t *\n\t * @param {Vector2D} [centerPoint=new Vector2D] The point in the center\n\t * @param {Number} [force=100]\t\t\t\t\tThe force\t\n\t * @param {Number} [life=Infinity]\t\t\t\tthis behaviour's life\n\t * @param {String} [easing=easeLinear]\tthis behaviour's easing\n\t *\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(centerPoint, force, life, easing) {\n\t\tsuper(life, easing);\n\n\t\tthis.distanceVec = new Vector2D();\n\t\tthis.centerPoint = Util.initValue(centerPoint, new Vector2D);\n\t\tthis.force = Util.initValue(this.normalizeValue(force), 100);\n\n\t\tthis.name = \"GravityWell\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#GravityWell\n\t * @instance\n\t *\n\t * @param {Vector2D} [centerPoint=new Vector2D] The point in the center\n\t * @param {Number} [force=100]\t\t\t\t\tThe force\t\n\t * @param {Number} [life=Infinity]\t\t\t\tthis behaviour's life\n\t * @param {String} [easing=easeLinear]\tthis behaviour's easing\n\t */\n\treset(centerPoint, force, life, easing) {\n\t\tthis.distanceVec = new Vector2D();\n\t\tthis.centerPoint = Util.initValue(centerPoint, new Vector2D);\n\t\tthis.force = Util.initValue(this.normalizeValue(force), 100);\n\t\t\n\t\tlife && super.reset(life, easing);\n\t};\n\n\t/**\n\t * @inheritdoc\n\t */\n\tinitialize(particle) {\n\t};\n\n\t/**\n\t * Apply this behaviour for all particles every time\n\t *\n\t * @method applyBehaviour\n\t * @memberof Proton#GravityWell\n\t * @instance\n\t *\n\t * @param {Particle} particle\n\t * @param {Number} the integrate time 1/ms\n\t * @param {Int} the particle index\n\t */\n\tapplyBehaviour(particle, time, index) {\n\t\tthis.distanceVec.set(this.centerPoint.x - particle.p.x, this.centerPoint.y - particle.p.y);\n\t\tconst distanceSq = this.distanceVec.lengthSq();\n\n\t\tif (distanceSq != 0) {\n\t\t\tconst distance = this.distanceVec.length();\n\t\t\tconst factor = (this.force * time) / (distanceSq * distance);\n\n\t\t\tparticle.v.x += factor * this.distanceVec.x;\n\t\t\tparticle.v.y += factor * this.distanceVec.y;\n\t\t}\n\t}\n}","import Util from '../utils/Util';\nimport MathUtils from '../math/MathUtils';\n\nexport default {\n\n\tinitialize(emitter, particle, initializes) {\n\t\tconst length = initializes.length;\n\t\tlet i;\n\n\t\tfor (i = 0; i < length; i++) {\n\t\t\tif (initializes[i] instanceof Proton.Initialize)\n\t\t\t\tinitializes[i].init(emitter, particle);\n\t\t\telse\n\t\t\t\tthis.init(emitter, particle, initializes[i]);\n\t\t}\n\n\t\tthis.bindEmitter(emitter, particle);\n\t},\n\n\t//////////////////////init//////////////////////\n\tinit(emitter, particle, initialize) {\n\t\tUtil.setPrototypeByObject(particle, initialize);\n\t\tUtil.setVector2DByObject(particle, initialize);\n\t},\n\t\n\tbindEmitter(emitter, particle) {\n\t\tif (emitter.bindEmitter) {\n\t\t\tparticle.p.add(emitter.p);\n\t\t\tparticle.v.add(emitter.v);\n\t\t\tparticle.a.add(emitter.a);\n\n\t\t\tparticle.v.rotate(MathUtils.degreeTransform(emitter.rotation));\n\t\t}\n\t}\n}\n","import Util from '../utils/Util';\nimport Particle from '../core/Particle';\nimport EventDispatcher from '../events/EventDispatcher';\n\nimport Rate from '../initialize/Rate';\nimport InitializeUtil from '../initialize/InitializeUtil';\n\nexport default class Emitter extends Particle {\n\n\tstatic ID = 0;\n\n\t/**\n\t * You can use this emit particles.\n\t *\n\t * It will dispatch follow events:\n\t * PARTICLE_CREATED\n\t * PARTICLE_UPDATA\n\t * PARTICLE_DEAD\n\t *\n\t * @class Emitter\n\t * @constructor\n\t * @param {Object} pObj the parameters object;\n\t * for example {damping:0.01,bindEmitter:false}\n\t */\n\tconstructor(pObj) {\n\t\tsuper(pObj);\n\n\t\tthis.initializes = [];\n\t\tthis.particles = [];\n\t\tthis.behaviours = [];\n\n\t\tthis.emitSpeed = 0;\n\t\tthis.currentEmitTime = 0;\n\t\tthis.totalEmitTimes = -1;\n\n\t\t/**\n\t\t * The friction coefficient for all particle emit by This;\n\t\t * @property damping\n\t\t * @type {Number}\n\t\t * @default 0.006\n\t\t */\n\t\tthis.damping = .006;\n\n\t\t/**\n\t\t * If bindEmitter the particles can bind this emitter's property;\n\t\t * @property bindEmitter\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.bindEmitter = true;\n\n\t\t/**\n\t\t * The number of particles per second emit (a [particle]/b [s]);\n\t\t * @property rate\n\t\t * @type {Rate}\n\t\t * @default Rate(1, .1)\n\t\t */\n\t\tthis.rate = new Rate(1, .1);\n\n\t\tthis.id = `emitter_${Emitter.ID++}`;\n\t\tthis.name = 'Emitter';\n\t}\n\n\t/**\n\t * start emit particle\n\t * @method emit\n\t * @param {Number} currentEmitTime begin emit time;\n\t * @param {String} life the life of this emitter\n\t */\n\temit(totalEmitTimes, life) {\n\t\tthis.stoped = false;\n\t\tthis.currentEmitTime = 0;\n\t\tthis.totalEmitTimes = Util.initValue(totalEmitTimes, Infinity);\n\n\t\tif (life == true || life == 'life' || life == 'destroy') {\n\t\t\tthis.life = totalEmitTimes == 'once' ? 1 : this.totalEmitTimes;\n\t\t} else if (!isNaN(life)) {\n\t\t\tthis.life = life;\n\t\t}\n\n\t\tthis.rate.init();\n\t}\n\n\t/**\n\t * stop emiting\n\t * @method stop\n\t */\n\tstop() {\n\t\tthis.totalEmitTimes = -1;\n\t\tthis.currentEmitTime = 0;\n\t\tthis.stoped = true;\n\t}\n\n\t/**\n\t * remove current all particles\n\t * @method removeAllParticles\n\t */\n\tremoveAllParticles() {\n\t\tlet i = this.particles.length;\n\t\twhile (i--) this.particles[i].dead = true;\n\t}\n\n\t/**\n\t * add initialize to this emitter\n\t * @method addSelfInitialize\n\t */\n\taddSelfInitialize(pObj) {\n\t\tif (pObj['init']) {\n\t\t\tpObj.init(this);\n\t\t} else {\n\t\t\tthis.initAll();\n\t\t}\n\t}\n\n\t/**\n\t * add the Initialize to particles;\n\t * \n\t * you can use initializes array:for example emitter.addInitialize(initialize1,initialize2,initialize3);\n\t * @method addInitialize\n\t * @param {Initialize} initialize like this new Radius(1, 12)\n\t */\n\taddInitialize(...rest) {\n\t\tlet i = rest.length;\n\t\twhile (i--)\n\t\t\tthis.initializes.push(rest[i]);\n\t}\n\n\t/**\n\t * remove the Initialize\n\t * @method removeInitialize\n\t * @param {Initialize} initialize a initialize\n\t */\n\tremoveInitialize(initializer) {\n\t\tconst index = this.initializes.indexOf(initializer);\n\t\tif (index > -1) this.initializes.splice(index, 1);\n\t}\n\n\t/**\n\t * remove all Initializes\n\t * @method removeInitializers\n\t */\n\tremoveAllInitializers() {\n\t\tUtil.destroyArray(this.initializes);\n\t}\n\n\t/**\n\t * add the Behaviour to particles;\n\t * \n\t * you can use Behaviours array:emitter.addBehaviour(Behaviour1,Behaviour2,Behaviour3);\n\t * @method addBehaviour\n\t * @param {Behaviour} behaviour like this new Color('random')\n\t */\n\taddBehaviour(...rest) {\n\t\tlet i = arguments.length;\n\t\twhile (i--) {\n\t\t\tlet behaviour = rest[i];\n\t\t\tthis.behaviours.push(behaviour);\n\t\t\tif (behaviour.parents) behaviour.parents.push(this);\n\t\t}\n\t}\n\n\t/**\n\t * remove the Behaviour\n\t * @method removeBehaviour\n\t * @param {Behaviour} behaviour a behaviour\n\t */\n\tremoveBehaviour(behaviour) {\n\t\tlet index = this.behaviours.indexOf(behaviour);\n\t\tthis.behaviours.splice(index, 1);\n\n\t\tif (behaviour.parents) {\n\t\t\tindex = behaviour.parents.indexOf(behaviour);\n\t\t\tbehaviour.parents.splice(index, 1);\n\t\t}\n\n\t\treturn index;\n\t}\n\n\t/**\n\t * remove all behaviours\n\t * @method removeAllBehaviours\n\t */\n\tremoveAllBehaviours() {\n\t\tUtil.destroyArray(this.behaviours);\n\t}\n\n\t// emitter update \n\tupdate(time) {\n\t\tthis.age += time;\n\t\tif (this.age >= this.life || this.dead) this.destroy();\n\n\t\tthis.emitting(time);\n\t\tthis.integrate(time);\n\t}\n\n\tintegrate(time) {\n\t\tif (!this.parent) return;\n\n\t\tconst damping = 1 - this.damping;\n\t\tthis.parent.integrator.calculate(this, time, damping);\n\n\t\tconst length = this.particles.length;\n\t\tlet i, particle;\n\n\t\tfor (i = length - 1; i >= 0; i--) {\n\t\t\tparticle = this.particles[i];\n\n\t\t\t// particle update\n\t\t\tparticle.update(time, i);\n\t\t\tthis.parent.integrator.calculate(particle, time, damping);\n\t\t\tthis.dispatch(\"PARTICLE_UPDATE\", particle);\n\n\t\t\t// check dead\n\t\t\tif (particle.dead) {\n\t\t\t\tthis.dispatch(\"PARTICLE_DEAD\", particle);\n\n\t\t\t\tthis.parent.pool.expire(particle);\n\t\t\t\tthis.particles.splice(i, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\tdispatch(event, target) {\n\t\tthis.parent && this.parent.dispatchEvent(event, target);\n\t\tProton.bindEmtterEvent && this.dispatchEvent(event, target);\n\t}\n\n\temitting(time) {\n\t\tif (this.totalEmitTimes == 'once') {\n\t\t\tlet i;\n\t\t\tconst length = this.rate.getValue(99999);\n\n\t\t\tif (length > 0) this.emitSpeed = length;\n\t\t\tfor (i = 0; i < length; i++) this.createParticle();\n\t\t\tthis.totalEmitTimes = 'none';\n\t\t}\n\n\t\telse {\n\t\t\tthis.currentEmitTime += time;\n\n\t\t\tif (this.currentEmitTime < this.totalEmitTimes) {\n\t\t\t\tconst length = this.rate.getValue(time)\n\t\t\t\tlet i;\n\n\t\t\t\tif (length > 0) this.emitSpeed = length;\n\t\t\t\tfor (i = 0; i < length; i++) this.createParticle();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * create single particle;\n\t * \n\t * can use emit({x:10},new Gravity(10),{'particleUpdate',fun}) or emit([{x:10},new Initialize],new Gravity(10),{'particleUpdate',fun})\n\t * @method removeAllParticles\n\t */\n\tcreateParticle(initialize, behaviour) {\n\t\tconst particle = this.parent.pool.get(Particle);\n\t\tthis.setupParticle(particle, initialize, behaviour);\n\t\tthis.dispatch(\"PARTICLE_CREATED\", particle);\n\n\t\treturn particle;\n\t}\n\n\tsetupParticle(particle, initialize, behaviour) {\n\t\tlet initializes = this.initializes;\n\t\tlet behaviours = this.behaviours;\n\n\t\tif (initialize) {\n\t\t\tinitializes = Util.isArray(initialize) ? initialize : [initialize];\n\t\t}\n\n\t\tif (behaviour) {\n\t\t\tbehaviour = Util.isArray(behaviour) ? behaviour : [behaviour];\n\t\t}\n\n\t\tparticle.reset();\n\t\tInitializeUtil.initialize(this, particle, initializes);\n\t\tparticle.addBehaviours(behaviours);\n\t\tparticle.parent = this;\n\n\t\tthis.particles.push(particle);\n\t}\n\n\tremove(){\n\t\tthis.stop();\n\t\tUtil.destroy(this.particles);\n\t}\n\n\t/**\n\t * Destory this Emitter\n\t * @method destroy\n\t */\n\tdestroy(slow) {\n\t\tthis.dead = true;\n\t\tthis.remove();\n\t\tthis.removeAllInitializers();\n\t\tthis.removeAllBehaviours();\n\t\tthis.parent && this.parent.removeEmitter(this);\n\t}\n\n}\n\nEventDispatcher.bind(Emitter);","import Util from '../utils/Util';\nimport Emitter from './Emitter';\n\nexport default class BehaviourEmitter extends Emitter {\n\n\t/**\n\t * The BehaviourEmitter class inherits from Proton.Emitter\n\t *\n\t * use the BehaviourEmitter you can add behaviours to self;\n\t * @class Proton.BehaviourEmitter\n\t * @constructor\n\t * @param {Object} pObj the parameters object;\n\t */\n\tconstructor(pObj) {\n\t\tsuper(pObj);\n\n\t\tthis.selfBehaviours = [];\n\t};\n\t\n\t/**\n\t * add the Behaviour to emitter;\n\t *\n\t * you can use Behaviours array:emitter.addSelfBehaviour(Behaviour1,Behaviour2,Behaviour3);\n\t * @method addSelfBehaviour\n\t * @param {Proton.Behaviour} behaviour like this new Proton.Color('random')\n\t */\n\taddSelfBehaviour(...rest) {\n\t\tconst length = rest.length;\n\t\tlet i;\n\n\t\tfor (i = 0; i < length; i++) {\n\t\t\tthis.selfBehaviours.push(rest[i]);\n\t\t}\n\t};\n\n\t/**\n\t * remove the Behaviour for self\n\t * @method removeSelfBehaviour\n\t * @param {Proton.Behaviour} behaviour a behaviour\n\t */\n\tremoveSelfBehaviour(behaviour) {\n\t\tconst index = this.selfBehaviours.indexOf(behaviour);\n\t\tif (index > -1) this.selfBehaviours.splice(index, 1);\n\t};\n\n\tupdate(time) {\n\t\tsuper.update(time);\n\n\t\tif (!this.sleep) {\n\t\t\tconst length = this.selfBehaviours.length;\n\t\t\tlet i;\n\n\t\t\tfor (i = 0; i < length; i++) {\n\t\t\t\tthis.selfBehaviours[i].applyBehaviour(this, time, i);\n\t\t\t}\n\t\t}\n\t}\n}","import Util from '../utils/Util';\nimport Emitter from './Emitter';\n\nexport default class FollowEmitter extends Emitter {\n\n\t/**\n\t * The FollowEmitter class inherits from Proton.Emitter\n\t *\n\t * use the FollowEmitter will emit particle when mousemoving\n\t *\n\t * @class Proton.FollowEmitter\n\t * @constructor\n\t * @param {Element} mouseTarget mouseevent's target;\n\t * @param {Number} ease the easing of following speed;\n\t * @default 0.7\n\t * @param {Object} pObj the parameters object;\n\t */\n\tconstructor(mouseTarget, ease, pObj) {\n\t\tsuper(pObj);\n\n\t\tthis.mouseTarget = Util.initValue(mouseTarget, window);\n\t\tthis.ease = Util.initValue(ease, .7);\n\n\t\tthis._allowEmitting = false;\n\t\tthis.initEventHandler();\n\t};\n\n\tinitEventHandler() {\n\t\tthis.mousemoveHandler = e => this.mousemove.call(this, e);\n\t\tthis.mousedownHandler = e => this.mousedown.call(this, e);\n\t\tthis.mouseupHandler = e => this.mouseup.call(this, e);\n\n\t\tthis.mouseTarget.addEventListener('mousemove', this.mousemoveHandler, false);\n\t}\n\n\t/**\n\t * start emit particle\n\t * @method emit\n\t */\n\temit() {\n\t\tthis._allowEmitting = true;\n\t}\n\n\t/**\n\t * stop emiting\n\t * @method stop\n\t */\n\tstop() {\n\t\tthis._allowEmitting = false;\n\t}\n\n\tmousemove(e) {\n\t\tif (e.layerX || e.layerX == 0) {\n\t\t\tthis.p.x += (e.layerX - this.p.x) * this.ease;\n\t\t\tthis.p.y += (e.layerY - this.p.y) * this.ease;\n\t\t} else if (e.offsetX || e.offsetX == 0) {\n\t\t\tthis.p.x += (e.offsetX - this.p.x) * this.ease;\n\t\t\tthis.p.y += (e.offsetY - this.p.y) * this.ease;\n\t\t}\n\n\t\tif (this._allowEmitting) super.emit('once');\n\t};\n\n\t/**\n\t * Destory this Emitter\n\t * @method destroy\n\t */\n\tdestroy() {\n\t\tsuper.destroy();\n\t\tthis.mouseTarget.removeEventListener('mousemove', this.mousemoveHandler, false);\n\t}\n\n}\n","import Pool from '../core/Pool';\nimport Util from '../utils/Util';\n\nexport default class BaseRenderer {\n\n constructor(element, stroke) {\n this.element = element;\n this.stroke = stroke;\n\n this.initHandler();\n\n this.circleConf = { isCircle: true };\n this.pool = new Pool();\n this.name = 'BaseRenderer';\n }\n\n setStroke(color, thinkness) {\n color = Util.initValue(color, '#000000');\n thinkness = Util.initValue(thinkness, 1);\n\n this.stroke = { color, thinkness };\n }\n\n initHandler() {\n this._protonUpdateHandler = () => { this.onProtonUpdate.call(this) };\n this._protonUpdateAfterHandler = () => { this.onProtonUpdateAfter.call(this) };\n this._emitterAddedHandler = (emitter) => { this.onEmitterAdded.call(this, emitter) };\n this._emitterRemovedHandler = (emitter) => { this.onEmitterRemoved.call(this, emitter) };\n this._particleCreatedHandler = (particle) => { this.onParticleCreated.call(this, particle) };\n this._particleUpdateHandler = (particle) => { this.onParticleUpdate.call(this, particle) };\n this._particleDeadHandler = (particle) => { this.onParticleDead.call(this, particle) };\n }\n\n init(proton) {\n this.parent = proton;\n\n proton.addEventListener(Proton.PROTON_UPDATE, this._protonUpdateHandler);\n proton.addEventListener(Proton.PROTON_UPDATE_AFTER, this._protonUpdateAfterHandler);\n\n proton.addEventListener(Proton.EMITTER_ADDED, this._emitterAddedHandler);\n proton.addEventListener(Proton.EMITTER_REMOVED, this._emitterRemovedHandler);\n\n proton.addEventListener(Proton.PARTICLE_CREATED, this._particleCreatedHandler);\n proton.addEventListener(Proton.PARTICLE_UPDATE, this._particleUpdateHandler);\n proton.addEventListener(Proton.PARTICLE_DEAD, this._particleDeadHandler);\n }\n\n resize(width, height) {}\n\n remove(proton) {\n this.parent.removeEventListener(Proton.PROTON_UPDATE, this._protonUpdateHandler);\n this.parent.removeEventListener(Proton.PROTON_UPDATE_AFTER, this._protonUpdateAfterHandler);\n\n this.parent.removeEventListener(Proton.EMITTER_ADDED, this._emitterAddedHandler);\n this.parent.removeEventListener(Proton.EMITTER_REMOVED, this._emitterRemovedHandler);\n\n this.parent.removeEventListener(Proton.PARTICLE_CREATED, this._particleCreatedHandler);\n this.parent.removeEventListener(Proton.PARTICLE_UPDATE, this._particleUpdateHandler);\n this.parent.removeEventListener(Proton.PARTICLE_DEAD, this._particleDeadHandler);\n\n this.parent = null;\n }\n\n destroy(){\n this.remove();\n }\n \n onProtonUpdate() {}\n onProtonUpdateAfter() {}\n\n onEmitterAdded(emitter) {}\n onEmitterRemoved(emitter) {}\n\n onParticleCreated(particle) {}\n onParticleUpdate(particle) {}\n onParticleDead(particle) {}\n}","import Util from '../utils/Util';\nimport ImgUtil from '../utils/ImgUtil';\nimport ColorUtil from '../utils/ColorUtil';\nimport MathUtils from '../math/MathUtils';\nimport BaseRenderer from './BaseRenderer';\n\nexport default class CanvasRenderer extends BaseRenderer {\n\n constructor(element) {\n super(element);\n\n this.stroke = null;\n this.context = this.element.getContext(\"2d\");\n this.bufferCache = {};\n\n this.name = 'CanvasRenderer';\n }\n\n resize(width, height) {\n this.element.width = width;\n this.element.height = height;\n }\n\n onProtonUpdate() {\n this.context.clearRect(0, 0, this.element.width, this.element.height);\n }\n\n onParticleCreated(particle) {\n if (particle.body)\n ImgUtil.getImgFromCache(particle.body, this.addImg2Body, particle);\n else\n particle.color = particle.color || '#ff0000';\n }\n\n onParticleUpdate(particle) {\n if (particle.body) {\n if (particle.body instanceof Image) this.drawImage(particle);\n } else {\n this.drawCircle(particle);\n }\n }\n\n onParticleDead(particle) {\n particle.body = null;\n }\n\n\n // private \n addImg2Body(img, particle) {\n particle.body = img;\n }\n\n // private drawCircle --\n drawImage(particle) {\n const w = particle.body.width * particle.scale | 0;\n const h = particle.body.height * particle.scale | 0;\n const x = particle.p.x - w / 2;\n const y = particle.p.y - h / 2;\n\n if (!!particle.color) {\n if (!particle.transform[\"buffer\"]) particle.transform.buffer = this.createBuffer(particle.body);\n\n const bufferContext = particle.transform.buffer.getContext('2d');\n bufferContext.clearRect(0, 0, particle.transform.buffer.width, particle.transform.buffer.height);\n bufferContext.globalAlpha = particle.alpha;\n bufferContext.drawImage(particle.body, 0, 0);\n\n bufferContext.globalCompositeOperation = \"source-atop\";\n bufferContext.fillStyle = ColorUtil.rgbToHex(particle.transform.rgb);\n bufferContext.fillRect(0, 0, particle.transform.buffer.width, particle.transform.buffer.height);\n bufferContext.globalCompositeOperation = \"source-over\";\n bufferContext.globalAlpha = 1;\n\n this.context.drawImage(particle.transform.buffer, 0, 0, particle.transform.buffer.width, particle.transform.buffer.height, x, y, w, h);\n } else {\n this.context.save();\n\n this.context.globalAlpha = particle.alpha;\n this.context.translate(particle.p.x, particle.p.y);\n this.context.rotate(MathUtils.degreeTransform(particle.rotation));\n this.context.translate(-particle.p.x, -particle.p.y);\n this.context.drawImage(particle.body, 0, 0, particle.body.width, particle.body.height, x, y, w, h);\n\n this.context.globalAlpha = 1;\n this.context.restore();\n }\n }\n\n // private drawCircle --\n drawCircle(particle) {\n if (particle.transform[\"rgb\"])\n this.context.fillStyle = 'rgba(' + particle.transform.rgb.r + ',' + particle.transform.rgb.g + ',' + particle.transform.rgb.b + ',' + particle.alpha + ')';\n else\n this.context.fillStyle = particle.color;\n\n // draw circle\n this.context.beginPath();\n this.context.arc(particle.p.x, particle.p.y, particle.radius, 0, Math.PI * 2, true);\n\n if (this.stroke) {\n this.context.strokeStyle = this.stroke.color;\n this.context.lineWidth = this.stroke.thinkness;\n this.context.stroke();\n }\n\n this.context.closePath();\n this.context.fill();\n }\n\n // private createBuffer --\n createBuffer(image) {\n if (image instanceof Image) {\n const size = image.width + '_' + image.height;\n let canvas = this.bufferCache[size];\n\n if (!canvas) {\n canvas = document.createElement('canvas');\n canvas.width = image.width;\n canvas.height = image.height;\n this.bufferCache[size] = canvas;\n }\n\n return canvas;\n }\n }\n}","import Util from '../utils/Util';\nimport DomUtil from '../utils/DomUtil';\nimport ImgUtil from '../utils/ImgUtil';\nimport MathUtils from '../math/MathUtils';\nimport BaseRenderer from './BaseRenderer';\n\nexport default class DomRenderer extends BaseRenderer {\n\n constructor(element) {\n super(element);\n\n this.stroke = null;\n this.pool.create = (body, particle) => this.createBody(body, particle);\n this.addImg2Body = this.addImg2Body.bind(this);\n\n this.transform3d = false;\n\n this.name = 'DomRenderer';\n }\n\n onParticleCreated(particle) {\n if (particle.body) {\n ImgUtil.getImgFromCache(particle.body, this.addImg2Body, particle);\n } else {\n particle.body = this.pool.get(this.circleConf, particle);\n this.element.appendChild(particle.body);\n }\n }\n\n onParticleUpdate(particle) {\n if (this.bodyReady(particle)) {\n if (this.transform3d)\n DomUtil.transform3d(particle.body, particle.p.x, particle.p.y, particle.scale, particle.rotation);\n else\n DomUtil.transform(particle.body, particle.p.x, particle.p.y, particle.scale, particle.rotation);\n\n particle.body.style.opacity = particle.alpha;\n if (particle.body.isCircle) {\n particle.body.style.backgroundColor = particle.color || '#ff0000';\n }\n }\n }\n\n onParticleDead(particle) {\n if (this.bodyReady(particle)) {\n this.element.removeChild(particle.body);\n this.pool.expire(particle.body);\n particle.body = null;\n }\n }\n\n bodyReady(particle) {\n return typeof particle.body === 'object' && particle.body && !particle.body.isInner;\n }\n\n // private \n addImg2Body(img, particle) {\n if (particle.dead) return;\n particle.body = this.pool.get(img, particle);\n DomUtil.resize(particle.body, img.width, img.height);\n\n this.element.appendChild(particle.body);\n }\n\n createBody(body, particle) {\n if (body.isCircle)\n return this.createCircle(particle);\n else\n return this.createSprite(body, particle);\n }\n\n // private --\n createCircle(particle) {\n const dom = DomUtil.createDiv(`${particle.id}_dom`, 2 * particle.radius, 2 * particle.radius);\n dom.style.borderRadius = `${particle.radius}px`;\n\n if (this.stroke) {\n dom.style.borderColor = this.stroke.color;\n dom.style.borderWidth = `${this.stroke.thinkness}px`;\n }\n dom.isCircle = true;\n\n return dom;\n }\n\n createSprite(body, particle) {\n const url = typeof body === 'string' ? body : body.src;\n const dom = DomUtil.createDiv(`${particle.id}_dom`, body.width, body.height);\n dom.style.backgroundImage = `url(${url})`;\n\n return dom;\n }\n\n}","import Util from '../utils/Util';\nimport BaseRenderer from './BaseRenderer';\n\nexport default class EaselRenderer extends BaseRenderer {\n\n constructor(element, stroke) {\n super(element);\n\n this.stroke = stroke;\n this.name = 'EaselRenderer';\n }\n\n onParticleCreated(particle) {\n if (particle.body) {\n this.createSprite(particle);\n } else {\n this.createCircle(particle);\n }\n\n this.element.addChild(particle.body);\n }\n\n onParticleUpdate(particle) {\n if (particle.body) {\n particle.body.x = particle.p.x;\n particle.body.y = particle.p.y;\n\n particle.body.alpha = particle.alpha;\n particle.body.scaleX = particle.body.scaleY = particle.scale;\n particle.body.rotation = particle.rotation;\n }\n }\n\n onParticleDead(particle) {\n if (particle.body) {\n particle.body.parent && particle.body.parent.removeChild(particle.body);\n this.pool.expire(particle.body);\n particle.body = null;\n }\n\n if (particle.graphics) this.pool.expire(particle.graphics);\n }\n\n // private\n createSprite(particle) {\n particle.body = this.pool.get(particle.body);\n\n if (particle.body.parent) return;\n if (particle.body['image']) {\n particle.body.regX = particle.body.image.width / 2;\n particle.body.regY = particle.body.image.height / 2;\n }\n }\n\n createCircle(particle) {\n const graphics = this.pool.get(createjs.Graphics);\n\n if (this.stroke) {\n if (this.stroke instanceof String)\n graphics.beginStroke(this.stroke);\n else\n graphics.beginStroke('#000000');\n }\n graphics.beginFill(particle.color || '#ff0000').drawCircle(0, 0, particle.radius);\n\n const shape = this.pool.get(createjs.Shape, [graphics]);\n\n particle.body = shape;\n particle.graphics = graphics;\n }\n\n}","import Util from '../utils/Util';\nimport Rectangle from '../math/Rectangle';\nimport BaseRenderer from './BaseRenderer';\n\nexport default class PixelRenderer extends BaseRenderer {\n\n constructor(element, rectangle) {\n super(element);\n\n this.context = this.element.getContext('2d');\n this.imageData = null;\n this.rectangle = null;\n this.rectangle = rectangle;\n this.createImageData(rectangle);\n\n this.name = 'PixelRenderer';\n }\n\n resize(width, height) {\n this.element.width = width;\n this.element.height = height;\n }\n\n createImageData(rectangle) {\n this.rectangle = rectangle ? rectangle : new Rectangle(0, 0, this.element.width, this.element.height);\n this.imageData = this.context.createImageData(this.rectangle.width, this.rectangle.height);\n this.context.putImageData(this.imageData, this.rectangle.x, this.rectangle.y);\n }\n\n onProtonUpdate() {\n this.context.clearRect(this.rectangle.x, this.rectangle.y, this.rectangle.width, this.rectangle.height);\n this.imageData = this.context.getImageData(this.rectangle.x, this.rectangle.y, this.rectangle.width, this.rectangle.height);\n }\n\n onProtonUpdateAfter() {\n this.context.putImageData(this.imageData, this.rectangle.x, this.rectangle.y);\n }\n\n onParticleCreated(particle) {}\n\n onParticleUpdate(particle) {\n if (this.imageData) {\n this.setPixel(this.imageData, Math.floor(particle.p.x - this.rectangle.x), Math.floor(particle.p.y - this.rectangle.y), particle);\n }\n }\n\n setPixel(imagedata, x, y, particle) {\n const rgb = particle.transform.rgb;\n\n if ((x < 0) || (x > this.element.width) || (y < 0) || (y > this.elementwidth))\n return;\n\n const i = ((y >> 0) * imagedata.width + (x >> 0)) * 4;\n\n imagedata.data[i] = rgb.r;\n imagedata.data[i + 1] = rgb.g;\n imagedata.data[i + 2] = rgb.b;\n imagedata.data[i + 3] = particle.alpha * 255;\n }\n\n onParticleDead(particle) {\n\n }\n\n}","import Pool from '../core/Pool';\nimport Util from '../utils/Util';\nimport ColorUtil from '../utils/ColorUtil';\nimport MathUtils from '../math/MathUtils';\nimport BaseRenderer from './BaseRenderer';\n\nexport default class PixiRenderer extends BaseRenderer {\n\n constructor(element, stroke) {\n super(element);\n\n this.stroke = stroke;\n this.setColor = false;\n this.pool.create = (body, particle) => this.createBody(body, particle);\n this.name = 'PixiRenderer';\n }\n\n onProtonUpdate() { }\n\n /**\n * @param particle\n */\n onParticleCreated(particle) {\n if (particle.body) {\n particle.body = this.pool.get(particle.body, particle);\n } else {\n particle.body = this.pool.get(this.circleConf, particle);\n }\n\n this.element.addChild(particle.body);\n }\n\n /**\n * @param particle\n */\n onParticleUpdate(particle) {\n this.transform(particle, particle.body);\n if (this.setColor) particle.body.tint = ColorUtil.getHex16FromParticle(particle);\n }\n\n /**\n * @param particle\n */\n onParticleDead(particle) {\n this.element.removeChild(particle.body);\n this.pool.expire(particle.body);\n particle.body = null;\n }\n\n destroy(particles) {\n super.destroy();\n this.pool.destroy();\n\n let i = particles.length;\n while (i--) {\n let particle = particles[i];\n if (particle.body) {\n this.element.removeChild(particle.body);\n }\n }\n }\n\n transform(particle, target) {\n target.x = particle.p.x;\n target.y = particle.p.y;\n\n target.alpha = particle.alpha;\n\n target.scale.x = particle.scale;\n target.scale.y = particle.scale;\n\n // using cached version of MathUtils.PI_180 for slight performance increase.\n target.rotation = particle.rotation * MathUtils.PI_180; // MathUtils.PI_180;\n }\n\n createBody(body, particle) {\n if (body.isCircle)\n return this.createCircle(particle);\n else\n return this.createSprite(body);\n }\n\n createSprite(body) {\n const sprite = body.isInner ? PIXI.Sprite.fromImage(body.src) : new PIXI.Sprite(body);\n sprite.anchor.x = 0.5;\n sprite.anchor.y = 0.5;\n\n return sprite;\n }\n\n createCircle(particle) {\n const graphics = new PIXI.Graphics();\n\n if (this.stroke) {\n let stroke = this.stroke instanceof String ? this.stroke : 0x000000;\n graphics.beginStroke(this.stroke);\n }\n\n graphics.beginFill(particle.color || 0x008ced);\n graphics.drawCircle(0, 0, particle.radius);\n graphics.endFill();\n\n return graphics;\n }\n}","import Mat3 from '../math/Mat3';\n\nexport default class MStack {\n\n\tconstructor() {\n\t\tthis.mats = [];\n\t\tthis.size = 0;\n\n\t\tfor (let i = 0; i < 20; i++) this.mats.push(Mat3.create([0, 0, 0, 0, 0, 0, 0, 0, 0]));\n\t}\n\n\tset(m, i) {\n\t\tif (i == 0)\n\t\t\tMat3.set(m, this.mats[0]);\n\t\telse\n\t\t\tMat3.multiply(this.mats[i - 1], m, this.mats[i]);\n\n\t\tthis.size = Math.max(this.size, i + 1);\n\t}\n\n\tpush(m) {\n\t\tif (this.size == 0)\n\t\t\tMat3.set(m, this.mats[0]);\n\t\telse\n\t\t\tMat3.multiply(this.mats[this.size - 1], m, this.mats[this.size]);\n\n\t\tthis.size++;\n\t}\n\n\tpop() {\n\t\tif (this.size > 0)\n\t\t\tthis.size--;\n\t}\n\n\ttop() {\n\t\treturn (this.mats[this.size - 1]);\n\t}\n}","import Mat3 from '../math/Mat3';\nimport BaseRenderer from './BaseRenderer';\n\nimport Util from '../utils/Util';\nimport ImgUtil from '../utils/ImgUtil';\nimport MStack from '../utils/MStack';\nimport DomUtil from '../utils/DomUtil';\nimport WebGLUtil from '../utils/WebGLUtil';\nimport MathUtils from '../math/MathUtils';\n\nexport default class WebGLRenderer extends BaseRenderer {\n\n constructor(element) {\n super(element);\n\n this.gl = this.element.getContext('experimental-webgl', { antialias: true, stencil: false, depth: false });\n if (!this.gl) alert(\"Sorry your browser do not suppest WebGL!\");\n\n this.initVar();\n this.setMaxRadius();\n this.initShaders();\n this.initBuffers();\n\n this.gl.blendEquation(this.gl.FUNC_ADD);\n this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA);\n this.gl.enable(this.gl.BLEND);\n\n this.addImg2Body = this.addImg2Body.bind(this);\n\n this.name = 'WebGLRenderer';\n }\n\n init(proton) {\n super.init(proton);\n this.resize(this.element.width, this.element.height);\n }\n\n resize(width, height) {\n this.umat[4] = -2;\n this.umat[7] = 1;\n\n this.smat[0] = 1 / width;\n this.smat[4] = 1 / height;\n\n this.mstack.set(this.umat, 0);\n this.mstack.set(this.smat, 1);\n\n this.gl.viewport(0, 0, width, height);\n this.element.width = width;\n this.element.height = height;\n }\n\n setMaxRadius(radius) {\n this.circleCanvasURL = this.createCircle(radius);\n }\n\n getVertexShader() {\n const vsSource = [\"uniform vec2 viewport;\", \"attribute vec2 aVertexPosition;\", \"attribute vec2 aTextureCoord;\", \"uniform mat3 tMat;\", \"varying vec2 vTextureCoord;\", \"varying float alpha;\", \"void main() {\", \"vec3 v = tMat * vec3(aVertexPosition, 1.0);\", \"gl_Position = vec4(v.x, v.y, 0, 1);\", \"vTextureCoord = aTextureCoord;\", \"alpha = tMat[0][2];\", \"}\"].join(\"\\n\");\n return vsSource;\n }\n\n getFragmentShader() {\n const fsSource = [\"precision mediump float;\", \"varying vec2 vTextureCoord;\", \"varying float alpha;\", \"uniform sampler2D uSampler;\", \"uniform vec4 color;\", \"uniform bool useTexture;\", \"uniform vec3 uColor;\", \"void main() {\", \"vec4 textureColor = texture2D(uSampler, vTextureCoord);\", \"gl_FragColor = textureColor * vec4(uColor, 1.0);\", \"gl_FragColor.w *= alpha;\", \"}\"].join(\"\\n\");\n return fsSource;\n }\n\n initVar() {\n this.mstack = new MStack();\n this.umat = Mat3.create([2, 0, 1, 0, -2, 0, -1, 1, 1]);\n this.smat = Mat3.create([1 / 100, 0, 1, 0, 1 / 100, 0, 0, 0, 1]);\n this.texturebuffers = {};\n }\n\n blendEquation(A) {\n this.gl.blendEquation(this.gl[A]);\n }\n\n blendFunc(A, B) {\n this.gl.blendFunc(this.gl[A], this.gl[B]);\n }\n\n getShader(gl, str, fs) {\n const shader = fs ? gl.createShader(gl.FRAGMENT_SHADER) : gl.createShader(gl.VERTEX_SHADER);\n\n gl.shaderSource(shader, str);\n gl.compileShader(shader);\n\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n alert(gl.getShaderInfoLog(shader));\n return null;\n }\n\n return shader;\n }\n\n initShaders() {\n const fragmentShader = this.getShader(this.gl, this.getFragmentShader(), true);\n const vertexShader = this.getShader(this.gl, this.getVertexShader(), false);\n\n this.sprogram = this.gl.createProgram();\n this.gl.attachShader(this.sprogram, vertexShader);\n this.gl.attachShader(this.sprogram, fragmentShader);\n this.gl.linkProgram(this.sprogram);\n\n if (!this.gl.getProgramParameter(this.sprogram, this.gl.LINK_STATUS))\n alert(\"Could not initialise shaders\");\n\n this.gl.useProgram(this.sprogram);\n this.sprogram.vpa = this.gl.getAttribLocation(this.sprogram, \"aVertexPosition\");\n this.sprogram.tca = this.gl.getAttribLocation(this.sprogram, \"aTextureCoord\");\n this.gl.enableVertexAttribArray(this.sprogram.tca);\n this.gl.enableVertexAttribArray(this.sprogram.vpa);\n\n this.sprogram.tMatUniform = this.gl.getUniformLocation(this.sprogram, \"tMat\");\n this.sprogram.samplerUniform = this.gl.getUniformLocation(this.sprogram, \"uSampler\");\n this.sprogram.useTex = this.gl.getUniformLocation(this.sprogram, \"useTexture\");\n this.sprogram.color = this.gl.getUniformLocation(this.sprogram, \"uColor\");\n this.gl.uniform1i(this.sprogram.useTex, 1);\n };\n\n initBuffers() {\n const vs = [0, 3, 1, 0, 2, 3];\n let idx;\n\n this.unitIBuffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.unitIBuffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(vs), this.gl.STATIC_DRAW);\n\n let i;\n let ids = [];\n for (i = 0; i < 100; i++) ids.push(i);\n idx = new Uint16Array(ids);\n\n this.unitI33 = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.unitI33);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, idx, this.gl.STATIC_DRAW);\n\n ids = [];\n for (i = 0; i < 100; i++) ids.push(i, i + 1, i + 2);\n idx = new Uint16Array(ids);\n\n this.stripBuffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.stripBuffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, idx, this.gl.STATIC_DRAW);\n };\n\n createCircle(raidus) {\n this.circleCanvasRadius = WebGLUtil.nhpot(Util.initValue(raidus, 32));\n const canvas = DomUtil.createCanvas('circle_canvas', this.circleCanvasRadius * 2, this.circleCanvasRadius * 2);\n const context = canvas.getContext('2d');\n\n context.beginPath();\n context.arc(this.circleCanvasRadius, this.circleCanvasRadius, this.circleCanvasRadius, 0, Math.PI * 2, true);\n context.closePath();\n context.fillStyle = '#FFF';\n context.fill();\n\n return canvas.toDataURL();\n };\n\n drawImg2Canvas(particle) {\n const _w = particle.body.width;\n const _h = particle.body.height;\n\n const _width = WebGLUtil.nhpot(particle.body.width);\n const _height = WebGLUtil.nhpot(particle.body.height);\n\n const _scaleX = particle.body.width / _width;\n const _scaleY = particle.body.height / _height;\n\n if (!this.texturebuffers[particle.transform.src])\n this.texturebuffers[particle.transform.src] = [this.gl.createTexture(), this.gl.createBuffer(), this.gl.createBuffer()];\n\n particle.transform.texture = this.texturebuffers[particle.transform.src][0];\n particle.transform.vcBuffer = this.texturebuffers[particle.transform.src][1];\n particle.transform.tcBuffer = this.texturebuffers[particle.transform.src][2];\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, particle.transform.tcBuffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([0.0, 0.0, _scaleX, 0.0, 0.0, _scaleY, _scaleY, _scaleY]), this.gl.STATIC_DRAW);\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, particle.transform.vcBuffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([0.0, 0.0, _w, 0.0, 0.0, _h, _w, _h]), this.gl.STATIC_DRAW);\n\n const context = particle.transform.canvas.getContext('2d');\n const data = context.getImageData(0, 0, _width, _height);\n\n this.gl.bindTexture(this.gl.TEXTURE_2D, particle.transform.texture);\n this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, this.gl.RGBA, this.gl.UNSIGNED_BYTE, data);\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR);\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR_MIPMAP_NEAREST);\n this.gl.generateMipmap(this.gl.TEXTURE_2D);\n\n particle.transform.textureLoaded = true;\n particle.transform.textureWidth = _w;\n particle.transform.textureHeight = _h;\n }\n\n onProtonUpdate() {\n //this.gl.clearColor(0, 0, 0, 1);\n //this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);\n }\n\n onParticleCreated(particle) {\n particle.transform.textureLoaded = false;\n particle.transform.tmat = Mat3.create();\n particle.transform.tmat[8] = 1;\n particle.transform.imat = Mat3.create();\n particle.transform.imat[8] = 1;\n\n if (particle.body) {\n ImgUtil.getImgFromCache(particle.body, this.addImg2Body, particle);\n } else {\n ImgUtil.getImgFromCache(this.circleCanvasURL, this.addImg2Body, particle);\n particle.transform.oldScale = particle.radius / this.circleCanvasRadius;\n }\n }\n\n // private \n addImg2Body(img, particle) {\n if (particle.dead) return;\n \n particle.body = img;\n particle.transform.src = img.src;\n particle.transform.canvas = ImgUtil.getCanvasFromCache(img);\n particle.transform.oldScale = 1;\n\n this.drawImg2Canvas(particle);\n }\n\n onParticleUpdate(particle) {\n if (particle.transform.textureLoaded) {\n this.updateMatrix(particle);\n\n this.gl.uniform3f(this.sprogram.color, particle.transform.rgb.r / 255, particle.transform.rgb.g / 255, particle.transform.rgb.b / 255);\n this.gl.uniformMatrix3fv(this.sprogram.tMatUniform, false, this.mstack.top());\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, particle.transform.vcBuffer);\n this.gl.vertexAttribPointer(this.sprogram.vpa, 2, this.gl.FLOAT, false, 0, 0);\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, particle.transform.tcBuffer);\n this.gl.vertexAttribPointer(this.sprogram.tca, 2, this.gl.FLOAT, false, 0, 0);\n this.gl.bindTexture(this.gl.TEXTURE_2D, particle.transform.texture);\n this.gl.uniform1i(this.sprogram.samplerUniform, 0);\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.unitIBuffer);\n\n this.gl.drawElements(this.gl.TRIANGLES, 6, this.gl.UNSIGNED_SHORT, 0);\n\n this.mstack.pop();\n }\n }\n\n onParticleDead(particle) { }\n\n updateMatrix(particle) {\n const moveOriginMatrix = WebGLUtil.makeTranslation(-particle.transform.textureWidth / 2, -particle.transform.textureHeight / 2);\n const translationMatrix = WebGLUtil.makeTranslation(particle.p.x, particle.p.y);\n\n const angel = particle.rotation * (MathUtils.PI_180);\n const rotationMatrix = WebGLUtil.makeRotation(angel);\n\n const scale = particle.scale * particle.transform.oldScale;\n const scaleMatrix = WebGLUtil.makeScale(scale, scale);\n let matrix = WebGLUtil.matrixMultiply(moveOriginMatrix, scaleMatrix);\n\n matrix = WebGLUtil.matrixMultiply(matrix, rotationMatrix);\n matrix = WebGLUtil.matrixMultiply(matrix, translationMatrix);\n\n Mat3.inverse(matrix, particle.transform.imat);\n matrix[2] = particle.alpha;\n\n this.mstack.push(matrix);\n }\n}","import Util from '../utils/Util';\nimport BaseRenderer from './BaseRenderer';\n\nexport default class CustomRenderer extends BaseRenderer {\n\n constructor(element) {\n super(element);\n\n this.name = 'CustomRenderer';\n }\n\n}","import Zone from './Zone';\nimport Util from '../utils/Util';\nimport MathUtils from '../math/MathUtils';\n\nexport default class CircleZone extends Zone {\n\n\tconstructor(x1, y1, x2, y2, direction) {\n\t\tsuper();\n\n\t\tif (x2 - x1 >= 0) {\n\t\t\tthis.x1 = x1;\n\t\t\tthis.y1 = y1;\n\t\t\tthis.x2 = x2;\n\t\t\tthis.y2 = y2;\n\t\t} else {\n\t\t\tthis.x1 = x2;\n\t\t\tthis.y1 = y2;\n\t\t\tthis.x2 = x1;\n\t\t\tthis.y2 = y1;\n\t\t}\n\n\t\tthis.dx = this.x2 - this.x1;\n\t\tthis.dy = this.y2 - this.y1;\n\n\t\tthis.minx = Math.min(this.x1, this.x2);\n\t\tthis.miny = Math.min(this.y1, this.y2);\n\t\tthis.maxx = Math.max(this.x1, this.x2);\n\t\tthis.maxy = Math.max(this.y1, this.y2);\n\n\t\tthis.dot = this.x2 * this.y1 - this.x1 * this.y2;\n\t\tthis.xxyy = this.dx * this.dx + this.dy * this.dy;\n\n\t\tthis.gradient = this.getGradient();\n\t\tthis.length = this.getLength();\n\t\tthis.direction = Util.initValue(direction, '>');\n\t}\n\n\n\tgetPosition() {\n\t\tthis.random = Math.random();\n\t\tthis.vector.x = this.x1 + this.random * this.length * Math.cos(this.gradient);\n\t\tthis.vector.y = this.y1 + this.random * this.length * Math.sin(this.gradient);\n\n\t\treturn this.vector;\n\t}\n\n\tgetDirection(x, y) {\n\t\tconst A = this.dy;\n\t\tconst B = -this.dx;\n\t\tconst C = this.dot;\n\t\tconst D = B == 0 ? 1 : B;\n\n\t\tif ((A * x + B * y + C) * D > 0)\n\t\t\treturn true;\n\t\telse\n\t\t\treturn false;\n\t}\n\n\tgetDistance(x, y) {\n\t\tconst A = this.dy;\n\t\tconst B = -this.dx;\n\t\tconst C = this.dot;\n\t\tconst D = (A * x + B * y + C);\n\n\t\treturn D / Math.sqrt(this.xxyy);\n\t}\n\n\tgetSymmetric(v) {\n\t\tconst tha2 = v.getGradient();\n\t\tconst tha1 = this.getGradient();\n\t\tconst tha = 2 * (tha1 - tha2);\n\n\t\tconst oldx = v.x;\n\t\tconst oldy = v.y;\n\n\t\tv.x = oldx * Math.cos(tha) - oldy * Math.sin(tha);\n\t\tv.y = oldx * Math.sin(tha) + oldy * Math.cos(tha);\n\n\t\treturn v;\n\t}\n\n\tgetGradient() {\n\t\treturn Math.atan2(this.dy, this.dx);\n\t}\n\n\trangeOut(particle) {\n\t\tconst angle = Math.abs(this.getGradient());\n\n\t\tif (angle <= MathUtils.PI / 4) {\n\t\t\tif (particle.p.x <= this.maxx && particle.p.x >= this.minx) return true;\n\t\t} else {\n\t\t\tif (particle.p.y <= this.maxy && particle.p.y >= this.miny) return true;\n\t\t}\n\t\t\n\t\treturn false;\n\t}\n\n\tgetLength() {\n\t\treturn Math.sqrt(this.dx * this.dx + this.dy * this.dy)\n\t}\n\n\tcrossing(particle) {\n\t\tif (this.crossType == \"dead\") {\n\t\t\tif (this.direction == \">\" || this.direction == \"R\" || this.direction == \"right\" || this.direction == \"down\") {\n\t\t\t\tif (!this.rangeOut(particle)) return;\n\t\t\t\tif (this.getDirection(particle.p.x, particle.p.y)) particle.dead = true;\n\t\t\t} else {\n\t\t\t\tif (!this.rangeOut(particle)) return;\n\t\t\t\tif (!this.getDirection(particle.p.x, particle.p.y)) particle.dead = true;\n\t\t\t}\n\t\t}\n\n\t\telse if (this.crossType == \"bound\") {\n\t\t\tif (!this.rangeOut(particle)) return;\n\n\t\t\tif (this.getDistance(particle.p.x, particle.p.y) <= particle.radius) {\n\t\t\t\tif (this.dx == 0) {\n\t\t\t\t\tparticle.v.x *= -1;\n\t\t\t\t} else if (this.dy == 0) {\n\t\t\t\t\tparticle.v.y *= -1;\n\t\t\t\t} else {\n\t\t\t\t\tthis.getSymmetric(particle.v);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\telse if (this.crossType == \"cross\") {\n\t\t\tif (this.alert) {\n\t\t\t\tconsole.error('Sorry lineZone does not support cross method');\n\t\t\t\tthis.alert = false;\n\t\t\t}\n\t\t}\n\t}\n\n}","import Zone from './Zone';\nimport MathUtils from '../math/MathUtils';\n\nexport default class CircleZone extends Zone {\n\n constructor(x, y, radius) {\n super();\n\n this.x = x;\n this.y = y;\n this.radius = radius;\n\n this.angle = 0;\n this.center = { x, y };\n }\n\n getPosition() {\n this.random = Math.random();\n this.angle = MathUtils.PIx2 * Math.random();\n\n this.vector.x = this.x + this.random * this.radius * Math.cos(this.angle);\n this.vector.y = this.y + this.random * this.radius * Math.sin(this.angle);\n\n return this.vector;\n }\n\n setCenter(x, y) {\n this.center.x = x;\n this.center.y = y;\n }\n\n crossing(particle) {\n const d = particle.p.distanceTo(this.center);\n\n if (this.crossType == \"dead\") {\n if (d - particle.radius > this.radius)\n particle.dead = true;\n } else if (this.crossType == \"bound\") {\n if (d + particle.radius >= this.radius)\n this.getSymmetric(particle);\n } else if (this.crossType == \"cross\") {\n if (this.alert) {\n alert('Sorry CircleZone does not support cross method');\n this.alert = false;\n }\n }\n }\n\n getSymmetric(particle) {\n let tha2 = particle.v.getGradient();\n let tha1 = this.getGradient(particle);\n\n let tha = 2 * (tha1 - tha2);\n let oldx = particle.v.x;\n let oldy = particle.v.y;\n\n particle.v.x = oldx * Math.cos(tha) - oldy * Math.sin(tha);\n particle.v.y = oldx * Math.sin(tha) + oldy * Math.cos(tha);\n }\n\n getGradient(particle) {\n return -MathUtils.PI_2 + Math.atan2(particle.p.y - this.center.y, particle.p.x - this.center.x);\n }\n}","import Zone from './Zone';\n\nexport default class PointZoneRectZone extends Zone {\n\n\tconstructor(x, y, width, height) {\n\t\tsuper();\n\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.width = width;\n\t\tthis.height = height;\n\t}\n\n\tgetPosition() {\n\t\tthis.vector.x = this.x + Math.random() * this.width;\n\t\tthis.vector.y = this.y + Math.random() * this.height;\n\n\t\treturn this.vector;\n\t}\n\n\tcrossing(particle) {\n\t\tif (this.crossType == \"dead\") {\n\t\t\tif (particle.p.x + particle.radius < this.x)\n\t\t\t\tparticle.dead = true;\n\t\t\telse if (particle.p.x - particle.radius > this.x + this.width)\n\t\t\t\tparticle.dead = true;\n\n\t\t\tif (particle.p.y + particle.radius < this.y)\n\t\t\t\tparticle.dead = true;\n\t\t\telse if (particle.p.y - particle.radius > this.y + this.height)\n\t\t\t\tparticle.dead = true;\n\t\t}\n\n\t\telse if (this.crossType == \"bound\") {\n\t\t\tif (particle.p.x - particle.radius < this.x) {\n\t\t\t\tparticle.p.x = this.x + particle.radius;\n\t\t\t\tparticle.v.x *= -1;\n\t\t\t} else if (particle.p.x + particle.radius > this.x + this.width) {\n\t\t\t\tparticle.p.x = this.x + this.width - particle.radius;\n\t\t\t\tparticle.v.x *= -1;\n\t\t\t}\n\n\t\t\tif (particle.p.y - particle.radius < this.y) {\n\t\t\t\tparticle.p.y = this.y + particle.radius;\n\t\t\t\tparticle.v.y *= -1;\n\t\t\t} else if (particle.p.y + particle.radius > this.y + this.height) {\n\t\t\t\tparticle.p.y = this.y + this.height - particle.radius;\n\t\t\t\tparticle.v.y *= -1;\n\t\t\t}\n\t\t}\n\n\t\telse if (this.crossType == \"cross\") {\n\t\t\tif (particle.p.x + particle.radius < this.x && particle.v.x <= 0)\n\t\t\t\tparticle.p.x = this.x + this.width + particle.radius;\n\t\t\telse if (particle.p.x - particle.radius > this.x + this.width && particle.v.x >= 0)\n\t\t\t\tparticle.p.x = this.x - particle.radius;\n\n\t\t\tif (particle.p.y + particle.radius < this.y && particle.v.y <= 0)\n\t\t\t\tparticle.p.y = this.y + this.height + particle.radius;\n\t\t\telse if (particle.p.y - particle.radius > this.y + this.height && particle.v.y >= 0)\n\t\t\t\tparticle.p.y = this.y - particle.radius;\n\t\t}\n\t}\n}","import Zone from './Zone';\nimport Util from '../utils/Util';\n\nexport default class ImageZone extends Zone {\n\n\tconstructor(imageData, x, y, d) {\n\t\tsuper();\n\n\t\tthis.reset(imageData, x, y, d);\n\t}\n\n\treset(imageData, x, y, d) {\n\t\tthis.imageData = imageData;\n\t\tthis.x = Util.initValue(x, 0);\n\t\tthis.y = Util.initValue(y, 0);\n\t\tthis.d = Util.initValue(d, 2);\n\n\t\tthis.vectors = [];\n\t\tthis.setVectors();\n\t}\n\n\tsetVectors() {\n\t\tlet i, j;\n\t\tconst length1 = this.imageData.width;\n\t\tconst length2 = this.imageData.height;\n\n\t\tfor (i = 0; i < length1; i += this.d) {\n\t\t\tfor (j = 0; j < length2; j += this.d) {\n\t\t\t\tlet index = ((j >> 0) * length1 + (i >> 0)) * 4;\n\n\t\t\t\tif (this.imageData.data[index + 3] > 0) {\n\t\t\t\t\tthis.vectors.push({ x: i + this.x, y: j + this.y });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn this.vector;\n\t}\n\n\tgetBound(x, y) {\n\t\tvar index = ((y >> 0) * this.imageData.width + (x >> 0)) * 4;\n\t\tif (this.imageData.data[index + 3] > 0)\n\t\t\treturn true;\n\t\telse\n\t\t\treturn false;\n\t}\n\n\tgetPosition() {\n\t\treturn this.vector.copy(this.vectors[Math.floor(Math.random() * this.vectors.length)]);\n\t}\n\n\tgetColor(x, y) {\n\t\tx -= this.x;\n\t\ty -= this.y;\n\t\tvar i = ((y >> 0) * this.imageData.width + (x >> 0)) * 4;\n\n\t\treturn {\n\t\t\tr: this.imageData.data[i],\n\t\t\tg: this.imageData.data[i + 1],\n\t\t\tb: this.imageData.data[i + 2],\n\t\t\ta: this.imageData.data[i + 3]\n\t\t};\n\t}\n\n\tcrossing(particle) {\n\t\tif (this.crossType == \"dead\") {\n\t\t\tif (this.getBound(particle.p.x - this.x, particle.p.y - this.y))\n\t\t\t\tparticle.dead = true;\n\t\t\telse\n\t\t\t\tparticle.dead = false;\n\t\t} \n\t\t\n\t\telse if (this.crossType == \"bound\") {\n\t\t\tif (!this.getBound(particle.p.x - this.x, particle.p.y - this.y))\n\t\t\t\tparticle.v.negate();\n\t\t}\n\t}\n}","import Util from '../utils/Util';\nimport ColorUtil from '../utils/ColorUtil';\nimport MathUtils from '../math/MathUtils';\nimport CircleZone from '../zone/CircleZone';\nimport PointZone from '../zone/PointZone';\nimport LineZone from '../zone/LineZone';\nimport RectZone from '../zone/RectZone';\n\nexport default {\n\taddEventListener(proton, fun) {\n\t\tproton.addEventListener(\"PROTON_UPDATE_AFTER\", () => fun());\n\t},\n\n\tgetStyle(color) {\n\t\tconst rgb = ColorUtil.hexToRGB(color || '#ff0000');\n\t\treturn `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, 0.5)`;\n\t},\n\t\n\tdrawZone(proton, canvas, zone, clear) {\n\t\tconst context = canvas.getContext('2d');\n\t\tconst style = this.getStyle();\n\n\t\tthis.addEventListener(proton, () => {\n\t\t\tif (clear)\n\t\t\t\tcontext.clearRect(0, 0, canvas.width, canvas.height);\n\n\t\t\tif (zone instanceof PointZone) {\n\t\t\t\tcontext.beginPath();\n\t\t\t\tcontext.fillStyle = style;\n\t\t\t\tcontext.arc(zone.x, zone.y, 10, 0, Math.PI * 2, true);\n\t\t\t\tcontext.fill();\n\t\t\t\tcontext.closePath();\n\t\t\t} else if (zone instanceof LineZone) {\n\t\t\t\tcontext.beginPath();\n\t\t\t\tcontext.strokeStyle = style;\n\t\t\t\tcontext.moveTo(zone.x1, zone.y1);\n\t\t\t\tcontext.lineTo(zone.x2, zone.y2);\n\t\t\t\tcontext.stroke();\n\t\t\t\tcontext.closePath();\n\t\t\t} else if (zone instanceof RectZone) {\n\t\t\t\tcontext.beginPath();\n\t\t\t\tcontext.strokeStyle = style;\n\t\t\t\tcontext.drawRect(zone.x, zone.y, zone.width, zone.height);\n\t\t\t\tcontext.stroke();\n\t\t\t\tcontext.closePath();\n\t\t\t} else if (zone instanceof CircleZone) {\n\t\t\t\tcontext.beginPath();\n\t\t\t\tcontext.strokeStyle = style;\n\t\t\t\tcontext.arc(zone.x, zone.y, zone.radius, 0, Math.PI * 2, true);\n\t\t\t\tcontext.stroke();\n\t\t\t\tcontext.closePath();\n\t\t\t}\n\t\t});\n\t},\n\t\n\tdrawEmitter(proton, canvas, emitter, clear) {\n\t\tconst context = canvas.getContext('2d');\n\t\tconst style = this.getStyle();\n\n\t\tthis.addEventListener(proton, () => {\n\t\t\tif (clear) context.clearRect(0, 0, canvas.width, canvas.height);\n\t\t\t\n\t\t\tcontext.beginPath();\n\t\t\tcontext.fillStyle = style;\n\t\t\tcontext.arc(emitter.p.x, emitter.p.y, 10, 0, Math.PI * 2, true);\n\t\t\tcontext.fill();\n\t\t\tcontext.closePath();\n\t\t});\n\t},\n}\n\n","// http://paulirish.com/2011/requestanimationframe-for-smart-animating/\n// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating\n\n// requestAnimationFrame polyfill by Erik Möller\n// fixes from Paul Irish and Tino Zijdel\n( function() {\n\t\tvar lastTime = 0;\n\t\tvar vendors = ['ms', 'moz', 'webkit', 'o'];\n\t\tfor (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {\n\t\t\twindow.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];\n\t\t\twindow.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];\n\t\t}\n\n\t\tif (!window.requestAnimationFrame)\n\t\t\twindow.requestAnimationFrame = function(callback, element) {\n\t\t\t\tvar currTime = new Date().getTime();\n\t\t\t\tvar timeToCall = Math.max(0, 16 - (currTime - lastTime));\n\t\t\t\tvar id = window.setTimeout(function() {\n\t\t\t\t\tcallback(currTime + timeToCall);\n\t\t\t\t}, timeToCall);\n\t\t\t\tlastTime = currTime + timeToCall;\n\t\t\t\treturn id;\n\t\t\t};\n\n\t\tif (!window.cancelAnimationFrame)\n\t\t\twindow.cancelAnimationFrame = function(id) {\n\t\t\t\tclearTimeout(id);\n\t\t\t};\n\t}()); ","// import \nimport Proton from \"./core/Proton\";\nimport Particle from \"./core/Particle\";\nimport Pool from \"./core/Pool\";\n\nimport Util from \"./utils/Util\";\nimport ColorUtil from \"./utils/ColorUtil\";\nimport MathUtils from \"./math/MathUtils\";\nimport Vector2D from \"./math/Vector2D\";\nimport Polar2D from \"./math/Polar2D\";\nimport Mat3 from \"./math/Mat3\";\nimport Span from \"./math/Span\";\nimport ArraySpan from \"./math/ArraySpan\";\nimport Rectangle from \"./math/Rectangle\";\nimport ease from \"./math/ease\";\n\nimport Rate from \"./initialize/Rate\";\nimport Initialize from \"./initialize/Initialize\";\nimport Life from \"./initialize/Life\";\nimport Position from \"./initialize/Position\";\nimport Velocity from \"./initialize/Velocity\";\nimport Mass from \"./initialize/Mass\";\nimport Radius from \"./initialize/Radius\";\nimport Body from \"./initialize/Body\";\n\nimport Behaviour from \"./behaviour/Behaviour\";\nimport Force from \"./behaviour/Force\";\nimport Attraction from \"./behaviour/Attraction\";\nimport RandomDrift from \"./behaviour/RandomDrift\";\nimport Gravity from \"./behaviour/Gravity\";\nimport Collision from \"./behaviour/Collision\";\nimport CrossZone from \"./behaviour/CrossZone\";\nimport Alpha from \"./behaviour/Alpha\";\nimport Scale from \"./behaviour/Scale\";\nimport Rotate from \"./behaviour/Rotate\";\nimport Color from \"./behaviour/Color\";\nimport Repulsion from \"./behaviour/Repulsion\";\nimport GravityWell from \"./behaviour/GravityWell\";\n\nimport Emitter from \"./emitter/Emitter\";\nimport BehaviourEmitter from \"./emitter/BehaviourEmitter\";\nimport FollowEmitter from \"./emitter/FollowEmitter\";\n\nimport CanvasRenderer from \"./render/CanvasRenderer\";\nimport DomRenderer from \"./render/DomRenderer\";\nimport EaselRenderer from \"./render/EaselRenderer\";\nimport PixelRenderer from \"./render/PixelRenderer\";\nimport PixiRenderer from \"./render/PixiRenderer\";\nimport WebGLRenderer from \"./render/WebGLRenderer\";\nimport CustomRenderer from \"./render/CustomRenderer\";\n\nimport Zone from \"./zone/Zone\";\nimport LineZone from \"./zone/LineZone\";\nimport CircleZone from \"./zone/CircleZone\";\nimport PointZone from \"./zone/PointZone\";\nimport RectZone from \"./zone/RectZone\";\nimport ImageZone from \"./zone/ImageZone\";\n\nimport Debug from \"./debug/Debug\";\nimport \"./polyfill/requestAnimationFrame\";\n\n// namespace\nProton.Particle = Proton.P = Particle;\nProton.Pool = Pool;\n\nProton.Util = Util;\nProton.ColorUtil = ColorUtil;\nProton.MathUtils = MathUtils;\nProton.Vector2D = Proton.Vector = Vector2D;\nProton.Polar2D = Proton.Polar = Polar2D;\nProton.ArraySpan = ArraySpan;\nProton.Rectangle = Rectangle;\nProton.Rate = Rate;\nProton.ease = ease;\nProton.Span = Span;\nProton.Mat3 = Mat3;\nProton.getSpan = (a, b, center) => new Span(a, b, center);\nProton.createArraySpan = ArraySpan.createArraySpan;\n\nProton.Initialize = Proton.Init = Initialize;\nProton.Life = Proton.L = Life;\nProton.Position = Proton.P = Position;\nProton.Velocity = Proton.V = Velocity;\nProton.Mass = Proton.M = Mass;\nProton.Radius = Proton.R = Radius;\nProton.Body = Proton.B = Body;\n\nProton.Behaviour = Behaviour;\nProton.Force = Proton.F = Force;\nProton.Attraction = Proton.A = Attraction;\nProton.RandomDrift = Proton.RD = RandomDrift;\nProton.Gravity = Proton.G = Gravity;\nProton.Collision = Collision;\nProton.CrossZone = CrossZone;\nProton.Alpha = Proton.A = Alpha;\nProton.Scale = Proton.S = Scale;\nProton.Rotate = Rotate;\nProton.Color = Color;\nProton.Repulsion = Repulsion;\nProton.GravityWell = GravityWell;\n\nProton.Emitter = Emitter;\nProton.BehaviourEmitter = BehaviourEmitter;\nProton.FollowEmitter = FollowEmitter;\n\nProton.Zone = Zone;\nProton.LineZone = LineZone;\nProton.CircleZone = CircleZone;\nProton.PointZone = PointZone;\nProton.RectZone = RectZone;\nProton.ImageZone = ImageZone;\n\nProton.CanvasRenderer = CanvasRenderer;\nProton.DomRenderer = DomRenderer;\nProton.EaselRenderer = EaselRenderer;\nProton.PixiRenderer = PixiRenderer;\nProton.PixelRenderer = PixelRenderer;\nProton.WebGLRenderer = Proton.WebGlRenderer = WebGLRenderer;\nProton.CustomRenderer = CustomRenderer;\n\nProton.Debug = Debug;\n\nObject.assign(Proton, ease);\n\n// export\nexport default Proton;"],"names":["PI","MathUtils","a","b","INT","Math","random","floor","center","f","randomAToB","display","num","toString","slice","Vector2D","x","y","atan2","PI_2","v","w","undefined","addVectors","subVectors","s","set","multiplyScalar","sqrt","divideScalar","length","distanceToSquared","tha","cos","sin","dx","dy","alpha","Span","isArray","Util","initValue","randomFloating","i","tx","ty","angleInRadians","c","sx","sy","a00","a01","a02","a10","a11","a12","a20","a21","a22","b00","b01","b02","b10","b11","b12","b20","b21","b22","id","width","height","position","dom","document","createElement","style","opacity","transform","resize","marginLeft","marginTop","div","scale","rotate","willChange","css3","key","val","bkey","charAt","toUpperCase","substr","IMG_CACHE","CANVAS_CACHE","canvasID","context","image","rect","drawImage","imagedata","getImageData","clearRect","img","callback","param","src","Image","onload","e","target","WebGLUtil","nhpot","canvas","DomUtil","createCanvas","getContext","value","defaults","Object","prototype","call","array","obj","ignore","o","indexOf","constructor","args","concat","factoryFunction","bind","apply","pOBJ","hasProp","p","particle","copy","prototypeObject","filters","singleProp","hasOwnProperty","getSpanValue","pan","getValue","ImgUtil","arr","destroy","uid","getCacheID","cache","isInner","Pool","total","params","__puid","PUID","getID","pop","createOrClone","getCache","push","create","classApply","clone","count","Stats","proton","container","type","emitterIndex","rendererIndex","body","add","emitter","getEmitter","renderer","getRenderer","str","emitters","emitSpeed","getEmitterPos","initializes","concatArr","behaviours","name","getCreatedNumber","getCount","pool","innerHTML","cssText","join","addEventListener","bg","color","parentNode","appendChild","renderers","result","cpool","round","EventDispatcher","_listeners","listener","removeEventListener","splice","listeners","handler","TargetClass","dispatchEvent","hasEventListener","removeAllEventListeners","Integration","particles","time","damping","eulerIntegrate","sleep","old","mass","clear","Proton","integrationType","oldTime","elapsed","stats","EULER","integrator","render","init","index","remove","parent","EMITTER_ADDED","EMITTER_REMOVED","PROTON_UPDATE","USE_CLOCK","Date","getTime","amendChangeTabsBug","emittersUpdate","PROTON_UPDATE_AFTER","update","getAllParticles","MEASURE","RK2","PARTICLE_CREATED","PARTICLE_UPDATE","PARTICLE_SLEEP","PARTICLE_DEAD","bindEmtterEvent","pow","ease","easeLinear","Particle","ID","reset","setPrototypeByObject","N180_PI","life","Infinity","age","energy","dead","sprite","radius","rotation","easing","destroyObject","removeAllBehaviours","rgb","r","g","applyBehaviours","max","applyBehaviour","behaviour","parents","initialize","addBehaviour","destroyArray","h","hex16","substring","parseInt","rbg","Number","Polar2D","abs","getX","getY","mat3","mat","Float32Array","mat1","mat2","d","m","vec","ArraySpan","_arr","randomColor","Rectangle","bottom","right","Rate","numpan","timepan","numPan","setSpanValue","timePan","startTime","nextTime","Initialize","Life","lifePan","Zone","vector","crossType","alert","PointZone","Position","zone","getPosition","Velocity","rpan","thapan","rPan","thaPan","vr","polar2d","normalizeVelocity","PI_180","Mass","massPan","Radius","oldRadius","Body","imagetarget","inner","Behaviour","getEasing","force","removeBehaviour","Force","fx","fy","normalizeForce","calculate","Attraction","targetPosition","normalizeValue","radiusSq","attractionForce","lengthSq","sub","normalize","RandomDrift","driftX","driftY","delay","panFoce","addXY","Gravity","Collision","collisionPool","delta","newPool","otherParticle","overlap","totalMass","averageMass1","averageMass2","distance","CrossZone","crossing","Alpha","same","alphaA","alphaB","Scale","scaleA","scaleB","Rotate","rotationA","rotationB","getDirection","Color","createArraySpan","colorA","ColorUtil","hexToRGB","colorB","Repulsion","GravityWell","centerPoint","distanceVec","distanceSq","factor","bindEmitter","setVector2DByObject","degreeTransform","Emitter","pObj","currentEmitTime","totalEmitTimes","rate","stoped","isNaN","initAll","rest","initializer","arguments","emitting","integrate","dispatch","expire","event","createParticle","get","setupParticle","addBehaviours","stop","slow","removeAllInitializers","removeEmitter","BehaviourEmitter","selfBehaviours","FollowEmitter","mouseTarget","window","_allowEmitting","initEventHandler","mousemoveHandler","mousemove","mousedownHandler","mousedown","mouseupHandler","mouseup","layerX","layerY","offsetX","offsetY","babelHelpers.get","BaseRenderer","element","stroke","initHandler","circleConf","isCircle","thinkness","_protonUpdateHandler","onProtonUpdate","_protonUpdateAfterHandler","onProtonUpdateAfter","_emitterAddedHandler","onEmitterAdded","_emitterRemovedHandler","onEmitterRemoved","_particleCreatedHandler","onParticleCreated","_particleUpdateHandler","onParticleUpdate","_particleDeadHandler","onParticleDead","CanvasRenderer","bufferCache","getImgFromCache","addImg2Body","drawCircle","buffer","createBuffer","bufferContext","globalAlpha","globalCompositeOperation","fillStyle","rgbToHex","fillRect","save","translate","restore","beginPath","arc","strokeStyle","lineWidth","closePath","fill","size","DomRenderer","createBody","transform3d","bodyReady","backgroundColor","removeChild","babelHelpers.typeof","createCircle","createSprite","createDiv","borderRadius","borderColor","borderWidth","url","backgroundImage","EaselRenderer","addChild","scaleX","scaleY","graphics","regX","regY","createjs","Graphics","String","beginStroke","beginFill","shape","Shape","PixelRenderer","rectangle","imageData","createImageData","putImageData","setPixel","elementwidth","data","PixiRenderer","setColor","tint","getHex16FromParticle","PIXI","Sprite","fromImage","anchor","endFill","MStack","mats","Mat3","multiply","WebGLRenderer","gl","antialias","stencil","depth","initVar","setMaxRadius","initShaders","initBuffers","blendEquation","FUNC_ADD","blendFunc","SRC_ALPHA","ONE_MINUS_SRC_ALPHA","enable","BLEND","umat","smat","mstack","viewport","circleCanvasURL","vsSource","fsSource","texturebuffers","A","B","fs","shader","createShader","FRAGMENT_SHADER","VERTEX_SHADER","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","getShaderInfoLog","fragmentShader","getShader","getFragmentShader","vertexShader","getVertexShader","sprogram","createProgram","attachShader","linkProgram","getProgramParameter","LINK_STATUS","useProgram","vpa","getAttribLocation","tca","enableVertexAttribArray","tMatUniform","getUniformLocation","samplerUniform","useTex","uniform1i","vs","idx","unitIBuffer","bindBuffer","ELEMENT_ARRAY_BUFFER","bufferData","Uint16Array","STATIC_DRAW","ids","unitI33","stripBuffer","raidus","circleCanvasRadius","toDataURL","_w","_h","_width","_height","_scaleX","_scaleY","createTexture","texture","vcBuffer","tcBuffer","ARRAY_BUFFER","bindTexture","TEXTURE_2D","texImage2D","RGBA","UNSIGNED_BYTE","texParameteri","TEXTURE_MAG_FILTER","LINEAR","TEXTURE_MIN_FILTER","LINEAR_MIPMAP_NEAREST","generateMipmap","textureLoaded","textureWidth","textureHeight","tmat","imat","oldScale","getCanvasFromCache","drawImg2Canvas","updateMatrix","uniform3f","uniformMatrix3fv","top","vertexAttribPointer","FLOAT","drawElements","TRIANGLES","UNSIGNED_SHORT","moveOriginMatrix","makeTranslation","translationMatrix","angel","rotationMatrix","makeRotation","scaleMatrix","makeScale","matrix","matrixMultiply","inverse","CustomRenderer","CircleZone","x1","y1","x2","y2","direction","minx","min","miny","maxx","maxy","dot","xxyy","gradient","getGradient","getLength","C","D","tha2","tha1","oldx","oldy","angle","rangeOut","getDistance","getSymmetric","error","PIx2","distanceTo","PointZoneRectZone","ImageZone","vectors","setVectors","j","length1","length2","getBound","negate","fun","getStyle","LineZone","moveTo","lineTo","RectZone","drawRect","lastTime","vendors","requestAnimationFrame","cancelAnimationFrame","currTime","timeToCall","setTimeout","P","Vector","Polar","getSpan","Init","L","V","M","R","F","RD","G","S","WebGlRenderer","Debug","assign"],"mappings":";;;;;;AAAA,IAAMA,KAAK,SAAX;;AAEA,IAAMC,YAAY;;QAEVD,EAFU;UAGRA,KAAK,CAHG;UAIRA,KAAK,CAJG;YAKNA,KAAK,GALC;aAML,MAAMA,EAND;;cAAA,sBAQHE,CARG,EAQAC,CARA,EAQGC,GARH,EAQQ;YACd,CAACA,GAAL,EACI,OAAOF,IAAIG,KAAKC,MAAL,MAAiBH,IAAID,CAArB,CAAX,CADJ,KAGI,OAAOG,KAAKE,KAAL,CAAWF,KAAKC,MAAL,MAAiBH,IAAID,CAArB,CAAX,IAAsCA,CAA7C;KAZM;kBAAA,0BAeCM,MAfD,EAeSC,CAfT,EAeYL,GAfZ,EAeiB;eACpB,KAAKM,UAAL,CAAgBF,SAASC,CAAzB,EAA4BD,SAASC,CAArC,EAAwCL,GAAxC,CAAP;KAhBU;cAAA,sBAmBHO,OAnBG,EAmBM,EAnBN;mBAAA,2BAqBET,CArBF,EAqBK;eACRA,IAAIF,EAAJ,GAAS,GAAhB;KAtBU;aAAA,qBAyBJY,GAzBI,EAyBC;eACJ,MAAMA,IAAIC,QAAJ,CAAa,EAAb,CAAb;KA1BU;eAAA,yBA6BA;eACH,MAAM,CAAC,UAAU,CAACR,KAAKC,MAAL,KAAgB,SAAhB,IAA6B,CAA9B,EAAiCO,QAAjC,CAA0C,EAA1C,CAAX,EAA0DC,KAA1D,CAAgE,CAAC,CAAjE,CAAb;;C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KAAP,GAAeA,KAAf;AACAtK,SAAO4K,SAAP,GAAmBA,SAAnB;AACA5K,SAAO6K,WAAP,GAAqBA,WAArB;;AAEA7K,SAAOqL,OAAP,GAAiBA,OAAjB;AACArL,SAAO6M,gBAAP,GAA0BA,gBAA1B;AACA7M,SAAO+M,aAAP,GAAuBA,aAAvB;;AAEA/M,SAAO+F,IAAP,GAAcA,IAAd;AACA/F,SAAO+d,QAAP,GAAkBA,UAAlB;AACA/d,SAAOub,UAAP,GAAoBA,YAApB;AACAvb,SAAOmG,SAAP,GAAmBA,SAAnB;AACAnG,SAAOke,QAAP,GAAkBA,iBAAlB;AACAle,SAAOqd,SAAP,GAAmBA,SAAnB;;AAEArd,SAAOoP,cAAP,GAAwBA,cAAxB;AACApP,SAAO2Q,WAAP,GAAqBA,WAArB;AACA3Q,SAAO0R,aAAP,GAAuBA,aAAvB;AACA1R,SAAOgT,YAAP,GAAsBA,YAAtB;AACAhT,SAAOwS,aAAP,GAAuBA,aAAvB;AACAxS,SAAO6T,aAAP,GAAuB7T,SAAOwf,aAAP,GAAuB3L,aAA9C;AACA7T,SAAOsb,cAAP,GAAwBA,cAAxB;;AAEAtb,SAAOyf,KAAP,GAAeA,KAAf;;AAEA/lB,OAAOgmB,MAAP,CAAc1f,QAAd,EAAsB+B,IAAtB;;;;;;;;"}
\ No newline at end of file
diff --git a/build/proton.min.js b/build/proton.min.js
index d769c64..c019325 100644
--- a/build/proton.min.js
+++ b/build/proton.min.js
@@ -1,10 +1,11 @@
/*!
- * Proton v2.2.1
- * https://github.com/a-jie/Proton
- *
- * Copyright 2011-2017, A-JIE
- * Licensed under the MIT license
- * http://www.opensource.org/licenses/mit-license
- *
- */
-(function(a,b){typeof define=="function"&&define.amd?define([],b):typeof module!="undefined"&&module.exports?module.exports=b():a.Proton=b()})(this,function(){function be(a,b,c,d){be._super_.call(this),this.reset(a,b,c,d)}function bd(a,b,c,d){bd._super_.call(this),this.x=a,this.y=b,this.width=c,this.height=d}function bc(a,b){bc._super_.call(this),this.x=a,this.y=b}function bb(a,b,c){bb._super_.call(this),this.x=a,this.y=b,this.radius=c,this.angle=0,this.center={x:this.x,y:this.y}}function ba(b,c,d,e,f){ba._super_.call(this),d-b>=0?(this.x1=b,this.y1=c,this.x2=d,this.y2=e):(this.x1=d,this.y1=e,this.x2=b,this.y2=c),this.dx=this.x2-this.x1,this.dy=this.y2-this.y1,this.minx=Math.min(this.x1,this.x2),this.miny=Math.min(this.y1,this.y2),this.maxx=Math.max(this.x1,this.x2),this.maxy=Math.max(this.y1,this.y2),this.dot=this.x2*this.y1-this.x1*this.y2,this.xxyy=this.dx*this.dx+this.dy*this.dy,this.gradient=this.getGradient(),this.length=this.getLength(),this.direction=a.Util.initValue(f,">")}function _(){this.vector=new a.Vector2D(0,0),this.random=0,this.crossType="dead",this.alert=!0}function $(a,b){$._super_.call(this,a,b),this.gl=this.element.getContext("experimental-webgl",{antialias:!0,stencil:!1,depth:!1}),this.gl||alert("Sorry your browser do not suppest WebGL!"),this.initVar(),this.setMaxRadius(),this.initShaders(),this.initBuffers(),this.gl.blendEquation(this.gl.FUNC_ADD),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.enable(this.gl.BLEND)}function Z(a,b,c){Z._super_.call(this,a,b),this.context=this.element.getContext("2d"),this.imageData=null,this.rectangle=null,this.rectangle=c,this.createImageData(c)}function Y(a,b){Y._super_.call(this,a,b),this.stroke=null,this.context=this.element.getContext("2d"),this.bufferCache={}}function X(a,b,c){X._super_.call(this,a,b),this.stroke=c}function W(a,b){W._super_.call(this,a,b),this.stroke=null}function V(b,c,d){this.proton=b,this.element=c,this.stroke=d,this.pool=new a.Pool}function U(b,c,d){this.element=d,this.type=a.Util.initValue(b,"canvas"),this.proton=c,this.renderer=this.getRenderer()}function R(b,c,d){this.mouseTarget=a.Util.initValue(b,window),this.ease=a.Util.initValue(c,.7),this._allowEmitting=!1,this.initEventHandler(),R._super_.call(this,d)}function Q(a){this.selfBehaviours=[],Q._super_.call(this,a)}function P(b){this.initializes=[],this.particles=[],this.behaviours=[],this.emitTime=0,this.emitTotalTimes=-1,this.damping=.006,this.bindEmitter=!0,this.rate=new a.Rate(1,.1),P._super_.call(this,b),this.id="emitter_"+P.ID++}function O(b,c,d,e){O._super_.call(this,d,e),this.distanceVec=new a.Vector2D,this.centerPoint=a.Util.initValue(b,new a.Vector2D),this.force=a.Util.initValue(this.normalizeValue(c),100),this.name="GravityWell"}function N(a,b,c,d){N._super_.call(this,c,d),this.reset(a,b),this.name="Color"}function M(a,b,c,d,e){M._super_.call(this,d,e),this.reset(a,b,c),this.name="Rotate"}function L(a,b,c,d){L._super_.call(this,c,d),this.reset(a,b),this.name="Scale"}function K(a,b,c,d){K._super_.call(this,c,d),this.reset(a,b),this.name="Alpha"}function J(a,b,c,d){J._super_.call(this,c,d),this.reset(a,b),this.name="CrossZone"}function I(a,b,c,d,e){I._super_.call(this,d,e),this.reset(a,b,c),this.name="Collision"}function H(a,b,c){H._super_.call(this,0,a,b,c),this.name="Gravity"}function G(a,b,c,d,e){G._super_.call(this,a,b,c,d,e),this.force*=-1,this.name="Repulsion"}function F(a,b,c,d,e){F._super_.call(this,d,e),this.reset(a,b,c),this.time=0,this.name="RandomDrift"}function E(b,c,d,e,f){E._super_.call(this,e,f),this.targetPosition=a.Util.initValue(b,new a.Vector2D),this.radius=a.Util.initValue(d,1e3),this.force=a.Util.initValue(this.normalizeValue(c),100),this.radiusSq=this.radius*this.radius,this.attractionForce=new a.Vector2D,this.lengthSq=0,this.name="Attraction"}function D(b,c,d,e){D._super_.call(this,d,e),this.force=this.normalizeForce(new a.Vector2D(b,c)),this.name="Force"}function C(b,c,d){C._super_.call(this),this.image=this.setSpanValue(b),this.w=a.Util.initValue(c,20),this.h=a.Util.initValue(d,this.w)}function B(b,c,d){B._super_.call(this),this.radius=a.Util.setSpanValue(b,c,d)}function A(b,c,d){A._super_.call(this),this.massPan=a.Util.setSpanValue(b,c,d)}function z(b,c,d){z._super_.call(this),this.rPan=a.Util.setSpanValue(b),this.thaPan=a.Util.setSpanValue(c),this.type=a.Util.initValue(d,"vector")}function y(b){y._super_.call(this),this.zone=a.Util.initValue(b,new a.PointZone)}function x(b,c,d){x._super_.call(this),this.lifePan=a.Util.setSpanValue(b,c,d)}function v(){}function u(b,c){this.numPan=a.Util.initValue(b,1),this.timePan=a.Util.initValue(c,1),this.numPan=a.Util.setSpanValue(this.numPan),this.timePan=a.Util.setSpanValue(this.timePan),this.startTime=0,this.nextTime=0,this.init()}function t(b,c){this.id="Behaviour_"+t.id++,this.life=a.Util.initValue(b,Infinity),this.easing=a.ease.setEasingByName(c),this.age=0,this.energy=1,this.dead=!1,this.parents=[],this.name="Behaviour"}function r(a,b,c,d){this.x=a,this.y=b,this.width=c,this.height=d,this.bottom=this.y+this.height,this.right=this.x+this.width}function q(b){a.Util.isArray(b)?this.colorArr=b:this.colorArr=[b]}function p(b,c,d){this.isArray=!1,a.Util.isArray(b)?(this.isArray=!0,this.a=b):(this.a=a.Util.initValue(b,1),this.b=a.Util.initValue(c,this.a),this.center=a.Util.initValue(d,!1))}function i(){this.cID=0,this.list={}}function h(b){this.id="particle_"+h.ID++,this.reset(!0),a.Util.setPrototypeByObject(this,b)}function g(){this.mats=[],this.size=0;for(var b=0;b<20;b++)this.mats.push(a.Mat3.create([0,0,0,0,0,0,0,0,0]))}function b(){this.initialize()}function a(b,c){this.integrationType=a.Util.initValue(c,a.EULER),this.emitters=[],this.renderers=[],this.time=0,this.oldTime=0,a.pool=new a.Pool(100),a.integrator=new a.NumericalIntegration(this.integrationType)}a.POOL_MAX=1e3,a.TIME_STEP=60,a.USE_CLOCK=!1,a.MEASURE=100,a.EULER="euler",a.RK2="runge-kutta2",a.VERLET="verlet",a.PARTICLE_CREATED="partilcleCreated",a.PARTICLE_UPDATE="partilcleUpdate",a.PARTICLE_SLEEP="particleSleep",a.PARTICLE_DEAD="partilcleDead",a.PROTON_UPDATE="protonUpdate",a.PROTON_UPDATE_AFTER="protonUpdateAfter",a.EMITTER_ADDED="emitterAdded",a.EMITTER_REMOVED="emitterRemoved",a.amendChangeTabsBug=!0,a.TextureBuffer={},a.TextureCanvasBuffer={},a.prototype={addRender:function(a){a.proton=this,this.renderers.push(a.proton)},addEmitter:function(b){this.emitters.push(b),b.parent=this,this.dispatchEvent(a.EMITTER_ADDED,b)},removeEmitter:function(b){var c=this.emitters.indexOf(b);this.emitters.splice(c,1),b.parent=null,this.dispatchEvent(a.EMITTER_REMOVED,b)},update:function(){this.dispatchEvent(a.PROTON_UPDATE);if(a.USE_CLOCK){this.oldTime||(this.oldTime=(new Date).getTime());var b=(new Date).getTime();this.elapsed=(b-this.oldTime)/1e3,a.amendChangeTabsBug&&this.amendChangeTabsBug(),this.oldTime=b}else this.elapsed=.0167;if(this.elapsed>0)for(var c=0;c.5&&(this.oldTime=(new Date).getTime(),this.elapsed=0)},getCount:function(){var a=0,b=this.emitters.length;for(var c=0;c>b;return a+1},makeTranslation:function(a,b){return[1,0,0,0,1,0,a,b,1]},makeRotation:function(a){var b=Math.cos(a),c=Math.sin(a);return[b,-c,0,c,b,0,0,0,1]},makeScale:function(a,b){return[a,0,0,0,b,0,0,0,1]},matrixMultiply:function(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],i=a[6],j=a[7],k=a[8],l=b[0],m=b[1],n=b[2],o=b[3],p=b[4],q=b[5],r=b[6],s=b[7],t=b[8];return[c*l+d*o+e*r,c*m+d*p+e*s,c*n+d*q+e*t,f*l+g*o+h*r,f*m+g*p+h*s,f*n+g*q+h*t,i*l+j*o+k*r,i*m+j*p+k*s,i*n+j*q+k*t]}};a.WebGLUtil=e;var f=f||{createCanvas:function(a,b,c,d){var e=document.createElement("canvas"),f=d?d:"absolute";e.id=a,e.width=b,e.height=c,e.style.position=f,e.style.opacity=0,this.transformDom(e,-500,-500,0,0);return e},transformDom:function(a,b,c,d,e){a.style.WebkitTransform="translate("+b+"px, "+c+"px) "+"scale("+d+") "+"rotate("+e+"deg)",a.style.MozTransform="translate("+b+"px, "+c+"px) "+"scale("+d+") "+"rotate("+e+"deg)",a.style.OTransform="translate("+b+"px, "+c+"px) "+"scale("+d+") "+"rotate("+e+"deg)",a.style.msTransform="translate("+b+"px, "+c+"px) "+"scale("+d+") "+"rotate("+e+"deg)",a.style.transform="translate("+b+"px, "+c+"px) "+"scale("+d+") "+"rotate("+e+"deg)"}};a.DomUtil=f,g.prototype.set=function(b,c){c==0?a.Mat3.set(b,this.mats[0]):a.Mat3.multiply(this.mats[c-1],b,this.mats[c]),this.size=Math.max(this.size,c+1)},g.prototype.push=function(b){this.size==0?a.Mat3.set(b,this.mats[0]):a.Mat3.multiply(this.mats[this.size-1],b,this.mats[this.size]),this.size++},g.prototype.pop=function(){this.size>0&&this.size--},g.prototype.top=function(){return this.mats[this.size-1]},a.MStack=g,h.ID=0,h.prototype={getDirection:function(){return Math.atan2(this.v.x,-this.v.y)*(180/Math.PI)},reset:function(b){this.life=Infinity,this.age=0,this.energy=1,this.dead=!1,this.sleep=!1,this.target=null,this.sprite=null,this.parent=null,this.mass=1,this.radius=10,this.alpha=1,this.scale=1,this.rotation=0,this.color=null,this.easing=a.ease.setEasingByName(a.easeLinear),b?(this.transform={},this.p=new a.Vector2D,this.v=new a.Vector2D,this.a=new a.Vector2D,this.old={p:new a.Vector2D,v:new a.Vector2D,a:new a.Vector2D},this.behaviours=[]):(a.Util.destroyObject(this.transform),this.p.set(0,0),this.v.set(0,0),this.a.set(0,0),this.old.p.set(0,0),this.old.v.set(0,0),this.old.a.set(0,0),this.removeAllBehaviours()),this.transform.rgb={r:255,g:255,b:255};return this},update:function(a,b){if(!this.sleep){this.age+=a;var c=this.behaviours.length,d;for(d=0;d=this.life)this.destroy();else{var e=this.easing(this.age/this.life);this.energy=Math.max(1-e,0)}},addBehaviour:function(a){this.behaviours.push(a),a.hasOwnProperty("parents")&&a.parents.push(this),a.initialize(this)},addBehaviours:function(a){var b=a.length,c;for(c=0;c-1){var a=this.behaviours.splice(b,1);a.parents=null}},removeAllBehaviours:function(){a.Util.destroyArray(this.behaviours)},destroy:function(){this.removeAllBehaviours(),this.energy=0,this.dead=!0,this.parent=null}},a.Particle=h,i.prototype={create:function(b,c){this.cID++;return typeof b=="function"?a.Util.classApply(b,c):b.clone()},getCount:function(){var a=0;for(var b in this.list)a+=this.list[b].length;return a++},get:function(a,b){var c,d=a.__puid||j.id(a);this.list[d]&&this.list[d].length>0?c=this.list[d].pop():c=this.create(a,b),c.__puid=a.__puid||d;return c},set:function(a){return this._getList(a.__puid).push(a)},destroy:function(){for(var a in this.list)this.list[a].length=0,delete this.list[a]},_getList:function(a){a=a||"default",this.list[a]||(this.list[a]=[]);return this.list[a]}},a.Pool=i;var j={_id:0,_uids:{},id:function(a){for(var b in this._uids)if(this._uids[b]==a)return b;var c="PUID_"+this._id++;this._uids[c]=a;return c},hash:function(a){return}},k={randomAToB:function(a,b,c){return c?Math.floor(Math.random()*(b-a))+a:a+Math.random()*(b-a)},randomFloating:function(a,b,c){return k.randomAToB(a-b,a+b,c)},randomZone:function(a){},degreeTransform:function(a){return a*Math.PI/180},toColor16:function(a){return"#"+a.toString(16)},randomColor:function(){return"#"+("00000"+(Math.random()*16777216<<0).toString(16)).slice(-6)}};a.MathUtils=k;var m=function(b){this.type=a.Util.initValue(b,a.EULER)};m.prototype={integrate:function(a,b,c){this.eulerIntegrate(a,b,c)},eulerIntegrate:function(a,b,c){a.sleep||(a.old.p.copy(a.p),a.old.v.copy(a.v),a.a.multiplyScalar(1/a.mass),a.v.add(a.a.multiplyScalar(b)),a.p.add(a.old.v.multiplyScalar(b)),c&&a.v.multiplyScalar(c),a.a.clear())}},a.NumericalIntegration=m;var n=function(a,b){this.x=a||0,this.y=b||0};n.prototype={set:function(a,b){this.x=a,this.y=b;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},getGradient:function(){if(this.x!=0)return Math.atan2(this.y,this.x);if(this.y>0)return Math.PI/2;if(this.y<0)return-Math.PI/2},copy:function(a){this.x=a.x,this.y=a.y;return this},add:function(a,b){if(b!==undefined)return this.addVectors(a,b);this.x+=a.x,this.y+=a.y;return this},addXY:function(a,b){this.x+=a,this.y+=b;return this},addVectors:function(a,b){this.x=a.x+b.x,this.y=a.y+b.y;return this},addScalar:function(a){this.x+=a,this.y+=a;return this},sub:function(a,b){if(b!==undefined)return this.subVectors(a,b);this.x-=a.x,this.y-=a.y;return this},subVectors:function(a,b){this.x=a.x-b.x,this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a,this.y*=a;return this},divideScalar:function(a){a!==0?(this.x/=a,this.y/=a):this.set(0,0);return this},min:function(a){this.x>a.x&&(this.x=a.x),this.y>a.y&&(this.y=a.y);return this},max:function(a){this.x=this.x&&b<=this.bottom&&b>=this.y?!0:!1}},a.Rectangle=r;var s=s||{create:function(a){var b=new Float32Array(9);a&&this.set(a,b);return b},set:function(a,b){for(var c=0;c<9;c++)b[c]=a[c];return b},multiply:function(a,b,c){var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[6],j=a[7],k=b[0],l=b[1],m=b[2],n=b[3],o=b[4],p=b[6],q=b[7];c[0]=k*d+l*g,c[1]=k*e+l*h,c[2]=f*m,c[3]=n*d+o*g,c[4]=n*e+o*h,c[6]=p*d+q*g+i,c[7]=p*e+q*h+j;return c},inverse:function(a,b){var c=a[0],d=a[1],e=a[3],f=a[4],g=a[6],h=a[7],i=f,j=-e,k=h*e-f*g,l=c*i+d*j,m;m=1/l,b[0]=i*m,b[1]=-d*m,b[3]=j*m,b[4]=c*m,b[6]=k*m,b[7]=(-h*c+d*g)*m;return b},multiplyVec2:function(a,b,c){var d=b[0],e=b[1];c[0]=d*a[0]+e*a[3]+a[6],c[1]=d*a[1]+e*a[4]+a[7];return c}};a.Mat3=s,t.id=0,t.prototype={reset:function(b,c){this.life=a.Util.initValue(b,Infinity),this.easing=a.Util.initValue(c,a.ease.setEasingByName(a.easeLinear))},normalizeForce:function(b){return b.multiplyScalar(a.MEASURE)},normalizeValue:function(b){return b*a.MEASURE},initialize:function(a){},applyBehaviour:function(a,b,c){this.age+=b;if(this.age>=this.life||this.dead)this.energy=0,this.dead=!0,this.destroy();else{var d=this.easing(a.age/a.life);this.energy=Math.max(1-d,0)}},destroy:function(){var a,b=this.parents.length,c;for(c=0;c=this.nextTime){this.startTime=0,this.nextTime=this.timePan.getValue();return this.numPan.b==1?this.numPan.getValue(!1)>.5?1:0:this.numPan.getValue(!0)}return 0}},a.Rate=u,v.prototype.reset=function(){},v.prototype.init=function(a,b){b?this.initialize(b):this.initialize(a)},v.prototype.initialize=function(a){},a.Initialize=v;var w={initialize:function(b,c,d){var e=d.length,f;for(f=0;f4e-6&&this.lengthSq=this.delay&&(b.a.addXY(a.MathUtils.randomAToB(-this.panFoce.x,this.panFoce.x),a.MathUtils.randomAToB(-this.panFoce.y,this.panFoce.y)),this.time=0)},a.RandomDrift=F,a.Util.inherits(G,a.Attraction),G.prototype.reset=function(a,b,c,d,e){G._super_.prototype.reset.call(this,a,b,c,d,e),this.force*=-1},a.Repulsion=G,a.Util.inherits(H,a.Force),H.prototype.reset=function(a,b,c){H._super_.prototype.reset.call(this,0,a,b,c)},a.Gravity=H,a.G=H,a.Util.inherits(I,a.Behaviour),I.prototype.reset=function(b,c,d,e,f){this.emitter=a.Util.initValue(b,null),this.mass=a.Util.initValue(c,!0),this.callback=a.Util.initValue(d,null),this.collisionPool=[],this.delta=new a.Vector2D,e&&I._super_.prototype.reset.call(this,e,f)},I.prototype.applyBehaviour=function(a,b,c){var d=this.emitter?this.emitter.particles.slice(c):this.pool.slice(c),e,f,g,h,i,j=d.length;for(var k=0;k-1&&this.initializes.splice(b,1)},P.prototype.removeInitializers=function(){a.Util.destroyArray(this.initializes)},P.prototype.addBehaviour=function(){var a=arguments.length,b;for(b=0;b-1&&this.behaviours.splice(b,1)},P.prototype.removeAllBehaviours=function(){a.Util.destroyArray(this.behaviours)},P.prototype.integrate=function(b){var c=1-this.damping;a.integrator.integrate(this,b,c);var d=this.particles.length,e;for(e=0;e=this.life||this.dead)&&this.destroy(),this.emitting(b),this.integrate(b);var c,d=this.particles.length,e;for(e=d-1;e>=0;e--)c=this.particles[e],c.dead&&(this.dispatchEvent(a.PARTICLE_DEAD,c),a.pool.set(c),this.particles.splice(e,1))},P.prototype.setupParticle=function(b,c,d){var e=this.initializes,f=this.behaviours;c&&(c instanceof Array?e=c:e=[c]),d&&(d instanceof Array?f=d:f=[d]),b.reset(),a.InitializeUtil.initialize(this,b,e),b.addBehaviours(f),b.parent=this,this.particles.push(b)},P.prototype.destroy=function(){this.dead=!0,this.emitTotalTimes=-1,this.particles.length==0&&(this.removeInitializers(),this.removeAllBehaviours(),this.parent&&this.parent.removeEmitter(this))},a.Emitter=P,a.Util.inherits(Q,a.Emitter),Q.prototype.addSelfBehaviour=function(){var a=arguments.length,b;for(b=0;b-1&&this.selfBehaviours.splice(b,1)},Q.prototype.update=function(a){Q._super_.prototype.update.call(this,a);if(!this.sleep){var b=this.selfBehaviours.length,c;for(c=0;cthis.element.width||c<0||c>this.elementwidth)){var f=((c>>0)*a.width+(b>>0))*4;a.data[f]=e.r,a.data[f+1]=e.g,a.data[f+2]=e.b,a.data[f+3]=d.alpha*255}},Z.prototype.onParticleDead=function(a){},a.PixelRender=Z,a.Util.inherits($,a.BaseRender),$.prototype.resize=function(a,b){this.umat[4]=-2,this.umat[7]=1,this.smat[0]=1/a,this.smat[4]=1/b,this.mstack.set(this.umat,0),this.mstack.set(this.smat,1),this.gl.viewport(0,0,a,b),this.element.width=a,this.element.height=b},$.prototype.setMaxRadius=function(a){this.circleCanvasURL=this.createCircle(a)},$.prototype.getVertexShader=function(){var a=["uniform vec2 viewport;","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","uniform mat3 tMat;","varying vec2 vTextureCoord;","varying float alpha;","void main() {","vec3 v = tMat * vec3(aVertexPosition, 1.0);","gl_Position = vec4(v.x, v.y, 0, 1);","vTextureCoord = aTextureCoord;","alpha = tMat[0][2];","}"].join("\n");return a},$.prototype.getFragmentShader=function(){var a=["precision mediump float;","varying vec2 vTextureCoord;","varying float alpha;","uniform sampler2D uSampler;","uniform vec4 color;","uniform bool useTexture;","uniform vec3 uColor;","void main() {","vec4 textureColor = texture2D(uSampler, vTextureCoord);","gl_FragColor = textureColor * vec4(uColor, 1.0);","gl_FragColor.w *= alpha;","}"].join("\n");return a},$.prototype.initVar=function(){this.mstack=new a.MStack,this.umat=a.Mat3.create([2,0,1,0,-2,0,-1,1,1]),this.smat=a.Mat3.create([.01,0,1,0,.01,0,0,0,1]),this.texturebuffers={}},$.prototype.start=function(){$._super_.prototype.start.call(this),this.resize(this.element.width,this.element.height)},$.prototype.blendEquation=function(a){this.gl.blendEquation(this.gl[a])},$.prototype.blendFunc=function(a,b){this.gl.blendFunc(this.gl[a],this.gl[b])},$.prototype.getShader=function(a,b,c){var d;c?d=a.createShader(a.FRAGMENT_SHADER):d=a.createShader(a.VERTEX_SHADER),a.shaderSource(d,b),a.compileShader(d);if(!a.getShaderParameter(d,a.COMPILE_STATUS)){alert(a.getShaderInfoLog(d));return null}return d},$.prototype.initShaders=function(){var a=this.getShader(this.gl,this.getFragmentShader(),!0),b=this.getShader(this.gl,this.getVertexShader(),!1);this.sprogram=this.gl.createProgram(),this.gl.attachShader(this.sprogram,b),this.gl.attachShader(this.sprogram,a),this.gl.linkProgram(this.sprogram),this.gl.getProgramParameter(this.sprogram,this.gl.LINK_STATUS)||alert("Could not initialise shaders"),this.gl.useProgram(this.sprogram),this.sprogram.vpa=this.gl.getAttribLocation(this.sprogram,"aVertexPosition"),this.sprogram.tca=this.gl.getAttribLocation(this.sprogram,"aTextureCoord"),this.gl.enableVertexAttribArray(this.sprogram.tca),this.gl.enableVertexAttribArray(this.sprogram.vpa),this.sprogram.tMatUniform=this.gl.getUniformLocation(this.sprogram,"tMat"),this.sprogram.samplerUniform=this.gl.getUniformLocation(this.sprogram,"uSampler"),this.sprogram.useTex=this.gl.getUniformLocation(this.sprogram,"useTexture"),this.sprogram.color=this.gl.getUniformLocation(this.sprogram,"uColor"),this.gl.uniform1i(this.sprogram.useTex,1)},$.prototype.initBuffers=function(){this.unitIBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.unitIBuffer);var a=[0,3,1,0,2,3];this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,new Uint16Array(a),this.gl.STATIC_DRAW);var b=[];for(var c=0;c<100;c++)b.push(c);idx=new Uint16Array(b),this.unitI33=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.unitI33),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,idx,this.gl.STATIC_DRAW),b=[];for(c=0;c<100;c++)b.push(c,c+1,c+2);idx=new Uint16Array(b),this.stripBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.stripBuffer),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,idx,this.gl.STATIC_DRAW)},$.prototype.createCircle=function(b){this.circleCanvasRadius=a.WebGLUtil.nhpot(a.Util.initValue(b,32));var c=a.DomUtil.createCanvas("circle_canvas",this.circleCanvasRadius*2,this.circleCanvasRadius*2),d=c.getContext("2d");d.beginPath(),d.arc(this.circleCanvasRadius,this.circleCanvasRadius,this.circleCanvasRadius,0,Math.PI*2,!0),d.closePath(),d.fillStyle="#FFF",d.fill();return c.toDataURL()},$.prototype.setImgInCanvas=function(b){var c=b.target.width,d=b.target.height,e=a.WebGLUtil.nhpot(b.target.width),f=a.WebGLUtil.nhpot(b.target.height),g=b.target.width/e,h=b.target.height/f;this.texturebuffers[b.transform.src]||(this.texturebuffers[b.transform.src]=[this.gl.createTexture(),this.gl.createBuffer(),this.gl.createBuffer()]),b.transform.texture=this.texturebuffers[b.transform.src][0],b.transform.vcBuffer=this.texturebuffers[b.transform.src][1],b.transform.tcBuffer=this.texturebuffers[b.transform.src][2],this.gl.bindBuffer(this.gl.ARRAY_BUFFER,b.transform.tcBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([0,0,g,0,0,h,h,h]),this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,b.transform.vcBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([0,0,c,0,0,d,c,d]),this.gl.STATIC_DRAW);var i=b.transform.canvas.getContext("2d"),j=i.getImageData(0,0,e,f);this.gl.bindTexture(this.gl.TEXTURE_2D,b.transform.texture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,j),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_NEAREST),this.gl.generateMipmap(this.gl.TEXTURE_2D),b.transform.textureLoaded=!0,b.transform.textureWidth=c,b.transform.textureHeight=d},$.prototype.setStroke=function(a,b){},$.prototype.onProtonUpdate=function(){},$.prototype.onParticleCreated=function(b){var c=this;b.transform.textureLoaded=!1,b.transform.tmat=a.Mat3.create(),b.transform.tmat[8]=1,b.transform.imat=a.Mat3.create(),b.transform.imat[8]=1,b.target?a.Util.getImage(b.target,b,!0,function(a){c.setImgInCanvas.call(c,a),a.transform.oldScale=1}):a.Util.getImage(this.circleCanvasURL,b,!0,function(a){c.setImgInCanvas.call(c,a),a.transform.oldScale=a.radius/c.circleCanvasRadius})},$.prototype.onParticleUpdate=function(a){a.transform.textureLoaded&&(this.updateMatrix(a),this.gl.uniform3f(this.sprogram.color,a.transform.rgb.r/255,a.transform.rgb.g/255,a.transform.rgb.b/255),this.gl.uniformMatrix3fv(this.sprogram.tMatUniform,!1,this.mstack.top()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,a.transform.vcBuffer),this.gl.vertexAttribPointer(this.sprogram.vpa,2,this.gl.FLOAT,!1,0,0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,a.transform.tcBuffer),this.gl.vertexAttribPointer(this.sprogram.tca,2,this.gl.FLOAT,!1,0,0),this.gl.bindTexture(this.gl.TEXTURE_2D,a.transform.texture),this.gl.uniform1i(this.sprogram.samplerUniform,0),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.unitIBuffer),this.gl.drawElements(this.gl.TRIANGLES,6,this.gl.UNSIGNED_SHORT,0),this.mstack.pop())},$.prototype.onParticleDead=function(a){},$.prototype.updateMatrix=function(b){var c=a.WebGLUtil.makeTranslation(-b.transform.textureWidth/2,-b.transform.textureHeight/2),d=a.WebGLUtil.makeTranslation(b.p.x,b.p.y),e=b.rotation*(Math.PI/180),f=a.WebGLUtil.makeRotation(e),g=b.scale*b.transform.oldScale,h=a.WebGLUtil.makeScale(g,g),i=a.WebGLUtil.matrixMultiply(c,h);i=a.WebGLUtil.matrixMultiply(i,f),i=a.WebGLUtil.matrixMultiply(i,d),a.Mat3.inverse(i,b.transform.imat),i[2]=b.alpha,this.mstack.push(i)},a.WebGLRender=$,_.prototype={getPosition:function(){},crossing:function(a){}},a.Zone=_,a.Util.inherits(ba,a.Zone),ba.prototype.getPosition=function(){this.random=Math.random(),this.vector.x=this.x1+this.random*this.length*Math.cos(this.gradient),this.vector.y=this.y1+this.random*this.length*Math.sin(this.gradient);return this.vector},ba.prototype.getDirection=function(a,b){var c=this.dy,d=-this.dx,e=this.dot,f=d==0?1:d;return(c*a+d*b+e)*f>0?!0:!1},ba.prototype.getDistance=function(a,b){var c=this.dy,d=-this.dx,e=this.dot,f=c*a+d*b+e;return f/Math.sqrt(this.xxyy)},ba.prototype.getSymmetric=function(a){var b=a.getGradient(),c=this.getGradient(),d=2*(c-b),e=a.x,f=a.y;a.x=e*Math.cos(d)-f*Math.sin(d),a.y=e*Math.sin(d)+f*Math.cos(d);return a},ba.prototype.getGradient=function(){return Math.atan2(this.dy,this.dx)},ba.prototype.getRange=function(a,b){var c=Math.abs(this.getGradient());c<=Math.PI/4?a.p.xthis.minx&&b():a.p.ythis.miny&&b()},ba.prototype.getLength=function(){return Math.sqrt(this.dx*this.dx+this.dy*this.dy)},ba.prototype.crossing=function(a){var b=this;this.crossType=="dead"?this.direction==">"||this.direction=="R"||this.direction=="right"||this.direction=="down"?this.getRange(a,function(){b.getDirection(a.p.x,a.p.y)&&(a.dead=!0)}):this.getRange(a,function(){b.getDirection(a.p.x,a.p.y)||(a.dead=!0)}):this.crossType=="bound"?this.getRange(a,function(){b.getDistance(a.p.x,a.p.y)<=a.radius&&(b.dx==0?a.v.x*=-1:b.dy==0?a.v.y*=-1:b.getSymmetric(a.v))}):this.crossType=="cross"&&this.alert&&(alert("Sorry lineZone does not support cross method"),this.alert=!1)},a.LineZone=ba,a.Util.inherits(bb,a.Zone),bb.prototype.getPosition=function(){this.random=Math.random(),this.angle=Math.PI*2*Math.random(),this.vector.x=this.x+this.random*this.radius*Math.cos(this.angle),this.vector.y=this.y+this.random*this.radius*Math.sin(this.angle);return this.vector},bb.prototype.setCenter=function(a,b){this.center.x=a,this.center.y=b},bb.prototype.crossing=function(a){var b=a.p.distanceTo(this.center);this.crossType=="dead"?b-a.radius>this.radius&&(a.dead=!0):this.crossType=="bound"?b+a.radius>=this.radius&&this.getSymmetric(a):this.crossType=="cross"&&this.alert&&(alert("Sorry CircleZone does not support cross method"),this.alert=!1)},bb.prototype.getSymmetric=function(a){var b=a.v.getGradient(),c=this.getGradient(a),d=2*(c-b),e=a.v.x,f=a.v.y;a.v.x=e*Math.cos(d)-f*Math.sin(d),a.v.y=e*Math.sin(d)+f*Math.cos(d)},bb.prototype.getGradient=function(a){return-Math.PI/2+Math.atan2(a.p.y-this.center.y,a.p.x-this.center.x)},a.CircleZone=bb,a.Util.inherits(bc,a.Zone),bc.prototype.getPosition=function(){this.vector.x=this.x,this.vector.y=this.y;return this.vector},bc.prototype.crossing=function(a){this.alert&&(alert("Sorry PointZone does not support crossing method"),this.alert=!1)},a.PointZone=bc,a.Util.inherits(bd,a.Zone),bd.prototype.getPosition=function(){this.vector.x=this.x+Math.random()*this.width,this.vector.y=this.y+Math.random()*this.height;return this.vector},bd.prototype.crossing=function(a){this.crossType=="dead"?(a.p.x+a.radiusthis.x+this.width&&(a.dead=!0),a.p.y+a.radiusthis.y+this.height&&(a.dead=!0)):this.crossType=="bound"?(a.p.x-a.radiusthis.x+this.width&&(a.p.x=this.x+this.width-a.radius,a.v.x*=-1),a.p.y-a.radiusthis.y+this.height&&(a.p.y=this.y+this.height-a.radius,a.v.y*=-1)):this.crossType=="cross"&&(a.p.x+a.radiusthis.x+this.width&&a.v.x>=0&&(a.p.x=this.x-a.radius),a.p.y+a.radiusthis.y+this.height&&a.v.y>=0&&(a.p.y=this.y-a.radius))},a.RectZone=bd,a.Util.inherits(be,a.Zone),be.prototype.reset=function(b,c,d,e){this.imageData=b,this.x=a.Util.initValue(c,0),this.y=a.Util.initValue(d,0),this.d=a.Util.initValue(e,2),this.vectors=[],this.setVectors()},be.prototype.setVectors=function(){var a,b,c=this.imageData.width,d=this.imageData.height;for(a=0;a>0)*c+(a>>0))*4;this.imageData.data[e+3]>0&&this.vectors.push({x:a+this.x,y:b+this.y})}return this.vector},be.prototype.getBound=function(a,b){var c=((b>>0)*this.imageData.width+(a>>0))*4;return this.imageData.data[c+3]>0?!0:!1},be.prototype.getPosition=function(){return this.vector.copy(this.vectors[Math.floor(Math.random()*this.vectors.length)])},be.prototype.getColor=function(a,b){a-=this.x,b-=this.y;var c=((b>>0)*this.imageData.width+(a>>0))*4;return{r:this.imageData.data[c],g:this.imageData.data[c+1],b:this.imageData.data[c+2],a:this.imageData.data[c+3]}},be.prototype.crossing=function(a){this.crossType=="dead"?this.getBound(a.p.x-this.x,a.p.y-this.y)?a.dead=!0:a.dead=!1:this.crossType=="bound"&&(this.getBound(a.p.x-this.x,a.p.y-this.y)||a.v.negate())},a.ImageZone=be;var bf=bf||{addEventListener:function(b,c){b.addEventListener(a.PROTON_UPDATE,function(){c()})},setStyle:function(b){var c=b||"#ff0000",d=a.Util.hexToRGB(c),e="rgba("+d.r+","+d.g+","+d.b+","+.5+")";return e},drawZone:function(b,c,d,e){var f=c.getContext("2d"),g=this.setStyle();this.addEventListener(b,function(){e&&f.clearRect(0,0,c.width,c.height),d instanceof a.PointZone?(f.beginPath(),f.fillStyle=g,f.arc(d.x,d.y,10,0,Math.PI*2,!0),f.fill(),f.closePath()):d instanceof a.LineZone?(f.beginPath(),f.strokeStyle=g,f.moveTo(d.x1,d.y1),f.lineTo(d.x2,d.y2),f.stroke(),f.closePath()):d instanceof a.RectZone?(f.beginPath(),f.strokeStyle=g,f.drawRect(d.x,d.y,d.width,d.height),f.stroke(),f.closePath()):d instanceof a.CircleZone&&(f.beginPath(),f.strokeStyle=g,f.arc(d.x,d.y,d.radius,0,Math.PI*2,!0),f.stroke(),f.closePath())})},drawEmitter:function(a,b,c,d){var e=b.getContext("2d"),f=this.setStyle();this.addEventListener(a,function(){d&&e.clearRect(0,0,b.width,b.height),e.beginPath(),e.fillStyle=f,e.arc(c.p.x,c.p.y,10,0,Math.PI*2,!0),e.fill(),e.closePath()})},test:{},setTest:function(a,b){this.test[a]=b},getTest:function(a){return this.test.hasOwnProperty(a)?this.test[a]:!1}};a.Debug=bf,function(){var a=0,b=["ms","moz","webkit","o"];for(var c=0;c0?e.PI_2:this.y<0?-e.PI_2:void 0}},{key:"copy",value:function(t){return this.x=t.x,this.y=t.y,this}},{key:"add",value:function(t,e){return void 0!==e?this.addVectors(t,e):(this.x+=t.x,this.y+=t.y,this)}},{key:"addXY",value:function(t,e){return this.x+=t,this.y+=e,this}},{key:"addVectors",value:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}},{key:"sub",value:function(t,e){return void 0!==e?this.subVectors(t,e):(this.x-=t.x,this.y-=t.y,this)}},{key:"subVectors",value:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}},{key:"divideScalar",value:function(t){return 0!==t?(this.x/=t,this.y/=t):this.set(0,0),this}},{key:"multiplyScalar",value:function(t){return this.x*=t,this.y*=t,this}},{key:"negate",value:function(){return this.multiplyScalar(-1)}},{key:"dot",value:function(t){return this.x*t.x+this.y*t.y}},{key:"lengthSq",value:function(){return this.x*this.x+this.y*this.y}},{key:"length",value:function(){return Math.sqrt(this.x*this.x+this.y*this.y)}},{key:"normalize",value:function(){return this.divideScalar(this.length())}},{key:"distanceTo",value:function(t){return Math.sqrt(this.distanceToSquared(t))}},{key:"rotate",value:function(t){var e=this.x,i=this.y;return this.x=e*Math.cos(t)+i*Math.sin(t),this.y=-e*Math.sin(t)+i*Math.cos(t),this}},{key:"distanceToSquared",value:function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i}},{key:"lerp",value:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}},{key:"equals",value:function(t){return t.x===this.x&&t.y===this.y}},{key:"clear",value:function(){return this.x=0,this.y=0,this}},{key:"clone",value:function(){return new t(this.x,this.y)}}]),t}(),l=function(){function t(e,i,n){r(this,t),this.isArray=!1,x.isArray(e)?(this.isArray=!0,this.a=e):(this.a=x.initValue(e,1),this.b=x.initValue(i,this.a),this.center=x.initValue(n,!1))}return n(t,[{key:"getValue",value:function(t){return this.isArray?this.a[Math.floor(this.a.length*Math.random())]:this.center?e.randomFloating(this.a,this.b,t):e.randomAToB(this.a,this.b,t)}}]),t}(),u=function(t){--t;for(var e=1;e<32;e<<=1)t|=t>>e;return t+1},c=function(t,e){return[1,0,0,0,1,0,t,e,1]},f=function(t){var e=Math.cos(t),i=Math.sin(t);return[e,-i,0,i,e,0,0,0,1]},d=function(t,e){return[t,0,0,0,e,0,0,0,1]},y=function(t,e){var i=t[0],r=t[1],n=t[2],a=t[3],s=t[4],o=t[5],h=t[6],l=t[7],u=t[8],c=e[0],f=e[1],d=e[2],y=e[3],p=e[4],v=e[5],g=e[6],m=e[7],b=e[8];return[i*c+r*y+n*g,i*f+r*p+n*m,i*d+r*v+n*b,a*c+s*y+o*g,a*f+s*p+o*m,a*d+s*v+o*b,h*c+l*y+u*g,h*f+l*p+u*m,h*d+l*v+u*b]},p={createCanvas:function(t,e,i,r){var n=document.createElement("canvas");return r=r||"absolute",n.id=t,n.width=e,n.height=i,n.style.opacity=0,n.style.position=r,this.transform(n,-500,-500,0,0),n},createDiv:function(t,e,i){var r=document.createElement("div");return r.id=t,r.style.position="absolute",this.resize(r,e,i),r},resize:function(t,e,i){t.style.width=e+"px",t.style.height=i+"px",t.style.marginLeft=-e/2+"px",t.style.marginTop=-i/2+"px"},transform:function(t,e,i,r,n){var a="translate("+e+"px, "+i+"px) scale("+r+") rotate("+n+"deg)";t.style.willChange="transform",this.css3(t,"transform",a)},transform3d:function(t,e,i,r,n){var a="translate3d("+e+"px, "+i+"px, 0) scale("+r+") rotate("+n+"deg)";t.style.willChange="transform",this.css3(t,"backfaceVisibility","hidden"),this.css3(t,"transform",a)},css3:function(t,e,i){var r=e.charAt(0).toUpperCase()+e.substr(1);t.style["Webkit"+r]=i,t.style["Moz"+r]=i,t.style["O"+r]=i,t.style["ms"+r]=i,t.style[""+e]=i}},v={},g={},m=function(t,e,i){t.drawImage(e,i.x,i.y);var r=t.getImageData(i.x,i.y,i.width,i.height);return t.clearRect(i.x,i.y,i.width,i.height),r},b=function(t,e,i){var r="string"==typeof t?t:t.src;if(v[r])e(v[r],i);else{var n=new Image;n.onload=function(t){v[r]=t.target,e(v[r],i)},n.src=r}},_=function(t,e,i){var r=t.src;if(!g[r]){var n=u(t.width),a=u(t.height),s=p.createCanvas("canvas_cache_0",n,a);s.getContext("2d").drawImage(t,0,0,t.width,t.height),g[r]=s}return e&&e(g[r],i),g[r]},x={initValue:function(t,e){return t=null!==t&&void 0!==t?t:e},isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},destroyArray:function(t){t&&(t.length=0)},destroyObject:function(t,e){for(var i in t)e&&e.indexOf(i)>-1||delete t[i]},classApply:function(t,e){return e?(e=[null].concat(e),new(t.bind.apply(t,e))):new t},setVector2DByObject:function(t,e){this.hasProp(e,"x")&&(t.p.x=e.x),this.hasProp(e,"y")&&(t.p.y=e.y),this.hasProp(e,"vx")&&(t.v.x=e.vx),this.hasProp(e,"vy")&&(t.v.y=e.vy),this.hasProp(e,"ax")&&(t.a.x=e.ax),this.hasProp(e,"ay")&&(t.a.y=e.ay),this.hasProp(e,"p")&&particle.p.copy(e.p),this.hasProp(e,"v")&&particle.v.copy(e.v),this.hasProp(e,"a")&&particle.a.copy(e.a),this.hasProp(e,"position")&&particle.p.copy(e.position),this.hasProp(e,"velocity")&&particle.v.copy(e.velocity),this.hasProp(e,"accelerate")&&particle.a.copy(e.accelerate)},hasProp:function(t,e){return!!t&&void 0!==t[e]},setPrototypeByObject:function(t,e,i){for(var r in e)t.hasOwnProperty(r)&&(i?i.indexOf(r)<0&&(t[r]=this.getSpanValue(e[r])):t[r]=this.getSpanValue(e[r]));return t},setSpanValue:function(t,e,i){return t instanceof l?t:e?i?new l(t,e,i):new l(t,e):new l(t)},getSpanValue:function(t){return t instanceof l?t.getValue():t},getImageData:function(t,e,i){return m(t,e,i)},destroy:function(t,e){for(var i=t.length;i--;){try{t[i].destroy(e)}catch(t){}delete t[i]}t.length=0}},k={id:0,cache:{},getID:function(t){var e=this.getCacheID(t);return e||(e="PUID_"+this.id++,this.cache[e]=t,e)},getCacheID:function(t){var e=void 0;for(var r in this.cache){if((e=this.cache[r])===t)return r;if("object"===(void 0===e?"undefined":i(e))&&"object"===(void 0===t?"undefined":i(t))&&e.isInner&&t.isInner&&e.src===t.src)return r}return null},getTarget:function(t){return this.cache[t]}},P=function(){function t(e){r(this,t),this.total=0,this.cache={}}return n(t,[{key:"get",value:function(t,e,i){var r=void 0;return i=i||t.__puid||k.getID(t),(r=this.cache[i]&&this.cache[i].length>0?this.cache[i].pop():this.createOrClone(t,e)).__puid=t.__puid||i,r}},{key:"expire",value:function(t){return this.getCache(t.__puid).push(t)}},{key:"createOrClone",value:function(t,e){return this.total++,this.create?this.create(t,e):"function"==typeof t?x.classApply(t,e):t.clone()}},{key:"getCount",value:function(){var t=0;for(var e in this.cache)t+=this.cache[e].length;return t++}},{key:"destroy",value:function(){for(var t in this.cache)this.cache[t].length=0,delete this.cache[t]}},{key:"getCache",value:function(t){return t=t||"default",this.cache[t]||(this.cache[t]=[]),this.cache[t]}}]),t}(),E=function(){function t(e){r(this,t),this.proton=e,this.container=null,this.type=1,this.emitterIndex=0,this.rendererIndex=0}return n(t,[{key:"update",value:function(t,e){this.add(t,e);var i=this.getEmitter(),r=this.getRenderer(),n="";switch(this.type){case 2:n+="emitter:"+this.proton.emitters.length+"
",i&&(n+="em speed:"+i.emitSpeed+"
"),i&&(n+="pos:"+this.getEmitterPos(i));break;case 3:i&&(n+="initializes:"+i.initializes.length+"
"),i&&(n+=""+this.concatArr(i.initializes)+"
"),i&&(n+="behaviours:"+i.behaviours.length+"
"),i&&(n+=""+this.concatArr(i.behaviours)+"
");break;case 4:r&&(n+=r.name+"
"),r&&(n+="body:"+this.getCreatedNumber(r)+"
");break;default:n+="particles:"+this.proton.getCount()+"
",n+="pool:"+this.proton.pool.getCount()+"
",n+="total:"+this.proton.pool.total}this.container.innerHTML=n}},{key:"add",value:function(t,e){var i=this;if(!this.container){this.type=1,this.container=document.createElement("div"),this.container.style.cssText=["position:absolute;bottom:0px;left:0;cursor:pointer;","opacity:0.9;z-index:10000;padding:10px;font-size:12px;","width:120px;height:50px;background-color:#002;color:#0ff;"].join(""),this.container.addEventListener("click",function(t){i.type++,i.type>4&&(i.type=1)},!1);var r=void 0,n=void 0;switch(t){case 2:r="#201",n="#f08";break;case 3:r="#020",n="#0f0";break;default:r="#002",n="#0ff"}this.container.style["background-color"]=r,this.container.style.color=n}this.container.parentNode||(e=e||this.body||document.body).appendChild(this.container)}},{key:"getEmitter",value:function(){return this.proton.emitters[this.emitterIndex]}},{key:"getRenderer",value:function(){return this.proton.renderers[this.rendererIndex]}},{key:"concatArr",value:function(t){var e="";if(!t||!t.length)return e;for(var i=0;i0&&this.emittersUpdate(this.elapsed),this.dispatchEvent(t.PROTON_UPDATE_AFTER)}},{key:"emittersUpdate",value:function(t){for(var e=this.emitters.length;e--;)this.emitters[e].update(t)}},{key:"amendChangeTabsBug",value:function(){this.elapsed>.5&&(this.oldTime=(new Date).getTime(),this.elapsed=0)}},{key:"getCount",value:function(){for(var t=0,e=this.emitters.length;e--;)t+=this.emitters[e].particles.length;return t}},{key:"getAllParticles",value:function(){for(var t=[],e=this.emitters.length;e--;)t=t.concat(this.emitters[e].particles);return t}},{key:"destroy",value:function(){x.destroy(this.renderers,this.getAllParticles()),x.destroy(this.emitters),this.time=0,this.oldTime=0,this.pool.destroy()}}]),t}();R.USE_CLOCK=!1,R.MEASURE=100,R.EULER="euler",R.RK2="runge-kutta2",R.PARTICLE_CREATED="PARTICLE_CREATED",R.PARTICLE_UPDATE="PARTICLE_UPDATE",R.PARTICLE_SLEEP="PARTICLE_SLEEP",R.PARTICLE_DEAD="PARTICLE_DEAD",R.PROTON_UPDATE="PROTON_UPDATE",R.PROTON_UPDATE_AFTER="PROTON_UPDATE_AFTER",R.EMITTER_ADDED="EMITTER_ADDED",R.EMITTER_REMOVED="EMITTER_REMOVED",R.amendChangeTabsBug=!0,R.bindEmtterEvent=!1,A.bind(R);var w={easeLinear:function(t){return t},easeInQuad:function(t){return Math.pow(t,2)},easeOutQuad:function(t){return-(Math.pow(t-1,2)-1)},easeInOutQuad:function(t){return(t/=.5)<1?.5*Math.pow(t,2):-.5*((t-=2)*t-2)},easeInCubic:function(t){return Math.pow(t,3)},easeOutCubic:function(t){return Math.pow(t-1,3)+1},easeInOutCubic:function(t){return(t/=.5)<1?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)},easeInQuart:function(t){return Math.pow(t,4)},easeOutQuart:function(t){return-(Math.pow(t-1,4)-1)},easeInOutQuart:function(t){return(t/=.5)<1?.5*Math.pow(t,4):-.5*((t-=2)*Math.pow(t,3)-2)},easeInSine:function(t){return 1-Math.cos(t*e.PI_2)},easeOutSine:function(t){return Math.sin(t*e.PI_2)},easeInOutSine:function(t){return-.5*(Math.cos(e.PI*t)-1)},easeInExpo:function(t){return 0===t?0:Math.pow(2,10*(t-1))},easeOutExpo:function(t){return 1===t?1:1-Math.pow(2,-10*t)},easeInOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*--t))},easeInCirc:function(t){return-(Math.sqrt(1-t*t)-1)},easeOutCirc:function(t){return Math.sqrt(1-Math.pow(t-1,2))},easeInOutCirc:function(t){return(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInBack:function(t){return t*t*(2.70158*t-1.70158)},easeOutBack:function(t){return(t-=1)*t*(2.70158*t+1.70158)+1},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},getEasing:function(t){return"function"==typeof t?t:this[t]||this.easeLinear}},O=function(){function t(e){r(this,t),this.id="particle_"+t.ID++,this.reset("init"),e&&x.setPrototypeByObject(this,e)}return n(t,[{key:"getDirection",value:function(){return Math.atan2(this.v.x,-this.v.y)*e.N180_PI}},{key:"reset",value:function(t){return this.life=1/0,this.age=0,this.energy=1,this.dead=!1,this.sleep=!1,this.body=null,this.sprite=null,this.parent=null,this.mass=1,this.radius=10,this.alpha=1,this.scale=1,this.rotation=0,this.color=null,this.easing=w.easeLinear,"init"==t?(this.transform={},this.p=new h,this.v=new h,this.a=new h,this.old={p:new h,v:new h,a:new h},this.behaviours=[]):(x.destroyObject(this.transform,"rgb"),this.p.set(0,0),this.v.set(0,0),this.a.set(0,0),this.old.p.set(0,0),this.old.v.set(0,0),this.old.a.set(0,0),this.removeAllBehaviours()),this.transform.rgb?(this.transform.rgb.r=255,this.transform.rgb.g=255,this.transform.rgb.b=255):this.transform.rgb={r:255,g:255,b:255},this}},{key:"update",value:function(t,e){if(this.sleep||(this.age+=t,this.applyBehaviours(t,e)),this.age-1&&(this.behaviours.splice(e,1).parents=null)}},{key:"removeAllBehaviours",value:function(){x.destroyArray(this.behaviours)}},{key:"destroy",value:function(){this.removeAllBehaviours(),this.energy=0,this.dead=!0,this.parent=null}}]),t}();O.ID=0;var C={hexToRGB:function(t){var e="#"==t.charAt(0)?t.substring(1,7):t;return{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16)}},rgbToHex:function(t){return"rgb("+t.r+", "+t.g+", "+t.b+")"},getHex16FromParticle:function(t){return 65536*Number(t.transform.rgb.r)+256*Number(t.transform.rgb.g)+Number(t.transform.rgb.b)}},S=function(){function t(e,i){r(this,t),this.r=Math.abs(e)||0,this.tha=i||0}return n(t,[{key:"set",value:function(t,e){return this.r=t,this.tha=e,this}},{key:"setR",value:function(t){return this.r=t,this}},{key:"setTha",value:function(t){return this.tha=t,this}},{key:"copy",value:function(t){return this.r=t.r,this.tha=t.tha,this}},{key:"toVector",value:function(){return new h(this.getX(),this.getY())}},{key:"getX",value:function(){return this.r*Math.sin(this.tha)}},{key:"getY",value:function(){return-this.r*Math.cos(this.tha)}},{key:"normalize",value:function(){return this.r=1,this}},{key:"equals",value:function(t){return t.r===this.r&&t.tha===this.tha}},{key:"clear",value:function(){return this.r=0,this.tha=0,this}},{key:"clone",value:function(){return new t(this.r,this.tha)}}]),t}(),I={create:function(t){var e=new Float32Array(9);return t&&this.set(t,e),e},set:function(t,e){for(var i=0;i<9;i++)e[i]=t[i];return e},multiply:function(t,e,i){var r=t[0],n=t[1],a=t[2],s=t[3],o=t[4],h=t[6],l=t[7],u=e[0],c=e[1],f=e[2],d=e[3],y=e[4],p=e[6],v=e[7];return i[0]=u*r+c*s,i[1]=u*n+c*o,i[2]=a*f,i[3]=d*r+y*s,i[4]=d*n+y*o,i[6]=p*r+v*s+h,i[7]=p*n+v*o+l,i},inverse:function(t,e){var i,r=t[0],n=t[1],a=t[3],s=t[4],o=t[6],h=t[7],l=s,u=-a,c=h*a-s*o;return i=1/(r*l+n*u),e[0]=l*i,e[1]=-n*i,e[3]=u*i,e[4]=r*i,e[6]=c*i,e[7]=(-h*r+n*o)*i,e},multiplyVec2:function(t,e,i){var r=e[0],n=e[1];return i[0]=r*t[0]+n*t[3]+t[6],i[1]=r*t[1]+n*t[4]+t[7],i}},D=function(t){function i(t){r(this,i);var e=o(this,(i.__proto__||Object.getPrototypeOf(i)).call(this));return e._arr=x.isArray(t)?t:[t],e}return s(i,l),n(i,[{key:"getValue",value:function(){var t=this._arr[Math.floor(this._arr.length*Math.random())];return"random"===t||"Random"===t?e.randomColor():t}}],[{key:"createArraySpan",value:function(t){return t?t instanceof i?t:new i(t):null}}]),i}(),B=function(){function t(e,i,n,a){r(this,t),this.x=e,this.y=i,this.width=n,this.height=a,this.bottom=this.y+this.height,this.right=this.x+this.width}return n(t,[{key:"contains",value:function(t,e){return t<=this.right&&t>=this.x&&e<=this.bottom&&e>=this.y}}]),t}(),V=function(){function t(e,i){r(this,t),this.numPan=x.setSpanValue(x.initValue(e,1)),this.timePan=x.setSpanValue(x.initValue(i,1)),this.startTime=0,this.nextTime=0,this.init()}return n(t,[{key:"init",value:function(){this.startTime=0,this.nextTime=this.timePan.getValue()}},{key:"getValue",value:function(t){return this.startTime+=t,this.startTime>=this.nextTime?(this.startTime=0,this.nextTime=this.timePan.getValue(),1==this.numPan.b?this.numPan.getValue(!1)>.5?1:0:this.numPan.getValue(!0)):0}}]),t}(),M=function(){function t(){r(this,t)}return n(t,[{key:"reset",value:function(){}},{key:"init",value:function(t,e){e?this.initialize(e):this.initialize(t)}},{key:"initialize",value:function(t){}}]),t}(),L=function(t){function e(t,i,n){r(this,e);var a=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return a.lifePan=x.setSpanValue(t,i,n),a.name="Life",a}return s(e,M),n(e,[{key:"initialize",value:function(t){this.lifePan.a==1/0?t.life=1/0:t.life=this.lifePan.getValue()}}]),e}(),U=function(){function t(){r(this,t),this.vector=new h(0,0),this.random=0,this.crossType="dead",this.alert=!0}return n(t,[{key:"getPosition",value:function(){}},{key:"crossing",value:function(t){}}]),t}(),F=function(t){function e(t,i){r(this,e);var n=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.x=t,n.y=i,n}return s(e,U),n(e,[{key:"getPosition",value:function(){return this.vector.x=this.x,this.vector.y=this.y,this.vector}},{key:"crossing",value:function(t){this.alert&&(alert("Sorry PointZone does not support crossing method"),this.alert=!1)}}]),e}(),z=function(t){function e(t){r(this,e);var i=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return i.zone=x.initValue(t,new F),i.name="Position",i}return s(e,M),n(e,[{key:"reset",value:function(t){this.zone=x.initValue(t,new F)}},{key:"initialize",value:function(t){this.zone.getPosition(),t.p.x=this.zone.vector.x,t.p.y=this.zone.vector.y}}]),e}(),j=function(t){function i(t,e,n){r(this,i);var a=o(this,(i.__proto__||Object.getPrototypeOf(i)).call(this));return a.rPan=x.setSpanValue(t),a.thaPan=x.setSpanValue(e),a.type=x.initValue(n,"vector"),a.name="Velocity",a}return s(i,M),n(i,[{key:"reset",value:function(t,e,i){this.rPan=x.setSpanValue(t),this.thaPan=x.setSpanValue(e),this.type=x.initValue(i,"vector")}},{key:"normalizeVelocity",value:function(t){return t*R.MEASURE}},{key:"initialize",value:function(t){if("p"==this.type||"P"==this.type||"polar"==this.type){var i=new S(this.normalizeVelocity(this.rPan.getValue()),this.thaPan.getValue()*e.PI_180);t.v.x=i.getX(),t.v.y=i.getY()}else t.v.x=this.normalizeVelocity(this.rPan.getValue()),t.v.y=this.normalizeVelocity(this.thaPan.getValue())}}]),i}(),N=function(t){function e(t,i,n){r(this,e);var a=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return a.massPan=x.setSpanValue(t,i,n),a.name="Mass",a}return s(e,M),n(e,[{key:"initialize",value:function(t){t.mass=this.massPan.getValue()}}]),e}(),H=function(t){function e(t,i,n){r(this,e);var a=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return a.radius=x.setSpanValue(t,i,n),a.name="Radius",a}return s(e,M),n(e,[{key:"reset",value:function(t,e,i){this.radius=x.setSpanValue(t,e,i)}},{key:"initialize",value:function(t){t.radius=this.radius.getValue(),t.transform.oldRadius=t.radius}}]),e}(),q=function(t){function e(t,i,n){r(this,e);var a=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return a.image=a.setSpanValue(t),a.w=x.initValue(i,20),a.h=x.initValue(n,a.w),a.name="Body",a}return s(e,M),n(e,[{key:"initialize",value:function(t){var e=this.image.getValue();t.body="string"==typeof e?{width:this.w,height:this.h,src:e,isInner:!0,inner:!0}:e}},{key:"setSpanValue",value:function(t){return t instanceof D?t:new D(t)}}]),e}(),G=function(){function t(e,i){r(this,t),this.life=x.initValue(e,1/0),this.easing=w.getEasing(i),this.age=0,this.energy=1,this.dead=!1,this.parents=[],this.id="Behaviour_"+t.id++,this.name="Behaviour"}return n(t,[{key:"reset",value:function(t,e){this.life=x.initValue(t,1/0),this.easing=w.getEasing(e)}},{key:"normalizeForce",value:function(t){return t.multiplyScalar(R.MEASURE)}},{key:"normalizeValue",value:function(t){return t*R.MEASURE}},{key:"initialize",value:function(t){}},{key:"calculate",value:function(t,e,i){if(this.age+=e,this.age>=this.life||this.dead)this.energy=0,this.dead=!0,this.destroy();else{var r=this.easing(t.age/t.life);this.energy=Math.max(1-r,0)}}},{key:"destroy",value:function(){for(var t=this.parents.length;t--;)this.parents[t].removeBehaviour(this);this.parents.length=0}}]),t}();G.id=0;var X=function(t){function e(t,i,n,a){r(this,e);var s=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,n,a));return s.force=s.normalizeForce(new h(t,i)),s.name="Force",s}return s(e,G),n(e,[{key:"reset",value:function(t,i,r,n){this.force=this.normalizeForce(new h(t,i)),r&&a(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"reset",this).call(this,r,n)}},{key:"applyBehaviour",value:function(t,e,i){this.calculate(t,e,i),t.a.add(this.force)}}]),e}(),Y=function(t){function e(t,i,n,a,s){r(this,e);var l=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,a,s));return l.targetPosition=x.initValue(t,new h),l.radius=x.initValue(n,1e3),l.force=x.initValue(l.normalizeValue(i),100),l.radiusSq=l.radius*l.radius,l.attractionForce=new h,l.lengthSq=0,l.name="Attraction",l}return s(e,G),n(e,[{key:"reset",value:function(t,i,r,n,s){this.targetPosition=x.initValue(t,new h),this.radius=x.initValue(r,1e3),this.force=x.initValue(this.normalizeValue(i),100),this.radiusSq=this.radius*this.radius,this.attractionForce=new h,this.lengthSq=0,n&&a(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"reset",this).call(this,n,s)}},{key:"applyBehaviour",value:function(t,e,i){this.calculate(t,e,i),this.attractionForce.copy(this.targetPosition),this.attractionForce.sub(t.p),this.lengthSq=this.attractionForce.lengthSq(),this.lengthSq>4e-6&&this.lengthSq=this.delay&&(t.a.addXY(e.randomAToB(-this.panFoce.x,this.panFoce.x),e.randomAToB(-this.panFoce.y,this.panFoce.y)),this.time=0)}}]),i}(),Z=function(t){function e(t,i,n){r(this,e);var a=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,0,t,i,n));return a.name="Gravity",a}return s(e,X),n(e,[{key:"reset",value:function(t,i,r){a(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"reset",this).call(this,0,t,i,r)}}]),e}(),Q=function(t){function e(t,i,n,a,s){r(this,e);var h=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,a,s));return h.reset(t,i,n),h.name="Collision",h}return s(e,G),n(e,[{key:"reset",value:function(t,i,r,n,s){this.emitter=x.initValue(t,null),this.mass=x.initValue(i,!0),this.callback=x.initValue(r,null),this.collisionPool=[],this.delta=new h,n&&a(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"reset",this).call(this,n,s)}},{key:"applyBehaviour",value:function(t,e,i){var r=this.emitter?this.emitter.particles.slice(i):this.pool.slice(i),n=r.length,a=void 0,s=void 0,o=void 0,h=void 0,l=void 0,u=void 0,c=void 0;for(c=0;c-1&&this.initializes.splice(e,1)}},{key:"removeAllInitializers",value:function(){x.destroyArray(this.initializes)}},{key:"addBehaviour",value:function(){for(var t=arguments.length,e=Array(t),i=0;i=this.life||this.dead)&&this.destroy(),this.emitting(t),this.integrate(t)}},{key:"integrate",value:function(t){if(this.parent){var e=1-this.damping;this.parent.integrator.calculate(this,t,e);var i=void 0,r=void 0;for(i=this.particles.length-1;i>=0;i--)(r=this.particles[i]).update(t,i),this.parent.integrator.calculate(r,t,e),this.dispatch("PARTICLE_UPDATE",r),r.dead&&(this.dispatch("PARTICLE_DEAD",r),this.parent.pool.expire(r),this.particles.splice(i,1))}}},{key:"dispatch",value:function(t,e){this.parent&&this.parent.dispatchEvent(t,e),Proton.bindEmtterEvent&&this.dispatchEvent(t,e)}},{key:"emitting",value:function(t){if("once"==this.totalEmitTimes){var e=void 0,i=this.rate.getValue(99999);for(i>0&&(this.emitSpeed=i),e=0;e0&&(this.emitSpeed=r),n=0;n-1&&this.selfBehaviours.splice(e,1)}},{key:"update",value:function(t){if(a(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"update",this).call(this,t),!this.sleep){var i=this.selfBehaviours.length,r=void 0;for(r=0;rthis.element.width||i<0||i>this.elementwidth)){var a=4*((i>>0)*t.width+(e>>0));t.data[a]=n.r,t.data[a+1]=n.g,t.data[a+2]=n.b,t.data[a+3]=255*r.alpha}}},{key:"onParticleDead",value:function(t){}}]),e}(),dt=function(t){function i(t,e){r(this,i);var n=o(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t));return n.stroke=e,n.setColor=!1,n.pool.create=function(t,e){return n.createBody(t,e)},n.name="PixiRenderer",n}return s(i,ht),n(i,[{key:"onProtonUpdate",value:function(){}},{key:"onParticleCreated",value:function(t){t.body?t.body=this.pool.get(t.body,t):t.body=this.pool.get(this.circleConf,t),this.element.addChild(t.body)}},{key:"onParticleUpdate",value:function(t){this.transform(t,t.body),this.setColor&&(t.body.tint=C.getHex16FromParticle(t))}},{key:"onParticleDead",value:function(t){this.element.removeChild(t.body),this.pool.expire(t.body),t.body=null}},{key:"destroy",value:function(t){a(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"destroy",this).call(this),this.pool.destroy();for(var e=t.length;e--;){var r=t[e];r.body&&this.element.removeChild(r.body)}}},{key:"transform",value:function(t,i){i.x=t.p.x,i.y=t.p.y,i.alpha=t.alpha,i.scale.x=t.scale,i.scale.y=t.scale,i.rotation=t.rotation*e.PI_180}},{key:"createBody",value:function(t,e){return t.isCircle?this.createCircle(e):this.createSprite(t)}},{key:"createSprite",value:function(t){var e=t.isInner?PIXI.Sprite.fromImage(t.src):new PIXI.Sprite(t);return e.anchor.x=.5,e.anchor.y=.5,e}},{key:"createCircle",value:function(t){var e=new PIXI.Graphics;if(this.stroke){this.stroke instanceof String&&this.stroke;e.beginStroke(this.stroke)}return e.beginFill(t.color||36077),e.drawCircle(0,0,t.radius),e.endFill(),e}}]),i}(),yt=function(){function t(){r(this,t),this.mats=[],this.size=0;for(var e=0;e<20;e++)this.mats.push(I.create([0,0,0,0,0,0,0,0,0]))}return n(t,[{key:"set",value:function(t,e){0==e?I.set(t,this.mats[0]):I.multiply(this.mats[e-1],t,this.mats[e]),this.size=Math.max(this.size,e+1)}},{key:"push",value:function(t){0==this.size?I.set(t,this.mats[0]):I.multiply(this.mats[this.size-1],t,this.mats[this.size]),this.size++}},{key:"pop",value:function(){this.size>0&&this.size--}},{key:"top",value:function(){return this.mats[this.size-1]}}]),t}(),pt=function(t){function i(t){r(this,i);var e=o(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,t));return e.gl=e.element.getContext("experimental-webgl",{antialias:!0,stencil:!1,depth:!1}),e.gl||alert("Sorry your browser do not suppest WebGL!"),e.initVar(),e.setMaxRadius(),e.initShaders(),e.initBuffers(),e.gl.blendEquation(e.gl.FUNC_ADD),e.gl.blendFunc(e.gl.SRC_ALPHA,e.gl.ONE_MINUS_SRC_ALPHA),e.gl.enable(e.gl.BLEND),e.addImg2Body=e.addImg2Body.bind(e),e.name="WebGLRenderer",e}return s(i,ht),n(i,[{key:"init",value:function(t){a(i.prototype.__proto__||Object.getPrototypeOf(i.prototype),"init",this).call(this,t),this.resize(this.element.width,this.element.height)}},{key:"resize",value:function(t,e){this.umat[4]=-2,this.umat[7]=1,this.smat[0]=1/t,this.smat[4]=1/e,this.mstack.set(this.umat,0),this.mstack.set(this.smat,1),this.gl.viewport(0,0,t,e),this.element.width=t,this.element.height=e}},{key:"setMaxRadius",value:function(t){this.circleCanvasURL=this.createCircle(t)}},{key:"getVertexShader",value:function(){return["uniform vec2 viewport;","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","uniform mat3 tMat;","varying vec2 vTextureCoord;","varying float alpha;","void main() {","vec3 v = tMat * vec3(aVertexPosition, 1.0);","gl_Position = vec4(v.x, v.y, 0, 1);","vTextureCoord = aTextureCoord;","alpha = tMat[0][2];","}"].join("\n")}},{key:"getFragmentShader",value:function(){return["precision mediump float;","varying vec2 vTextureCoord;","varying float alpha;","uniform sampler2D uSampler;","uniform vec4 color;","uniform bool useTexture;","uniform vec3 uColor;","void main() {","vec4 textureColor = texture2D(uSampler, vTextureCoord);","gl_FragColor = textureColor * vec4(uColor, 1.0);","gl_FragColor.w *= alpha;","}"].join("\n")}},{key:"initVar",value:function(){this.mstack=new yt,this.umat=I.create([2,0,1,0,-2,0,-1,1,1]),this.smat=I.create([.01,0,1,0,.01,0,0,0,1]),this.texturebuffers={}}},{key:"blendEquation",value:function(t){this.gl.blendEquation(this.gl[t])}},{key:"blendFunc",value:function(t,e){this.gl.blendFunc(this.gl[t],this.gl[e])}},{key:"getShader",value:function(t,e,i){var r=i?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);return t.shaderSource(r,e),t.compileShader(r),t.getShaderParameter(r,t.COMPILE_STATUS)?r:(alert(t.getShaderInfoLog(r)),null)}},{key:"initShaders",value:function(){var t=this.getShader(this.gl,this.getFragmentShader(),!0),e=this.getShader(this.gl,this.getVertexShader(),!1);this.sprogram=this.gl.createProgram(),this.gl.attachShader(this.sprogram,e),this.gl.attachShader(this.sprogram,t),this.gl.linkProgram(this.sprogram),this.gl.getProgramParameter(this.sprogram,this.gl.LINK_STATUS)||alert("Could not initialise shaders"),this.gl.useProgram(this.sprogram),this.sprogram.vpa=this.gl.getAttribLocation(this.sprogram,"aVertexPosition"),this.sprogram.tca=this.gl.getAttribLocation(this.sprogram,"aTextureCoord"),this.gl.enableVertexAttribArray(this.sprogram.tca),this.gl.enableVertexAttribArray(this.sprogram.vpa),this.sprogram.tMatUniform=this.gl.getUniformLocation(this.sprogram,"tMat"),this.sprogram.samplerUniform=this.gl.getUniformLocation(this.sprogram,"uSampler"),this.sprogram.useTex=this.gl.getUniformLocation(this.sprogram,"useTexture"),this.sprogram.color=this.gl.getUniformLocation(this.sprogram,"uColor"),this.gl.uniform1i(this.sprogram.useTex,1)}},{key:"initBuffers",value:function(){var t=void 0;this.unitIBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.unitIBuffer),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,3,1,0,2,3]),this.gl.STATIC_DRAW);var e=void 0,i=[];for(e=0;e<100;e++)i.push(e);for(t=new Uint16Array(i),this.unitI33=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.unitI33),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,t,this.gl.STATIC_DRAW),i=[],e=0;e<100;e++)i.push(e,e+1,e+2);t=new Uint16Array(i),this.stripBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.stripBuffer),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,t,this.gl.STATIC_DRAW)}},{key:"createCircle",value:function(t){this.circleCanvasRadius=u(x.initValue(t,32));var e=p.createCanvas("circle_canvas",2*this.circleCanvasRadius,2*this.circleCanvasRadius),i=e.getContext("2d");return i.beginPath(),i.arc(this.circleCanvasRadius,this.circleCanvasRadius,this.circleCanvasRadius,0,2*Math.PI,!0),i.closePath(),i.fillStyle="#FFF",i.fill(),e.toDataURL()}},{key:"drawImg2Canvas",value:function(t){var e=t.body.width,i=t.body.height,r=u(t.body.width),n=u(t.body.height),a=t.body.width/r,s=t.body.height/n;this.texturebuffers[t.transform.src]||(this.texturebuffers[t.transform.src]=[this.gl.createTexture(),this.gl.createBuffer(),this.gl.createBuffer()]),t.transform.texture=this.texturebuffers[t.transform.src][0],t.transform.vcBuffer=this.texturebuffers[t.transform.src][1],t.transform.tcBuffer=this.texturebuffers[t.transform.src][2],this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t.transform.tcBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([0,0,a,0,0,s,s,s]),this.gl.STATIC_DRAW),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t.transform.vcBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array([0,0,e,0,0,i,e,i]),this.gl.STATIC_DRAW);var o=t.transform.canvas.getContext("2d").getImageData(0,0,r,n);this.gl.bindTexture(this.gl.TEXTURE_2D,t.transform.texture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,o),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR_MIPMAP_NEAREST),this.gl.generateMipmap(this.gl.TEXTURE_2D),t.transform.textureLoaded=!0,t.transform.textureWidth=e,t.transform.textureHeight=i}},{key:"onProtonUpdate",value:function(){}},{key:"onParticleCreated",value:function(t){t.transform.textureLoaded=!1,t.transform.tmat=I.create(),t.transform.tmat[8]=1,t.transform.imat=I.create(),t.transform.imat[8]=1,t.body?b(t.body,this.addImg2Body,t):(b(this.circleCanvasURL,this.addImg2Body,t),t.transform.oldScale=t.radius/this.circleCanvasRadius)}},{key:"addImg2Body",value:function(t,e){e.dead||(e.body=t,e.transform.src=t.src,e.transform.canvas=_(t),e.transform.oldScale=1,this.drawImg2Canvas(e))}},{key:"onParticleUpdate",value:function(t){t.transform.textureLoaded&&(this.updateMatrix(t),this.gl.uniform3f(this.sprogram.color,t.transform.rgb.r/255,t.transform.rgb.g/255,t.transform.rgb.b/255),this.gl.uniformMatrix3fv(this.sprogram.tMatUniform,!1,this.mstack.top()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t.transform.vcBuffer),this.gl.vertexAttribPointer(this.sprogram.vpa,2,this.gl.FLOAT,!1,0,0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t.transform.tcBuffer),this.gl.vertexAttribPointer(this.sprogram.tca,2,this.gl.FLOAT,!1,0,0),this.gl.bindTexture(this.gl.TEXTURE_2D,t.transform.texture),this.gl.uniform1i(this.sprogram.samplerUniform,0),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.unitIBuffer),this.gl.drawElements(this.gl.TRIANGLES,6,this.gl.UNSIGNED_SHORT,0),this.mstack.pop())}},{key:"onParticleDead",value:function(t){}},{key:"updateMatrix",value:function(t){var i=c(-t.transform.textureWidth/2,-t.transform.textureHeight/2),r=c(t.p.x,t.p.y),n=t.rotation*e.PI_180,a=f(n),s=t.scale*t.transform.oldScale,o=d(s,s),h=y(i,o);h=y(h,a),h=y(h,r),I.inverse(h,t.transform.imat),h[2]=t.alpha,this.mstack.push(h)}}]),i}(),vt=function(t){function e(t){r(this,e);var i=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return i.name="CustomRenderer",i}return s(e,ht),e}(),gt=function(t){function i(t,e,n,a,s){r(this,i);var h=o(this,(i.__proto__||Object.getPrototypeOf(i)).call(this));return n-t>=0?(h.x1=t,h.y1=e,h.x2=n,h.y2=a):(h.x1=n,h.y1=a,h.x2=t,h.y2=e),h.dx=h.x2-h.x1,h.dy=h.y2-h.y1,h.minx=Math.min(h.x1,h.x2),h.miny=Math.min(h.y1,h.y2),h.maxx=Math.max(h.x1,h.x2),h.maxy=Math.max(h.y1,h.y2),h.dot=h.x2*h.y1-h.x1*h.y2,h.xxyy=h.dx*h.dx+h.dy*h.dy,h.gradient=h.getGradient(),h.length=h.getLength(),h.direction=x.initValue(s,">"),h}return s(i,U),n(i,[{key:"getPosition",value:function(){return this.random=Math.random(),this.vector.x=this.x1+this.random*this.length*Math.cos(this.gradient),this.vector.y=this.y1+this.random*this.length*Math.sin(this.gradient),this.vector}},{key:"getDirection",value:function(t,e){var i=this.dy,r=-this.dx;return(i*t+r*e+this.dot)*(0==r?1:r)>0}},{key:"getDistance",value:function(t,e){return(this.dy*t+-this.dx*e+this.dot)/Math.sqrt(this.xxyy)}},{key:"getSymmetric",value:function(t){var e=t.getGradient(),i=2*(this.getGradient()-e),r=t.x,n=t.y;return t.x=r*Math.cos(i)-n*Math.sin(i),t.y=r*Math.sin(i)+n*Math.cos(i),t}},{key:"getGradient",value:function(){return Math.atan2(this.dy,this.dx)}},{key:"rangeOut",value:function(t){if(Math.abs(this.getGradient())<=e.PI/4){if(t.p.x<=this.maxx&&t.p.x>=this.minx)return!0}else if(t.p.y<=this.maxy&&t.p.y>=this.miny)return!0;return!1}},{key:"getLength",value:function(){return Math.sqrt(this.dx*this.dx+this.dy*this.dy)}},{key:"crossing",value:function(t){if("dead"==this.crossType)if(">"==this.direction||"R"==this.direction||"right"==this.direction||"down"==this.direction){if(!this.rangeOut(t))return;this.getDirection(t.p.x,t.p.y)&&(t.dead=!0)}else{if(!this.rangeOut(t))return;this.getDirection(t.p.x,t.p.y)||(t.dead=!0)}else if("bound"==this.crossType){if(!this.rangeOut(t))return;this.getDistance(t.p.x,t.p.y)<=t.radius&&(0==this.dx?t.v.x*=-1:0==this.dy?t.v.y*=-1:this.getSymmetric(t.v))}else"cross"==this.crossType&&this.alert&&(console.error("Sorry lineZone does not support cross method"),this.alert=!1)}}]),i}(),mt=function(t){function i(t,e,n){r(this,i);var a=o(this,(i.__proto__||Object.getPrototypeOf(i)).call(this));return a.x=t,a.y=e,a.radius=n,a.angle=0,a.center={x:t,y:e},a}return s(i,U),n(i,[{key:"getPosition",value:function(){return this.random=Math.random(),this.angle=e.PIx2*Math.random(),this.vector.x=this.x+this.random*this.radius*Math.cos(this.angle),this.vector.y=this.y+this.random*this.radius*Math.sin(this.angle),this.vector}},{key:"setCenter",value:function(t,e){this.center.x=t,this.center.y=e}},{key:"crossing",value:function(t){var e=t.p.distanceTo(this.center);"dead"==this.crossType?e-t.radius>this.radius&&(t.dead=!0):"bound"==this.crossType?e+t.radius>=this.radius&&this.getSymmetric(t):"cross"==this.crossType&&this.alert&&(alert("Sorry CircleZone does not support cross method"),this.alert=!1)}},{key:"getSymmetric",value:function(t){var e=t.v.getGradient(),i=2*(this.getGradient(t)-e),r=t.v.x,n=t.v.y;t.v.x=r*Math.cos(i)-n*Math.sin(i),t.v.y=r*Math.sin(i)+n*Math.cos(i)}},{key:"getGradient",value:function(t){return-e.PI_2+Math.atan2(t.p.y-this.center.y,t.p.x-this.center.x)}}]),i}(),bt=function(t){function e(t,i,n,a){r(this,e);var s=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return s.x=t,s.y=i,s.width=n,s.height=a,s}return s(e,U),n(e,[{key:"getPosition",value:function(){return this.vector.x=this.x+Math.random()*this.width,this.vector.y=this.y+Math.random()*this.height,this.vector}},{key:"crossing",value:function(t){"dead"==this.crossType?(t.p.x+t.radiusthis.x+this.width&&(t.dead=!0),t.p.y+t.radiusthis.y+this.height&&(t.dead=!0)):"bound"==this.crossType?(t.p.x-t.radiusthis.x+this.width&&(t.p.x=this.x+this.width-t.radius,t.v.x*=-1),t.p.y-t.radiusthis.y+this.height&&(t.p.y=this.y+this.height-t.radius,t.v.y*=-1)):"cross"==this.crossType&&(t.p.x+t.radiusthis.x+this.width&&t.v.x>=0&&(t.p.x=this.x-t.radius),t.p.y+t.radiusthis.y+this.height&&t.v.y>=0&&(t.p.y=this.y-t.radius))}}]),e}(),_t=function(t){function e(t,i,n,a){r(this,e);var s=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return s.reset(t,i,n,a),s}return s(e,U),n(e,[{key:"reset",value:function(t,e,i,r){this.imageData=t,this.x=x.initValue(e,0),this.y=x.initValue(i,0),this.d=x.initValue(r,2),this.vectors=[],this.setVectors()}},{key:"setVectors",value:function(){var t=void 0,e=void 0,i=this.imageData.width,r=this.imageData.height;for(t=0;t>0)*i+(t>>0));this.imageData.data[n+3]>0&&this.vectors.push({x:t+this.x,y:e+this.y})}return this.vector}},{key:"getBound",value:function(t,e){var i=4*((e>>0)*this.imageData.width+(t>>0));return this.imageData.data[i+3]>0}},{key:"getPosition",value:function(){return this.vector.copy(this.vectors[Math.floor(Math.random()*this.vectors.length)])}},{key:"getColor",value:function(t,e){t-=this.x;var i=4*(((e-=this.y)>>0)*this.imageData.width+(t>>0));return{r:this.imageData.data[i],g:this.imageData.data[i+1],b:this.imageData.data[i+2],a:this.imageData.data[i+3]}}},{key:"crossing",value:function(t){"dead"==this.crossType?this.getBound(t.p.x-this.x,t.p.y-this.y)?t.dead=!0:t.dead=!1:"bound"==this.crossType&&(this.getBound(t.p.x-this.x,t.p.y-this.y)||t.v.negate())}}]),e}(),xt={addEventListener:function(t,e){t.addEventListener("PROTON_UPDATE_AFTER",function(){return e()})},getStyle:function(t){var e=C.hexToRGB(t||"#ff0000");return"rgba("+e.r+", "+e.g+", "+e.b+", 0.5)"},drawZone:function(t,e,i,r){var n=e.getContext("2d"),a=this.getStyle();this.addEventListener(t,function(){r&&n.clearRect(0,0,e.width,e.height),i instanceof F?(n.beginPath(),n.fillStyle=a,n.arc(i.x,i.y,10,0,2*Math.PI,!0),n.fill(),n.closePath()):i instanceof gt?(n.beginPath(),n.strokeStyle=a,n.moveTo(i.x1,i.y1),n.lineTo(i.x2,i.y2),n.stroke(),n.closePath()):i instanceof bt?(n.beginPath(),n.strokeStyle=a,n.drawRect(i.x,i.y,i.width,i.height),n.stroke(),n.closePath()):i instanceof mt&&(n.beginPath(),n.strokeStyle=a,n.arc(i.x,i.y,i.radius,0,2*Math.PI,!0),n.stroke(),n.closePath())})},drawEmitter:function(t,e,i,r){var n=e.getContext("2d"),a=this.getStyle();this.addEventListener(t,function(){r&&n.clearRect(0,0,e.width,e.height),n.beginPath(),n.fillStyle=a,n.arc(i.p.x,i.p.y,10,0,2*Math.PI,!0),n.fill(),n.closePath()})}};return function(){for(var t=0,e=["ms","moz","webkit","o"],i=0;i 0)\n return MathUtils.PI_2;\n else if (this.y < 0)\n return -MathUtils.PI_2;\n }\n\n copy(v) {\n this.x = v.x;\n this.y = v.y;\n\n return this;\n }\n\n add(v, w) {\n if (w !== undefined) {\n return this.addVectors(v, w);\n }\n\n this.x += v.x;\n this.y += v.y;\n\n return this;\n }\n\n addXY(a, b) {\n this.x += a;\n this.y += b;\n\n return this;\n }\n\n addVectors(a, b) {\n this.x = a.x + b.x;\n this.y = a.y + b.y;\n\n return this;\n }\n\n sub(v, w) {\n if (w !== undefined) {\n return this.subVectors(v, w);\n }\n\n this.x -= v.x;\n this.y -= v.y;\n\n return this;\n }\n\n subVectors(a, b) {\n this.x = a.x - b.x;\n this.y = a.y - b.y;\n\n return this;\n }\n\n divideScalar(s) {\n if (s !== 0) {\n this.x /= s;\n this.y /= s;\n } else {\n this.set(0, 0);\n }\n\n return this;\n }\n\n multiplyScalar(s) {\n this.x *= s;\n this.y *= s;\n\n return this;\n }\n\n negate() {\n return this.multiplyScalar(-1);\n }\n\n dot(v) {\n return this.x * v.x + this.y * v.y;\n }\n\n lengthSq() {\n return this.x * this.x + this.y * this.y;\n }\n\n length() {\n return Math.sqrt(this.x * this.x + this.y * this.y);\n }\n\n normalize() {\n return this.divideScalar(this.length());\n }\n\n distanceTo(v) {\n return Math.sqrt(this.distanceToSquared(v));\n }\n\n rotate(tha) {\n const x = this.x;\n const y = this.y;\n\n this.x = x * Math.cos(tha) + y * Math.sin(tha);\n this.y = -x * Math.sin(tha) + y * Math.cos(tha);\n\n return this;\n }\n\n distanceToSquared(v) {\n const dx = this.x - v.x;\n const dy = this.y - v.y;\n\n return dx * dx + dy * dy;\n }\n\n lerp(v, alpha) {\n this.x += (v.x - this.x) * alpha;\n this.y += (v.y - this.y) * alpha;\n\n return this;\n }\n\n equals(v) {\n return ((v.x === this.x) && (v.y === this.y));\n }\n\n clear() {\n this.x = 0.0;\n this.y = 0.0;\n return this;\n }\n\n clone() {\n return new Vector2D(this.x, this.y);\n }\n}","import Util from '../utils/Util';\nimport MathUtils from '../math/MathUtils';\n\nexport default class Span {\n\n\tconstructor(a, b, center) {\n\t\tthis.isArray = false;\n\n\t\tif (Util.isArray(a)) {\n\t\t\tthis.isArray = true;\n\t\t\tthis.a = a;\n\t\t} else {\n\t\t\tthis.a = Util.initValue(a, 1);\n\t\t\tthis.b = Util.initValue(b, this.a);\n\t\t\tthis.center = Util.initValue(center, false);\n\t\t}\n\n\t}\n\n\tgetValue(INT) {\n\t\tif (this.isArray) {\n\t\t\treturn this.a[Math.floor(this.a.length * Math.random())];\n\t\t} else {\n\t\t\tif (!this.center)\n\t\t\t\treturn MathUtils.randomAToB(this.a, this.b, INT);\n\t\t\telse\n\t\t\t\treturn MathUtils.randomFloating(this.a, this.b, INT);\n\t\t}\n\t}\n}","export default {\n\n /**\n * @memberof Proton#Proton.WebGLUtil\n * @method ipot\n *\n * @todo add description\n * @todo add length description\n *\n * @param {Number} length\n *\n * @return {Boolean}\n */\n ipot(length) {\n return (length & (length - 1)) == 0;\n },\n\n /**\n * @memberof Proton#Proton.WebGLUtil\n * @method nhpot\n *\n * @todo add description\n * @todo add length description\n *\n * @param {Number} length\n *\n * @return {Number}\n */\n nhpot(length) {\n --length;\n for (let i = 1; i < 32; i <<= 1) {\n length = length | length >> i;\n }\n\n return length + 1;\n },\n\n /**\n * @memberof Proton#Proton.WebGLUtil\n * @method makeTranslation\n *\n * @todo add description\n * @todo add tx, ty description\n * @todo add return description\n *\n * @param {Number} tx either 0 or 1\n * @param {Number} ty either 0 or 1\n *\n * @return {Object}\n */\n makeTranslation(tx, ty) {\n return [1, 0, 0, 0, 1, 0, tx, ty, 1];\n },\n\n /**\n * @memberof Proton#Proton.WebGLUtil\n * @method makeRotation\n *\n * @todo add description\n * @todo add return description\n *\n * @param {Number} angleInRadians\n *\n * @return {Object}\n */\n makeRotation(angleInRadians) {\n let c = Math.cos(angleInRadians);\n let s = Math.sin(angleInRadians);\n\n return [c, -s, 0, s, c, 0, 0, 0, 1];\n },\n\n /**\n * @memberof Proton#Proton.WebGLUtil\n * @method makeScale\n *\n * @todo add description\n * @todo add tx, ty description\n * @todo add return description\n *\n * @param {Number} sx either 0 or 1\n * @param {Number} sy either 0 or 1\n *\n * @return {Object}\n */\n makeScale(sx, sy) {\n return [sx, 0, 0, 0, sy, 0, 0, 0, 1];\n },\n\n /**\n * @memberof Proton#Proton.WebGLUtil\n * @method matrixMultiply\n *\n * @todo add description\n * @todo add a, b description\n * @todo add return description\n *\n * @param {Object} a\n * @param {Object} b\n *\n * @return {Object}\n */\n matrixMultiply(a, b) {\n let a00 = a[0 * 3 + 0];\n let a01 = a[0 * 3 + 1];\n let a02 = a[0 * 3 + 2];\n let a10 = a[1 * 3 + 0];\n let a11 = a[1 * 3 + 1];\n let a12 = a[1 * 3 + 2];\n let a20 = a[2 * 3 + 0];\n let a21 = a[2 * 3 + 1];\n let a22 = a[2 * 3 + 2];\n let b00 = b[0 * 3 + 0];\n let b01 = b[0 * 3 + 1];\n let b02 = b[0 * 3 + 2];\n let b10 = b[1 * 3 + 0];\n let b11 = b[1 * 3 + 1];\n let b12 = b[1 * 3 + 2];\n let b20 = b[2 * 3 + 0];\n let b21 = b[2 * 3 + 1];\n let b22 = b[2 * 3 + 2];\n\n return [\n a00 * b00 + a01 * b10 + a02 * b20,\n a00 * b01 + a01 * b11 + a02 * b21,\n a00 * b02 + a01 * b12 + a02 * b22,\n a10 * b00 + a11 * b10 + a12 * b20,\n a10 * b01 + a11 * b11 + a12 * b21,\n a10 * b02 + a11 * b12 + a12 * b22,\n a20 * b00 + a21 * b10 + a22 * b20,\n a20 * b01 + a21 * b11 + a22 * b21,\n a20 * b02 + a21 * b12 + a22 * b22\n ];\n }\n}","export default {\n\n /**\n * Creates and returns a new canvas. The opacity is by default set to 0\n *\n * @memberof Proton#Proton.DomUtil\n * @method createCanvas\n *\n * @param {String} $id the canvas' id\n * @param {Number} $width the canvas' width\n * @param {Number} $height the canvas' height\n * @param {String} [$position=absolute] the canvas' position, default is 'absolute' \n *\n * @return {Object}\n */\n createCanvas(id, width, height, position) {\n const dom = document.createElement(\"canvas\");\n position = position || 'absolute';\n\n dom.id = id;\n dom.width = width;\n dom.height = height;\n dom.style.opacity = 0;\n dom.style.position = position;\n\n this.transform(dom, -500, -500, 0, 0);\n\n return dom;\n },\n\n createDiv(id, width, height) {\n const dom = document.createElement(\"div\");\n\n dom.id = id;\n dom.style.position = 'absolute';\n this.resize(dom, width, height);\n\n return dom;\n },\n\n resize(dom, width, height) {\n dom.style.width = width + 'px';\n dom.style.height = height + 'px';\n dom.style.marginLeft = -width / 2 + 'px';\n dom.style.marginTop = -height / 2 + 'px';\n },\n\n /**\n * Adds a transform: translate(), scale(), rotate() to a given div dom for all browsers\n *\n * @memberof Proton#Proton.DomUtil\n * @method transform\n *\n * @param {HTMLDivElement} div \n * @param {Number} $x \n * @param {Number} $y \n * @param {Number} $scale \n * @param {Number} $rotate \n */\n transform(div, x, y, scale, rotate) {\n const transform = `translate(${x}px, ${y}px) scale(${scale}) rotate(${rotate}deg)`;\n\n div.style.willChange = 'transform';\n this.css3(div, 'transform', transform);\n },\n\n transform3d(div, x, y, scale, rotate) {\n const transform = `translate3d(${x}px, ${y}px, 0) scale(${scale}) rotate(${rotate}deg)`;\n\n div.style.willChange = 'transform';\n this.css3(div, 'backfaceVisibility', 'hidden');\n this.css3(div, 'transform', transform);\n },\n\n css3(div, key, val) {\n const bkey = key.charAt(0).toUpperCase() + key.substr(1);\n\n div.style[`Webkit${bkey}`] = val;\n div.style[`Moz${bkey}`] = val;\n div.style[`O${bkey}`] = val;\n div.style[`ms${bkey}`] = val;\n div.style[`${key}`] = val;\n }\n}","import WebGLUtil from './WebGLUtil';\nimport DomUtil from './DomUtil';\n\nconst IMG_CACHE = {};\nconst CANVAS_CACHE = {};\nlet canvasID = 0;\n\nexport default {\n\n /**\n * This will get the image data. It could be necessary to create a Proton.Zone.\n *\n * @memberof Proton#Proton.Util\n * @method getImageData\n *\n * @param {HTMLCanvasElement} context any canvas, must be a 2dContext 'canvas.getContext('2d')'\n * @param {Object} image could be any dom image, e.g. document.getElementById('thisIsAnImgTag');\n * @param {Proton.Rectangle} rect\n */\n getImageData(context, image, rect) {\n context.drawImage(image, rect.x, rect.y);\n const imagedata = context.getImageData(rect.x, rect.y, rect.width, rect.height);\n context.clearRect(rect.x, rect.y, rect.width, rect.height);\n\n return imagedata;\n },\n\n /**\n * @memberof Proton#Proton.Util\n * @method getImgFromCache\n *\n * @todo add description\n * @todo describe func\n *\n * @param {Mixed} img\n * @param {Proton.Particle} particle\n * @param {Boolean} drawCanvas set to true if a canvas should be saved into particle.transform.canvas\n * @param {Boolean} func\n */\n getImgFromCache(img, callback, param) {\n const src = typeof (img) == 'string' ? img : img.src;\n\n if (IMG_CACHE[src]) {\n callback(IMG_CACHE[src], param);\n } else {\n const image = new Image();\n image.onload = e => {\n IMG_CACHE[src] = e.target;\n callback(IMG_CACHE[src], param);\n }\n\n image.src = src;\n }\n },\n\n getCanvasFromCache(img, callback, param) {\n const src = img.src;\n\n if (!CANVAS_CACHE[src]) {\n const width = WebGLUtil.nhpot(img.width);\n const height = WebGLUtil.nhpot(img.height);\n\n const canvas = DomUtil.createCanvas(`canvas_cache_${canvasID}`, width, height);\n const context = canvas.getContext('2d');\n context.drawImage(img, 0, 0, img.width, img.height);\n\n CANVAS_CACHE[src] = canvas;\n }\n\n callback && callback(CANVAS_CACHE[src], param);\n\n return CANVAS_CACHE[src];\n }\n}","import Vector2D from '../math/Vector2D';\nimport Span from '../math/Span';\nimport ImgUtil from './ImgUtil';\nimport DomUtil from './DomUtil';\n\nexport default {\n\n /**\n * Returns the default if the value is null or undefined\n *\n * @memberof Proton#Proton.Util\n * @method initValue\n *\n * @param {Mixed} value a specific value, could be everything but null or undefined\n * @param {Mixed} defaults the default if the value is null or undefined\n */\n initValue(value, defaults) {\n value = (value !== null && value !== undefined) ? value : defaults;\n return value;\n },\n\n /**\n * Checks if the value is a valid array\n *\n * @memberof Proton#Proton.Util\n * @method isArray\n *\n * @param {Array} value Any array\n *\n * @returns {Boolean} \n */\n isArray(value) {\n return Object.prototype.toString.call(value) === '[object Array]';\n },\n\n /**\n * Destroyes the given array\n *\n * @memberof Proton#Proton.Util\n * @method destroyArray\n *\n * @param {Array} array Any array\n */\n destroyArray(array) {\n if (array) array.length = 0;\n },\n\n /**\n * Destroyes the given object\n *\n * @memberof Proton#Proton.Util\n * @method destroyObject\n *\n * @param {Object} obj Any object\n */\n destroyObject(obj, ignore) {\n for (let o in obj) {\n if (ignore && ignore.indexOf(o) > -1) continue;\n delete obj[o];\n }\n },\n\n /**\n * Makes an instance of a class and binds the given array\n *\n * @memberof Proton#Proton.Util\n * @method classApply\n *\n * @param {Function} constructor A class to make an instance from\n * @param {Array} [args] Any array to bind it to the constructor\n *\n * @return {Object} The instance of constructor, optionally bind with args\n */\n classApply(constructor, args) {\n if (!args) return new constructor;\n\n args = [null].concat(args);\n const factoryFunction = constructor.bind.apply(constructor, args);\n return new factoryFunction();\n },\n\n /**\n * @memberof Proton#Proton.Util\n * @method setVector2DByObject\n *\n * @todo add description for param `target`\n * @todo add description for param `pOBJ`\n * @todo add description for function\n *\n * @param {Object} target\n * @param {Object} pOBJ\n */\n setVector2DByObject(target, pOBJ) {\n if (this.hasProp(pOBJ, 'x')) target.p.x = pOBJ['x'];\n if (this.hasProp(pOBJ, 'y')) target.p.y = pOBJ['y'];\n\n if (this.hasProp(pOBJ, 'vx')) target.v.x = pOBJ['vx'];\n if (this.hasProp(pOBJ, 'vy')) target.v.y = pOBJ['vy'];\n\n if (this.hasProp(pOBJ, 'ax')) target.a.x = pOBJ['ax'];\n if (this.hasProp(pOBJ, 'ay')) target.a.y = pOBJ['ay'];\n\n if (this.hasProp(pOBJ, 'p')) particle.p.copy(pOBJ['p']);\n if (this.hasProp(pOBJ, 'v')) particle.v.copy(pOBJ['v']);\n if (this.hasProp(pOBJ, 'a')) particle.a.copy(pOBJ['a']);\n\n if (this.hasProp(pOBJ, 'position')) particle.p.copy(pOBJ['position']);\n if (this.hasProp(pOBJ, 'velocity')) particle.v.copy(pOBJ['velocity']);\n if (this.hasProp(pOBJ, 'accelerate')) particle.a.copy(pOBJ['accelerate']);\n },\n\n hasProp(obj, key) {\n if (!obj) return false;\n return obj[key] !== undefined;\n // return obj.hasOwnProperty(key);\n },\n\n /**\n * set the prototype in a given prototypeObject\n *\n * @memberof Proton#Proton.Util\n * @method setPrototypeByObject\n *\n * @todo add description for param `target`\n * @todo add description for param `filters`\n * @todo translate desription from chinese to english\n *\n * @param {Object} target\n * @param {Object} prototypeObject An object of single prototypes\n * @param {Object} filters\n *\n * @return {Object} target\n */\n setPrototypeByObject(target, prototypeObject, filters) {\n for (let singleProp in prototypeObject) {\n if (target.hasOwnProperty(singleProp)) {\n if (filters) {\n if (filters.indexOf(singleProp) < 0)\n target[singleProp] = this.getSpanValue(prototypeObject[singleProp]);\n } else {\n target[singleProp] = this.getSpanValue(prototypeObject[singleProp]);\n }\n }\n }\n\n return target;\n },\n\n /**\n * Returns a new Span object\n *\n * @memberof Proton#Proton.Util\n * @method setSpanValue\n *\n * @todo a, b and c should be 'Mixed' or 'Number'?\n *\n * @param {Mixed | Span} a\n * @param {Mixed} b\n * @param {Mixed} c\n *\n * @return {Span}\n */\n setSpanValue(a, b, c) {\n if (a instanceof Span) {\n return a;\n } else {\n if (!b) {\n return new Span(a);\n } else {\n if (!c)\n return new Span(a, b);\n else\n return new Span(a, b, c);\n }\n }\n },\n\n /**\n * Returns the value from a Span, if the param is not a Span it will return the given parameter\n *\n * @memberof Proton#Proton.Util\n * @method getSpanValue\n *\n * @param {Mixed | Span} pan\n *\n * @return {Mixed} the value of Span OR the parameter if it is not a Span\n */\n getSpanValue(pan) {\n return pan instanceof Span ? pan.getValue() : pan;\n },\n\n /**\n * This will get the image data. It could be necessary to create a Proton.Zone.\n *\n * @memberof Proton#Proton.Util\n * @method getImageData\n *\n * @param {HTMLCanvasElement} context any canvas, must be a 2dContext 'canvas.getContext('2d')'\n * @param {Object} image could be any dom image, e.g. document.getElementById('thisIsAnImgTag');\n * @param {Proton.Rectangle} rect\n */\n getImageData(context, image, rect) {\n return ImgUtil.getImageData(context, image, rect);\n },\n\n destroy(arr, param) {\n let i = arr.length;\n\n while (i--) {\n try { arr[i].destroy(param); } catch (e) { }\n delete arr[i];\n }\n\n arr.length = 0;\n }\n\n}","export default {\n id: 0,\n cache: {},\n\n getID(target) {\n let uid = this.getCacheID(target);\n if (uid) return uid;\n\n uid = `PUID_${this.id++}`;\n this.cache[uid] = target;\n\n return uid;\n },\n\n getCacheID(target) {\n let obj;\n for (let id in this.cache) {\n obj = this.cache[id];\n\n if (obj === target) return id;\n \n if (typeof obj === 'object' && typeof target === 'object' && obj.isInner && target.isInner) {\n if (obj.src === target.src)\n return id;\n }\n }\n\n return null;\n },\n\n getTarget(uid) {\n return this.cache[uid];\n }\n}","/**\n * get -> PUID :: uid-> Body\n * -> cache[abc]. -> cache[abc] .pop()\n * -> create [new Body| clone]\n * -> return p1: { __pid: abc }\n * \n * expire -> cache[abc]= [p0, p1];\n * \n */\nimport Util from '../utils/Util';\nimport PUID from '../utils/PUID';\n\nexport default class Pool {\n\n /**\n * @memberof! Proton#\n * @constructor\n * @alias Proton.Pool\n *\n * @todo add description\n * @todo add description of properties\n *\n * @property {Number} total\n * @property {Object} cache\n */\n constructor(num) {\n this.total = 0;\n this.cache = {};\n }\n\n /**\n * @todo add description\n *\n * @method get\n * @memberof Proton#Proton.Pool\n *\n * @param {Object|Function} target\n * @param {Object} [params] just add if `target` is a function\n *\n * @return {Object}\n */\n get(target, params, uid) {\n let p;\n uid = uid || target.__puid || PUID.getID(target);\n\n if (this.cache[uid] && this.cache[uid].length > 0)\n p = this.cache[uid].pop();\n else\n p = this.createOrClone(target, params);\n\n p.__puid = target.__puid || uid;\n return p;\n }\n\n /**\n * @todo add description\n *\n * @method set\n * @memberof Proton#Proton.Pool\n *\n * @param {Object} target\n *\n * @return {Object}\n */\n expire(target) {\n return this.getCache(target.__puid).push(target);\n }\n\n /**\n * Creates a new class instance\n *\n * @todo add more documentation \n *\n * @method create\n * @memberof Proton#Proton.Pool\n *\n * @param {Object|Function} target any Object or Function\n * @param {Object} [params] just add if `target` is a function\n *\n * @return {Object}\n */\n createOrClone(target, params) {\n this.total++;\n\n if (this.create) {\n return this.create(target, params);\n } else if (typeof target == \"function\") {\n return Util.classApply(target, params);\n } else {\n return target.clone();\n }\n }\n\n /**\n * @todo add description - what is in the cache?\n *\n * @method getCount\n * @memberof Proton#Proton.Pool\n *\n * @return {Number}\n */\n getCount() {\n let count = 0;\n\n for (let id in this.cache)\n count += this.cache[id].length;\n\n return count++;;\n }\n\n /**\n * Destroyes all items from Pool.cache\n *\n * @method destroy\n * @memberof Proton#Proton.Pool\n */\n destroy() {\n for (let id in this.cache) {\n this.cache[id].length = 0;\n delete this.cache[id];\n }\n }\n\n /**\n * Returns Pool.cache\n *\n * @method getCache\n * @memberof Proton#Proton.Pool\n * @private\n *\n * @param {Number} uid the unique id\n *\n * @return {Object}\n */\n getCache(uid) {\n uid = uid || \"default\";\n\n if (!this.cache[uid]) this.cache[uid] = [];\n return this.cache[uid];\n }\n}","export default class Stats {\n\n constructor(proton) {\n this.proton = proton;\n this.container = null;\n this.type = 1;\n\n this.emitterIndex = 0;\n this.rendererIndex = 0;\n }\n\n update(style, body) {\n this.add(style, body);\n\n const emitter = this.getEmitter();\n const renderer = this.getRenderer();\n let str = \"\";\n\n switch (this.type) {\n case 2:\n str += \"emitter:\" + this.proton.emitters.length + \"
\";\n if (emitter) str += \"em speed:\" + emitter.emitSpeed + \"
\";\n if (emitter) str += \"pos:\" + this.getEmitterPos(emitter);\n break;\n\n case 3:\n if (emitter) str += \"initializes:\" + emitter.initializes.length + \"
\";\n if (emitter) str += \"\" + this.concatArr(emitter.initializes) + \"
\";\n if (emitter) str += \"behaviours:\" + emitter.behaviours.length + \"
\";\n if (emitter) str += \"\" + this.concatArr(emitter.behaviours) + \"
\";\n break;\n\n case 4:\n if (renderer) str += renderer.name + \"
\";\n if (renderer) str += \"body:\" + this.getCreatedNumber(renderer) + \"
\";\n break;\n\n default:\n str += \"particles:\" + this.proton.getCount() + \"
\";\n str += \"pool:\" + this.proton.pool.getCount() + \"
\";\n str += \"total:\" + this.proton.pool.total;\n }\n\n this.container.innerHTML = str;\n }\n\n add(style, body) {\n if (!this.container) {\n this.type = 1;\n\n this.container = document.createElement('div');\n this.container.style.cssText = [\n 'position:absolute;bottom:0px;left:0;cursor:pointer;',\n 'opacity:0.9;z-index:10000;padding:10px;font-size:12px;',\n 'width:120px;height:50px;background-color:#002;color:#0ff;'\n ].join('');\n\n this.container.addEventListener('click', e => {\n this.type++;\n if (this.type > 4) this.type = 1;\n }, false);\n\n let bg, color;\n switch (style) {\n case 2:\n bg = \"#201\";\n color = \"#f08\";\n break;\n\n case 3:\n bg = \"#020\";\n color = \"#0f0\";\n break;\n\n default:\n bg = \"#002\";\n color = \"#0ff\";\n }\n\n this.container.style[\"background-color\"] = bg;\n this.container.style[\"color\"] = color;\n }\n\n if (!this.container.parentNode) {\n body = body || this.body || document.body;\n body.appendChild(this.container);\n }\n }\n\n getEmitter() {\n return this.proton.emitters[this.emitterIndex];\n }\n\n getRenderer() {\n return this.proton.renderers[this.rendererIndex];\n }\n\n concatArr(arr) {\n let result = '';\n if (!arr || !arr.length) return result;\n\n for (let i = 0; i < arr.length; i++) {\n result += (arr[i].name || '').substr(0, 1) + '.';\n }\n\n return result;\n }\n\n getCreatedNumber(renderer) {\n return renderer.pool.total || (renderer.cpool && renderer.cpool.total) || 0;\n }\n\n getEmitterPos(e) {\n return Math.round(e.p.x) + \",\" + Math.round(e.p.y);\n }\n}","/*\n * EventDispatcher\n * This code reference since http://createjs.com/.\n *\n **/\n\nexport default class EventDispatcher {\n\n constructor() {\n this._listeners = null;\n }\n\n static bind(TargetClass){\n TargetClass.prototype.dispatchEvent = EventDispatcher.prototype.dispatchEvent;\n TargetClass.prototype.hasEventListener = EventDispatcher.prototype.hasEventListener;\n TargetClass.prototype.addEventListener = EventDispatcher.prototype.addEventListener;\n TargetClass.prototype.removeEventListener = EventDispatcher.prototype.removeEventListener;\n TargetClass.prototype.removeAllEventListeners = EventDispatcher.prototype.removeAllEventListeners;\n }\n\n addEventListener(type, listener) {\n if (!this._listeners) {\n this._listeners = {};\n } else {\n this.removeEventListener(type, listener);\n }\n\n if (!this._listeners[type]) this._listeners[type] = [];\n this._listeners[type].push(listener);\n\n return listener;\n }\n\n removeEventListener(type, listener) {\n if (!this._listeners) return;\n if (!this._listeners[type]) return;\n\n const arr = this._listeners[type];\n const length = arr.length;\n\n for (let i = 0;i < length; i++) {\n if (arr[i] == listener) {\n if (length == 1) {\n delete (this._listeners[type]);\n }\n\n // allows for faster checks.\n else {\n arr.splice(i, 1);\n }\n\n break;\n }\n }\n }\n\n removeAllEventListeners(type) {\n if (!type)\n this._listeners = null;\n else if (this._listeners)\n delete (this._listeners[type]);\n }\n\n dispatchEvent(type, args) {\n let result = false;\n const listeners = this._listeners;\n\n if (type && listeners) {\n let arr = listeners[type];\n if (!arr) return result;\n\n //arr = arr.slice();\n // to avoid issues with items being removed or added during the dispatch\n\n let handler;\n let i = arr.length;\n while (i--) {\n handler = arr[i];\n result = result || handler(args);\n }\n\n }\n\n return !!result;\n }\n\n hasEventListener(type) {\n const listeners = this._listeners;\n return !!(listeners && listeners[type]);\n }\n\n}","import Util from '../utils/Util';\n\nexport default class Integration {\n\n\tconstructor(type) {\n\t\tthis.type = type;\n\t}\n\n\tcalculate(particles, time, damping) {\n\t\tthis.eulerIntegrate(particles, time, damping);\n\t}\n\n\t// Euler Integrate\n\teulerIntegrate(particle, time, damping) {\n\t\tif (!particle.sleep) {\n\t\t\tparticle.old.p.copy(particle.p);\n\t\t\tparticle.old.v.copy(particle.v);\n\n\t\t\tparticle.a.multiplyScalar(1 / particle.mass);\n\t\t\tparticle.v.add(particle.a.multiplyScalar(time));\n\t\t\tparticle.p.add(particle.old.v.multiplyScalar(time));\n\n\t\t\tif (damping) particle.v.multiplyScalar(damping);\n\n\t\t\tparticle.a.clear();\n\t\t}\n\t}\n}","import Pool from './Pool';\nimport Util from '../utils/Util';\nimport Stats from '../debug/Stats';\nimport EventDispatcher from '../events/EventDispatcher';\nimport Integration from '../math/Integration';\n\nexport default class Proton {\n\n static USE_CLOCK = false;\n\n //1:100\n static MEASURE = 100;\n static EULER = 'euler';\n static RK2 = 'runge-kutta2';\n\n static PARTICLE_CREATED = 'PARTICLE_CREATED';\n static PARTICLE_UPDATE = 'PARTICLE_UPDATE';\n static PARTICLE_SLEEP = 'PARTICLE_SLEEP';\n static PARTICLE_DEAD = 'PARTICLE_DEAD';\n static PROTON_UPDATE = 'PROTON_UPDATE';\n static PROTON_UPDATE_AFTER = 'PROTON_UPDATE_AFTER';\n static EMITTER_ADDED = 'EMITTER_ADDED';\n static EMITTER_REMOVED = 'EMITTER_REMOVED';\n\n static amendChangeTabsBug = true;\n static bindEmtterEvent = false;\n\n /**\n * The constructor to add emitters\n *\n * @constructor Proton\n *\n * @todo proParticleCount is not in use\n * @todo add more documentation of the single properties and parameters\n *\n * @param {Number} [proParticleCount] not in use?\n * @param {Number} [integrationType=Proton.EULER]\n *\n * @property {String} [integrationType=Proton.EULER]\n * @property {Array} emitters All added emitter\n * @property {Array} renderers All added renderer\n * @property {Number} time The active time\n * @property {Number} oldtime The old time\n */\n constructor(integrationType) {\n\n this.emitters = [];\n this.renderers = [];\n\n this.time = 0;\n this.oldTime = 0;\n this.elapsed = 0;\n\n this.stats = new Stats(this);\n this.pool = new Pool(80);\n\n this.integrationType = Util.initValue(integrationType, Proton.EULER);\n this.integrator = new Integration(this.integrationType);\n }\n\n /**\n * add a type of Renderer\n *\n * @method addRenderer\n * @memberof Proton\n * @instance\n *\n * @param {Renderer} render\n */\n addRenderer(render) {\n render.init(this);\n this.renderers.push(render);\n }\n\n /**\n * @name add a type of Renderer\n *\n * @method addRenderer\n * @param {Renderer} render\n */\n removeRenderer(render) {\n const index = this.renderers.indexOf(render);\n this.renderers.splice(index, 1);\n render.remove(this);\n }\n\n /**\n * add the Emitter\n *\n * @method addEmitter\n * @memberof Proton\n * @instance\n *\n * @param {Emitter} emitter\n */\n addEmitter(emitter) {\n this.emitters.push(emitter);\n emitter.parent = this;\n\n this.dispatchEvent(Proton.EMITTER_ADDED, emitter);\n }\n\n /**\n * Removes an Emitter\n *\n * @method removeEmitter\n * @memberof Proton\n * @instance\n *\n * @param {Proton.Emitter} emitter\n */\n removeEmitter(emitter) {\n const index = this.emitters.indexOf(emitter);\n this.emitters.splice(index, 1);\n emitter.parent = null;\n\n this.dispatchEvent(Proton.EMITTER_REMOVED, emitter);\n }\n\n /**\n * Updates all added emitters\n *\n * @method update\n * @memberof Proton\n * @instance\n */\n update() {\n this.dispatchEvent(Proton.PROTON_UPDATE);\n\n if (Proton.USE_CLOCK) {\n if (!this.oldTime) this.oldTime = (new Date()).getTime();\n\n let time = new Date().getTime();\n this.elapsed = (time - this.oldTime) / 1000;\n Proton.amendChangeTabsBug && this.amendChangeTabsBug();\n\n this.oldTime = time;\n } else {\n this.elapsed = 0.0167;\n }\n\n // emitter update\n if (this.elapsed > 0) this.emittersUpdate(this.elapsed);\n\n this.dispatchEvent(Proton.PROTON_UPDATE_AFTER);\n }\n\n emittersUpdate(elapsed) {\n let i = this.emitters.length;\n while (i--) this.emitters[i].update(elapsed);\n }\n\n /**\n * @todo add description\n *\n * @method amendChangeTabsBug\n * @memberof Proton\n * @instance\n */\n amendChangeTabsBug() {\n if (this.elapsed > .5) {\n this.oldTime = (new Date()).getTime();\n this.elapsed = 0;\n }\n }\n\n /**\n * Counts all particles from all emitters\n *\n * @method getCount\n * @memberof Proton\n * @instance\n */\n getCount() {\n let total = 0;\n let i = this.emitters.length;\n\n while (i--) total += this.emitters[i].particles.length;\n return total;\n }\n\n getAllParticles() {\n let particles = [];\n let i = this.emitters.length;\n\n while (i--) particles = particles.concat(this.emitters[i].particles);\n return particles;\n }\n\n /**\n * Destroys everything related to this Proton instance. This includes all emitters, and all properties\n *\n * @method destroy\n * @memberof Proton\n * @instance\n */\n destroy() {\n Util.destroy(this.renderers, this.getAllParticles());\n Util.destroy(this.emitters);\n\n this.time = 0;\n this.oldTime = 0;\n\n this.pool.destroy();\n }\n}\n\nEventDispatcher.bind(Proton);","import MathUtils from './MathUtils';\n\nexport default {\n\n easeLinear(value) {\n return value;\n },\n\n easeInQuad(value) {\n return Math.pow(value, 2);\n },\n\n easeOutQuad(value) {\n return -(Math.pow((value - 1), 2) - 1);\n },\n\n easeInOutQuad(value) {\n if ((value /= 0.5) < 1)\n return 0.5 * Math.pow(value, 2);\n\n return -0.5 * ((value -= 2) * value - 2);\n },\n\n easeInCubic(value) {\n return Math.pow(value, 3);\n },\n\n easeOutCubic(value) {\n return (Math.pow((value - 1), 3) + 1);\n },\n\n easeInOutCubic(value) {\n if ((value /= 0.5) < 1)\n return 0.5 * Math.pow(value, 3);\n\n return 0.5 * (Math.pow((value - 2), 3) + 2);\n },\n\n easeInQuart(value) {\n return Math.pow(value, 4);\n },\n\n easeOutQuart(value) {\n return -(Math.pow((value - 1), 4) - 1);\n },\n\n easeInOutQuart(value) {\n if ((value /= 0.5) < 1)\n return 0.5 * Math.pow(value, 4);\n\n return -0.5 * ((value -= 2) * Math.pow(value, 3) - 2);\n },\n\n easeInSine(value) {\n return -Math.cos(value * (MathUtils.PI_2)) + 1;\n },\n\n easeOutSine(value) {\n return Math.sin(value * (MathUtils.PI_2));\n },\n\n easeInOutSine(value) {\n return (-0.5 * (Math.cos(MathUtils.PI * value) - 1));\n },\n\n easeInExpo(value) {\n return (value === 0) ? 0 : Math.pow(2, 10 * (value - 1));\n },\n\n easeOutExpo(value) {\n return (value === 1) ? 1 : -Math.pow(2, -10 * value) + 1;\n },\n\n easeInOutExpo(value) {\n if (value === 0)\n return 0;\n\n if (value === 1)\n return 1;\n\n if ((value /= 0.5) < 1)\n return 0.5 * Math.pow(2, 10 * (value - 1));\n\n return 0.5 * (-Math.pow(2, -10 * --value) + 2);\n },\n\n easeInCirc(value) {\n return -(Math.sqrt(1 - (value * value)) - 1);\n },\n\n easeOutCirc(value) {\n return Math.sqrt(1 - Math.pow((value - 1), 2));\n },\n\n easeInOutCirc(value) {\n if ((value /= 0.5) < 1)\n return -0.5 * (Math.sqrt(1 - value * value) - 1);\n return 0.5 * (Math.sqrt(1 - (value -= 2) * value) + 1);\n },\n\n easeInBack(value) {\n let s = 1.70158;\n return (value) * value * ((s + 1) * value - s);\n },\n\n easeOutBack(value) {\n let s = 1.70158;\n return (value = value - 1) * value * ((s + 1) * value + s) + 1;\n },\n\n easeInOutBack(value) {\n let s = 1.70158;\n if ((value /= 0.5) < 1)\n return 0.5 * (value * value * (((s *= (1.525)) + 1) * value - s));\n return 0.5 * ((value -= 2) * value * (((s *= (1.525)) + 1) * value + s) + 2);\n },\n\n getEasing(ease) {\n if (typeof ease === 'function')\n return ease;\n else\n return this[ease] || this.easeLinear;\n }\n};","import Util from '../utils/Util';\nimport ease from '../math/ease';\nimport Vector2D from '../math/Vector2D';\nimport MathUtils from '../math/MathUtils';\n\nexport default class Particle {\n\n static ID = 0;\n\n /**\n * the Particle class\n *\n * @class Proton.Particle\n * @constructor\n * @param {Object} pObj the parameters object;\n * for example {life:3,dead:false}\n */\n constructor(pOBJ) {\n /**\n * The particle's id;\n * @property id\n * @type {string}\n */\n this.id = `particle_${Particle.ID++}`;\n this.reset('init');\n\n pOBJ && Util.setPrototypeByObject(this, pOBJ);\n }\n\n getDirection() {\n return Math.atan2(this.v.x, -this.v.y) * MathUtils.N180_PI;\n }\n\n reset(init) {\n this.life = Infinity;\n this.age = 0;\n\n //Energy loss\n this.energy = 1;\n this.dead = false;\n this.sleep = false;\n this.body = null;\n this.sprite = null;\n this.parent = null;\n\n this.mass = 1;\n this.radius = 10;\n this.alpha = 1;\n this.scale = 1;\n this.rotation = 0;\n this.color = null;\n\n this.easing = ease.easeLinear;\n\n if (init == 'init') {\n this.transform = {};\n this.p = new Vector2D();\n this.v = new Vector2D();\n this.a = new Vector2D();\n\n this.old = {\n p: new Vector2D(),\n v: new Vector2D(),\n a: new Vector2D()\n };\n\n this.behaviours = [];\n } else {\n Util.destroyObject(this.transform, 'rgb');\n\n this.p.set(0, 0);\n this.v.set(0, 0);\n this.a.set(0, 0);\n\n this.old.p.set(0, 0);\n this.old.v.set(0, 0);\n this.old.a.set(0, 0);\n\n this.removeAllBehaviours();\n }\n\n if (!this.transform.rgb) {\n this.transform.rgb = { r: 255, g: 255, b: 255 };\n } else {\n this.transform.rgb.r = 255;\n this.transform.rgb.g = 255;\n this.transform.rgb.b = 255;\n }\n\n return this;\n }\n\n update(time, index) {\n if (!this.sleep) {\n this.age += time;\n this.applyBehaviours(time, index);\n }\n\n if (this.age < this.life) {\n const scale = this.easing(this.age / this.life);\n this.energy = Math.max(1 - scale, 0);\n } else {\n this.destroy();\n }\n }\n\n applyBehaviours(time, index) {\n const length = this.behaviours.length;\n let i;\n\n for (i = 0; i < length; i++) {\n this.behaviours[i] && this.behaviours[i].applyBehaviour(this, time, index)\n }\n }\n\n addBehaviour(behaviour) {\n this.behaviours.push(behaviour);\n\n if (behaviour.hasOwnProperty('parents')) behaviour.parents.push(this);\n behaviour.initialize(this);\n }\n\n addBehaviours(behaviours) {\n const length = behaviours.length;\n let i;\n\n for (i = 0; i < length; i++) {\n this.addBehaviour(behaviours[i]);\n }\n }\n\n removeBehaviour(behaviour) {\n const index = this.behaviours.indexOf(behaviour);\n\n if (index > -1) {\n const behaviour = this.behaviours.splice(index, 1);\n behaviour.parents = null;\n }\n }\n\n removeAllBehaviours() {\n Util.destroyArray(this.behaviours);\n }\n\n /**\n * Destory this particle\n * @method destroy\n */\n destroy() {\n this.removeAllBehaviours();\n this.energy = 0;\n this.dead = true;\n this.parent = null;\n }\n\n}","export default {\n\n /**\n * @typedef {Object} rgbObject\n * @property {Number} r red value\n * @property {Number} g green value\n * @property {Number} b blue value\n */\n /**\n * converts a hex value to a rgb object\n *\n * @memberof Proton#Proton.Util\n * @method hexToRGB\n *\n * @param {String} h any hex value, e.g. #000000 or 000000 for black\n *\n * @return {rgbObject}\n */\n hexToRGB(h) {\n const hex16 = (h.charAt(0) == \"#\") ? h.substring(1, 7) : h;\n const r = parseInt(hex16.substring(0, 2), 16);\n const g = parseInt(hex16.substring(2, 4), 16);\n const b = parseInt(hex16.substring(4, 6), 16);\n\n return { r, g, b };\n },\n\n /**\n * converts a rgb value to a rgb string\n *\n * @memberof Proton#Proton.Util\n * @method rgbToHex\n *\n * @param {Object | Proton.hexToRGB} rgb a rgb object like in {@link Proton#Proton.}\n *\n * @return {String} rgb()\n */\n rgbToHex(rbg) {\n return `rgb(${rbg.r}, ${rbg.g}, ${rbg.b})`;\n },\n\n getHex16FromParticle(p) {\n return Number(p.transform.rgb.r) * 65536 + Number(p.transform.rgb.g) * 256 + Number(p.transform.rgb.b);\n }\n}","import Vector2D from './Vector2D';\n\nexport default class Polar2D {\n\n\tconstructor(r, tha) {\n\t\tthis.r = Math.abs(r) || 0;\n\t\tthis.tha = tha || 0;\n\t}\n\n\tset(r, tha) {\n\t\tthis.r = r;\n\t\tthis.tha = tha;\n\t\treturn this;\n\t}\n\n\tsetR(r) {\n\t\tthis.r = r;\n\t\treturn this;\n\t}\n\n\tsetTha(tha) {\n\t\tthis.tha = tha;\n\t\treturn this;\n\t}\n\n\tcopy(p) {\n\t\tthis.r = p.r;\n\t\tthis.tha = p.tha;\n\t\treturn this;\n\t}\n\n\ttoVector() {\n\t\treturn new Vector2D(this.getX(), this.getY());\n\t}\n\n\tgetX() {\n\t\treturn this.r * Math.sin(this.tha);\n\t}\n\n\tgetY() {\n\t\treturn -this.r * Math.cos(this.tha);\n\t}\n\n\tnormalize() {\n\t\tthis.r = 1;\n\t\treturn this;\n\t}\n\n\tequals(v) {\n\t\treturn ((v.r === this.r) && (v.tha === this.tha));\n\t}\n\n\tclear() {\n\t\tthis.r = 0.0;\n\t\tthis.tha = 0.0;\n\t\treturn this;\n\t}\n\n\tclone() {\n\t\treturn new Polar2D(this.r, this.tha);\n\t}\n}","export default {\n\tcreate(mat3) {\n\t\tconst mat = new Float32Array(9);\n\t\tif (mat3) this.set(mat3, mat);\n\n\t\treturn mat;\n\t},\n\n\tset(mat1, mat2) {\n\t\tfor (let i = 0; i < 9; i++)\n\t\t\tmat2[i] = mat1[i];\n\n\t\treturn mat2;\n\t},\n\n\tmultiply(mat, mat2, mat3) {\n\t\tlet a00 = mat[0], a01 = mat[1], a02 = mat[2], a10 = mat[3], a11 = mat[4], a20 = mat[6], a21 = mat[7], b00 = mat2[0], b01 = mat2[1], b02 = mat2[2], b10 = mat2[3], b11 = mat2[4], b20 = mat2[6], b21 = mat2[7];\n\n\t\tmat3[0] = b00 * a00 + b01 * a10;\n\t\tmat3[1] = b00 * a01 + b01 * a11;\n\t\tmat3[2] = a02 * b02;\n\t\tmat3[3] = b10 * a00 + b11 * a10;\n\t\tmat3[4] = b10 * a01 + b11 * a11;\n\t\tmat3[6] = b20 * a00 + b21 * a10 + a20;\n\t\tmat3[7] = b20 * a01 + b21 * a11 + a21;\n\n\t\treturn mat3;\n\t},\n\n\tinverse(mat, mat3) {\n\t\tlet a00 = mat[0], a01 = mat[1], a10 = mat[3], a11 = mat[4], a20 = mat[6], a21 = mat[7], b01 = a11, b11 = -a10, b21 = a21 * a10 - a11 * a20, d = a00 * b01 + a01 * b11, id;\n\n\t\tid = 1 / d;\n\t\tmat3[0] = b01 * id;\n\t\tmat3[1] = (-a01) * id;\n\t\tmat3[3] = b11 * id;\n\t\tmat3[4] = a00 * id;\n\t\tmat3[6] = b21 * id;\n\t\tmat3[7] = (-a21 * a00 + a01 * a20) * id;\n\n\t\treturn mat3;\n\t},\n\n\tmultiplyVec2(m, vec, mat3) {\n\t\tlet x = vec[0], y = vec[1];\n\n\t\tmat3[0] = x * m[0] + y * m[3] + m[6];\n\t\tmat3[1] = x * m[1] + y * m[4] + m[7];\n\n\t\treturn mat3;\n\t}\n}","import Span from './Span';\nimport Util from '../utils/Util';\nimport MathUtils from './MathUtils';\n\nexport default class ArraySpan extends Span {\n\n constructor(color) {\n super();\n this._arr = Util.isArray(color) ? color : [color];\n }\n\n getValue() {\n const color = this._arr[Math.floor(this._arr.length * Math.random())];\n return color === 'random' || color === 'Random' ? MathUtils.randomColor() : color;\n }\n\n /**\n * Make sure that the color is an instance of Proton.ArraySpan, if not it makes a new instance\n *\n * @method setSpanValue\n * @memberof Proton#Proton.Color\n * @instance\n *\n * @param {Proton.Particle} particle\n * @param {Number} the integrate time 1/ms\n * @param {Int} the particle index\n */\n static createArraySpan(arr) {\n if (!arr) return null;\n\n if (arr instanceof ArraySpan)\n return arr;\n else\n return new ArraySpan(arr);\n }\n\n}","export default class Rectangle {\n\n\tconstructor(x, y, w, h) {\n\t\tthis.x = x;\n\t\tthis.y = y;\n\n\t\tthis.width = w;\n\t\tthis.height = h;\n\n\t\tthis.bottom = this.y + this.height;\n\t\tthis.right = this.x + this.width;\n\t}\n\n\tcontains(x, y) {\n\t\tif (x <= this.right && x >= this.x && y <= this.bottom && y >= this.y)\n\t\t\treturn true;\n\t\telse\n\t\t\treturn false;\n\t}\n}\n","import Util from '../utils/Util';\n\nexport default class Rate {\n\n\t/**\n\t * The number of particles per second emission (a [particle]/b [s]);\n\t * @namespace\n\t * @memberof! Proton#\n\t * @constructor\n\t * @alias Rate\n\t *\n\t * @param {Array | Number | Span} numpan the number of each emission;\n\t * @param {Array | Number | Span} timepan the time of each emission;\n\t * for example: new Rate(new Span(10, 20), new Span(.1, .25));\n\t */\n\tconstructor(numpan, timepan) {\n\t\tthis.numPan = Util.setSpanValue(Util.initValue(numpan, 1));\n\t\tthis.timePan = Util.setSpanValue(Util.initValue(timepan, 1));\n\n\t\tthis.startTime = 0;\n\t\tthis.nextTime = 0;\n\t\tthis.init();\n\t}\n\n\tinit() {\n\t\tthis.startTime = 0;\n\t\tthis.nextTime = this.timePan.getValue();\n\t}\n\n\tgetValue(time) {\n\t\tthis.startTime += time;\n\n\t\tif (this.startTime >= this.nextTime) {\n\t\t\tthis.startTime = 0;\n\t\t\tthis.nextTime = this.timePan.getValue();\n\n\t\t\tif (this.numPan.b == 1) {\n\t\t\t\tif (this.numPan.getValue(false) > 0.5)\n\t\t\t\t\treturn 1;\n\t\t\t\telse\n\t\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\treturn this.numPan.getValue(true);\n\t\t\t}\n\t\t}\n\n\t\treturn 0;\n\t}\n}","export default class Initialize {\n\t\n\treset() {\n\t}\n\n\tinit(emitter, particle) {\n\t\tif (particle) {\n\t\t\tthis.initialize(particle);\n\t\t} else {\n\t\t\tthis.initialize(emitter);\n\t\t}\n\t};\n\n\t///sub class init\n\tinitialize(target) {\n\t};\n}","import Util from '../utils/Util';\nimport Initialize from './Initialize';\n\nexport default class Life extends Initialize {\n\n\tconstructor(a, b, c) {\n\t\tsuper();\n\n\t\tthis.lifePan = Util.setSpanValue(a, b, c);\n\t\tthis.name = 'Life';\n\t}\n\n\tinitialize(target) {\n\t\tif (this.lifePan.a == Infinity)\n\t\t\ttarget.life = Infinity;\n\t\telse\n\t\t\ttarget.life = this.lifePan.getValue();\n\t}\n}\n","import Vector2D from '../math/Vector2D';\n\nexport default class Zone {\n\tconstructor() {\n\t\tthis.vector = new Vector2D(0, 0);\n\t\tthis.random = 0;\n\t\tthis.crossType = \"dead\";\n\t\tthis.alert = true;\n\t}\n\n\tgetPosition() {\n\t}\n\n\tcrossing(particle) {\n\t}\n}","import Zone from './Zone';\n\nexport default class PointZone extends Zone {\n\n\tconstructor(x, y) {\n\t\tsuper();\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t}\n\n\tgetPosition() {\n\t\tthis.vector.x = this.x;\n\t\tthis.vector.y = this.y;\n\n\t\treturn this.vector;\n\t}\n\n\tcrossing(particle) {\n\t\t\n\t\tif (this.alert) {\n\t\t\talert('Sorry PointZone does not support crossing method');\n\t\t\tthis.alert = false;\n\t\t}\n\t}\n}","import Util from '../utils/Util';\nimport PointZone from '../zone/PointZone';\nimport Initialize from './Initialize';\n\nexport default class Position extends Initialize {\n\n\tconstructor(zone) {\n\t\tsuper();\n\t\tthis.zone = Util.initValue(zone, new PointZone());\n\n\t\tthis.name = 'Position';\n\t}\n\n\treset(zone) {\n\t\tthis.zone = Util.initValue(zone, new PointZone());\n\t}\n\n\tinitialize(target) {\n\t\tthis.zone.getPosition();\n\n\t\ttarget.p.x = this.zone.vector.x;\n\t\ttarget.p.y = this.zone.vector.y;\n\t};\n\n}\n","import Proton from '../core/Proton';\nimport Util from '../utils/Util';\nimport Polar2D from '../math/Polar2D';\nimport MathUtils from '../math/MathUtils';\nimport Initialize from './Initialize';\n\nexport default class Velocity extends Initialize {\n\n constructor(rpan, thapan, type) {\n super();\n\n this.rPan = Util.setSpanValue(rpan);\n this.thaPan = Util.setSpanValue(thapan);\n this.type = Util.initValue(type, 'vector');\n\n this.name = 'Velocity';\n }\n\n reset(rpan, thapan, type) {\n this.rPan = Util.setSpanValue(rpan);\n this.thaPan = Util.setSpanValue(thapan);\n this.type = Util.initValue(type, 'vector');\n };\n\n normalizeVelocity(vr) {\n return vr * Proton.MEASURE;\n }\n\n initialize(target) {\n if (this.type == 'p' || this.type == 'P' || this.type == 'polar') {\n const polar2d = new Polar2D(this.normalizeVelocity(this.rPan.getValue()), this.thaPan.getValue() * MathUtils.PI_180);\n\n target.v.x = polar2d.getX();\n target.v.y = polar2d.getY();\n } else {\n target.v.x = this.normalizeVelocity(this.rPan.getValue());\n target.v.y = this.normalizeVelocity(this.thaPan.getValue());\n }\n };\n}","import Util from '../utils/Util';\nimport Initialize from './Initialize';\n\nexport default class Mass extends Initialize {\n\n\tconstructor(a, b, c) {\n\t\tsuper();\n\t\tthis.massPan = Util.setSpanValue(a, b, c);\n\t\tthis.name = 'Mass';\n\t}\n\n\tinitialize(target) {\n\t\ttarget.mass = this.massPan.getValue();\n\t}\n}","import Util from '../utils/Util';\nimport Initialize from './Initialize';\n\nexport default class Radius extends Initialize {\n\n\tconstructor(a, b, c) {\n\t\tsuper();\n\t\tthis.radius = Util.setSpanValue(a, b, c);\n\n\t\tthis.name = 'Radius';\n\t}\n\n\treset(a, b, c) {\n\t\tthis.radius = Util.setSpanValue(a, b, c);\n\t};\n\n\tinitialize(particle) {\n\t\tparticle.radius = this.radius.getValue();\n\t\tparticle.transform.oldRadius = particle.radius;\n\t};\n}","import Util from '../utils/Util';\nimport ArraySpan from '../math/ArraySpan';\nimport Initialize from './Initialize';\n\nexport default class Body extends Initialize {\n\n constructor(image, w, h) {\n super();\n\n this.image = this.setSpanValue(image);\n this.w = Util.initValue(w, 20);\n this.h = Util.initValue(h, this.w);\n this.name = 'Body';\n }\n\n initialize(particle) {\n const imagetarget = this.image.getValue();\n\n if (typeof(imagetarget) == 'string') {\n particle.body = { width: this.w, height: this.h, src: imagetarget , isInner: true, inner: true };\n } else {\n particle.body = imagetarget;\n }\n };\n\n setSpanValue(color) {\n return color instanceof ArraySpan ? color : new ArraySpan(color);\n }\n}","import Proton from '../core/Proton';\nimport Util from '../utils/Util';\nimport ease from '../math/ease';\n\nexport default class Behaviour {\n static id = 0;\n\n /**\n * The Behaviour class is the base for the other Behaviour\n *\n * @memberof! -\n * @interface\n * @alias Proton.Behaviour\n *\n * @param {Number} life \tthe behaviours life\n * @param {String} easing \tThe behaviour's decaying trend, for example ease.easeOutQuart\n *\n * @property {String} id \t\tThe behaviours id\n * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n * @property {Number} age=0 \tHow long the particle should be 'alife'\n * @property {Number} energy=1\n * @property {Boolean} dead=false The particle is dead at first\n * @property {Array} parents \tThe behaviour's parents array\n * @property {String} name \tThe behaviour name\n */\n constructor(life, easing) {\n\n this.life = Util.initValue(life, Infinity);\n this.easing = ease.getEasing(easing);\n\n this.age = 0;\n this.energy = 1;\n this.dead = false;\n this.parents = [];\n\n this.id = `Behaviour_${Behaviour.id++}`;\n this.name = 'Behaviour';\n }\n\n /**\n * Reset this behaviour's parameters\n *\n * @method reset\n * @memberof Proton.Behaviour\n * @instance\n *\n * @param {Number} [life=Infinity] \t\tthis behaviour's life\n * @param {String} [easing=easeLinear] \tthis behaviour's easing\n */\n reset(life, easing) {\n this.life = Util.initValue(life, Infinity);\n this.easing = ease.getEasing(easing);\n }\n\n /**\n * Normalize a force by 1:100;\n *\n * @method normalizeForce\n * @memberof Proton.Behaviour\n * @instance\n *\n * @param {Proton.Vector2D} force \n */\n normalizeForce(force) {\n return force.multiplyScalar(Proton.MEASURE);\n }\n\n /**\n * Normalize a value by 1:100;\n *\n * @method normalizeValue\n * @memberof Proton.Behaviour\n * @instance\n *\n * @param {Number} value\n */\n normalizeValue(value) {\n return value * Proton.MEASURE;\n }\n\n /**\n * Initialize the behaviour's parameters for all particles\n *\n * @method initialize\n * @memberof Proton.Behaviour\n * @instance\n *\n * @param {Proton.Particle} particle\n */\n initialize(particle) {}\n\n /**\n * Apply this behaviour for all particles every time\n *\n * @method applyBehaviour\n * @memberof Proton.Behaviour\n * @instance\n *\n * @param {Proton.Particle} particle\n * @param {Number} \t\t\ttime the integrate time 1/ms\n * @param {Int} \t\t\tindex the particle index\n */\n calculate(particle, time, index) {\n this.age += time;\n\n if (this.age >= this.life || this.dead) {\n this.energy = 0;\n this.dead = true;\n this.destroy();\n } else {\n const scale = this.easing(particle.age / particle.life);\n this.energy = Math.max(1 - scale, 0);\n }\n }\n\n /**\n * Destory this behaviour\n *\n * @method destroy\n * @memberof Proton.Behaviour\n * @instance\n */\n destroy() {\n let i = this.parents.length;\n while (i--) {\n this.parents[i].removeBehaviour(this);\n }\n\n this.parents.length = 0;\n }\n}","import Util from '../utils/Util';\nimport Vector2D from '../math/Vector2D';\nimport Behaviour from './Behaviour';\n\nexport default class Force extends Behaviour {\n\n\t/**\n\t * @memberof! Proton#\n\t * @augments Proton.Behaviour\n\t * @constructor\n\t * @alias Proton.Force\n\t *\n\t * @param {Number} fx\n\t * @param {Number} fy\n\t * @param {Number} [life=Infinity] \t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(fx, fy, life, easing) {\n\t\tsuper(life, easing);\n\n\t\tthis.force = this.normalizeForce(new Vector2D(fx, fy));\n\t\tthis.name = \"Force\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#Proton.Force\n\t * @instance\n\t *\n\t * @param {Number} fx\n\t * @param {Number} fy\n\t * @param {Number} [life=Infinity] \t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t */\n\treset(fx, fy, life, easing) {\n\t\tthis.force = this.normalizeForce(new Vector2D(fx, fy));\n\n\t\tlife && super.reset(life, easing);\n\t}\n\n\t/**\n\t * Apply this behaviour for all particles every time\n\t *\n\t * @method applyBehaviour\n\t * @memberof Proton#Proton.Force\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle\n\t * @param {Number} the integrate time 1/ms\n\t * @param {Int} the particle index\n\t */\n\tapplyBehaviour(particle, time, index) {\n\t\tthis.calculate(particle, time, index);\n\t\tparticle.a.add(this.force);\n\t}\n}","import Util from '../utils/Util';\nimport Vector2D from '../math/Vector2D';\nimport Behaviour from './Behaviour';\n\nexport default class Attraction extends Behaviour {\n\n\t/**\n\t * This behaviour let the particles follow one specific Proton.Vector2D\n\t *\n\t * @memberof! Proton#\n\t * @augments Proton.Behaviour\n\t * @constructor\n\t * @alias Proton.Attraction\n\t *\n\t * @todo add description for 'force' and 'radius'\n\t *\n\t * @param {Proton.Vector2D} targetPosition the attraction point coordinates\n\t * @param {Number} [force=100]\n\t * @param {Number} [radius=1000]\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {Proton.Vector2D} targetPosition\n\t * @property {Number} radius\n\t * @property {Number} force\n\t * @property {Number} radiusSq\n\t * @property {Proton.Vector2D} attractionForce\n\t * @property {Number} lengthSq\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(targetPosition, force, radius, life, easing) {\n\t\tsuper(life, easing);\n\n\t\tthis.targetPosition = Util.initValue(targetPosition, new Vector2D);\n\t\tthis.radius = Util.initValue(radius, 1000);\n\t\tthis.force = Util.initValue(this.normalizeValue(force), 100);\n\n\t\tthis.radiusSq = this.radius * this.radius\n\t\tthis.attractionForce = new Vector2D();\n\t\tthis.lengthSq = 0;\n\n\t\tthis.name = \"Attraction\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#Proton.Attraction\n\t * @instance\n\t *\n\t * @todo add description for 'force' and 'radius'\n\t *\n\t * @param {Proton.Vector2D} targetPosition the attraction point coordinates\n\t * @param {Number} [force=100]\n\t * @param {Number} [radius=1000]\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t */\n\treset(targetPosition, force, radius, life, easing) {\n\t\tthis.targetPosition = Util.initValue(targetPosition, new Vector2D);\n\t\tthis.radius = Util.initValue(radius, 1000);\n\t\tthis.force = Util.initValue(this.normalizeValue(force), 100);\n\n\t\tthis.radiusSq = this.radius * this.radius\n\t\tthis.attractionForce = new Vector2D();\n\t\tthis.lengthSq = 0;\n\n\t\tlife && super.reset(life, easing);\n\t}\n\n\t/**\n\t * Apply this behaviour for all particles every time\n\t *\n\t * @memberof Proton#Proton.Attraction\n\t * @method applyBehaviour\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle\n\t * @param {Number} \t\t\ttime the integrate time 1/ms\n\t * @param {Int} \t\t\tindex the particle index\n\t */\n\tapplyBehaviour(particle, time, index) {\n\t\tthis.calculate(particle, time, index);\n\n\t\tthis.attractionForce.copy(this.targetPosition);\n\t\tthis.attractionForce.sub(particle.p);\n\t\tthis.lengthSq = this.attractionForce.lengthSq();\n\n\t\tif (this.lengthSq > 0.000004 && this.lengthSq < this.radiusSq) {\n\t\t\tthis.attractionForce.normalize();\n\t\t\tthis.attractionForce.multiplyScalar(1 - this.lengthSq / this.radiusSq);\n\t\t\tthis.attractionForce.multiplyScalar(this.force);\n\n\t\t\tparticle.a.add(this.attractionForce);\n\t\t}\n\t}\n}\n\n","import Util from '../utils/Util';\nimport Vector2D from '../math/Vector2D';\nimport MathUtils from '../math/MathUtils';\nimport Behaviour from './Behaviour';\n\nexport default class RandomDrift extends Behaviour {\n\n\t/**\n\t * @memberof! Proton#\n\t * @augments Behaviour\n\t * @constructor\n\t * @alias RandomDrift\n\t *\n\t * @param {Number} driftX \t\t\t\tX value of the new Vector2D\n\t * @param {Number} driftY \t\t\t\tY value of the new Vector2D\n\t * @param {Number} delay \t\t\t\tHow much delay the drift should have\n\t * @param {Number} [life=Infinity] \t\tthis behaviour's life\n\t * @param {String} [easing=easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {Number} time The time of the drift\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(driftX, driftY, delay, life, easing) {\n\t\tsuper(life, easing);\n\n\t\tthis.reset(driftX, driftY, delay);\n\t\tthis.time = 0;\n\t\tthis.name = \"RandomDrift\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#RandomDrift\n\t * @instance\n\t *\n\t * @param {Number} driftX \t\t\t\tX value of the new Vector2D\n\t * @param {Number} driftY \t\t\t\tY value of the new Vector2D\n\t * @param {Number} delay \t\t\t\tHow much delay the drift should have\n\t * @param {Number} [life=Infinity] \t\tthis behaviour's life\n\t * @param {String} [easing=easeLinear] \tthis behaviour's easing\n\t */\n\treset(driftX, driftY, delay, life, easing) {\n\t\tthis.panFoce = new Vector2D(driftX, driftY);\n\t\tthis.panFoce = this.normalizeForce(this.panFoce);\n\t\tthis.delay = delay;\n\n\t\tlife && super.reset(life, easing);\n\t}\n\n\t/**\n\t * Apply this behaviour for all particles every time\n\t *\n\t * @method applyBehaviour\n\t * @memberof Proton#RandomDrift\n\t * @instance\n\t *\n\t * @param {Particle} particle\n\t * @param {Number} \t\t\ttime the integrate time 1/ms\n\t * @param {Int} \t\t\tindex the particle index\n\t */\n\tapplyBehaviour(particle, time, index) {\n\t\tthis.calculate(particle, time, index);\n\t\tthis.time += time;\n\n\t\tif (this.time >= this.delay) {\n\t\t\tparticle.a.addXY(MathUtils.randomAToB(-this.panFoce.x, this.panFoce.x), MathUtils.randomAToB(-this.panFoce.y, this.panFoce.y));\n\t\t\tthis.time = 0;\n\t\t};\n\t}\n}\n","import Util from '../utils/Util';\nimport Vector2D from '../math/Vector2D';\nimport Force from './Force';\n\nexport default class Gravity extends Force {\n\n\t/**\n\t * @memberof! Proton#\n\t * @augments Proton#Proton.Force\n\t * @constructor\n\t * @alias Proton.Gravity\n\t *\n\t * @param {Number} g \t\t\t\t\t\t\tGravity\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(g, life, easing) {\n\t\tsuper(0, g, life, easing);\n\t\tthis.name = \"Gravity\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#Proton.Gravity\n\t * @instance\n\t *\n\t * @param {Number} g \t\t\t\t\t\t\tGravity\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t */\n\treset(g, life, easing) {\n\t\tsuper.reset(0, g, life, easing);\n\t}\n}","import Util from '../utils/Util';\nimport Vector2D from '../math/Vector2D';\nimport Behaviour from './Behaviour';\n\n//can use Collision(emitter,true,function(){}) or Collision();\nexport default class Collision extends Behaviour {\n\n\t/**\n\t * The callback after collision\n\t *\n\t * @callback Callback\n\t *\n\t * @param {Proton.Particle} particle\n\t * @param {Proton.Paritcle} otherParticle\n\t */\n\t/**\n\t * @memberof! Proton#\n\t * @augments Proton.Behaviour\n\t * @constructor\n\t * @alias Proton.Collision\n\t *\n\t * @todo add description to mass\n\t *\n\t * @param {Proton.Emitter} \t[emitter=null] \t\tthe attraction point coordinates\n\t * @param {Boolean} \t\t[mass=true]\t\t\t\n\t * @param {Callback}\t \t[callback=null]\t\tthe callback after the collision\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(emitter, mass, callback, life, easing) {\n\t\tsuper(life, easing);\n\n\t\tthis.reset(emitter, mass, callback);\n\t\tthis.name = \"Collision\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @memberof Proton#Proton.Collision\n\t * @method reset\n\t * @instance\n\t *\n\t * @todo add description to mass\n\t *\n\t * @param {Proton.Emitter} \t[emitter=null] \t\tthe attraction point coordinates\n\t * @param {Boolean} \t\t[mass=true]\t\t\t\n\t * @param {Callback}\t \t[callback=null]\t\tthe callback after the collision\n\t * @param {Number} \t\t\t[life=Infinity] \tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t */\n\treset(emitter, mass, callback, life, easing) {\n\t\tthis.emitter = Util.initValue(emitter, null);\n\t\tthis.mass = Util.initValue(mass, true);\n\t\tthis.callback = Util.initValue(callback, null);\n\n\t\tthis.collisionPool = [];\n\t\tthis.delta = new Vector2D();\n\n\t\tlife && super.reset(life, easing);\n\t}\n\n\t/**\n\t * Apply this behaviour for all particles every time\n\t *\n\t * @memberof Proton#Proton.Collision\n\t * @method applyBehaviour\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle\n\t * @param {Number} \t\t\ttime the integrate time 1/ms\n\t * @param {Int} \t\t\tindex the particle index\n\t */\n\tapplyBehaviour(particle, time, index) {\n\t\tconst newPool = this.emitter ? this.emitter.particles.slice(index) : this.pool.slice(index);\n\t\tconst length = newPool.length;\n\n\t\tlet otherParticle;\n\t\tlet lengthSq;\n\t\tlet overlap;\n\t\tlet totalMass;\n\t\tlet averageMass1, averageMass2;\n\t\tlet i;\n\n\t\tfor (i = 0; i < length; i++) {\n\t\t\totherParticle = newPool[i];\n\n\t\t\tif (otherParticle !== particle) {\n\t\t\t\tthis.delta.copy(otherParticle.p);\n\t\t\t\tthis.delta.sub(particle.p);\n\n\t\t\t\tlengthSq = this.delta.lengthSq();\n\t\t\t\tconst distance = particle.radius + otherParticle.radius;\n\n\t\t\t\tif (lengthSq <= distance * distance) {\n\t\t\t\t\toverlap = distance - Math.sqrt(lengthSq);\n\t\t\t\t\toverlap += 0.5;\n\n\t\t\t\t\ttotalMass = particle.mass + otherParticle.mass;\n\t\t\t\t\taverageMass1 = this.mass ? otherParticle.mass / totalMass : 0.5;\n\t\t\t\t\taverageMass2 = this.mass ? particle.mass / totalMass : 0.5;\n\t\t\t\t\t\n\t\t\t\t\tparticle.p.add(this.delta.clone().normalize().multiplyScalar(overlap * -averageMass1));\n\t\t\t\t\totherParticle.p.add(this.delta.normalize().multiplyScalar(overlap * averageMass2));\n\n\t\t\t\t\tthis.callback && this.callback(particle, otherParticle);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n","import Util from '../utils/Util';\nimport Behaviour from './Behaviour';\n\nexport default class CrossZone extends Behaviour {\n\n /**\n * Defines what happens if the particles come to the end of the specified zone\n *\n * @memberof! Proton#\n * @augments Proton.Behaviour\n * @constructor\n * @alias Proton.CrossZone\n *\n * @param {Proton.Zone} zone \t\t\t\t\t\tcan be any Proton.Zone - e.g. Proton.RectZone()\n * @param {String} \t\t[crossType=dead] \t\t\twhat happens if the particles pass the zone - allowed strings: dead | bound | cross\n * @param {Number} \t\t[life=Infinity] \t\t\tthis behaviour's life\n * @param {String} \t\t[easing=ease.easeLinear] \tthis behaviour's easing\n *\n * @property {String} name The Behaviour name\n */\n constructor(zone, crossType, life, easing) {\n super(life, easing);\n\n this.reset(zone, crossType);\n this.name = \"CrossZone\";\n }\n\n /**\n * Reset this behaviour's parameters\n *\n * @method reset\n * @memberof Proton#Proton.CrossZone\n * @instance\n *\n * @param {Proton.Zone} zone \t\t\t\tcan be any Proton.Zone - e.g. Proton.RectZone()\n * @param {String} \t\t[crossType=dead] \twhat happens if the particles pass the zone - allowed strings: dead | bound | cross\n * @param {Number} \t\t[life=Infinity] \tthis behaviour's life\n * @param {String} \t\t[easing=easeLinear]\tthis behaviour's easing\n */\n reset(zone, crossType, life, easing) {\n this.zone = zone;\n this.zone.crossType = Util.initValue(crossType, \"dead\");\n\n life && super.reset(life, easing);\n }\n\n /**\n * Apply this behaviour for all particles every time\n *\n * @method applyBehaviour\n * @memberof Proton#Proton.CrossZone\n * @instance\n *\n * @param {Proton.Particle} particle\n * @param {Number} the integrate time 1/ms\n * @param {Int} the particle index\n */\n applyBehaviour(particle, time, index) {\n this.calculate(particle, time, index);\n this.zone.crossing(particle);\n };\n}","import Util from '../utils/Util';\nimport Behaviour from './Behaviour';\n\nexport default class Alpha extends Behaviour {\n\n\t/**\n\t * @memberof! Proton#\n\t * @augments Proton.Behaviour\n\t * @constructor\n\t * @alias Proton.Alpha\n\t *\n\t * @todo add description for 'a' and 'b'\n\t *\n\t * @param {Number} a\n\t * @param {String} b\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(a, b, life, easing) {\n\t\tsuper(life, easing);\n\n\t\tthis.reset(a, b);\n\t\tthis.name = \"Alpha\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#Proton.Alpha\n\t * @instance\n\t *\n\t * @todo add description for 'a' and 'b'\n\t *\n\t * @param {Number} a\n\t * @param {String} b\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t */\n\treset(a, b, life, easing) {\n\t\tthis.same = b === null || b === undefined ? true : false;\n\t\tthis.a = Util.setSpanValue(Util.initValue(a, 1));\n\t\tthis.b = Util.setSpanValue(b);\n\n\t\tlife && super.reset(life, easing);\n\t}\n\t\n\t/**\n\t * Sets the new alpha value of the particle\n\t *\n\t * @method initialize\n\t * @memberof Proton#Proton.Alpha\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle A single Proton generated particle\n\t */\n\tinitialize(particle) {\n\t\tparticle.transform.alphaA = this.a.getValue();\n\n\t\tif (this.same)\n\t\t\tparticle.transform.alphaB = particle.transform.alphaA;\n\t\telse\n\t\t\tparticle.transform.alphaB = this.b.getValue();\n\t}\n\n\t/**\n\t * @method applyBehaviour\n\t * @memberof Proton#Proton.Alpha\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle\n\t * @param {Number} \t\t\ttime the integrate time 1/ms\n\t * @param {Int} \t\t\tindex the particle index\n \t */\n\tapplyBehaviour(particle, time, index) {\n\t\tthis.calculate(particle, time, index);\n\t\t\n\t\tparticle.alpha = particle.transform.alphaB + (particle.transform.alphaA - particle.transform.alphaB) * this.energy;\n\t\tif (particle.alpha < 0.001) particle.alpha = 0;\n\t}\n}\n","import Util from '../utils/Util';\nimport Behaviour from './Behaviour';\n\nexport default class Scale extends Behaviour {\n\n\t/**\n\t * @memberof! Proton#\n\t * @augments Proton.Behaviour\n\t * @constructor\n\t * @alias Proton.Scale\n\t *\n\t * @todo add description for 'a' and 'b'\n\t *\n\t * @param {Number} a\n\t * @param {String} b\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(a, b, life, easing) {\n\t\tsuper(life, easing);\n\n\t\tthis.reset(a, b);\n\t\tthis.name = \"Scale\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#Proton.Scale\n\t * @instance\n\t *\n\t * @param {Number} a\n\t * @param {String} b\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t */\n\treset(a, b, life, easing) {\n\t\tthis.same = b === null || b === undefined ? true : false;\n\t\tthis.a = Util.setSpanValue(Util.initValue(a, 1));\n\t\tthis.b = Util.setSpanValue(b);\n\n\t\tlife && super.reset(life, easing);\n\t}\n\n\t/**\n\t * Initialize the behaviour's parameters for all particles\n\t *\n\t * @method initialize\n\t * @memberof Proton#Proton.Scale\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle\n\t */\n\tinitialize(particle) {\n\t\tparticle.transform.scaleA = this.a.getValue();\n\t\tparticle.transform.oldRadius = particle.radius;\n\t\tparticle.transform.scaleB = this.same ? particle.transform.scaleA : this.b.getValue();\n\t};\n\n\t/**\n\t * Apply this behaviour for all particles every time\n\t *\n\t * @method applyBehaviour\n\t * @memberof Proton#Proton.Scale\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle\n\t * @param {Number} \t\t\ttime the integrate time 1/ms\n\t * @param {Int} \t\t\tindex the particle index\n\t */\n\tapplyBehaviour(particle, time, index) {\n\t\tthis.calculate(particle, time, index);\n\t\tparticle.scale = particle.transform.scaleB + (particle.transform.scaleA - particle.transform.scaleB) * this.energy;\n\n\t\tif (particle.scale < 0.0001) particle.scale = 0;\n\t\tparticle.radius = particle.transform.oldRadius * particle.scale;\n\t}\n}","import Util from '../utils/Util';\nimport Behaviour from './Behaviour';\n\nexport default class Rotate extends Behaviour {\n\n\t/**\n\t * @memberof! Proton#\n\t * @augments Proton.Behaviour\n\t * @constructor\n\t * @alias Proton.Rotate\n\t *\n\t * @todo add description for 'a', 'b' and 'style'\n\t *\n\t * @param {Number} a\n\t * @param {String} b\n\t * @param {String} [style=to]\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(a, b, style, life, easing) {\n\t\tsuper(life, easing);\n\n\t\tthis.reset(a, b, style);\n\t\tthis.name = \"Rotate\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#Proton.Rotate\n\t * @instance\n\t *\n\t * @todo add description for 'a', 'b' and 'style'\n\t *\n\t * @param {Number} a\n\t * @param {String} b\n\t * @param {String} [style=to]\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t */\n\treset(a, b, style, life, easing) {\n\t\tthis.same = b === null || b === undefined ? true : false;\n\n\t\tthis.a = Util.setSpanValue(Util.initValue(a, \"Velocity\"));\n\t\tthis.b = Util.setSpanValue(Util.initValue(b, 0));\n\t\tthis.style = Util.initValue(style, 'to');\n\n\t\tlife && super.reset(life, easing);\n\t}\n\n\t/**\n\t * Initialize the behaviour's parameters for all particles\n\t *\n\t * @method initialize\n\t * @memberof Proton#Proton.Rotate\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle\n\t */\n\tinitialize(particle) {\n\t\tparticle.rotation = this.a.getValue();\n\t\tparticle.transform.rotationA = this.a.getValue();\n\n\t\tif (!this.same) particle.transform.rotationB = this.b.getValue();\n\t};\n\n\t/**\n\t * Apply this behaviour for all particles every time\n\t *\n\t * @method applyBehaviour\n\t * @memberof Proton#Proton.Rotate\n\t * @instance\n\t *\n\t * @param {Proton.Particle} particle\n\t * @param {Number} \t\t\ttime the integrate time 1/ms\n\t * @param {Int} \t\t\tindex the particle index\n\t */\n\tapplyBehaviour(particle, time, index) {\n\t\tthis.calculate(particle, time, index);\n\n\t\tif (!this.same) {\n\t\t\tif (this.style == 'to' || this.style == 'TO' || this.style == '_') {\n\t\t\t\tparticle.rotation += particle.transform.rotationB + (particle.transform.rotationA - particle.transform.rotationB) * this.energy\n\t\t\t} else {\n\t\t\t\tparticle.rotation += particle.transform.rotationB;\n\t\t\t}\n\t\t} else if (this.a.a == \"V\" || this.a.a == \"Velocity\" || this.a.a == \"v\") {\n\t\t\t//beta...\n\t\t\tparticle.rotation = particle.getDirection();\n\t\t}\n\t}\n\n}","import Util from '../utils/Util';\nimport ColorUtil from '../utils/ColorUtil';\nimport ArraySpan from '../math/ArraySpan';\nimport Behaviour from './Behaviour';\n\nexport default class Color extends Behaviour {\n\n /**\n * @memberof! Proton#\n * @augments Proton.Behaviour\n * @constructor\n * @alias Proton.Color\n *\n * @param {Proton.ArraySpan | String} a the string should be a hex e.g. #000000 for black\n * @param {Proton.ArraySpan | String} b the string should be a hex e.g. #000000 for black\n * @param {Number} [life=Infinity] \tthis behaviour's life\n * @param {String} [easing=easeLinear] \tthis behaviour's easing\n *\n * @property {String} name The Behaviour name\n */\n constructor(a, b, life, easing) {\n super(life, easing);\n\n this.reset(a, b);\n this.name = \"Color\";\n }\n\n /**\n * Reset this behaviour's parameters\n *\n * @method reset\n * @memberof Proton#Proton.Color\n * @instance\n *\n * @param {Proton.ArraySpan | String} a the string should be a hex e.g. #000000 for black\n * @param {Proton.ArraySpan | String} b the string should be a hex e.g. #000000 for black\n * @param {Number} [life=Infinity] \tthis behaviour's life\n * @param {String} [easing=easeLinear] \tthis behaviour's easing\n */\n reset(a, b, life, easing) {\n this.a = ArraySpan.createArraySpan(a);\n this.b = ArraySpan.createArraySpan(b);\n\n life && super.reset(life, easing);\n }\n\n /**\n * Initialize the behaviour's parameters for all particles\n *\n * @method initialize\n * @memberof Proton#Proton.Color\n * @instance\n *\n * @param {Proton.Particle} particle\n */\n initialize(particle) {\n particle.color = this.a.getValue();\n particle.transform.colorA = ColorUtil.hexToRGB(particle.color);\n\n if (this.b)\n particle.transform.colorB = ColorUtil.hexToRGB(this.b.getValue());\n };\n\n /**\n * Apply this behaviour for all particles every time\n *\n * @method applyBehaviour\n * @memberof Proton#Proton.Color\n * @instance\n *\n * @param {Proton.Particle} particle\n * @param {Number} the integrate time 1/ms\n * @param {Int} the particle index\n */\n applyBehaviour(particle, time, index) {\n if (this.b) {\n this.calculate(particle, time, index);\n\n particle.transform.rgb.r = particle.transform.colorB.r + (particle.transform.colorA.r - particle.transform.colorB.r) * this.energy;\n particle.transform.rgb.g = particle.transform.colorB.g + (particle.transform.colorA.g - particle.transform.colorB.g) * this.energy;\n particle.transform.rgb.b = particle.transform.colorB.b + (particle.transform.colorA.b - particle.transform.colorB.b) * this.energy;\n\n particle.transform.rgb.r = Math.floor(particle.transform.rgb.r);\n particle.transform.rgb.g = Math.floor(particle.transform.rgb.g);\n particle.transform.rgb.b = Math.floor(particle.transform.rgb.b);\n\n } else {\n particle.transform.rgb.r = particle.transform.colorA.r;\n particle.transform.rgb.g = particle.transform.colorA.g;\n particle.transform.rgb.b = particle.transform.colorA.b;\n }\n };\n\n}","import Util from '../utils/Util';\nimport Attraction from './Attraction';\n\nexport default class Repulsion extends Attraction {\n\n\t/**\n\t * The oppisite of Proton.Attraction - turns the force\n\t *\n\t * @memberof! Proton#\n\t * @augments Proton#Proton.Attraction\n\t * @constructor\n\t * @alias Proton.Repulsion\n\t *\n\t * @todo add description for 'force' and 'radius'\n\t *\n\t * @param {Proton.Vector2D} targetPosition the attraction point coordinates\n\t * @param {Number} [force=100]\n\t * @param {Number} [radius=1000]\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t *\n\t * @property {Number} force\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(targetPosition, force, radius, life, easing) {\n\t\tsuper(targetPosition, force, radius, life, easing);\n\n\t\tthis.force *= -1;\n\t\tthis.name = \"Repulsion\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#Proton.Repulsion\n\t * @instance\n\t *\n\t * @todo add description for 'force' and 'radius'\n\t *\n\t * @param {Proton.Vector2D} targetPosition the attraction point coordinates\n\t * @param {Number} [force=100]\n\t * @param {Number} [radius=1000]\n\t * @param {Number} [life=Infinity] \t\t\t\tthis behaviour's life\n\t * @param {String} [easing=ease.easeLinear] \tthis behaviour's easing\n\t */\n\treset(targetPosition, force, radius, life, easing) {\n\t\tsuper.reset(targetPosition, force, radius, life, easing);\n\t\tthis.force *= -1;\n\t}\n}\n","import Util from '../utils/Util';\nimport Vector2D from '../math/Vector2D';\nimport Behaviour from './Behaviour';\n\nexport default class GravityWell extends Behaviour {\n\n\t/**\n\t * @memberof! Proton#\n\t * @augments Behaviour\n\t * @constructor\n\t * @alias GravityWell\n\t *\n\t * @param {Vector2D} [centerPoint=new Vector2D] The point in the center\n\t * @param {Number} [force=100]\t\t\t\t\tThe force\t\n\t * @param {Number} [life=Infinity]\t\t\t\tthis behaviour's life\n\t * @param {String} [easing=easeLinear]\tthis behaviour's easing\n\t *\n\t * @property {String} name The Behaviour name\n\t */\n\tconstructor(centerPoint, force, life, easing) {\n\t\tsuper(life, easing);\n\n\t\tthis.distanceVec = new Vector2D();\n\t\tthis.centerPoint = Util.initValue(centerPoint, new Vector2D);\n\t\tthis.force = Util.initValue(this.normalizeValue(force), 100);\n\n\t\tthis.name = \"GravityWell\";\n\t}\n\n\t/**\n\t * Reset this behaviour's parameters\n\t *\n\t * @method reset\n\t * @memberof Proton#GravityWell\n\t * @instance\n\t *\n\t * @param {Vector2D} [centerPoint=new Vector2D] The point in the center\n\t * @param {Number} [force=100]\t\t\t\t\tThe force\t\n\t * @param {Number} [life=Infinity]\t\t\t\tthis behaviour's life\n\t * @param {String} [easing=easeLinear]\tthis behaviour's easing\n\t */\n\treset(centerPoint, force, life, easing) {\n\t\tthis.distanceVec = new Vector2D();\n\t\tthis.centerPoint = Util.initValue(centerPoint, new Vector2D);\n\t\tthis.force = Util.initValue(this.normalizeValue(force), 100);\n\t\t\n\t\tlife && super.reset(life, easing);\n\t};\n\n\t/**\n\t * @inheritdoc\n\t */\n\tinitialize(particle) {\n\t};\n\n\t/**\n\t * Apply this behaviour for all particles every time\n\t *\n\t * @method applyBehaviour\n\t * @memberof Proton#GravityWell\n\t * @instance\n\t *\n\t * @param {Particle} particle\n\t * @param {Number} the integrate time 1/ms\n\t * @param {Int} the particle index\n\t */\n\tapplyBehaviour(particle, time, index) {\n\t\tthis.distanceVec.set(this.centerPoint.x - particle.p.x, this.centerPoint.y - particle.p.y);\n\t\tconst distanceSq = this.distanceVec.lengthSq();\n\n\t\tif (distanceSq != 0) {\n\t\t\tconst distance = this.distanceVec.length();\n\t\t\tconst factor = (this.force * time) / (distanceSq * distance);\n\n\t\t\tparticle.v.x += factor * this.distanceVec.x;\n\t\t\tparticle.v.y += factor * this.distanceVec.y;\n\t\t}\n\t}\n}","import Util from '../utils/Util';\nimport MathUtils from '../math/MathUtils';\n\nexport default {\n\n\tinitialize(emitter, particle, initializes) {\n\t\tconst length = initializes.length;\n\t\tlet i;\n\n\t\tfor (i = 0; i < length; i++) {\n\t\t\tif (initializes[i] instanceof Proton.Initialize)\n\t\t\t\tinitializes[i].init(emitter, particle);\n\t\t\telse\n\t\t\t\tthis.init(emitter, particle, initializes[i]);\n\t\t}\n\n\t\tthis.bindEmitter(emitter, particle);\n\t},\n\n\t//////////////////////init//////////////////////\n\tinit(emitter, particle, initialize) {\n\t\tUtil.setPrototypeByObject(particle, initialize);\n\t\tUtil.setVector2DByObject(particle, initialize);\n\t},\n\t\n\tbindEmitter(emitter, particle) {\n\t\tif (emitter.bindEmitter) {\n\t\t\tparticle.p.add(emitter.p);\n\t\t\tparticle.v.add(emitter.v);\n\t\t\tparticle.a.add(emitter.a);\n\n\t\t\tparticle.v.rotate(MathUtils.degreeTransform(emitter.rotation));\n\t\t}\n\t}\n}\n","import Util from '../utils/Util';\nimport Particle from '../core/Particle';\nimport EventDispatcher from '../events/EventDispatcher';\n\nimport Rate from '../initialize/Rate';\nimport InitializeUtil from '../initialize/InitializeUtil';\n\nexport default class Emitter extends Particle {\n\n\tstatic ID = 0;\n\n\t/**\n\t * You can use this emit particles.\n\t *\n\t * It will dispatch follow events:\n\t * PARTICLE_CREATED\n\t * PARTICLE_UPDATA\n\t * PARTICLE_DEAD\n\t *\n\t * @class Emitter\n\t * @constructor\n\t * @param {Object} pObj the parameters object;\n\t * for example {damping:0.01,bindEmitter:false}\n\t */\n\tconstructor(pObj) {\n\t\tsuper(pObj);\n\n\t\tthis.initializes = [];\n\t\tthis.particles = [];\n\t\tthis.behaviours = [];\n\n\t\tthis.emitSpeed = 0;\n\t\tthis.currentEmitTime = 0;\n\t\tthis.totalEmitTimes = -1;\n\n\t\t/**\n\t\t * The friction coefficient for all particle emit by This;\n\t\t * @property damping\n\t\t * @type {Number}\n\t\t * @default 0.006\n\t\t */\n\t\tthis.damping = .006;\n\n\t\t/**\n\t\t * If bindEmitter the particles can bind this emitter's property;\n\t\t * @property bindEmitter\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.bindEmitter = true;\n\n\t\t/**\n\t\t * The number of particles per second emit (a [particle]/b [s]);\n\t\t * @property rate\n\t\t * @type {Rate}\n\t\t * @default Rate(1, .1)\n\t\t */\n\t\tthis.rate = new Rate(1, .1);\n\n\t\tthis.id = `emitter_${Emitter.ID++}`;\n\t\tthis.name = 'Emitter';\n\t}\n\n\t/**\n\t * start emit particle\n\t * @method emit\n\t * @param {Number} currentEmitTime begin emit time;\n\t * @param {String} life the life of this emitter\n\t */\n\temit(totalEmitTimes, life) {\n\t\tthis.stoped = false;\n\t\tthis.currentEmitTime = 0;\n\t\tthis.totalEmitTimes = Util.initValue(totalEmitTimes, Infinity);\n\n\t\tif (life == true || life == 'life' || life == 'destroy') {\n\t\t\tthis.life = totalEmitTimes == 'once' ? 1 : this.totalEmitTimes;\n\t\t} else if (!isNaN(life)) {\n\t\t\tthis.life = life;\n\t\t}\n\n\t\tthis.rate.init();\n\t}\n\n\t/**\n\t * stop emiting\n\t * @method stop\n\t */\n\tstop() {\n\t\tthis.totalEmitTimes = -1;\n\t\tthis.currentEmitTime = 0;\n\t\tthis.stoped = true;\n\t}\n\n\t/**\n\t * remove current all particles\n\t * @method removeAllParticles\n\t */\n\tremoveAllParticles() {\n\t\tlet i = this.particles.length;\n\t\twhile (i--) this.particles[i].dead = true;\n\t}\n\n\t/**\n\t * add initialize to this emitter\n\t * @method addSelfInitialize\n\t */\n\taddSelfInitialize(pObj) {\n\t\tif (pObj['init']) {\n\t\t\tpObj.init(this);\n\t\t} else {\n\t\t\tthis.initAll();\n\t\t}\n\t}\n\n\t/**\n\t * add the Initialize to particles;\n\t * \n\t * you can use initializes array:for example emitter.addInitialize(initialize1,initialize2,initialize3);\n\t * @method addInitialize\n\t * @param {Initialize} initialize like this new Radius(1, 12)\n\t */\n\taddInitialize(...rest) {\n\t\tlet i = rest.length;\n\t\twhile (i--)\n\t\t\tthis.initializes.push(rest[i]);\n\t}\n\n\t/**\n\t * remove the Initialize\n\t * @method removeInitialize\n\t * @param {Initialize} initialize a initialize\n\t */\n\tremoveInitialize(initializer) {\n\t\tconst index = this.initializes.indexOf(initializer);\n\t\tif (index > -1) this.initializes.splice(index, 1);\n\t}\n\n\t/**\n\t * remove all Initializes\n\t * @method removeInitializers\n\t */\n\tremoveAllInitializers() {\n\t\tUtil.destroyArray(this.initializes);\n\t}\n\n\t/**\n\t * add the Behaviour to particles;\n\t * \n\t * you can use Behaviours array:emitter.addBehaviour(Behaviour1,Behaviour2,Behaviour3);\n\t * @method addBehaviour\n\t * @param {Behaviour} behaviour like this new Color('random')\n\t */\n\taddBehaviour(...rest) {\n\t\tlet i = arguments.length;\n\t\twhile (i--) {\n\t\t\tlet behaviour = rest[i];\n\t\t\tthis.behaviours.push(behaviour);\n\t\t\tif (behaviour.parents) behaviour.parents.push(this);\n\t\t}\n\t}\n\n\t/**\n\t * remove the Behaviour\n\t * @method removeBehaviour\n\t * @param {Behaviour} behaviour a behaviour\n\t */\n\tremoveBehaviour(behaviour) {\n\t\tlet index = this.behaviours.indexOf(behaviour);\n\t\tthis.behaviours.splice(index, 1);\n\n\t\tif (behaviour.parents) {\n\t\t\tindex = behaviour.parents.indexOf(behaviour);\n\t\t\tbehaviour.parents.splice(index, 1);\n\t\t}\n\n\t\treturn index;\n\t}\n\n\t/**\n\t * remove all behaviours\n\t * @method removeAllBehaviours\n\t */\n\tremoveAllBehaviours() {\n\t\tUtil.destroyArray(this.behaviours);\n\t}\n\n\t// emitter update \n\tupdate(time) {\n\t\tthis.age += time;\n\t\tif (this.age >= this.life || this.dead) this.destroy();\n\n\t\tthis.emitting(time);\n\t\tthis.integrate(time);\n\t}\n\n\tintegrate(time) {\n\t\tif (!this.parent) return;\n\n\t\tconst damping = 1 - this.damping;\n\t\tthis.parent.integrator.calculate(this, time, damping);\n\n\t\tconst length = this.particles.length;\n\t\tlet i, particle;\n\n\t\tfor (i = length - 1; i >= 0; i--) {\n\t\t\tparticle = this.particles[i];\n\n\t\t\t// particle update\n\t\t\tparticle.update(time, i);\n\t\t\tthis.parent.integrator.calculate(particle, time, damping);\n\t\t\tthis.dispatch(\"PARTICLE_UPDATE\", particle);\n\n\t\t\t// check dead\n\t\t\tif (particle.dead) {\n\t\t\t\tthis.dispatch(\"PARTICLE_DEAD\", particle);\n\n\t\t\t\tthis.parent.pool.expire(particle);\n\t\t\t\tthis.particles.splice(i, 1);\n\t\t\t}\n\t\t}\n\t}\n\n\tdispatch(event, target) {\n\t\tthis.parent && this.parent.dispatchEvent(event, target);\n\t\tProton.bindEmtterEvent && this.dispatchEvent(event, target);\n\t}\n\n\temitting(time) {\n\t\tif (this.totalEmitTimes == 'once') {\n\t\t\tlet i;\n\t\t\tconst length = this.rate.getValue(99999);\n\n\t\t\tif (length > 0) this.emitSpeed = length;\n\t\t\tfor (i = 0; i < length; i++) this.createParticle();\n\t\t\tthis.totalEmitTimes = 'none';\n\t\t}\n\n\t\telse {\n\t\t\tthis.currentEmitTime += time;\n\n\t\t\tif (this.currentEmitTime < this.totalEmitTimes) {\n\t\t\t\tconst length = this.rate.getValue(time)\n\t\t\t\tlet i;\n\n\t\t\t\tif (length > 0) this.emitSpeed = length;\n\t\t\t\tfor (i = 0; i < length; i++) this.createParticle();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * create single particle;\n\t * \n\t * can use emit({x:10},new Gravity(10),{'particleUpdate',fun}) or emit([{x:10},new Initialize],new Gravity(10),{'particleUpdate',fun})\n\t * @method removeAllParticles\n\t */\n\tcreateParticle(initialize, behaviour) {\n\t\tconst particle = this.parent.pool.get(Particle);\n\t\tthis.setupParticle(particle, initialize, behaviour);\n\t\tthis.dispatch(\"PARTICLE_CREATED\", particle);\n\n\t\treturn particle;\n\t}\n\n\tsetupParticle(particle, initialize, behaviour) {\n\t\tlet initializes = this.initializes;\n\t\tlet behaviours = this.behaviours;\n\n\t\tif (initialize) {\n\t\t\tinitializes = Util.isArray(initialize) ? initialize : [initialize];\n\t\t}\n\n\t\tif (behaviour) {\n\t\t\tbehaviour = Util.isArray(behaviour) ? behaviour : [behaviour];\n\t\t}\n\n\t\tparticle.reset();\n\t\tInitializeUtil.initialize(this, particle, initializes);\n\t\tparticle.addBehaviours(behaviours);\n\t\tparticle.parent = this;\n\n\t\tthis.particles.push(particle);\n\t}\n\n\tremove(){\n\t\tthis.stop();\n\t\tUtil.destroy(this.particles);\n\t}\n\n\t/**\n\t * Destory this Emitter\n\t * @method destroy\n\t */\n\tdestroy(slow) {\n\t\tthis.dead = true;\n\t\tthis.remove();\n\t\tthis.removeAllInitializers();\n\t\tthis.removeAllBehaviours();\n\t\tthis.parent && this.parent.removeEmitter(this);\n\t}\n\n}\n\nEventDispatcher.bind(Emitter);","import Util from '../utils/Util';\nimport Emitter from './Emitter';\n\nexport default class BehaviourEmitter extends Emitter {\n\n\t/**\n\t * The BehaviourEmitter class inherits from Proton.Emitter\n\t *\n\t * use the BehaviourEmitter you can add behaviours to self;\n\t * @class Proton.BehaviourEmitter\n\t * @constructor\n\t * @param {Object} pObj the parameters object;\n\t */\n\tconstructor(pObj) {\n\t\tsuper(pObj);\n\n\t\tthis.selfBehaviours = [];\n\t};\n\t\n\t/**\n\t * add the Behaviour to emitter;\n\t *\n\t * you can use Behaviours array:emitter.addSelfBehaviour(Behaviour1,Behaviour2,Behaviour3);\n\t * @method addSelfBehaviour\n\t * @param {Proton.Behaviour} behaviour like this new Proton.Color('random')\n\t */\n\taddSelfBehaviour(...rest) {\n\t\tconst length = rest.length;\n\t\tlet i;\n\n\t\tfor (i = 0; i < length; i++) {\n\t\t\tthis.selfBehaviours.push(rest[i]);\n\t\t}\n\t};\n\n\t/**\n\t * remove the Behaviour for self\n\t * @method removeSelfBehaviour\n\t * @param {Proton.Behaviour} behaviour a behaviour\n\t */\n\tremoveSelfBehaviour(behaviour) {\n\t\tconst index = this.selfBehaviours.indexOf(behaviour);\n\t\tif (index > -1) this.selfBehaviours.splice(index, 1);\n\t};\n\n\tupdate(time) {\n\t\tsuper.update(time);\n\n\t\tif (!this.sleep) {\n\t\t\tconst length = this.selfBehaviours.length;\n\t\t\tlet i;\n\n\t\t\tfor (i = 0; i < length; i++) {\n\t\t\t\tthis.selfBehaviours[i].applyBehaviour(this, time, i);\n\t\t\t}\n\t\t}\n\t}\n}","import Util from '../utils/Util';\nimport Emitter from './Emitter';\n\nexport default class FollowEmitter extends Emitter {\n\n\t/**\n\t * The FollowEmitter class inherits from Proton.Emitter\n\t *\n\t * use the FollowEmitter will emit particle when mousemoving\n\t *\n\t * @class Proton.FollowEmitter\n\t * @constructor\n\t * @param {Element} mouseTarget mouseevent's target;\n\t * @param {Number} ease the easing of following speed;\n\t * @default 0.7\n\t * @param {Object} pObj the parameters object;\n\t */\n\tconstructor(mouseTarget, ease, pObj) {\n\t\tsuper(pObj);\n\n\t\tthis.mouseTarget = Util.initValue(mouseTarget, window);\n\t\tthis.ease = Util.initValue(ease, .7);\n\n\t\tthis._allowEmitting = false;\n\t\tthis.initEventHandler();\n\t};\n\n\tinitEventHandler() {\n\t\tthis.mousemoveHandler = e => this.mousemove.call(this, e);\n\t\tthis.mousedownHandler = e => this.mousedown.call(this, e);\n\t\tthis.mouseupHandler = e => this.mouseup.call(this, e);\n\n\t\tthis.mouseTarget.addEventListener('mousemove', this.mousemoveHandler, false);\n\t}\n\n\t/**\n\t * start emit particle\n\t * @method emit\n\t */\n\temit() {\n\t\tthis._allowEmitting = true;\n\t}\n\n\t/**\n\t * stop emiting\n\t * @method stop\n\t */\n\tstop() {\n\t\tthis._allowEmitting = false;\n\t}\n\n\tmousemove(e) {\n\t\tif (e.layerX || e.layerX == 0) {\n\t\t\tthis.p.x += (e.layerX - this.p.x) * this.ease;\n\t\t\tthis.p.y += (e.layerY - this.p.y) * this.ease;\n\t\t} else if (e.offsetX || e.offsetX == 0) {\n\t\t\tthis.p.x += (e.offsetX - this.p.x) * this.ease;\n\t\t\tthis.p.y += (e.offsetY - this.p.y) * this.ease;\n\t\t}\n\n\t\tif (this._allowEmitting) super.emit('once');\n\t};\n\n\t/**\n\t * Destory this Emitter\n\t * @method destroy\n\t */\n\tdestroy() {\n\t\tsuper.destroy();\n\t\tthis.mouseTarget.removeEventListener('mousemove', this.mousemoveHandler, false);\n\t}\n\n}\n","import Pool from '../core/Pool';\nimport Util from '../utils/Util';\n\nexport default class BaseRenderer {\n\n constructor(element, stroke) {\n this.element = element;\n this.stroke = stroke;\n\n this.initHandler();\n\n this.circleConf = { isCircle: true };\n this.pool = new Pool();\n this.name = 'BaseRenderer';\n }\n\n setStroke(color, thinkness) {\n color = Util.initValue(color, '#000000');\n thinkness = Util.initValue(thinkness, 1);\n\n this.stroke = { color, thinkness };\n }\n\n initHandler() {\n this._protonUpdateHandler = () => { this.onProtonUpdate.call(this) };\n this._protonUpdateAfterHandler = () => { this.onProtonUpdateAfter.call(this) };\n this._emitterAddedHandler = (emitter) => { this.onEmitterAdded.call(this, emitter) };\n this._emitterRemovedHandler = (emitter) => { this.onEmitterRemoved.call(this, emitter) };\n this._particleCreatedHandler = (particle) => { this.onParticleCreated.call(this, particle) };\n this._particleUpdateHandler = (particle) => { this.onParticleUpdate.call(this, particle) };\n this._particleDeadHandler = (particle) => { this.onParticleDead.call(this, particle) };\n }\n\n init(proton) {\n this.parent = proton;\n\n proton.addEventListener(Proton.PROTON_UPDATE, this._protonUpdateHandler);\n proton.addEventListener(Proton.PROTON_UPDATE_AFTER, this._protonUpdateAfterHandler);\n\n proton.addEventListener(Proton.EMITTER_ADDED, this._emitterAddedHandler);\n proton.addEventListener(Proton.EMITTER_REMOVED, this._emitterRemovedHandler);\n\n proton.addEventListener(Proton.PARTICLE_CREATED, this._particleCreatedHandler);\n proton.addEventListener(Proton.PARTICLE_UPDATE, this._particleUpdateHandler);\n proton.addEventListener(Proton.PARTICLE_DEAD, this._particleDeadHandler);\n }\n\n resize(width, height) {}\n\n remove(proton) {\n this.parent.removeEventListener(Proton.PROTON_UPDATE, this._protonUpdateHandler);\n this.parent.removeEventListener(Proton.PROTON_UPDATE_AFTER, this._protonUpdateAfterHandler);\n\n this.parent.removeEventListener(Proton.EMITTER_ADDED, this._emitterAddedHandler);\n this.parent.removeEventListener(Proton.EMITTER_REMOVED, this._emitterRemovedHandler);\n\n this.parent.removeEventListener(Proton.PARTICLE_CREATED, this._particleCreatedHandler);\n this.parent.removeEventListener(Proton.PARTICLE_UPDATE, this._particleUpdateHandler);\n this.parent.removeEventListener(Proton.PARTICLE_DEAD, this._particleDeadHandler);\n\n this.parent = null;\n }\n\n destroy(){\n this.remove();\n }\n \n onProtonUpdate() {}\n onProtonUpdateAfter() {}\n\n onEmitterAdded(emitter) {}\n onEmitterRemoved(emitter) {}\n\n onParticleCreated(particle) {}\n onParticleUpdate(particle) {}\n onParticleDead(particle) {}\n}","import Util from '../utils/Util';\nimport ImgUtil from '../utils/ImgUtil';\nimport ColorUtil from '../utils/ColorUtil';\nimport MathUtils from '../math/MathUtils';\nimport BaseRenderer from './BaseRenderer';\n\nexport default class CanvasRenderer extends BaseRenderer {\n\n constructor(element) {\n super(element);\n\n this.stroke = null;\n this.context = this.element.getContext(\"2d\");\n this.bufferCache = {};\n\n this.name = 'CanvasRenderer';\n }\n\n resize(width, height) {\n this.element.width = width;\n this.element.height = height;\n }\n\n onProtonUpdate() {\n this.context.clearRect(0, 0, this.element.width, this.element.height);\n }\n\n onParticleCreated(particle) {\n if (particle.body)\n ImgUtil.getImgFromCache(particle.body, this.addImg2Body, particle);\n else\n particle.color = particle.color || '#ff0000';\n }\n\n onParticleUpdate(particle) {\n if (particle.body) {\n if (particle.body instanceof Image) this.drawImage(particle);\n } else {\n this.drawCircle(particle);\n }\n }\n\n onParticleDead(particle) {\n particle.body = null;\n }\n\n\n // private \n addImg2Body(img, particle) {\n particle.body = img;\n }\n\n // private drawCircle --\n drawImage(particle) {\n const w = particle.body.width * particle.scale | 0;\n const h = particle.body.height * particle.scale | 0;\n const x = particle.p.x - w / 2;\n const y = particle.p.y - h / 2;\n\n if (!!particle.color) {\n if (!particle.transform[\"buffer\"]) particle.transform.buffer = this.createBuffer(particle.body);\n\n const bufferContext = particle.transform.buffer.getContext('2d');\n bufferContext.clearRect(0, 0, particle.transform.buffer.width, particle.transform.buffer.height);\n bufferContext.globalAlpha = particle.alpha;\n bufferContext.drawImage(particle.body, 0, 0);\n\n bufferContext.globalCompositeOperation = \"source-atop\";\n bufferContext.fillStyle = ColorUtil.rgbToHex(particle.transform.rgb);\n bufferContext.fillRect(0, 0, particle.transform.buffer.width, particle.transform.buffer.height);\n bufferContext.globalCompositeOperation = \"source-over\";\n bufferContext.globalAlpha = 1;\n\n this.context.drawImage(particle.transform.buffer, 0, 0, particle.transform.buffer.width, particle.transform.buffer.height, x, y, w, h);\n } else {\n this.context.save();\n\n this.context.globalAlpha = particle.alpha;\n this.context.translate(particle.p.x, particle.p.y);\n this.context.rotate(MathUtils.degreeTransform(particle.rotation));\n this.context.translate(-particle.p.x, -particle.p.y);\n this.context.drawImage(particle.body, 0, 0, particle.body.width, particle.body.height, x, y, w, h);\n\n this.context.globalAlpha = 1;\n this.context.restore();\n }\n }\n\n // private drawCircle --\n drawCircle(particle) {\n if (particle.transform[\"rgb\"])\n this.context.fillStyle = 'rgba(' + particle.transform.rgb.r + ',' + particle.transform.rgb.g + ',' + particle.transform.rgb.b + ',' + particle.alpha + ')';\n else\n this.context.fillStyle = particle.color;\n\n // draw circle\n this.context.beginPath();\n this.context.arc(particle.p.x, particle.p.y, particle.radius, 0, Math.PI * 2, true);\n\n if (this.stroke) {\n this.context.strokeStyle = this.stroke.color;\n this.context.lineWidth = this.stroke.thinkness;\n this.context.stroke();\n }\n\n this.context.closePath();\n this.context.fill();\n }\n\n // private createBuffer --\n createBuffer(image) {\n if (image instanceof Image) {\n const size = image.width + '_' + image.height;\n let canvas = this.bufferCache[size];\n\n if (!canvas) {\n canvas = document.createElement('canvas');\n canvas.width = image.width;\n canvas.height = image.height;\n this.bufferCache[size] = canvas;\n }\n\n return canvas;\n }\n }\n}","import Util from '../utils/Util';\nimport DomUtil from '../utils/DomUtil';\nimport ImgUtil from '../utils/ImgUtil';\nimport MathUtils from '../math/MathUtils';\nimport BaseRenderer from './BaseRenderer';\n\nexport default class DomRenderer extends BaseRenderer {\n\n constructor(element) {\n super(element);\n\n this.stroke = null;\n this.pool.create = (body, particle) => this.createBody(body, particle);\n this.addImg2Body = this.addImg2Body.bind(this);\n\n this.transform3d = false;\n\n this.name = 'DomRenderer';\n }\n\n onParticleCreated(particle) {\n if (particle.body) {\n ImgUtil.getImgFromCache(particle.body, this.addImg2Body, particle);\n } else {\n particle.body = this.pool.get(this.circleConf, particle);\n this.element.appendChild(particle.body);\n }\n }\n\n onParticleUpdate(particle) {\n if (this.bodyReady(particle)) {\n if (this.transform3d)\n DomUtil.transform3d(particle.body, particle.p.x, particle.p.y, particle.scale, particle.rotation);\n else\n DomUtil.transform(particle.body, particle.p.x, particle.p.y, particle.scale, particle.rotation);\n\n particle.body.style.opacity = particle.alpha;\n if (particle.body.isCircle) {\n particle.body.style.backgroundColor = particle.color || '#ff0000';\n }\n }\n }\n\n onParticleDead(particle) {\n if (this.bodyReady(particle)) {\n this.element.removeChild(particle.body);\n this.pool.expire(particle.body);\n particle.body = null;\n }\n }\n\n bodyReady(particle) {\n return typeof particle.body === 'object' && particle.body && !particle.body.isInner;\n }\n\n // private \n addImg2Body(img, particle) {\n if (particle.dead) return;\n particle.body = this.pool.get(img, particle);\n DomUtil.resize(particle.body, img.width, img.height);\n\n this.element.appendChild(particle.body);\n }\n\n createBody(body, particle) {\n if (body.isCircle)\n return this.createCircle(particle);\n else\n return this.createSprite(body, particle);\n }\n\n // private --\n createCircle(particle) {\n const dom = DomUtil.createDiv(`${particle.id}_dom`, 2 * particle.radius, 2 * particle.radius);\n dom.style.borderRadius = `${particle.radius}px`;\n\n if (this.stroke) {\n dom.style.borderColor = this.stroke.color;\n dom.style.borderWidth = `${this.stroke.thinkness}px`;\n }\n dom.isCircle = true;\n\n return dom;\n }\n\n createSprite(body, particle) {\n const url = typeof body === 'string' ? body : body.src;\n const dom = DomUtil.createDiv(`${particle.id}_dom`, body.width, body.height);\n dom.style.backgroundImage = `url(${url})`;\n\n return dom;\n }\n\n}","import Util from '../utils/Util';\nimport BaseRenderer from './BaseRenderer';\n\nexport default class EaselRenderer extends BaseRenderer {\n\n constructor(element, stroke) {\n super(element);\n\n this.stroke = stroke;\n this.name = 'EaselRenderer';\n }\n\n onParticleCreated(particle) {\n if (particle.body) {\n this.createSprite(particle);\n } else {\n this.createCircle(particle);\n }\n\n this.element.addChild(particle.body);\n }\n\n onParticleUpdate(particle) {\n if (particle.body) {\n particle.body.x = particle.p.x;\n particle.body.y = particle.p.y;\n\n particle.body.alpha = particle.alpha;\n particle.body.scaleX = particle.body.scaleY = particle.scale;\n particle.body.rotation = particle.rotation;\n }\n }\n\n onParticleDead(particle) {\n if (particle.body) {\n particle.body.parent && particle.body.parent.removeChild(particle.body);\n this.pool.expire(particle.body);\n particle.body = null;\n }\n\n if (particle.graphics) this.pool.expire(particle.graphics);\n }\n\n // private\n createSprite(particle) {\n particle.body = this.pool.get(particle.body);\n\n if (particle.body.parent) return;\n if (particle.body['image']) {\n particle.body.regX = particle.body.image.width / 2;\n particle.body.regY = particle.body.image.height / 2;\n }\n }\n\n createCircle(particle) {\n const graphics = this.pool.get(createjs.Graphics);\n\n if (this.stroke) {\n if (this.stroke instanceof String)\n graphics.beginStroke(this.stroke);\n else\n graphics.beginStroke('#000000');\n }\n graphics.beginFill(particle.color || '#ff0000').drawCircle(0, 0, particle.radius);\n\n const shape = this.pool.get(createjs.Shape, [graphics]);\n\n particle.body = shape;\n particle.graphics = graphics;\n }\n\n}","import Util from '../utils/Util';\nimport Rectangle from '../math/Rectangle';\nimport BaseRenderer from './BaseRenderer';\n\nexport default class PixelRenderer extends BaseRenderer {\n\n constructor(element, rectangle) {\n super(element);\n\n this.context = this.element.getContext('2d');\n this.imageData = null;\n this.rectangle = null;\n this.rectangle = rectangle;\n this.createImageData(rectangle);\n\n this.name = 'PixelRenderer';\n }\n\n resize(width, height) {\n this.element.width = width;\n this.element.height = height;\n }\n\n createImageData(rectangle) {\n this.rectangle = rectangle ? rectangle : new Rectangle(0, 0, this.element.width, this.element.height);\n this.imageData = this.context.createImageData(this.rectangle.width, this.rectangle.height);\n this.context.putImageData(this.imageData, this.rectangle.x, this.rectangle.y);\n }\n\n onProtonUpdate() {\n this.context.clearRect(this.rectangle.x, this.rectangle.y, this.rectangle.width, this.rectangle.height);\n this.imageData = this.context.getImageData(this.rectangle.x, this.rectangle.y, this.rectangle.width, this.rectangle.height);\n }\n\n onProtonUpdateAfter() {\n this.context.putImageData(this.imageData, this.rectangle.x, this.rectangle.y);\n }\n\n onParticleCreated(particle) {}\n\n onParticleUpdate(particle) {\n if (this.imageData) {\n this.setPixel(this.imageData, Math.floor(particle.p.x - this.rectangle.x), Math.floor(particle.p.y - this.rectangle.y), particle);\n }\n }\n\n setPixel(imagedata, x, y, particle) {\n const rgb = particle.transform.rgb;\n\n if ((x < 0) || (x > this.element.width) || (y < 0) || (y > this.elementwidth))\n return;\n\n const i = ((y >> 0) * imagedata.width + (x >> 0)) * 4;\n\n imagedata.data[i] = rgb.r;\n imagedata.data[i + 1] = rgb.g;\n imagedata.data[i + 2] = rgb.b;\n imagedata.data[i + 3] = particle.alpha * 255;\n }\n\n onParticleDead(particle) {\n\n }\n\n}","import Pool from '../core/Pool';\nimport Util from '../utils/Util';\nimport ColorUtil from '../utils/ColorUtil';\nimport MathUtils from '../math/MathUtils';\nimport BaseRenderer from './BaseRenderer';\n\nexport default class PixiRenderer extends BaseRenderer {\n\n constructor(element, stroke) {\n super(element);\n\n this.stroke = stroke;\n this.setColor = false;\n this.pool.create = (body, particle) => this.createBody(body, particle);\n this.name = 'PixiRenderer';\n }\n\n onProtonUpdate() { }\n\n /**\n * @param particle\n */\n onParticleCreated(particle) {\n if (particle.body) {\n particle.body = this.pool.get(particle.body, particle);\n } else {\n particle.body = this.pool.get(this.circleConf, particle);\n }\n\n this.element.addChild(particle.body);\n }\n\n /**\n * @param particle\n */\n onParticleUpdate(particle) {\n this.transform(particle, particle.body);\n if (this.setColor) particle.body.tint = ColorUtil.getHex16FromParticle(particle);\n }\n\n /**\n * @param particle\n */\n onParticleDead(particle) {\n this.element.removeChild(particle.body);\n this.pool.expire(particle.body);\n particle.body = null;\n }\n\n destroy(particles) {\n super.destroy();\n this.pool.destroy();\n\n let i = particles.length;\n while (i--) {\n let particle = particles[i];\n if (particle.body) {\n this.element.removeChild(particle.body);\n }\n }\n }\n\n transform(particle, target) {\n target.x = particle.p.x;\n target.y = particle.p.y;\n\n target.alpha = particle.alpha;\n\n target.scale.x = particle.scale;\n target.scale.y = particle.scale;\n\n // using cached version of MathUtils.PI_180 for slight performance increase.\n target.rotation = particle.rotation * MathUtils.PI_180; // MathUtils.PI_180;\n }\n\n createBody(body, particle) {\n if (body.isCircle)\n return this.createCircle(particle);\n else\n return this.createSprite(body);\n }\n\n createSprite(body) {\n const sprite = body.isInner ? PIXI.Sprite.fromImage(body.src) : new PIXI.Sprite(body);\n sprite.anchor.x = 0.5;\n sprite.anchor.y = 0.5;\n\n return sprite;\n }\n\n createCircle(particle) {\n const graphics = new PIXI.Graphics();\n\n if (this.stroke) {\n let stroke = this.stroke instanceof String ? this.stroke : 0x000000;\n graphics.beginStroke(this.stroke);\n }\n\n graphics.beginFill(particle.color || 0x008ced);\n graphics.drawCircle(0, 0, particle.radius);\n graphics.endFill();\n\n return graphics;\n }\n}","import Mat3 from '../math/Mat3';\n\nexport default class MStack {\n\n\tconstructor() {\n\t\tthis.mats = [];\n\t\tthis.size = 0;\n\n\t\tfor (let i = 0; i < 20; i++) this.mats.push(Mat3.create([0, 0, 0, 0, 0, 0, 0, 0, 0]));\n\t}\n\n\tset(m, i) {\n\t\tif (i == 0)\n\t\t\tMat3.set(m, this.mats[0]);\n\t\telse\n\t\t\tMat3.multiply(this.mats[i - 1], m, this.mats[i]);\n\n\t\tthis.size = Math.max(this.size, i + 1);\n\t}\n\n\tpush(m) {\n\t\tif (this.size == 0)\n\t\t\tMat3.set(m, this.mats[0]);\n\t\telse\n\t\t\tMat3.multiply(this.mats[this.size - 1], m, this.mats[this.size]);\n\n\t\tthis.size++;\n\t}\n\n\tpop() {\n\t\tif (this.size > 0)\n\t\t\tthis.size--;\n\t}\n\n\ttop() {\n\t\treturn (this.mats[this.size - 1]);\n\t}\n}","import Mat3 from '../math/Mat3';\nimport BaseRenderer from './BaseRenderer';\n\nimport Util from '../utils/Util';\nimport ImgUtil from '../utils/ImgUtil';\nimport MStack from '../utils/MStack';\nimport DomUtil from '../utils/DomUtil';\nimport WebGLUtil from '../utils/WebGLUtil';\nimport MathUtils from '../math/MathUtils';\n\nexport default class WebGLRenderer extends BaseRenderer {\n\n constructor(element) {\n super(element);\n\n this.gl = this.element.getContext('experimental-webgl', { antialias: true, stencil: false, depth: false });\n if (!this.gl) alert(\"Sorry your browser do not suppest WebGL!\");\n\n this.initVar();\n this.setMaxRadius();\n this.initShaders();\n this.initBuffers();\n\n this.gl.blendEquation(this.gl.FUNC_ADD);\n this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA);\n this.gl.enable(this.gl.BLEND);\n\n this.addImg2Body = this.addImg2Body.bind(this);\n\n this.name = 'WebGLRenderer';\n }\n\n init(proton) {\n super.init(proton);\n this.resize(this.element.width, this.element.height);\n }\n\n resize(width, height) {\n this.umat[4] = -2;\n this.umat[7] = 1;\n\n this.smat[0] = 1 / width;\n this.smat[4] = 1 / height;\n\n this.mstack.set(this.umat, 0);\n this.mstack.set(this.smat, 1);\n\n this.gl.viewport(0, 0, width, height);\n this.element.width = width;\n this.element.height = height;\n }\n\n setMaxRadius(radius) {\n this.circleCanvasURL = this.createCircle(radius);\n }\n\n getVertexShader() {\n const vsSource = [\"uniform vec2 viewport;\", \"attribute vec2 aVertexPosition;\", \"attribute vec2 aTextureCoord;\", \"uniform mat3 tMat;\", \"varying vec2 vTextureCoord;\", \"varying float alpha;\", \"void main() {\", \"vec3 v = tMat * vec3(aVertexPosition, 1.0);\", \"gl_Position = vec4(v.x, v.y, 0, 1);\", \"vTextureCoord = aTextureCoord;\", \"alpha = tMat[0][2];\", \"}\"].join(\"\\n\");\n return vsSource;\n }\n\n getFragmentShader() {\n const fsSource = [\"precision mediump float;\", \"varying vec2 vTextureCoord;\", \"varying float alpha;\", \"uniform sampler2D uSampler;\", \"uniform vec4 color;\", \"uniform bool useTexture;\", \"uniform vec3 uColor;\", \"void main() {\", \"vec4 textureColor = texture2D(uSampler, vTextureCoord);\", \"gl_FragColor = textureColor * vec4(uColor, 1.0);\", \"gl_FragColor.w *= alpha;\", \"}\"].join(\"\\n\");\n return fsSource;\n }\n\n initVar() {\n this.mstack = new MStack();\n this.umat = Mat3.create([2, 0, 1, 0, -2, 0, -1, 1, 1]);\n this.smat = Mat3.create([1 / 100, 0, 1, 0, 1 / 100, 0, 0, 0, 1]);\n this.texturebuffers = {};\n }\n\n blendEquation(A) {\n this.gl.blendEquation(this.gl[A]);\n }\n\n blendFunc(A, B) {\n this.gl.blendFunc(this.gl[A], this.gl[B]);\n }\n\n getShader(gl, str, fs) {\n const shader = fs ? gl.createShader(gl.FRAGMENT_SHADER) : gl.createShader(gl.VERTEX_SHADER);\n\n gl.shaderSource(shader, str);\n gl.compileShader(shader);\n\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n alert(gl.getShaderInfoLog(shader));\n return null;\n }\n\n return shader;\n }\n\n initShaders() {\n const fragmentShader = this.getShader(this.gl, this.getFragmentShader(), true);\n const vertexShader = this.getShader(this.gl, this.getVertexShader(), false);\n\n this.sprogram = this.gl.createProgram();\n this.gl.attachShader(this.sprogram, vertexShader);\n this.gl.attachShader(this.sprogram, fragmentShader);\n this.gl.linkProgram(this.sprogram);\n\n if (!this.gl.getProgramParameter(this.sprogram, this.gl.LINK_STATUS))\n alert(\"Could not initialise shaders\");\n\n this.gl.useProgram(this.sprogram);\n this.sprogram.vpa = this.gl.getAttribLocation(this.sprogram, \"aVertexPosition\");\n this.sprogram.tca = this.gl.getAttribLocation(this.sprogram, \"aTextureCoord\");\n this.gl.enableVertexAttribArray(this.sprogram.tca);\n this.gl.enableVertexAttribArray(this.sprogram.vpa);\n\n this.sprogram.tMatUniform = this.gl.getUniformLocation(this.sprogram, \"tMat\");\n this.sprogram.samplerUniform = this.gl.getUniformLocation(this.sprogram, \"uSampler\");\n this.sprogram.useTex = this.gl.getUniformLocation(this.sprogram, \"useTexture\");\n this.sprogram.color = this.gl.getUniformLocation(this.sprogram, \"uColor\");\n this.gl.uniform1i(this.sprogram.useTex, 1);\n };\n\n initBuffers() {\n const vs = [0, 3, 1, 0, 2, 3];\n let idx;\n\n this.unitIBuffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.unitIBuffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(vs), this.gl.STATIC_DRAW);\n\n let i;\n let ids = [];\n for (i = 0; i < 100; i++) ids.push(i);\n idx = new Uint16Array(ids);\n\n this.unitI33 = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.unitI33);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, idx, this.gl.STATIC_DRAW);\n\n ids = [];\n for (i = 0; i < 100; i++) ids.push(i, i + 1, i + 2);\n idx = new Uint16Array(ids);\n\n this.stripBuffer = this.gl.createBuffer();\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.stripBuffer);\n this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, idx, this.gl.STATIC_DRAW);\n };\n\n createCircle(raidus) {\n this.circleCanvasRadius = WebGLUtil.nhpot(Util.initValue(raidus, 32));\n const canvas = DomUtil.createCanvas('circle_canvas', this.circleCanvasRadius * 2, this.circleCanvasRadius * 2);\n const context = canvas.getContext('2d');\n\n context.beginPath();\n context.arc(this.circleCanvasRadius, this.circleCanvasRadius, this.circleCanvasRadius, 0, Math.PI * 2, true);\n context.closePath();\n context.fillStyle = '#FFF';\n context.fill();\n\n return canvas.toDataURL();\n };\n\n drawImg2Canvas(particle) {\n const _w = particle.body.width;\n const _h = particle.body.height;\n\n const _width = WebGLUtil.nhpot(particle.body.width);\n const _height = WebGLUtil.nhpot(particle.body.height);\n\n const _scaleX = particle.body.width / _width;\n const _scaleY = particle.body.height / _height;\n\n if (!this.texturebuffers[particle.transform.src])\n this.texturebuffers[particle.transform.src] = [this.gl.createTexture(), this.gl.createBuffer(), this.gl.createBuffer()];\n\n particle.transform.texture = this.texturebuffers[particle.transform.src][0];\n particle.transform.vcBuffer = this.texturebuffers[particle.transform.src][1];\n particle.transform.tcBuffer = this.texturebuffers[particle.transform.src][2];\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, particle.transform.tcBuffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([0.0, 0.0, _scaleX, 0.0, 0.0, _scaleY, _scaleY, _scaleY]), this.gl.STATIC_DRAW);\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, particle.transform.vcBuffer);\n this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([0.0, 0.0, _w, 0.0, 0.0, _h, _w, _h]), this.gl.STATIC_DRAW);\n\n const context = particle.transform.canvas.getContext('2d');\n const data = context.getImageData(0, 0, _width, _height);\n\n this.gl.bindTexture(this.gl.TEXTURE_2D, particle.transform.texture);\n this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, this.gl.RGBA, this.gl.UNSIGNED_BYTE, data);\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR);\n this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR_MIPMAP_NEAREST);\n this.gl.generateMipmap(this.gl.TEXTURE_2D);\n\n particle.transform.textureLoaded = true;\n particle.transform.textureWidth = _w;\n particle.transform.textureHeight = _h;\n }\n\n onProtonUpdate() {\n //this.gl.clearColor(0, 0, 0, 1);\n //this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);\n }\n\n onParticleCreated(particle) {\n particle.transform.textureLoaded = false;\n particle.transform.tmat = Mat3.create();\n particle.transform.tmat[8] = 1;\n particle.transform.imat = Mat3.create();\n particle.transform.imat[8] = 1;\n\n if (particle.body) {\n ImgUtil.getImgFromCache(particle.body, this.addImg2Body, particle);\n } else {\n ImgUtil.getImgFromCache(this.circleCanvasURL, this.addImg2Body, particle);\n particle.transform.oldScale = particle.radius / this.circleCanvasRadius;\n }\n }\n\n // private \n addImg2Body(img, particle) {\n if (particle.dead) return;\n \n particle.body = img;\n particle.transform.src = img.src;\n particle.transform.canvas = ImgUtil.getCanvasFromCache(img);\n particle.transform.oldScale = 1;\n\n this.drawImg2Canvas(particle);\n }\n\n onParticleUpdate(particle) {\n if (particle.transform.textureLoaded) {\n this.updateMatrix(particle);\n\n this.gl.uniform3f(this.sprogram.color, particle.transform.rgb.r / 255, particle.transform.rgb.g / 255, particle.transform.rgb.b / 255);\n this.gl.uniformMatrix3fv(this.sprogram.tMatUniform, false, this.mstack.top());\n\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, particle.transform.vcBuffer);\n this.gl.vertexAttribPointer(this.sprogram.vpa, 2, this.gl.FLOAT, false, 0, 0);\n this.gl.bindBuffer(this.gl.ARRAY_BUFFER, particle.transform.tcBuffer);\n this.gl.vertexAttribPointer(this.sprogram.tca, 2, this.gl.FLOAT, false, 0, 0);\n this.gl.bindTexture(this.gl.TEXTURE_2D, particle.transform.texture);\n this.gl.uniform1i(this.sprogram.samplerUniform, 0);\n this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.unitIBuffer);\n\n this.gl.drawElements(this.gl.TRIANGLES, 6, this.gl.UNSIGNED_SHORT, 0);\n\n this.mstack.pop();\n }\n }\n\n onParticleDead(particle) { }\n\n updateMatrix(particle) {\n const moveOriginMatrix = WebGLUtil.makeTranslation(-particle.transform.textureWidth / 2, -particle.transform.textureHeight / 2);\n const translationMatrix = WebGLUtil.makeTranslation(particle.p.x, particle.p.y);\n\n const angel = particle.rotation * (MathUtils.PI_180);\n const rotationMatrix = WebGLUtil.makeRotation(angel);\n\n const scale = particle.scale * particle.transform.oldScale;\n const scaleMatrix = WebGLUtil.makeScale(scale, scale);\n let matrix = WebGLUtil.matrixMultiply(moveOriginMatrix, scaleMatrix);\n\n matrix = WebGLUtil.matrixMultiply(matrix, rotationMatrix);\n matrix = WebGLUtil.matrixMultiply(matrix, translationMatrix);\n\n Mat3.inverse(matrix, particle.transform.imat);\n matrix[2] = particle.alpha;\n\n this.mstack.push(matrix);\n }\n}","import Util from '../utils/Util';\nimport BaseRenderer from './BaseRenderer';\n\nexport default class CustomRenderer extends BaseRenderer {\n\n constructor(element) {\n super(element);\n\n this.name = 'CustomRenderer';\n }\n\n}","import Zone from './Zone';\nimport Util from '../utils/Util';\nimport MathUtils from '../math/MathUtils';\n\nexport default class CircleZone extends Zone {\n\n\tconstructor(x1, y1, x2, y2, direction) {\n\t\tsuper();\n\n\t\tif (x2 - x1 >= 0) {\n\t\t\tthis.x1 = x1;\n\t\t\tthis.y1 = y1;\n\t\t\tthis.x2 = x2;\n\t\t\tthis.y2 = y2;\n\t\t} else {\n\t\t\tthis.x1 = x2;\n\t\t\tthis.y1 = y2;\n\t\t\tthis.x2 = x1;\n\t\t\tthis.y2 = y1;\n\t\t}\n\n\t\tthis.dx = this.x2 - this.x1;\n\t\tthis.dy = this.y2 - this.y1;\n\n\t\tthis.minx = Math.min(this.x1, this.x2);\n\t\tthis.miny = Math.min(this.y1, this.y2);\n\t\tthis.maxx = Math.max(this.x1, this.x2);\n\t\tthis.maxy = Math.max(this.y1, this.y2);\n\n\t\tthis.dot = this.x2 * this.y1 - this.x1 * this.y2;\n\t\tthis.xxyy = this.dx * this.dx + this.dy * this.dy;\n\n\t\tthis.gradient = this.getGradient();\n\t\tthis.length = this.getLength();\n\t\tthis.direction = Util.initValue(direction, '>');\n\t}\n\n\n\tgetPosition() {\n\t\tthis.random = Math.random();\n\t\tthis.vector.x = this.x1 + this.random * this.length * Math.cos(this.gradient);\n\t\tthis.vector.y = this.y1 + this.random * this.length * Math.sin(this.gradient);\n\n\t\treturn this.vector;\n\t}\n\n\tgetDirection(x, y) {\n\t\tconst A = this.dy;\n\t\tconst B = -this.dx;\n\t\tconst C = this.dot;\n\t\tconst D = B == 0 ? 1 : B;\n\n\t\tif ((A * x + B * y + C) * D > 0)\n\t\t\treturn true;\n\t\telse\n\t\t\treturn false;\n\t}\n\n\tgetDistance(x, y) {\n\t\tconst A = this.dy;\n\t\tconst B = -this.dx;\n\t\tconst C = this.dot;\n\t\tconst D = (A * x + B * y + C);\n\n\t\treturn D / Math.sqrt(this.xxyy);\n\t}\n\n\tgetSymmetric(v) {\n\t\tconst tha2 = v.getGradient();\n\t\tconst tha1 = this.getGradient();\n\t\tconst tha = 2 * (tha1 - tha2);\n\n\t\tconst oldx = v.x;\n\t\tconst oldy = v.y;\n\n\t\tv.x = oldx * Math.cos(tha) - oldy * Math.sin(tha);\n\t\tv.y = oldx * Math.sin(tha) + oldy * Math.cos(tha);\n\n\t\treturn v;\n\t}\n\n\tgetGradient() {\n\t\treturn Math.atan2(this.dy, this.dx);\n\t}\n\n\trangeOut(particle) {\n\t\tconst angle = Math.abs(this.getGradient());\n\n\t\tif (angle <= MathUtils.PI / 4) {\n\t\t\tif (particle.p.x <= this.maxx && particle.p.x >= this.minx) return true;\n\t\t} else {\n\t\t\tif (particle.p.y <= this.maxy && particle.p.y >= this.miny) return true;\n\t\t}\n\t\t\n\t\treturn false;\n\t}\n\n\tgetLength() {\n\t\treturn Math.sqrt(this.dx * this.dx + this.dy * this.dy)\n\t}\n\n\tcrossing(particle) {\n\t\tif (this.crossType == \"dead\") {\n\t\t\tif (this.direction == \">\" || this.direction == \"R\" || this.direction == \"right\" || this.direction == \"down\") {\n\t\t\t\tif (!this.rangeOut(particle)) return;\n\t\t\t\tif (this.getDirection(particle.p.x, particle.p.y)) particle.dead = true;\n\t\t\t} else {\n\t\t\t\tif (!this.rangeOut(particle)) return;\n\t\t\t\tif (!this.getDirection(particle.p.x, particle.p.y)) particle.dead = true;\n\t\t\t}\n\t\t}\n\n\t\telse if (this.crossType == \"bound\") {\n\t\t\tif (!this.rangeOut(particle)) return;\n\n\t\t\tif (this.getDistance(particle.p.x, particle.p.y) <= particle.radius) {\n\t\t\t\tif (this.dx == 0) {\n\t\t\t\t\tparticle.v.x *= -1;\n\t\t\t\t} else if (this.dy == 0) {\n\t\t\t\t\tparticle.v.y *= -1;\n\t\t\t\t} else {\n\t\t\t\t\tthis.getSymmetric(particle.v);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\telse if (this.crossType == \"cross\") {\n\t\t\tif (this.alert) {\n\t\t\t\tconsole.error('Sorry lineZone does not support cross method');\n\t\t\t\tthis.alert = false;\n\t\t\t}\n\t\t}\n\t}\n\n}","import Zone from './Zone';\nimport MathUtils from '../math/MathUtils';\n\nexport default class CircleZone extends Zone {\n\n constructor(x, y, radius) {\n super();\n\n this.x = x;\n this.y = y;\n this.radius = radius;\n\n this.angle = 0;\n this.center = { x, y };\n }\n\n getPosition() {\n this.random = Math.random();\n this.angle = MathUtils.PIx2 * Math.random();\n\n this.vector.x = this.x + this.random * this.radius * Math.cos(this.angle);\n this.vector.y = this.y + this.random * this.radius * Math.sin(this.angle);\n\n return this.vector;\n }\n\n setCenter(x, y) {\n this.center.x = x;\n this.center.y = y;\n }\n\n crossing(particle) {\n const d = particle.p.distanceTo(this.center);\n\n if (this.crossType == \"dead\") {\n if (d - particle.radius > this.radius)\n particle.dead = true;\n } else if (this.crossType == \"bound\") {\n if (d + particle.radius >= this.radius)\n this.getSymmetric(particle);\n } else if (this.crossType == \"cross\") {\n if (this.alert) {\n alert('Sorry CircleZone does not support cross method');\n this.alert = false;\n }\n }\n }\n\n getSymmetric(particle) {\n let tha2 = particle.v.getGradient();\n let tha1 = this.getGradient(particle);\n\n let tha = 2 * (tha1 - tha2);\n let oldx = particle.v.x;\n let oldy = particle.v.y;\n\n particle.v.x = oldx * Math.cos(tha) - oldy * Math.sin(tha);\n particle.v.y = oldx * Math.sin(tha) + oldy * Math.cos(tha);\n }\n\n getGradient(particle) {\n return -MathUtils.PI_2 + Math.atan2(particle.p.y - this.center.y, particle.p.x - this.center.x);\n }\n}","import Zone from './Zone';\n\nexport default class PointZoneRectZone extends Zone {\n\n\tconstructor(x, y, width, height) {\n\t\tsuper();\n\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.width = width;\n\t\tthis.height = height;\n\t}\n\n\tgetPosition() {\n\t\tthis.vector.x = this.x + Math.random() * this.width;\n\t\tthis.vector.y = this.y + Math.random() * this.height;\n\n\t\treturn this.vector;\n\t}\n\n\tcrossing(particle) {\n\t\tif (this.crossType == \"dead\") {\n\t\t\tif (particle.p.x + particle.radius < this.x)\n\t\t\t\tparticle.dead = true;\n\t\t\telse if (particle.p.x - particle.radius > this.x + this.width)\n\t\t\t\tparticle.dead = true;\n\n\t\t\tif (particle.p.y + particle.radius < this.y)\n\t\t\t\tparticle.dead = true;\n\t\t\telse if (particle.p.y - particle.radius > this.y + this.height)\n\t\t\t\tparticle.dead = true;\n\t\t}\n\n\t\telse if (this.crossType == \"bound\") {\n\t\t\tif (particle.p.x - particle.radius < this.x) {\n\t\t\t\tparticle.p.x = this.x + particle.radius;\n\t\t\t\tparticle.v.x *= -1;\n\t\t\t} else if (particle.p.x + particle.radius > this.x + this.width) {\n\t\t\t\tparticle.p.x = this.x + this.width - particle.radius;\n\t\t\t\tparticle.v.x *= -1;\n\t\t\t}\n\n\t\t\tif (particle.p.y - particle.radius < this.y) {\n\t\t\t\tparticle.p.y = this.y + particle.radius;\n\t\t\t\tparticle.v.y *= -1;\n\t\t\t} else if (particle.p.y + particle.radius > this.y + this.height) {\n\t\t\t\tparticle.p.y = this.y + this.height - particle.radius;\n\t\t\t\tparticle.v.y *= -1;\n\t\t\t}\n\t\t}\n\n\t\telse if (this.crossType == \"cross\") {\n\t\t\tif (particle.p.x + particle.radius < this.x && particle.v.x <= 0)\n\t\t\t\tparticle.p.x = this.x + this.width + particle.radius;\n\t\t\telse if (particle.p.x - particle.radius > this.x + this.width && particle.v.x >= 0)\n\t\t\t\tparticle.p.x = this.x - particle.radius;\n\n\t\t\tif (particle.p.y + particle.radius < this.y && particle.v.y <= 0)\n\t\t\t\tparticle.p.y = this.y + this.height + particle.radius;\n\t\t\telse if (particle.p.y - particle.radius > this.y + this.height && particle.v.y >= 0)\n\t\t\t\tparticle.p.y = this.y - particle.radius;\n\t\t}\n\t}\n}","import Zone from './Zone';\nimport Util from '../utils/Util';\n\nexport default class ImageZone extends Zone {\n\n\tconstructor(imageData, x, y, d) {\n\t\tsuper();\n\n\t\tthis.reset(imageData, x, y, d);\n\t}\n\n\treset(imageData, x, y, d) {\n\t\tthis.imageData = imageData;\n\t\tthis.x = Util.initValue(x, 0);\n\t\tthis.y = Util.initValue(y, 0);\n\t\tthis.d = Util.initValue(d, 2);\n\n\t\tthis.vectors = [];\n\t\tthis.setVectors();\n\t}\n\n\tsetVectors() {\n\t\tlet i, j;\n\t\tconst length1 = this.imageData.width;\n\t\tconst length2 = this.imageData.height;\n\n\t\tfor (i = 0; i < length1; i += this.d) {\n\t\t\tfor (j = 0; j < length2; j += this.d) {\n\t\t\t\tlet index = ((j >> 0) * length1 + (i >> 0)) * 4;\n\n\t\t\t\tif (this.imageData.data[index + 3] > 0) {\n\t\t\t\t\tthis.vectors.push({ x: i + this.x, y: j + this.y });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn this.vector;\n\t}\n\n\tgetBound(x, y) {\n\t\tvar index = ((y >> 0) * this.imageData.width + (x >> 0)) * 4;\n\t\tif (this.imageData.data[index + 3] > 0)\n\t\t\treturn true;\n\t\telse\n\t\t\treturn false;\n\t}\n\n\tgetPosition() {\n\t\treturn this.vector.copy(this.vectors[Math.floor(Math.random() * this.vectors.length)]);\n\t}\n\n\tgetColor(x, y) {\n\t\tx -= this.x;\n\t\ty -= this.y;\n\t\tvar i = ((y >> 0) * this.imageData.width + (x >> 0)) * 4;\n\n\t\treturn {\n\t\t\tr: this.imageData.data[i],\n\t\t\tg: this.imageData.data[i + 1],\n\t\t\tb: this.imageData.data[i + 2],\n\t\t\ta: this.imageData.data[i + 3]\n\t\t};\n\t}\n\n\tcrossing(particle) {\n\t\tif (this.crossType == \"dead\") {\n\t\t\tif (this.getBound(particle.p.x - this.x, particle.p.y - this.y))\n\t\t\t\tparticle.dead = true;\n\t\t\telse\n\t\t\t\tparticle.dead = false;\n\t\t} \n\t\t\n\t\telse if (this.crossType == \"bound\") {\n\t\t\tif (!this.getBound(particle.p.x - this.x, particle.p.y - this.y))\n\t\t\t\tparticle.v.negate();\n\t\t}\n\t}\n}","import Util from '../utils/Util';\nimport ColorUtil from '../utils/ColorUtil';\nimport MathUtils from '../math/MathUtils';\nimport CircleZone from '../zone/CircleZone';\nimport PointZone from '../zone/PointZone';\nimport LineZone from '../zone/LineZone';\nimport RectZone from '../zone/RectZone';\n\nexport default {\n\taddEventListener(proton, fun) {\n\t\tproton.addEventListener(\"PROTON_UPDATE_AFTER\", () => fun());\n\t},\n\n\tgetStyle(color) {\n\t\tconst rgb = ColorUtil.hexToRGB(color || '#ff0000');\n\t\treturn `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, 0.5)`;\n\t},\n\t\n\tdrawZone(proton, canvas, zone, clear) {\n\t\tconst context = canvas.getContext('2d');\n\t\tconst style = this.getStyle();\n\n\t\tthis.addEventListener(proton, () => {\n\t\t\tif (clear)\n\t\t\t\tcontext.clearRect(0, 0, canvas.width, canvas.height);\n\n\t\t\tif (zone instanceof PointZone) {\n\t\t\t\tcontext.beginPath();\n\t\t\t\tcontext.fillStyle = style;\n\t\t\t\tcontext.arc(zone.x, zone.y, 10, 0, Math.PI * 2, true);\n\t\t\t\tcontext.fill();\n\t\t\t\tcontext.closePath();\n\t\t\t} else if (zone instanceof LineZone) {\n\t\t\t\tcontext.beginPath();\n\t\t\t\tcontext.strokeStyle = style;\n\t\t\t\tcontext.moveTo(zone.x1, zone.y1);\n\t\t\t\tcontext.lineTo(zone.x2, zone.y2);\n\t\t\t\tcontext.stroke();\n\t\t\t\tcontext.closePath();\n\t\t\t} else if (zone instanceof RectZone) {\n\t\t\t\tcontext.beginPath();\n\t\t\t\tcontext.strokeStyle = style;\n\t\t\t\tcontext.drawRect(zone.x, zone.y, zone.width, zone.height);\n\t\t\t\tcontext.stroke();\n\t\t\t\tcontext.closePath();\n\t\t\t} else if (zone instanceof CircleZone) {\n\t\t\t\tcontext.beginPath();\n\t\t\t\tcontext.strokeStyle = style;\n\t\t\t\tcontext.arc(zone.x, zone.y, zone.radius, 0, Math.PI * 2, true);\n\t\t\t\tcontext.stroke();\n\t\t\t\tcontext.closePath();\n\t\t\t}\n\t\t});\n\t},\n\t\n\tdrawEmitter(proton, canvas, emitter, clear) {\n\t\tconst context = canvas.getContext('2d');\n\t\tconst style = this.getStyle();\n\n\t\tthis.addEventListener(proton, () => {\n\t\t\tif (clear) context.clearRect(0, 0, canvas.width, canvas.height);\n\t\t\t\n\t\t\tcontext.beginPath();\n\t\t\tcontext.fillStyle = style;\n\t\t\tcontext.arc(emitter.p.x, emitter.p.y, 10, 0, Math.PI * 2, true);\n\t\t\tcontext.fill();\n\t\t\tcontext.closePath();\n\t\t});\n\t},\n}\n\n","// http://paulirish.com/2011/requestanimationframe-for-smart-animating/\n// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating\n\n// requestAnimationFrame polyfill by Erik Möller\n// fixes from Paul Irish and Tino Zijdel\n( function() {\n\t\tvar lastTime = 0;\n\t\tvar vendors = ['ms', 'moz', 'webkit', 'o'];\n\t\tfor (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {\n\t\t\twindow.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];\n\t\t\twindow.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];\n\t\t}\n\n\t\tif (!window.requestAnimationFrame)\n\t\t\twindow.requestAnimationFrame = function(callback, element) {\n\t\t\t\tvar currTime = new Date().getTime();\n\t\t\t\tvar timeToCall = Math.max(0, 16 - (currTime - lastTime));\n\t\t\t\tvar id = window.setTimeout(function() {\n\t\t\t\t\tcallback(currTime + timeToCall);\n\t\t\t\t}, timeToCall);\n\t\t\t\tlastTime = currTime + timeToCall;\n\t\t\t\treturn id;\n\t\t\t};\n\n\t\tif (!window.cancelAnimationFrame)\n\t\t\twindow.cancelAnimationFrame = function(id) {\n\t\t\t\tclearTimeout(id);\n\t\t\t};\n\t}()); ","// import \nimport Proton from \"./core/Proton\";\nimport Particle from \"./core/Particle\";\nimport Pool from \"./core/Pool\";\n\nimport Util from \"./utils/Util\";\nimport ColorUtil from \"./utils/ColorUtil\";\nimport MathUtils from \"./math/MathUtils\";\nimport Vector2D from \"./math/Vector2D\";\nimport Polar2D from \"./math/Polar2D\";\nimport Mat3 from \"./math/Mat3\";\nimport Span from \"./math/Span\";\nimport ArraySpan from \"./math/ArraySpan\";\nimport Rectangle from \"./math/Rectangle\";\nimport ease from \"./math/ease\";\n\nimport Rate from \"./initialize/Rate\";\nimport Initialize from \"./initialize/Initialize\";\nimport Life from \"./initialize/Life\";\nimport Position from \"./initialize/Position\";\nimport Velocity from \"./initialize/Velocity\";\nimport Mass from \"./initialize/Mass\";\nimport Radius from \"./initialize/Radius\";\nimport Body from \"./initialize/Body\";\n\nimport Behaviour from \"./behaviour/Behaviour\";\nimport Force from \"./behaviour/Force\";\nimport Attraction from \"./behaviour/Attraction\";\nimport RandomDrift from \"./behaviour/RandomDrift\";\nimport Gravity from \"./behaviour/Gravity\";\nimport Collision from \"./behaviour/Collision\";\nimport CrossZone from \"./behaviour/CrossZone\";\nimport Alpha from \"./behaviour/Alpha\";\nimport Scale from \"./behaviour/Scale\";\nimport Rotate from \"./behaviour/Rotate\";\nimport Color from \"./behaviour/Color\";\nimport Repulsion from \"./behaviour/Repulsion\";\nimport GravityWell from \"./behaviour/GravityWell\";\n\nimport Emitter from \"./emitter/Emitter\";\nimport BehaviourEmitter from \"./emitter/BehaviourEmitter\";\nimport FollowEmitter from \"./emitter/FollowEmitter\";\n\nimport CanvasRenderer from \"./render/CanvasRenderer\";\nimport DomRenderer from \"./render/DomRenderer\";\nimport EaselRenderer from \"./render/EaselRenderer\";\nimport PixelRenderer from \"./render/PixelRenderer\";\nimport PixiRenderer from \"./render/PixiRenderer\";\nimport WebGLRenderer from \"./render/WebGLRenderer\";\nimport CustomRenderer from \"./render/CustomRenderer\";\n\nimport Zone from \"./zone/Zone\";\nimport LineZone from \"./zone/LineZone\";\nimport CircleZone from \"./zone/CircleZone\";\nimport PointZone from \"./zone/PointZone\";\nimport RectZone from \"./zone/RectZone\";\nimport ImageZone from \"./zone/ImageZone\";\n\nimport Debug from \"./debug/Debug\";\nimport \"./polyfill/requestAnimationFrame\";\n\n// namespace\nProton.Particle = Proton.P = Particle;\nProton.Pool = Pool;\n\nProton.Util = Util;\nProton.ColorUtil = ColorUtil;\nProton.MathUtils = MathUtils;\nProton.Vector2D = Proton.Vector = Vector2D;\nProton.Polar2D = Proton.Polar = Polar2D;\nProton.ArraySpan = ArraySpan;\nProton.Rectangle = Rectangle;\nProton.Rate = Rate;\nProton.ease = ease;\nProton.Span = Span;\nProton.Mat3 = Mat3;\nProton.getSpan = (a, b, center) => new Span(a, b, center);\nProton.createArraySpan = ArraySpan.createArraySpan;\n\nProton.Initialize = Proton.Init = Initialize;\nProton.Life = Proton.L = Life;\nProton.Position = Proton.P = Position;\nProton.Velocity = Proton.V = Velocity;\nProton.Mass = Proton.M = Mass;\nProton.Radius = Proton.R = Radius;\nProton.Body = Proton.B = Body;\n\nProton.Behaviour = Behaviour;\nProton.Force = Proton.F = Force;\nProton.Attraction = Proton.A = Attraction;\nProton.RandomDrift = Proton.RD = RandomDrift;\nProton.Gravity = Proton.G = Gravity;\nProton.Collision = Collision;\nProton.CrossZone = CrossZone;\nProton.Alpha = Proton.A = Alpha;\nProton.Scale = Proton.S = Scale;\nProton.Rotate = Rotate;\nProton.Color = Color;\nProton.Repulsion = Repulsion;\nProton.GravityWell = GravityWell;\n\nProton.Emitter = Emitter;\nProton.BehaviourEmitter = BehaviourEmitter;\nProton.FollowEmitter = FollowEmitter;\n\nProton.Zone = Zone;\nProton.LineZone = LineZone;\nProton.CircleZone = CircleZone;\nProton.PointZone = PointZone;\nProton.RectZone = RectZone;\nProton.ImageZone = ImageZone;\n\nProton.CanvasRenderer = CanvasRenderer;\nProton.DomRenderer = DomRenderer;\nProton.EaselRenderer = EaselRenderer;\nProton.PixiRenderer = PixiRenderer;\nProton.PixelRenderer = PixelRenderer;\nProton.WebGLRenderer = Proton.WebGlRenderer = WebGLRenderer;\nProton.CustomRenderer = CustomRenderer;\n\nProton.Debug = Debug;\n\nObject.assign(Proton, ease);\n\n// export\nexport default Proton;"],"names":["PI","MathUtils","a","b","INT","Math","floor","random","center","f","this","randomAToB","display","num","toString","slice","Vector2D","x","y","atan2","PI_2","v","w","undefined","addVectors","subVectors","s","set","multiplyScalar","sqrt","divideScalar","length","distanceToSquared","tha","cos","sin","dx","dy","alpha","Span","isArray","Util","initValue","randomFloating","i","tx","ty","angleInRadians","c","sx","sy","a00","a01","a02","a10","a11","a12","a20","a21","a22","b00","b01","b02","b10","b11","b12","b20","b21","b22","id","width","height","position","dom","document","createElement","style","opacity","transform","resize","marginLeft","marginTop","div","scale","rotate","willChange","css3","key","val","bkey","charAt","toUpperCase","substr","IMG_CACHE","CANVAS_CACHE","context","image","rect","drawImage","imagedata","getImageData","clearRect","img","callback","param","src","Image","onload","e","target","WebGLUtil","canvas","DomUtil","createCanvas","getContext","value","defaults","Object","prototype","call","array","obj","ignore","o","indexOf","constructor","args","concat","bind","apply","pOBJ","hasProp","p","particle","copy","prototypeObject","filters","singleProp","hasOwnProperty","getSpanValue","pan","getValue","ImgUtil","arr","destroy","uid","getCacheID","cache","isInner","Pool","total","params","__puid","PUID","getID","pop","createOrClone","getCache","push","create","classApply","clone","count","Stats","proton","container","type","emitterIndex","rendererIndex","body","add","emitter","getEmitter","renderer","getRenderer","str","emitters","emitSpeed","getEmitterPos","initializes","concatArr","behaviours","name","getCreatedNumber","getCount","pool","innerHTML","cssText","join","addEventListener","_this","bg","color","parentNode","appendChild","renderers","result","cpool","round","EventDispatcher","_listeners","listener","removeEventListener","splice","listeners","handler","TargetClass","dispatchEvent","hasEventListener","removeAllEventListeners","Integration","particles","time","damping","eulerIntegrate","sleep","old","mass","clear","Proton","integrationType","oldTime","elapsed","stats","EULER","integrator","render","init","index","remove","parent","EMITTER_ADDED","EMITTER_REMOVED","PROTON_UPDATE","USE_CLOCK","Date","getTime","amendChangeTabsBug","emittersUpdate","PROTON_UPDATE_AFTER","update","getAllParticles","MEASURE","RK2","PARTICLE_CREATED","PARTICLE_UPDATE","PARTICLE_SLEEP","PARTICLE_DEAD","bindEmtterEvent","pow","ease","easeLinear","Particle","ID","reset","setPrototypeByObject","N180_PI","life","Infinity","age","energy","dead","sprite","radius","rotation","easing","destroyObject","removeAllBehaviours","rgb","r","g","applyBehaviours","max","applyBehaviour","behaviour","parents","initialize","addBehaviour","destroyArray","h","hex16","substring","parseInt","rbg","Number","Polar2D","abs","getX","getY","mat3","mat","Float32Array","mat1","mat2","m","vec","ArraySpan","_arr","randomColor","Rectangle","bottom","right","Rate","numpan","timepan","numPan","setSpanValue","timePan","startTime","nextTime","Initialize","Life","lifePan","Zone","vector","crossType","alert","PointZone","Position","zone","getPosition","Velocity","rpan","thapan","rPan","thaPan","vr","polar2d","normalizeVelocity","PI_180","Mass","massPan","Radius","oldRadius","Body","imagetarget","inner","Behaviour","getEasing","force","removeBehaviour","Force","fx","fy","normalizeForce","calculate","Attraction","targetPosition","normalizeValue","radiusSq","attractionForce","lengthSq","sub","normalize","RandomDrift","driftX","driftY","delay","panFoce","addXY","Gravity","Collision","collisionPool","delta","newPool","otherParticle","overlap","totalMass","averageMass1","averageMass2","distance","CrossZone","crossing","Alpha","same","alphaA","alphaB","Scale","scaleA","scaleB","Rotate","rotationA","rotationB","getDirection","Color","createArraySpan","colorA","ColorUtil","hexToRGB","colorB","Repulsion","GravityWell","centerPoint","distanceVec","distanceSq","factor","bindEmitter","setVector2DByObject","degreeTransform","Emitter","pObj","currentEmitTime","totalEmitTimes","rate","stoped","isNaN","initAll","rest","initializer","arguments","emitting","integrate","dispatch","expire","event","createParticle","get","setupParticle","addBehaviours","stop","slow","removeAllInitializers","removeEmitter","BehaviourEmitter","selfBehaviours","FollowEmitter","mouseTarget","window","_allowEmitting","initEventHandler","mousemoveHandler","_this2","mousemove","mousedownHandler","mousedown","mouseupHandler","mouseup","layerX","layerY","offsetX","offsetY","babelHelpers.get","BaseRenderer","element","stroke","initHandler","circleConf","isCircle","thinkness","_protonUpdateHandler","onProtonUpdate","_protonUpdateAfterHandler","onProtonUpdateAfter","_emitterAddedHandler","onEmitterAdded","_emitterRemovedHandler","onEmitterRemoved","_particleCreatedHandler","onParticleCreated","_particleUpdateHandler","onParticleUpdate","_particleDeadHandler","onParticleDead","CanvasRenderer","bufferCache","addImg2Body","drawCircle","buffer","createBuffer","bufferContext","globalAlpha","globalCompositeOperation","fillStyle","rgbToHex","fillRect","save","translate","restore","beginPath","arc","strokeStyle","lineWidth","closePath","fill","size","DomRenderer","createBody","transform3d","bodyReady","backgroundColor","removeChild","babelHelpers.typeof","createCircle","createSprite","createDiv","borderRadius","borderColor","borderWidth","url","backgroundImage","EaselRenderer","addChild","scaleX","scaleY","graphics","regX","regY","createjs","Graphics","String","beginStroke","beginFill","shape","Shape","PixelRenderer","rectangle","imageData","createImageData","putImageData","setPixel","elementwidth","data","PixiRenderer","setColor","tint","getHex16FromParticle","PIXI","Sprite","fromImage","anchor","endFill","MStack","mats","Mat3","multiply","WebGLRenderer","gl","antialias","stencil","depth","initVar","setMaxRadius","initShaders","initBuffers","blendEquation","FUNC_ADD","blendFunc","SRC_ALPHA","ONE_MINUS_SRC_ALPHA","enable","BLEND","umat","smat","mstack","viewport","circleCanvasURL","texturebuffers","A","B","fs","shader","createShader","FRAGMENT_SHADER","VERTEX_SHADER","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","getShaderInfoLog","fragmentShader","getShader","getFragmentShader","vertexShader","getVertexShader","sprogram","createProgram","attachShader","linkProgram","getProgramParameter","LINK_STATUS","useProgram","vpa","getAttribLocation","tca","enableVertexAttribArray","tMatUniform","getUniformLocation","samplerUniform","useTex","uniform1i","idx","unitIBuffer","bindBuffer","ELEMENT_ARRAY_BUFFER","bufferData","Uint16Array","STATIC_DRAW","ids","unitI33","stripBuffer","raidus","circleCanvasRadius","toDataURL","_w","_h","_width","_height","_scaleX","_scaleY","createTexture","texture","vcBuffer","tcBuffer","ARRAY_BUFFER","bindTexture","TEXTURE_2D","texImage2D","RGBA","UNSIGNED_BYTE","texParameteri","TEXTURE_MAG_FILTER","LINEAR","TEXTURE_MIN_FILTER","LINEAR_MIPMAP_NEAREST","generateMipmap","textureLoaded","textureWidth","textureHeight","tmat","imat","oldScale","drawImg2Canvas","updateMatrix","uniform3f","uniformMatrix3fv","top","vertexAttribPointer","FLOAT","drawElements","TRIANGLES","UNSIGNED_SHORT","moveOriginMatrix","translationMatrix","angel","rotationMatrix","scaleMatrix","matrix","inverse","CustomRenderer","CircleZone","x1","y1","x2","y2","direction","minx","min","miny","maxx","maxy","dot","xxyy","gradient","getGradient","getLength","tha2","oldx","oldy","rangeOut","getDistance","getSymmetric","error","angle","PIx2","d","distanceTo","PointZoneRectZone","ImageZone","vectors","setVectors","j","length1","length2","getBound","negate","fun","getStyle","LineZone","moveTo","lineTo","RectZone","drawRect","lastTime","vendors","requestAnimationFrame","cancelAnimationFrame","currTime","timeToCall","setTimeout","P","Vector","Polar","getSpan","Init","L","V","M","R","F","RD","G","S","WebGlRenderer","Debug","assign"],"mappings":";;;;;;;;;kLAAA,IAAMA,EAAK,UAELC,MAEED,OACO,EAALA,OACAA,EAAK,SACHA,EAAK,YACJ,IAAMA,sBAEJE,EAAGC,EAAGC,UACRA,EAGMC,KAAKC,MAAMD,KAAKE,UAAYJ,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OzY,EAClC3F,EAAO4F,KAAO5F,EAAOqe,EAAIzY,EACzB5F,EAAOmG,SAAWnG,EAAOge,EAAI7X,EAC7BnG,EAAOsG,SAAWtG,EAAOse,EAAIhY,EAC7BtG,EAAO+G,KAAO/G,EAAOue,EAAIxX,EACzB/G,EAAOiH,OAASjH,EAAOwe,EAAIvX,EAC3BjH,EAAOmH,KAAOnH,EAAOmV,EAAIhO,EAEzBnH,EAAOsH,UAAYA,EACnBtH,EAAO0H,MAAQ1H,EAAOye,EAAI/W,EAC1B1H,EAAO+H,WAAa/H,EAAOkV,EAAInN,EAC/B/H,EAAOuI,YAAcvI,EAAO0e,GAAKnW,EACjCvI,EAAO6I,QAAU7I,EAAO2e,EAAI9V,EAC5B7I,EAAO8I,UAAYA,EACnB9I,EAAOwJ,UAAYA,EACnBxJ,EAAO0J,MAAQ1J,EAAOkV,EAAIxL,EAC1B1J,EAAO8J,MAAQ9J,EAAO4e,EAAI9U,EAC1B9J,EAAOiK,OAASA,GAChBjK,EAAOqK,MAAQA,GACfrK,EAAO2K,UAAYA,GACnB3K,EAAO4K,YAAcA,GAErB5K,EAAOoL,QAAUA,GACjBpL,EAAO4M,iBAAmBA,GAC1B5M,EAAO8M,cAAgBA,GAEvB9M,EAAO8F,KAAOA,EACd9F,EAAOod,SAAWA,GAClBpd,EAAO8a,WAAaA,GACpB9a,EAAOkG,UAAYA,EACnBlG,EAAOud,SAAWA,GAClBvd,EAAO0c,UAAYA,GAEnB1c,EAAOoP,eAAiBA,GACxBpP,EAAO0Q,YAAcA,GACrB1Q,EAAOyR,cAAgBA,GACvBzR,EAAO+S,aAAeA,GACtB/S,EAAOuS,cAAgBA,GACvBvS,EAAO4T,cAAgB5T,EAAO6e,cAAgBjL,GAC9C5T,EAAO6a,eAAiBA,GAExB7a,EAAO8e,MAAQA,GAEfplB,OAAOqlB,OAAO/e,EAAQ+B"}
\ No newline at end of file
diff --git a/example/behaviour/attraction/attraction1.html b/example/behaviour/attraction/attraction1.html
index f966c26..ebd552e 100644
--- a/example/behaviour/attraction/attraction1.html
+++ b/example/behaviour/attraction/attraction1.html
@@ -1,149 +1,161 @@
-
- behaviour-attraction1
-
-
-
-
-
-
-
-
-
-
+
+
+ behaviour-attraction1
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/behaviour/attraction/attraction2.html b/example/behaviour/attraction/attraction2.html
index ea3f2eb..6cf74c3 100644
--- a/example/behaviour/attraction/attraction2.html
+++ b/example/behaviour/attraction/attraction2.html
@@ -1,168 +1,176 @@
-
- behaviour-attraction2
-
-
-
-
-
-
-
-
-
-
+
+
+ behaviour-attraction2
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/behaviour/collision/collision.html b/example/behaviour/collision/collision.html
index f27ad71..2a9e1e9 100644
--- a/example/behaviour/collision/collision.html
+++ b/example/behaviour/collision/collision.html
@@ -1,141 +1,153 @@
-
- behaviour-Collision
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ behaviour-Collision
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/behaviour/collision/collisionBall.html b/example/behaviour/collision/collisionBall.html
index 42647c4..b7db0ce 100644
--- a/example/behaviour/collision/collisionBall.html
+++ b/example/behaviour/collision/collisionBall.html
@@ -1,107 +1,117 @@
-
- behaviour-collisionBall
-
-
-
-
-
-
-
- press
-
-
-
-
-
+
+
+ behaviour-collisionBall
+
+
+
+
+
+
+
+
+ press
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/behaviour/color/color.html b/example/behaviour/color/color.html
index 2289d10..a1e8f54 100644
--- a/example/behaviour/color/color.html
+++ b/example/behaviour/color/color.html
@@ -1,92 +1,98 @@
-
- proton.js-behaviour-custom
-
-
-
-
-
-
-
-
-
-
-
+
+
+
- stats.begin();
- proton.update();
- stats.end();
- }
-
-