Skip to content

Instantly share code, notes, and snippets.

@foldi
Last active December 30, 2015 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foldi/7774037 to your computer and use it in GitHub Desktop.
Save foldi/7774037 to your computer and use it in GitHub Desktop.
FloraJS | Multiple agents: followMouse and seekTarget

FloraJS | Multiple agents: followMouse and seekTarget

Creates two groups of agents, GroupA follows the mouse while GroupB follows a Walker.

If the simulation above does not render, click 'Open in a new window' above.

/*! Burner v2.1.4 - 2013-09-16 07:09:49
Vince Allen |Brooklyn, NY | vince@vinceallen.com | @vinceallenvince | License: MIT */
body{background-color:transparent}.world{position:absolute;top:0;left:0;margin:0;padding:0}.item{position:absolute;top:0;left:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-o-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}
/*! Burner v2.1.4 - 2013-09-16 07:09:49
Vince Allen |Brooklyn, NY | vince@vinceallen.com | @vinceallenvince | License: MIT */
!function(a,b){function c(a,b){var c=a||0,d=b||0;this.x=c,this.y=d}function d(){var a,b;this.name="StatsDisplay",this._active=!0,this._fps=0,this._time=Date.now?Date.now():0,this._timeLastFrame=this._time,this._timeLastSecond=this._time,this._frameCount=0,this.el=document.createElement("div"),this.el.id="statsDisplay",this.el.className="statsDisplay",this.el.style.backgroundColor="black",this.el.style.color="white",this.el.style.fontFamily="Helvetica",this.el.style.padding="0.5em",this.el.style.opacity="0.5",this._totalElementsValue=null,this._fpsValue=null,a=document.createElement("span"),a.className="statsDisplayLabel",a.style.marginLeft="0.5em",b=document.createTextNode("total elements: "),a.appendChild(b),this.el.appendChild(a),this._totalElementsValue=document.createTextNode("0"),this.el.appendChild(this._totalElementsValue),a=document.createElement("span"),a.className="statsDisplayLabel",a.style.marginLeft="0.5em",b=document.createTextNode("fps: "),a.appendChild(b),this.el.appendChild(a),this._fpsValue=document.createTextNode("0"),this.el.appendChild(this._fpsValue),document.body.appendChild(this.el),this._update(this)}function e(){}function f(b){if(!b||!b.world||"object"!=typeof b.world)throw new Error('Item: A valid DOM object is required for the new Item "world" property.');this.world=b.world,this.name=b.name||"Item",this.id=this.name+a.System.getNewId(),this._force=new a.Vector,this._camera=new a.Vector,this.el=document.createElement("div"),this.el.id=this.id,this.el.className="item "+this.name.toLowerCase(),this.el.style.visibility="hidden",this.world.el.appendChild(this.el)}function g(b,c){if(!b||"object"!=typeof b)throw new Error('World: A valid DOM object is required for the new World "el" property.');var d=c||{},e=a.System.getWindowSize();this.el=b,this.name="World",this.el.className=this.name.toLowerCase(),this.id=this.name+a.System.getNewId(),this.width=d.width||0,this.height=d.height||0,this.autoWidth=!!d.autoWidth,this.autoHeight=!!d.autoHeight,this.angle=0,this.color=d.color||"transparent",this.colorMode=d.colorMode||"rgb",this.visibility=d.visibility||"visible",this.opacity=d.opacity||1,this.borderWidth=d.borderWidth||0,this.borderStyle=d.borderStyle||"none",this.borderColor=d.borderColor||"transparent",this.boxShadowOffset=d.boxShadowOffset||new a.Vector,this.boxShadowBlur=d.boxShadowBlur||0,this.boxShadowSpread=d.boxShadowSpread||0,this.boxShadowColor=d.boxShadowColor||"transparent",this.gravity=d.gravity||new a.Vector(0,1),this.c=d.c||.1,this.boundToWindow=d.boundToWindow===!1?!1:!0,this.location=d.location||new a.Vector(e.width/2,e.height/2),this.initLocation=new a.Vector(this.location.x,this.location.y),this.position=d.position||"absolute",this.paddingTop=d.paddingTop||0,this.paddingRight=d.paddingRight||0,this.paddingBottom=d.paddingBottom||0,this.paddingLeft=d.paddingLeft||0,this.marginTop=d.marginTop||0,this.pauseStep=!1,this.pauseDraw=!1,this._setBounds(),this._pool=[],this.world={},this.draw(),this.isStatic="undefined"!=typeof d.isStatic?d.isStatic:!0,this.drawState=0}function h(b){var c=b||{};c.name="Box",a.Item.call(this,c)}function i(b){var c=b||{};c.name="Ball",a.Item.call(this,c)}b.Burner=a,window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,1e3/60)}}(),c.VectorSub=function(a,b){return new c(a.x-b.x,a.y-b.y)},c.VectorAdd=function(a,b){return new c(a.x+b.x,a.y+b.y)},c.VectorMult=function(a,b){return new c(a.x*b,a.y*b)},c.VectorDiv=function(a,b){return new c(a.x/b,a.y/b)},c.VectorDistance=function(a,b){return Math.sqrt(Math.pow(b.x-a.x,2)+Math.pow(b.y-a.y,2))},c.VectorMidPoint=function(a,b){return c.VectorAdd(a,b).div(2)},c.VectorAngleBetween=function(a,b){var c=a.dot(b),d=Math.acos(c/(a.mag()*b.mag()));return d},c.prototype.name="Vector",c.prototype.clone=function(){function a(){}return a.prototype=this,new a},c.prototype.add=function(a){return this.x+=a.x,this.y+=a.y,this},c.prototype.sub=function(a){return this.x-=a.x,this.y-=a.y,this},c.prototype.mult=function(a){return this.x*=a,this.y*=a,this},c.prototype.div=function(a){return this.x=this.x/a,this.y=this.y/a,this},c.prototype.mag=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},c.prototype.limit=function(a,b){var c=a||null,d=b||null;return c&&this.mag()>c&&(this.normalize(),this.mult(c)),d&&this.mag()<d&&(this.normalize(),this.mult(d)),this},c.prototype.normalize=function(){var a=this.mag();return 0!==a?this.div(a):void 0},c.prototype.distance=function(a){return Math.sqrt(Math.pow(a.x-this.x,2)+Math.pow(a.y-this.y,2))},c.prototype.rotate=function(a){var b=Math.cos(a),c=Math.sin(a),d=this.x,e=this.y;return this.x=d*b-e*c,this.y=d*c+e*b,this},c.prototype.midpoint=function(a){return c.VectorAdd(this,a).div(2)},c.prototype.dot=function(a){return this.z&&a.z?this.x*a.x+this.y*a.y+this.z*a.z:this.x*a.x+this.y*a.y},d.prototype.getFPS=function(){return this._fps},d.prototype._update=function(b){var c=a.System.count();b._time=Date.now?Date.now():0,b._frameCount++,b._time>b._timeLastSecond+1e3&&(b._fps=b._frameCount,b._timeLastSecond=b._time,b._frameCount=0,b._fpsValue.nodeValue=b._fps,b._totalElementsValue.nodeValue=c);var d=function(a){return function(){a._update(a)}}(this);this._active&&window.requestAnimFrame(d)},d.prototype.destroy=function(){this._active=!1,document.getElementById(this.el.id)&&document.body.removeChild(this.el)},e.detect=function(a){return this[a]?this[a].call(this):!1},e.csstransforms=function(){var a=["-webkit-transform: translateX(1px) translateY(1px)","-moz-transform: translateX(1px) translateY(1px)","-o-transform: translateX(1px) translateY(1px)","-ms-transform: translateX(1px) translateY(1px)"].join(";"),b=document.createDocumentFragment(),c=document.createElement("div");b.appendChild(c),c.style.cssText=a;for(var d=[c.style.transform,c.style.webkitTransform,c.style.MozTransform,c.style.OTransform,c.style.msTransform],e=!1,f=0;f<d.length;f+=1)if(d[f]){e=!0;break}return e},e.csstransforms3d=function(){var a=["-webkit-transform: translate3d(1px, 1px, 0)","-moz-transform: translate3d(1px, 1px, 0)","-o-transform: translate3d(1px, 1px, 0)","-ms-transform: translate3d(1px, 1px, 0)"].join(";"),b=document.createDocumentFragment(),c=document.createElement("div");b.appendChild(c),c.style.cssText=a;for(var d=[c.style.transform,c.style.webkitTransform,c.style.MozTransform,c.style.OTransform,c.style.msTransform],e=!1,f=0;f<d.length;f+=1)if(d[f]){e=!0;break}return e},e.touch=function(){var a=document.createElement("div");return a.setAttribute("ongesturestart","return;"),"function"==typeof a.ongesturestart?!0:!1},f.prototype.reset=function(b){var c,d=b||{};for(c in d)d.hasOwnProperty(c)&&(this[c]=d[c]);this.width="undefined"==typeof d.width?10:d.width,this.height="undefined"==typeof d.height?10:d.height,this.color=d.color||[0,0,0],this.colorMode=d.colorMode||"rgb",this.visibility=d.visibility||"visible",this.opacity="undefined"==typeof d.opacity?1:d.opacity,this.zIndex="undefined"==typeof d.zIndex?1:d.zIndex,this.borderWidth=d.borderWidth||0,this.borderStyle=d.borderStyle||"none",this.borderColor=d.borderColor||"transparent",this.borderRadius=d.borderRadius||0,this.boxShadowOffset="undefined"==typeof d.boxShadowOffset?new a.Vector:d.boxShadowOffset,this.boxShadowBlur=d.boxShadowBlur||0,this.boxShadowSpread=d.boxShadowSpread||0,this.boxShadowColor="undefined"==typeof d.boxShadowColor?"transparent":d.boxShadowColor,this.bounciness="undefined"==typeof d.bounciness?.8:d.bounciness,this.mass="undefined"==typeof d.mass?10:d.mass,this.acceleration="function"==typeof d.acceleration?d.acceleration.call(this):d.acceleration||new a.Vector,this.velocity="function"==typeof d.velocity?d.velocity.call(this):d.velocity||new a.Vector,this.location="function"==typeof d.location?d.location.call(this):d.location||new a.Vector(this.world.width/2,this.world.height/2),this.initLocation=new a.Vector,this.initLocation.x=this.location.x,this.initLocation.y=this.location.y,this.maxSpeed="undefined"==typeof d.maxSpeed?10:d.maxSpeed,this.minSpeed=d.minSpeed||0,this.angle=d.angle||0,this.position=d.position||"absolute",this.paddingTop=d.paddingTop||0,this.paddingRight=d.paddingRight||0,this.paddingBottom=d.paddingBottom||0,this.paddingLeft=d.paddingLeft||0,this.marginTop=d.marginTop||0,this.lifespan="undefined"==typeof d.lifespan?-1:d.lifespan,this.life=d.life||0,this.isStatic=!!d.isStatic,this.controlCamera=!!d.controlCamera,this.worldBounds=d.worldBounds||[!0,!0,!0,!0],this.checkWorldEdges="undefined"==typeof d.checkWorldEdges?!0:d.checkWorldEdges,this.wrapWorldEdges=!!d.wrapWorldEdges,this.wrapWorldEdgesSoft=!!d.wrapWorldEdgesSoft,this.avoidWorldEdges=!!d.avoidWorldEdges,this.avoidWorldEdgesStrength="undefined"==typeof d.avoidWorldEdgesStrength?50:d.avoidWorldEdgesStrength,this.world.isStatic=!1},f.prototype.step=function(){this.isStatic||(this.applyForce(this.world.gravity),this.velocity.add(this.acceleration),this.velocity.limit(this.maxSpeed,this.minSpeed),this.location.add(this.velocity),this.controlCamera&&this._checkCameraEdges(),this.checkWorldEdges&&this._checkWorldEdges(),this.acceleration.mult(0),this.life<this.lifespan?this.life++:-1!==this.lifespan&&a.System.destroyItem(this))},f.prototype.applyForce=function(a){return a?(this._force.x=a.x,this._force.y=a.y,this._force.div(this.mass),this.acceleration.add(this._force),this.acceleration):void 0},f.prototype._checkWorldEdges=function(){var a,b,c=this.world.bounds[1],d=this.world.bounds[2],e=this.worldBounds,f=this.location,g=this.velocity,h=this.width,i=this.height,j=this.bounciness;this.wrapWorldEdgesSoft?(a=f.x,b=f.y,f.x>c?(f.x=-(c-f.x),this.controlCamera&&(this.world.location.x=this.world.location.x+a-f.x)):f.x<0&&(f.x=c+f.x,this.controlCamera&&(this.world.location.x=this.world.location.x+a-f.x)),f.y>d?(f.y=-(d-f.y),this.controlCamera&&(this.world.location.y=this.world.location.y+b-f.y)):f.y<0&&(f.y=d+f.y,this.controlCamera&&(this.world.location.y=this.world.location.y+b-f.y))):this.wrapWorldEdges?(a=f.x,b=f.y,f.x>c?(f.x=0,this.controlCamera&&(this.world.location.x=this.world.location.x+a-f.x)):f.x<0&&(f.x=c,this.controlCamera&&(this.world.location.x=this.world.location.x+a-f.x)),f.y>d?(f.y=0,this.controlCamera&&(this.world.location.y=this.world.location.y+b-f.y)):f.y<0&&(f.y=d,this.controlCamera&&(this.world.location.y=this.world.location.y+b-f.y))):(f.x+h/2>c&&e[1]?(f.x=c-h/2,g.x*=-1*j):f.x<h/2&&e[3]&&(f.x=h/2,g.x*=-1*j),f.y+i/2>d&&e[2]?(f.y=d-i/2,g.y*=-1*j):f.y<i/2&&e[0]&&(f.y=i/2,g.y*=-1*j))},f.prototype._checkCameraEdges=function(){this._camera.x=this.velocity.x,this._camera.y=this.velocity.y,this.world.location.add(this._camera.mult(-1))},f.prototype.draw=function(){a.System._draw(this)};var j={name:"System"};j._stylePosition="",j.clock=0,j.supportedFeatures={csstransforms:!0,csstransforms3d:!0},j._records={lookup:{},list:[]},j._worlds={lookup:{},list:[]},j._caches={},j._idCount=0,j.mouse={location:new c,lastLocation:new c,velocity:new c},j._resizeTime=0,j.trace=!1,j.init=function(b,c,d,e){var f=b||function(){},g=c||new a.World(document.body),h=d||null,i=e?!0:!1;if(h){if("object"!=typeof h||"undefined"==typeof h.csstransforms||"undefined"==typeof h.csstransforms3d)throw new Error("System: supportedFeatures should be passed as an object.");this.supportedFeatures=h}else this.supportedFeatures=j._getSupportedFeatures();if(this._stylePosition=j.supportedFeatures.csstransforms3d?"transform: translate3d(<x>px, <y>px, 0) rotate(<angle>deg) scale(<scale>, <scale>); -webkit-transform: translate3d(<x>px, <y>px, 0) rotate(<angle>deg) scale(<scale>, <scale>); -moz-transform: translate3d(<x>px, <y>px, 0) rotate(<angle>deg) scale(<scale>, <scale>); -o-transform: translate3d(<x>px, <y>px, 0) rotate(<angle>deg) scale(<scale>, <scale>); -ms-transform: translate3d(<x>px, <y>px, 0) rotate(<angle>deg) scale(<scale>, <scale>);":j.supportedFeatures.csstransforms?"transform: translate(<x>px, <y>px) rotate(<angle>deg) scale(<scale>, <scale>); -webkit-transform: translate(<x>px, <y>px) rotate(<angle>deg) scale(<scale>, <scale>); -moz-transform: translate(<x>px, <y>px) rotate(<angle>deg) scale(<scale>, <scale>); -o-transform: translate(<x>px, <y>px) rotate(<angle>deg) scale(<scale>, <scale>); -ms-transform: translate(<x>px, <y>px) rotate(<angle>deg) scale(<scale>, <scale>);":"position: absolute; left: <x>px; top: <y>px;","[object Array]"===Object.prototype.toString.call(g))for(var k=0,l=g.length;l>k;k++)j._addWorld(g[k]);else j._addWorld(g);document.body.onorientationchange=j.updateOrientation,this._addEvent(window,"resize",function(a){j._resize.call(j,a)}),this._addEvent(document,"mousemove",function(a){j._recordMouseLoc.call(j,a)}),this._addEvent(window,"touchstart",function(a){j._recordMouseLoc.call(j,a)}),this._addEvent(window,"touchmove",function(a){j._recordMouseLoc.call(j,a)}),this._addEvent(window,"touchend",function(a){j._recordMouseLoc.call(j,a)}),this._addEvent(window,"devicemotion",function(a){var b,c=j._caches.World.list,d=a.accelerationIncludingGravity.x,e=a.accelerationIncludingGravity.y;for(k=0,l=c.length;l>k;k++)b=c[k],0===window.orientation?(b.gravity.x=d,b.gravity.y=-1*e):-90===window.orientation?(b.gravity.x=e,b.gravity.y=d):(b.gravity.x=-1*e,b.gravity.y=-1*d)}),this._addEvent(window,"keyup",function(a){j._keyup.call(j,a)}),this._setup=f,this._setup.call(this),i||this._update()},j._addWorld=function(a){j._records.list.push(a),j._worlds.list.push(j._records.list[j._records.list.length-1]),j._worlds.lookup[a.el.id]=j._records.list[j._records.list.length-1]},j.add=function(a,b,c){var d,e,f,g,h,i=this._records.list,k=this._records.lookup,l=b||{};if(l.world=c||i[0],h=this.getAllItemsByName(a,l.world._pool),h.length){for(d=0,e=l.world._pool.length;e>d;d++)if(l.world._pool[d].name===a){i[i.length]=l.world._pool.splice(d,1)[0],i[i.length-1].options=l,j._updateCacheLookup(i[i.length-1],!0);break}}else i[i.length]=Burner[a]?new Burner[a](l):new Burner.Classes[a](l);return f=i.length-1,g=i[f].el.parentNode,k[i[f].id]=g,i[f].reset(l),i[f].init(l),i[f]},j.start=function(){this._update()},j.updateCache=function(a){var b=j._caches[a.name]||(j._caches[a.name]={lookup:{},list:[]});return b.list[b.list.length]=a,b.lookup[a.id]=!0,b},j._updateCacheLookup=function(a,b){var c=j._caches[a.name];c&&(c.lookup[a.id]=b)},j.count=function(){return this._records.list.length},j.firstWorld=function(){return this._worlds.list.length?this._worlds.list[0]:null},j.lastWorld=function(){return this._worlds.list.length?this._worlds.list[this._worlds.list.length-1]:null},j.firstItem=function(){return this._records.list[0]},j.lastItem=function(){return this._records.list[this._records.list.length-1]},j.getAllWorlds=function(){return j._worlds.list},j._update=function(){var a,b,c,d,e=j._records.list,f=j.firstWorld();if(j._resizeTime&&(new Date).getTime()-j._resizeTime>100){for(j._resizeTime=0,d=j.getAllWorlds(),a=0,b=d.length;b>a;a++)d[a].pauseStep=!1;f.afterResize&&f.afterResize.call(this)}for(j.trace&&console.time("update"),a=e.length-1;a>=0;a-=1)c=e[a],c.step&&!c.world.pauseStep&&c.step();for(j.trace&&(console.timeEnd("update"),console.time("render")),a=e.length-1;a>=0;a-=1)c=e[a],c.draw&&!c.world.drawStep&&c.draw();j.trace&&console.timeEnd("render"),j.clock++,window.requestAnimFrame(j._update)},j._stepForward=function(){var a,b,c,d,e=j._records.list,f=j.getAllWorlds();for(a=0,c=f.length;c>a;a++){for(d=f[a],d.pauseStep=!0,b=e.length-1;b>=0;b-=1)e[b].step&&e[b].step();for(b=e.length-1;b>=0;b-=1)e[b].draw&&e[b].draw()}j.clock++},j._resetSystem=function(b){var c,d,e,f=j.getAllWorlds();for(c=0,d=f.length;d>c;c++)for(e=f[c],e.pauseStep=!1,e.pauseDraw=!1;e.el.firstChild;)e.el.removeChild(e.el.firstChild);j._caches={},j._destroyAllItems(),j._idCount=0,j.mouse={location:new a.Vector,lastLocation:new a.Vector,velocity:new a.Vector},j._resizeTime=0,b||j._setup.call(j)},j._destroySystem=function(){this._resetSystem(!0),this._destroyAllWorlds(),this.clock=0,this._idCount=0},j._destroyAllItems=function(){var a,b=this._records.list;for(a=b.length-1;a>=0;a--)"World"!==b[a].name&&b.splice(a,1)},j._destroyAllWorlds=function(){var a,b,c=this._records.list;for(a=c.length-1;a>=0;a--)b=c[a],"World"===b.name&&(b.el.parentNode.removeChild(b.el),c.splice(a,1));this._worlds={lookup:{},list:[]}},j.destroyItem=function(a){var b,c,d=this._records.list;for(b=0,c=d.length;c>b;b++)if(d[b].id===a.id){d[b].el.style.visibility="hidden",d[b].el.style.display="none",d[b].el.style.opacity=0,d[b].world._pool[d[b].world._pool.length]=d.splice(b,1)[0],j._updateCacheLookup(a,!1);break}},j.getAllItemsByName=function(a,b){var c,d,e=[],f=b||this._records.list;for(c=0,d=f.length;d>c;c++)f[c].name===a&&(e[e.length]=f[c]);return e},j.getAllItemsByAttribute=function(a,b){var c,d,e=[],f=this._records.list,g="undefined"!=typeof b?b:null;for(c=0,d=f.length;d>c;c++)if("undefined"!=typeof f[c][a]){if(null!==g&&f[c][a]!==g)continue;e[e.length]=f[c]}return e},j.updateItemPropsByName=function(a,b){var c,d,e,f=this.getAllItemsByName(a);for(c=0,d=f.length;d>c;c++)for(e in b)b.hasOwnProperty(e)&&(f[c][e]=b[e]);return f},j.getItem=function(a){var b,c,d=this._records.list;for(b=0,c=d.length;c>b;b+=1)if(d[b].id===a)return d[b];return null},j.updateItem=function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a},j._resize=function(){var b,c,d,e,f=this._records.list,g=this.getWindowSize(),h=j.getAllWorlds();for(b=0,c=f.length;c>b;b++)d=f[b],"World"!==d.name&&d.world.boundToWindow&&d.location&&(d.location.x=g.width*(d.location.x/d.world.width),d.location.y=g.height*(d.location.y/d.world.height));for(b=0,c=h.length;c>b;b++)e=h[b],e.boundToWindow&&(e.bounds=[0,g.width,g.height,0],e.width=g.width,e.height=g.height,e.location=new a.Vector(g.width/2,g.height/2))},j._keyup=function(a){var b,c,d,e=this.getAllWorlds();switch(a.keyCode){case 39:j._stepForward();break;case 80:for(b=0,c=e.length;c>b;b++)d=e[b],d.pauseStep=!d.pauseStep;break;case 82:j._resetSystem();break;case 83:j._toggleStats()}},j.getNewId=function(){return this._idCount++,this._idCount},j._addEvent=function(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c)},j._recordMouseLoc=function(a){var b,c=this.firstWorld();this.mouse.lastLocation.x=this.mouse.location.x,this.mouse.lastLocation.y=this.mouse.location.y,a.changedTouches&&(b=a.changedTouches[0]),a.pageX&&a.pageY?(this.mouse.location.x=this.map(a.pageX,0,window.innerWidth,0,c.width),this.mouse.location.y=this.map(a.pageY,0,window.innerHeight,0,c.height)):a.clientX&&a.clientY?(this.mouse.location.x=this.map(a.clientX,0,window.innerWidth,0,c.width),this.mouse.location.y=this.map(a.clientY,0,window.innerHeight,0,c.height)):b&&(this.mouse.location.x=b.pageX,this.mouse.location.y=b.pageY),this.mouse.velocity.x=this.mouse.lastLocation.x-this.mouse.location.x,this.mouse.velocity.y=this.mouse.lastLocation.y-this.mouse.location.y},j.extend=function(a,b){function c(){}c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a},j.getWindowSize=function(){var a={width:!1,height:!1};return"undefined"!=typeof window.innerWidth?(a.width=window.innerWidth,a.height=window.innerHeight):"undefined"!=typeof document.documentElement&&"undefined"!=typeof document.documentElement.clientWidth?(a.width=document.documentElement.clientWidth,a.height=document.documentElement.clientHeight):"undefined"!=typeof document.body&&(a.width=document.body.clientWidth,a.height=document.body.clientHeight),a},j.updateOrientation=function(){setTimeout(function(){j._records.list[0]._setBounds()},500)},j.getRandomNumber=function(a,b,c){return c?Math.random()*(b-(a-1))+a:Math.floor(Math.random()*(b-(a-1)))+a},j._toggleStats=function(){j._statsDisplay?j._statsDisplay&&j._statsDisplay._active?j._statsDisplay.destroy():j._statsDisplay&&!j._statsDisplay._active&&(j._statsDisplay=new a.StatsDisplay):j._statsDisplay=new a.StatsDisplay},j._getSupportedFeatures=function(){var b;return b=window.Modernizr?{csstransforms3d:Modernizr.csstransforms3d,csstransforms:Modernizr.csstransforms,touch:Modernizr.touch}:{csstransforms3d:a.FeatureDetector.detect("csstransforms3d"),csstransforms:a.FeatureDetector.detect("csstransforms"),touch:a.FeatureDetector.detect("touch")}},j.map=function(a,b,c,d,e){var f=(a-b)/(c-b);return f*(e-d)+d},j._draw=function(b){var c=a.System.getCSSText({x:b.location.x-b.width/2,y:b.location.y-b.height/2,angle:b.angle,scale:b.scale||1,width:b.autoWidth?null:b.width,height:b.autoHeight?null:b.height,color0:b.color[0],color1:b.color[1],color2:b.color[2],colorMode:b.colorMode,visibility:b.visibility,opacity:b.opacity,zIndex:b.zIndex,borderWidth:b.borderWidth,borderStyle:b.borderStyle,borderColor0:b.borderColor[0],borderColor1:b.borderColor[1],borderColor2:b.borderColor[2],borderRadius:b.borderRadius,boxShadowOffsetX:b.boxShadowOffset.x,boxShadowOffsetY:b.boxShadowOffset.y,boxShadowBlur:b.boxShadowBlur,boxShadowSpread:b.boxShadowSpread,boxShadowColor0:b.boxShadowColor[0],boxShadowColor1:b.boxShadowColor[1],boxShadowColor2:b.boxShadowColor[2],position:b.position,paddingTop:b.paddingTop,paddingRight:b.paddingRight,paddingBottom:b.paddingBottom,paddingLeft:b.paddingLeft,marginTop:b.marginTop});b.el.style.cssText=c},j.getCSSText=function(a){return this._stylePosition.replace(/<x>/g,a.x).replace(/<y>/g,a.y).replace(/<angle>/g,a.angle).replace(/<scale>/g,a.scale)+"width: "+a.width+"px; height: "+a.height+"px; background-color: "+a.colorMode+"("+a.color0+", "+a.color1+("hsl"===a.colorMode?"%":"")+", "+a.color2+("hsl"===a.colorMode?"%":"")+"); border: "+a.borderWidth+"px "+a.borderStyle+" "+a.colorMode+"("+a.borderColor0+", "+a.borderColor1+("hsl"===a.colorMode?"%":"")+", "+a.borderColor2+("hsl"===a.colorMode?"%":"")+"); border-radius: "+a.borderRadius+"%; box-shadow: "+a.boxShadowOffsetX+"px "+a.boxShadowOffsetY+"px "+a.boxShadowBlur+"px "+a.boxShadowSpread+"px "+a.colorMode+"("+a.boxShadowColor0+", "+a.boxShadowColor1+("hsl"===a.colorMode?"%":"")+", "+a.boxShadowColor2+("hsl"===a.colorMode?"%":"")+"); visibility: "+a.visibility+"; opacity: "+a.opacity+"; z-index: "+a.zIndex+"; position: "+a.position+"; padding-top: "+a.paddingTop+"px; padding-right: "+a.paddingRight+"px; padding-bottom: "+a.paddingBottom+"px; padding-left: "+a.paddingLeft+"px; margin-top: "+a.marginTop+"px;"},g.prototype.step=function(){},g.prototype.draw=function(){2===this.drawState&&this.isStatic||(this.drawState&&this.isStatic?1===this.drawState&&(this.el.style.cssText=""):a.System._draw(this),this.drawState++)},g.prototype._setBounds=function(){var b=a.System.getWindowSize();this.boundToWindow?(this.bounds=[0,b.width,b.height,0],this.width=b.width,this.height=b.height):this.bounds=[0,this.width,this.height,0],this.location||(this.location=new a.Vector(b.width/2,b.height/2))},j.extend(h,f),h.prototype.init=function(a){this.width=a.width||20,this.height=a.height||20,this.color=a.color||[100,100,100],this.borderRadius=a.borderRadius||0},j.extend(i,f),i.prototype.init=function(b){this.width=b.width||20,this.height=b.height||20,this.color=b.color||[0,0,0],this.colorMode=b.colorMode||"rgb",this.borderRadius=b.borderRadius||100,this.opacity=b.opacity||1,this.boxShadowOffset=b.boxShadowOffset||new a.Vector,this.boxShadowBlur=b.boxShadowBlur||0,this.boxShadowSpread=b.boxShadowSpread||0,this.boxShadowColor=b.boxShadowColor||[0,0,0]},a.Vector=c,a.StatsDisplay=d,a.FeatureDetector=e,a.Item=f,a.System=j,a.World=g,a.Box=h,a.Ball=i}({},function(){return this}());
/*! Flora v2.1.1 - 2013-09-11 05:09:09
Vince Allen |Brooklyn, NY | vince@vinceallen.com | @vinceallenvince | License: MIT */
body{margin:0;padding:0;overflow:hidden;width:100%;height:100%;background-color:#000}.hasSensor{border-radius:100%}.nose{position:absolute;left:80%;top:40%;width:20%;height:20%;background:#fff}.caption,.inputMenu{width:auto;position:absolute;font-family:"Franklin Gothic Medium","Franklin Gothic","ITC Franklin Gothic",Arial,sans-serif;color:#000;text-align:center;cursor:default;-webkit-user-select:none;-moz-user-select:none;-o-user-select:none;-ms-user-select:none;user-select:none}.captionTop,.inputMenuTop{bottom:90%}.captionBottom,.inputMenuBottom{top:90%}.captionLeft,.inputMenuLeft{left:0}.captionRight,.inputMenuRight{right:0}.captionCenter,.inputMenuCenter{width:100%;text-align:center;margin:0 auto}
/*! Flora v2.1.1 - 2013-09-11 05:09:09
Vince Allen |Brooklyn, NY | vince@vinceallen.com | @vinceallenvince | License: MIT */
!function(a,b){function c(a){this._borders=[],this.id=a||c._idCount,c._idCount++}function d(a){this._gradients=[],this._colors=[],this.id=a||d._idCount,d._idCount++}function e(){}function f(a){var b,c,d,e=a||{};for(this.world=e.world||Burner.System.firstWorld(),this.position=e.position||"top left",this.text=e.text||"",this.opacity="undefined"==typeof e.opacity?.75:e.opacity,this.color=e.color||[255,255,255],this.borderWidth=e.borderWidth||0,this.borderStyle=e.borderStyle||"none",this.borderColor=e.borderColor||[204,204,204],this.colorMode="rgb",this.el=document.createElement("div"),this.el.id="caption",this.el.className="caption ",d=this.position.split(" "),b=0,c=d.length;c>b;b++)this.el.className=this.el.className+"caption"+y.capitalizeFirstLetter(d[b])+" ";this.el.style.opacity=this.opacity,this.el.style.color=this.colorMode+"("+this.color[0]+", "+this.color[1]+", "+this.color[2]+")",this.el.style.borderWidth=this.borderWidth+"px",this.el.style.borderStyle=this.borderStyle,this.el.style.borderColor="string"==typeof this.borderColor?this.borderColor:this.colorMode+"("+this.borderColor[0]+", "+this.borderColor[1]+", "+this.borderColor[2]+")",this.el.appendChild(document.createTextNode(this.text)),document.getElementById("caption")&&document.getElementById("caption").parentNode.removeChild(document.getElementById("caption")),this.world.el.appendChild(this.el)}function g(a){var b,c,d,e=this,f=a||{};for(this.world=f.world||Burner.System.firstWorld(),this.position=f.position||"top left",this.opacity="undefined"==typeof f.opacity?.75:f.opacity,this.color=f.color||[255,255,255],this.borderWidth=f.borderWidth||0,this.borderStyle=f.borderStyle||"none",this.borderColor=f.borderColor||[204,204,204],this.colorMode="rgb",this.text=Burner.System.supportedFeatures.touch?w.touchMap.stats+"-finger tap = stats | "+w.touchMap.pause+"-finger tap = pause | "+w.touchMap.reset+"-finger tap = reset":"'"+String.fromCharCode(w.keyMap.pause).toLowerCase()+"' = pause | "+"'"+String.fromCharCode(w.keyMap.resetSystem).toLowerCase()+"' = reset | "+"'"+String.fromCharCode(w.keyMap.stats).toLowerCase()+"' = stats",this.el=document.createElement("div"),this.el.id="inputMenu",this.el.className="inputMenu ",d=this.position.split(" "),b=0,c=d.length;c>b;b++)this.el.className=this.el.className+"inputMenu"+y.capitalizeFirstLetter(d[b])+" ";this.el.style.opacity=this.opacity,this.el.style.color=this.colorMode+"("+this.color[0]+", "+this.color[1]+", "+this.color[2]+")",this.el.style.borderWidth=this.borderWidth+"px",this.el.style.borderStyle=this.borderStyle,this.el.style.borderColor="string"==typeof this.borderColor?this.borderColor:this.colorMode+"("+this.borderColor[0]+", "+this.borderColor[1]+", "+this.borderColor[2]+")",this.el.appendChild(document.createTextNode(this.text)),document.getElementById("inputMenu")&&document.getElementById("inputMenu").parentNode.removeChild(document.getElementById("inputMenu")),Burner.System.supportedFeatures.touch?y.addEvent(this.el,"touchstart",function(){e.destroy()}):y.addEvent(this.el,"mouseup",function(){e.destroy()}),this.world.el.appendChild(this.el)}function h(a){var b=a||{};b.name=b.name||"Mover",Burner.Item.call(this,b)}function i(a){var b=a||{};b.name=b.name||"Agent",h.call(this,b)}function j(a){var b=a||{};b.name=b.name||"Walker",h.call(this,b)}function k(a){var b=a||{};b.name=b.name||"Sensor",h.call(this,b)}function l(a){var b=a||{};b.name=b.name||"Connector",Burner.Item.call(this,b)}function m(a){var b=a||{};b.name=b.name||"Point",h.call(this,b)}function n(a){var b=a||{};b.name=b.name||"Particle",i.call(this,b)}function o(a){var b=a||{};b.name=b.name||"ParticleSystem",i.call(this,b)}function p(a){var b=a||{};b.name=b.name||"Oscillator",Burner.Item.call(this,b)}function q(a){var b=a||{};b.name=b.name||"Liquid",i.call(this,b)}function r(a){var b=a||{};b.name=b.name||"Attractor",i.call(this,b)}function s(a){var b=a||{};b.name=b.name||"Repeller",i.call(this,b)}function t(a){if(!a||!a.type)throw new Error("Stimulus: options.type is required.");a.name=a.type.substr(0,1).toUpperCase()+a.type.toLowerCase().substr(1,a.type.length),i.call(this,a)}function u(a){var b=a||{};b.name=b.name||"FlowField",Burner.Item.call(this,b)}function v(a){var b,c,d={location:"object",scale:"number",angle:"number",opacity:"number",width:"number",height:"number",colorMode:"string",color:"array"};return x.checkRequiredParams(a,d)?(b=document.createElement("div"),c=document.createElement("div"),b.className="flowFieldMarker item",c.className="nose",b.appendChild(c),b.style.cssText=Burner.System.getCSSText({x:a.location.x-a.width/2,y:a.location.y-a.height/2,width:a.width,height:a.height,opacity:a.opacity,angle:a.angle,scale:1,colorMode:a.colorMode,color0:a.color[0],color1:a.color[1],color2:a.color[2],zIndex:a.zIndex,borderRadius:a.borderRadius}),b):void 0}b.Flora=a,Burner.Classes=Flora;var w={borderStyles:["none","solid","dotted","dashed","double","inset","outset","groove","ridge"],defaultColorList:[{name:"cold",startColor:[88,129,135],endColor:[171,244,255],boxShadowColor:[132,192,201]},{name:"food",startColor:[186,255,130],endColor:[84,187,0],boxShadowColor:[57,128,0]},{name:"heat",startColor:[255,132,86],endColor:[175,47,0],boxShadowColor:[255,69,0]},{name:"light",startColor:[255,255,255],endColor:[189,148,0],boxShadowColor:[255,200,0]},{name:"oxygen",startColor:[130,136,255],endColor:[49,56,205],boxShadowColor:[60,64,140]}],keyMap:{pause:80,resetSystem:82,stats:83},touchMap:{stats:2,pause:3,reset:4}},x={};x.checkRequiredParams=function(a,b,c){var d,e,f=!0;for(d in b)if(b.hasOwnProperty(d))try{if("undefined"==typeof a)throw new Error("checkRequiredOptions: No options were passed.");if(!this.checkDataType(this.getDataType(a[d]),b[d].split("|"))||""===a[d])throw f=!1,e=""===a[d]?'checkRequiredOptions: required option "'+d+'" is empty.':"undefined"==typeof a[d]?'checkRequiredOptions: required option "'+d+'" is missing from passed options.':'checkRequiredOptions: passed option "'+d+'" must be type '+b[d]+". Passed as "+this.getDataType(a[d])+".",new Error(e)}catch(g){"undefined"!=typeof console&&console.log("ERROR: "+g.message+(c?" from: "+c:""))}return f},x.checkDataType=function(a,b){var c,d;for(c=0,d=b.length;d>c;c++)if(a===b[c])return!0;return!1},x.getDataType=function(a){return"[object Array]"===Object.prototype.toString.call(a)?"array":"[object NodeList]"===Object.prototype.toString.call(a)?"nodeList":typeof a};var y={};y.extend=function(a,b){function c(){}c.prototype=b.prototype,a.prototype=new c,a.prototype.constructor=a,a._superClass=b},y.map=function(a,b,c,d,e){var f=(a-b)/(c-b);return f*(e-d)+d},y.getRandomNumber=function(a,b,c){return c?Math.random()*(b-(a-1))+a:Math.floor(Math.random()*(b-(a-1)))+a},y.degreesToRadians=function(a){return"undefined"!=typeof a?2*Math.PI*(a/360):("undefined"!=typeof console&&console.log("Error: Utils.degreesToRadians is missing degrees param."),!1)},y.radiansToDegrees=function(a){return"undefined"!=typeof a?a*(180/Math.PI):("undefined"!=typeof console&&console.log("Error: Utils.radiansToDegrees is missing radians param."),!1)},y.constrain=function(a,b,c){return a>c?c:b>a?b:a},y.clone=function(a){function b(){}return b.prototype=a,new b},y.addEvent=function(a,b,c){a.addEventListener?this.addEventHandler=function(a,b,c){a.addEventListener(b,c,!1)}:a.attachEvent&&(this.addEventHandler=function(a,b,c){a.attachEvent("on"+b,c)}),this.addEventHandler(a,b,c)},y.log=function(a){"undefined"!=typeof console&&"undefined"!=typeof console.log?(this.log=function(a){console.log(a)},this.log.call(this,a)):this.log=function(){}},y.getWindowSize=function(){var a={width:!1,height:!1};return"undefined"!=typeof window.innerWidth?a.width=window.innerWidth:"undefined"!=typeof document.documentElement&&"undefined"!=typeof document.documentElement.clientWidth?a.width=document.documentElement.clientWidth:"undefined"!=typeof document.body&&(a.width=document.body.clientWidth),"undefined"!=typeof window.innerHeight?a.height=window.innerHeight:"undefined"!=typeof document.documentElement&&"undefined"!=typeof document.documentElement.clientHeight?a.height=document.documentElement.clientHeight:"undefined"!=typeof document.body&&(a.height=document.body.clientHeight),a},y.getDataType=function(a){return"[object Array]"===Object.prototype.toString.call(a)?"array":"[object NodeList]"===Object.prototype.toString.call(a)?"nodeList":typeof a},y.capitalizeFirstLetter=function(a){return a.charAt(0).toUpperCase()+a.slice(1)},y.isInside=function(a,b){return b&&a.location.x+a.width/2>b.location.x-b.width/2&&a.location.x-a.width/2<b.location.x+b.width/2&&a.location.y+a.height/2>b.location.y-b.height/2&&a.location.y-a.height/2<b.location.y+b.height/2?!0:!1},y.mouseIsInsideWorld=function(a){var b=Burner.System.mouse,c=b.location.x,d=b.location.y,e=a.el.offsetLeft,f=a.el.offsetTop;return a&&c>e&&c<e+a.bounds[1]&&d>f&&d<f+a.bounds[2]?!0:!1};var z=function(a){"undefined"==typeof a&&(a=Math);var b,c=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],d=[];for(b=0;256>b;b+=1)d[b]=Math.floor(256*a.random());var e=[];for(b=0;512>b;b+=1)e[b]=d[255&b];var f=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]];return{grad3:c,p:d,perm:e,simplex:f,dot:function(a,b,c){return a[0]*b+a[1]*c},noise:function(a,b){var c,d,e,f,g,h=.5*(Math.sqrt(3)-1),i=(a+b)*h,j=Math.floor(a+i),k=Math.floor(b+i),l=(3-Math.sqrt(3))/6,m=(j+k)*l,n=j-m,o=k-m,p=a-n,q=b-o;p>q?(f=1,g=0):(f=0,g=1);var r=p-f+l,s=q-g+l,t=p-1+2*l,u=q-1+2*l,v=255&j,w=255&k,x=this.perm[v+this.perm[w]]%12,y=this.perm[v+f+this.perm[w+g]]%12,z=this.perm[v+1+this.perm[w+1]]%12,A=.5-p*p-q*q;0>A?c=0:(A*=A,c=A*A*this.dot(this.grad3[x],p,q));var B=.5-r*r-s*s;0>B?d=0:(B*=B,d=B*B*this.dot(this.grad3[y],r,s));var C=.5-t*t-u*u;return 0>C?e=0:(C*=C,e=C*C*this.dot(this.grad3[z],t,u)),70*(c+d+e)},noise3d:function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n=1/3,o=(a+b+c)*n,p=Math.floor(a+o),q=Math.floor(b+o),r=Math.floor(c+o),s=1/6,t=(p+q+r)*s,u=p-t,v=q-t,w=r-t,x=a-u,y=b-v,z=c-w;x>=y?y>=z?(h=1,i=0,j=0,k=1,l=1,m=0):x>=z?(h=1,i=0,j=0,k=1,l=0,m=1):(h=0,i=0,j=1,k=1,l=0,m=1):z>y?(h=0,i=0,j=1,k=0,l=1,m=1):z>x?(h=0,i=1,j=0,k=0,l=1,m=1):(h=0,i=1,j=0,k=1,l=1,m=0);var A=x-h+s,B=y-i+s,C=z-j+s,D=x-k+2*s,E=y-l+2*s,F=z-m+2*s,G=x-1+3*s,H=y-1+3*s,I=z-1+3*s,J=255&p,K=255&q,L=255&r,M=this.perm[J+this.perm[K+this.perm[L]]]%12,N=this.perm[J+h+this.perm[K+i+this.perm[L+j]]]%12,O=this.perm[J+k+this.perm[K+l+this.perm[L+m]]]%12,P=this.perm[J+1+this.perm[K+1+this.perm[L+1]]]%12,Q=.6-x*x-y*y-z*z;0>Q?d=0:(Q*=Q,d=Q*Q*this.dot(this.grad3[M],x,y,z));var R=.6-A*A-B*B-C*C;0>R?e=0:(R*=R,e=R*R*this.dot(this.grad3[N],A,B,C));var S=.6-D*D-E*E-F*F;0>S?f=0:(S*=S,f=S*S*this.dot(this.grad3[O],D,E,F));var T=.6-G*G-H*H-I*I;return 0>T?g=0:(T*=T,g=T*T*this.dot(this.grad3[P],G,H,I)),32*(d+e+f+g)}}}({random:function(){return.1}});c._idCount=0,c.prototype.name="BorderPalette",c.prototype.addBorder=function(a){var b,c,d={min:"number",max:"number",style:"string"};if(x.checkRequiredParams(a,d))for(c=y.getRandomNumber(a.min,a.max),b=0;c>b;b++)this._borders.push(a.style);return this},c.prototype.getBorder=function(){if(this._borders.length>0)return this._borders[y.getRandomNumber(0,this._borders.length-1)];throw new Error("BorderPalette.getBorder: You must add borders via addBorder() before using getBorder().")},d._idCount=0,d.prototype.name="ColorPalette",d.prototype.addColor=function(a){var b,c,e,f={min:"number",max:"number",startColor:"array",endColor:"array"};if(x.checkRequiredParams(a,f))for(c=y.getRandomNumber(a.min,a.max),e=d._createColorRange(a.startColor,a.endColor,255),b=0;c>b;b++)this._colors.push(e[y.getRandomNumber(0,e.length-1)]);return this},d.prototype.createGradient=function(a){var b={startColor:"array",endColor:"array"};if(x.checkRequiredParams(a,b)){if(this.startColor=a.startColor,this.endColor=a.endColor,this.totalColors=a.totalColors||255,!(this.totalColors>0))throw new Error("ColorPalette: total colors must be greater than zero.");this._gradients.push(d._createColorRange(this.startColor,this.endColor,this.totalColors))}},d.prototype.getColor=function(){if(this._colors.length>0)return this._colors[y.getRandomNumber(0,this._colors.length-1)];throw new Error("ColorPalette.getColor: You must add colors via addColor() before using getColor().")},d.prototype.createSampleStrip=function(a){var b,c,d;for(b=0,c=this._colors.length;c>b;b++)d=document.createElement("div"),d.className="color-sample-strip",d.style.background="rgb("+this._colors[b].toString()+")",a.appendChild(d)},d._createColorRange=function(a,b,c){var d,e,f,g,h,i,j,k=[],l=a[0],m=a[1],n=a[2],o=b[0],p=b[1],q=b[2];for(e=o-l,f=p-m,g=q-n,d=0;c>d;d++)h=parseInt(e*d/c,10)+l,i=parseInt(f*d/c,10)+m,j=parseInt(g*d/c,10)+n,k.push([h,i,j]);return k},e.prototype.addColor=function(a){var b={name:"string",startColor:"array",endColor:"array"};return x.checkRequiredParams(a,b)&&(this[a.name]={startColor:a.startColor,endColor:a.endColor}),this},e.prototype.name="ColorTable",e.prototype.getColor=function(a,b,c){var d,e,f;if("string"!==x.getDataType(a))throw new Error("ColorTable: You must pass a name (string) for the color entry in the table.");if(!this[a])throw new Error("ColorTable: "+a+" does not exist. Add colors to the ColorTable via addColor().");return d=this[a],b&&(e=d.startColor),c&&(f=d.endColor),e&&f||!e&&!f?{startColor:d.startColor,endColor:d.endColor}:e?e:f?f:void 0},f.prototype.name="Caption",f.prototype.reset=function(){},f.prototype.init=function(){},f.prototype.destroy=function(){var a=this.el.id;return this.el.parentNode.removeChild(this.el),document.getElementById(a)?void 0:!0},g.prototype.name="InputMenu",g.prototype.reset=function(){},g.prototype.init=function(){},g.prototype.destroy=function(){var a=this.el.id;return this.el.parentNode.removeChild(this.el),document.getElementById(a)?void 0:!0},y.extend(h,Burner.Item),h.prototype.init=function(a){this.width="undefined"==typeof a.width?20:a.width,this.height="undefined"==typeof a.height?20:a.height,this.color=a.color||[255,255,255],this.motorSpeed=a.motorSpeed||0,this.angle=a.angle||0,this.pointToDirection="undefined"==typeof a.pointToDirection?!0:a.pointToDirection,this.draggable=!!a.draggable,this.parent=a.parent||null,this.pointToParentDirection=!!a.pointToParentDirection,this.offsetDistance="undefined"==typeof a.offsetDistance?30:a.offsetDistance,this.offsetAngle=a.offsetAngle||0,this.beforeStep=a.beforeStep||null,this.afterStep=a.afterStep||null,this.isMouseOut=!1,this.isPressed=!1;var b=function(a){return function(b){a.mouseover(b,a)}}(this),c=function(a){return function(b){a.mousedown(b,a)}}(this),d=function(a){return function(b){a.mousemove(b,a)}}(this),e=function(a){return function(b){a.mouseup(b,a)}}(this),f=function(a){return function(b){a.mouseout(b,a)}}(this);this.draggable&&(y.addEvent(this.el,"mouseover",b),y.addEvent(this.el,"mousedown",c),y.addEvent(this.el,"mousemove",d),y.addEvent(this.el,"mouseup",e),y.addEvent(this.el,"mouseout",f))},h.prototype.mouseover=function(){this.isMouseOut=!1,clearInterval(this.mouseOutInterval)},h.prototype.mousedown=function(a){var b,c=a.target||a.srcElement;a.changedTouches&&(b=a.changedTouches[0]),a.pageX&&a.pageY?(this.offsetX=a.pageX-c.offsetLeft,this.offsetY=a.pageY-c.offsetTop):a.clientX&&a.clientY?(this.offsetX=a.clientX-c.offsetLeft,this.offsetY=a.clientY-c.offsetTop):b&&(this.offsetX=b.pageX-c.offsetLeft,this.offsetY=b.pageY-c.offsetTop),this.isPressed=!0,this.isMouseOut=!1},h.prototype.mousemove=function(a){var b,c,d;this.isPressed&&(this.isMouseOut=!1,a.changedTouches&&(d=a.changedTouches[0]),a.pageX&&a.pageY?(b=a.pageX-this.world.el.offsetLeft,c=a.pageY-this.world.el.offsetTop):a.clientX&&a.clientY?(b=a.clientX-this.world.el.offsetLeft,c=a.clientY-this.world.el.offsetTop):d&&(b=d.pageX-this.world.el.offsetLeft,c=d.pageY-this.world.el.offsetTop),y.mouseIsInsideWorld(this.world)?this.location=new Burner.Vector(b,c):this.isPressed=!1)},h.prototype.mouseup=function(){this.isPressed=!1},h.prototype.mouseout=function(a,b){var c,d,e=b,f=Burner.System.mouse;b.isPressed&&(b.isMouseOut=!0,b.mouseOutInterval=setInterval(function(){e.isPressed&&e.isMouseOut&&(c=f.location.x-e.world.el.offsetLeft,d=f.location.y-e.world.el.offsetTop,e.location=new Burner.Vector(c,d))},16))},h.prototype.step=function(){var a,b,c,d,e;this.beforeStep&&this.beforeStep.apply(this),this.isStatic||this.isPressed||(this.world.c&&(a=y.clone(this.velocity),a.mult(-1),a.normalize(),a.mult(this.world.c),this.applyForce(a)),this.applyForce(this.world.gravity),this.applyForces&&this.applyForces(),this.velocity.add(this.acceleration),this.velocity.limit(this.maxSpeed,this.minSpeed),this.location.add(this.velocity),this.pointToDirection&&this.velocity.mag()>.1&&(this.angle=y.radiansToDegrees(Math.atan2(this.velocity.y,this.velocity.x)))),this.controlCamera&&this._checkCameraEdges(),this.checkWorldEdges&&this._checkWorldEdges(),this.parent&&(this.offsetDistance?(b=this.offsetDistance,c=y.degreesToRadians(this.parent.angle+this.offsetAngle),d=b*Math.cos(c),e=b*Math.sin(c),this.location.x=this.parent.location.x,this.location.y=this.parent.location.y,this.location.add(new Burner.Vector(d,e)),this.pointToParentDirection&&(this.angle=y.radiansToDegrees(Math.atan2(this.parent.velocity.y,this.parent.velocity.x)))):this.location=this.parent.location),this.acceleration.mult(0),this.life<this.lifespan?this.life+=1:-1!==this.lifespan&&Burner.System.destroyItem(this),this.afterStep&&this.afterStep.apply(this)},h.prototype._seek=function(a){var b=this.world,c=Burner.Vector.VectorSub(a.location,this.location),d=c.mag();if(c.normalize(),d<b.bounds[1]/2){var e=y.map(d,0,b.bounds[1]/2,0,this.maxSpeed);c.mult(e)}else c.mult(this.maxSpeed);return c.sub(this.velocity),c.limit(this.maxSteeringForce),c},h.prototype._checkAvoidEdges=function(){var a,b;this.location.x<this.avoidWorldEdgesStrength?a=this.maxSpeed:this.location.x>this.world.bounds[1]-this.avoidWorldEdgesStrength&&(a=-this.maxSpeed),a&&(b=new Burner.Vector(a,this.velocity.y),b.sub(this.velocity),b.limit(this.maxSteeringForce),this.applyForce(b)),this.location.y<this.avoidWorldEdgesStrength?a=this.maxSpeed:this.location.y>this.world.bounds[2]-this.avoidWorldEdgesStrength&&(a=-this.maxSpeed),a&&(b=new Burner.Vector(this.velocity.x,a),b.sub(this.velocity),b.limit(this.maxSteeringForce),this.applyForce(b))},h.prototype.drag=function(a){var b=this.velocity.mag(),c=-1*a.c*b*b,d=y.clone(this.velocity);return d.normalize(),d.mult(c),d},h.prototype.attract=function(a){var b,c,d=Burner.Vector.VectorSub(a.location,this.location);return b=d.mag(),b=y.constrain(b,this.width*this.height,a.width*a.height),d.normalize(),c=a.G*a.mass*this.mass/(b*b),d.mult(c),d},h.prototype.isInside=function(a){return a&&this.location.x+this.width/2>a.location.x-a.width/2&&this.location.x-this.width/2<a.location.x+a.width/2&&this.location.y+this.height/2>a.location.y-a.height/2&&this.location.y-this.height/2<a.location.y+a.height/2?!0:!1},y.extend(i,h),i.prototype.init=function(a){var b=a||{};i._superClass.prototype.init.call(this,b),this.followMouse=!!b.followMouse,this.maxSteeringForce="undefined"==typeof b.maxSteeringForce?10:b.maxSteeringForce,this.seekTarget=b.seekTarget||null,this.flocking=!!b.flocking,this.desiredSeparation="undefined"==typeof b.desiredSeparation?2*this.width:b.desiredSeparation,this.separateStrength="undefined"==typeof b.separateStrength?.3:b.separateStrength,this.alignStrength="undefined"==typeof b.alignStrength?.2:b.alignStrength,this.cohesionStrength="undefined"==typeof b.cohesionStrength?.1:b.cohesionStrength,this.flowField=b.flowField||null,this.sensors=b.sensors||[],this.color=b.color||[197,177,115],this.borderWidth=b.borderWidth||0,this.borderStyle=b.borderStyle||"none",this.borderColor=b.borderColor||"transparent",this.borderRadius=b.borderRadius||this.sensors.length?100:0,this.separateSumForceVector=new Burner.Vector,this.alignSumForceVector=new Burner.Vector,this.cohesionSumForceVector=new Burner.Vector,this.followTargetVector=new Burner.Vector,this.followDesiredVelocity=new Burner.Vector},i.prototype.applyForces=function(){var a,b,c,d,e,f,g,h,i,j=Burner.System._caches.Liquid,k=Burner.System._caches.Attractor,l=Burner.System._caches.Repeller;if(Burner.System._caches.Heat,j&&j.list.length>0)for(a=0,b=j.list.length;b>a;a+=1)this.id!==j.list[a].id&&y.isInside(this,j.list[a])&&this.applyForce(this.drag(j.list[a]));if(k&&k.list.length>0)for(a=0,b=k.list.length;b>a;a+=1)this.id!==k.list[a].id&&this.applyForce(this.attract(k.list[a]));if(l&&l.list.length>0)for(a=0,b=l.list.length;b>a;a+=1)this.id!==l.list[a].id&&this.applyForce(this.attract(l.list[a]));if(this.sensors.length>0)for(a=0,b=this.sensors.length;b>a;a+=1)e=this.sensors[a],f=e.offsetDistance,g=y.degreesToRadians(this.angle+e.offsetAngle),h=f*Math.cos(g),i=f*Math.sin(g),e.location.x=this.location.x,e.location.y=this.location.y,e.location.add(new Burner.Vector(h,i)),a&&(e.borderStyle="none"),e.activated&&(this.applyForce(e.getActivationForce(this)),c=!0);if(!c&&this.motorSpeed&&(d=y.clone(this.velocity),d.normalize(),this.velocity.mag()>this.motorSpeed?d.mult(-this.motorSpeed):d.mult(this.motorSpeed),this.applyForce(d)),this.followMouse&&!Burner.System.supportedFeatures.touch){var m={location:new Burner.Vector(Burner.System.mouse.location.x,Burner.System.mouse.location.y)};this.applyForce(this._seek(m))}if(this.seekTarget&&this.applyForce(this._seek(this.seekTarget)),this.flowField){var n,o,p=this.flowField.resolution,q=Math.floor(this.location.x/p),r=Math.floor(this.location.y/p);this.flowField.field[q]&&(n=this.flowField.field[q][r],n?(this.followTargetVector.x=n.x,this.followTargetVector.y=n.y):(this.followTargetVector.x=this.location.x,this.followTargetVector.y=this.location.y),o={location:this.followTargetVector},this.applyForce(this.follow(o)))}return this.flocking&&this.flock(Burner.System.getAllItemsByName("Agent")),this.acceleration},i.prototype.follow=function(a){return this.followDesiredVelocity.x=a.location.x,this.followDesiredVelocity.y=a.location.y,this.followDesiredVelocity.mult(this.maxSpeed),this.followDesiredVelocity.sub(this.velocity),this.followDesiredVelocity.limit(this.maxSteeringForce),this.followDesiredVelocity},i.prototype.flock=function(a){return this.applyForce(this.separate(a).mult(this.separateStrength)),this.applyForce(this.align(a).mult(this.alignStrength)),this.applyForce(this.cohesion(a).mult(this.cohesionStrength)),this.acceleration},i.prototype.separate=function(a){var b,c,d,e,f,g,h=0;for(this.separateSumForceVector.x=0,this.separateSumForceVector.y=0,g=this.separateSumForceVector,b=0,c=a.length;c>b;b+=1)d=a[b],this.className===d.className&&this.id!==d.id&&(f=this.location.distance(d.location),f>0&&f<this.desiredSeparation&&(e=Burner.Vector.VectorSub(this.location,d.location),e.normalize(),e.div(f),g.add(e),h+=1));return h>0?(g.div(h),g.normalize(),g.mult(this.maxSpeed),g.sub(this.velocity),g.limit(this.maxSteeringForce),g):new Burner.Vector},i.prototype.align=function(a){var b,c,d,e,f,g=2*this.width,h=0;for(this.alignSumForceVector.x=0,this.alignSumForceVector.y=0,f=this.alignSumForceVector,b=0,c=a.length;c>b;b+=1)d=a[b],e=this.location.distance(d.location),e>0&&g>e&&this.className===d.className&&this.id!==d.id&&(f.add(d.velocity),h+=1);return h>0?(f.div(h),f.normalize(),f.mult(this.maxSpeed),f.sub(this.velocity),f.limit(this.maxSteeringForce),f):new Burner.Vector},i.prototype.cohesion=function(a){var b,c,d,e,f,g=10,h=0;for(this.cohesionSumForceVector.x=0,this.cohesionSumForceVector.y=0,f=this.cohesionSumForceVector,b=0,c=a.length;c>b;b+=1)d=a[b],e=this.location.distance(d.location),e>0&&g>e&&this.className===d.className&&this.id!==d.id&&(f.add(d.location),h+=1);return h>0?(f.div(h),f.sub(this.location),f.normalize(),f.mult(this.maxSpeed),f.sub(this.velocity),f.limit(this.maxSteeringForce),f):new Burner.Vector},i.prototype.getLocation=function(a){return a?"x"===a?this.location.x:"y"===a?this.location.y:void 0:new Burner.Vector(this.location.x,this.location.y)},i.prototype.getVelocity=function(a){return a?"x"===a?this.velocity.x:"y"===a?this.velocity.y:void 0:new Burner.Vector(this.location.x,this.location.y)},y.extend(j,h),j.prototype.init=function(a){var b=a||{};this.width="undefined"==typeof b.width?10:b.width,this.height="undefined"==typeof b.height?10:b.height,this.perlin="undefined"==typeof b.perlin?!0:b.perlin,this.remainsOnScreen=!!b.remainsOnScreen,this.perlinSpeed="undefined"==typeof b.perlinSpeed?.005:b.perlinSpeed,this.perlinTime=b.perlinTime||0,this.perlinAccelLow="undefined"==typeof b.perlinAccelLow?-.075:b.perlinAccelLow,this.perlinAccelHigh="undefined"==typeof b.perlinAccelHigh?.075:b.perlinAccelHigh,this.offsetX="undefined"==typeof b.offsetX?1e4*Math.random():b.offsetX,this.offsetY="undefined"==typeof b.offsetY?1e4*Math.random():b.offsetY,this.random=!!b.random,this.randomRadius="undefined"==typeof b.randomRadius?100:b.randomRadius,this.color=b.color||[255,150,50],this.borderWidth="undefined"==typeof b.borderWidth?2:b.borderWidth,this.borderStyle=b.borderStyle||"solid",this.borderColor=b.borderColor||[255,255,255],this.borderRadius="undefined"==typeof b.borderRadius?100:b.borderRadius,this.avoidWorldEdges=!!b.avoidWorldEdges,this.avoidWorldEdgesStrength="undefined"==typeof b.avoidWorldEdgesStrength?50:b.avoidWorldEdgesStrength},j.prototype.applyForces=function(){this.perlin?(this.perlinTime+=this.perlinSpeed,this.remainsOnScreen?(this.acceleration=new Burner.Vector,this.velocity=new Burner.Vector,this.location.x=y.map(z.noise(this.perlinTime+this.offsetX,0,.1),-1,1,0,this.world.bounds[1]),this.location.y=y.map(z.noise(0,this.perlinTime+this.offsetY,.1),-1,1,0,this.world.bounds[2])):(this.acceleration.x=y.map(z.noise(this.perlinTime+this.offsetX,0,.1),-1,1,this.perlinAccelLow,this.perlinAccelHigh),this.acceleration.y=y.map(z.noise(0,this.perlinTime+this.offsetY,.1),-1,1,this.perlinAccelLow,this.perlinAccelHigh))):this.random&&(this.seekTarget={location:Burner.Vector.VectorAdd(this.location,new Burner.Vector(y.getRandomNumber(-this.randomRadius,this.randomRadius),y.getRandomNumber(-this.randomRadius,this.randomRadius)))},this.applyForce(this._seek(this.seekTarget))),this.avoidWorldEdges&&this._checkAvoidEdges()},y.extend(k,h),k.prototype.init=function(a){var b=a||{};k._superClass.prototype.init.call(this,b),this.type=b.type||"",this.behavior=b.behavior||"LOVE",this.sensitivity="undefined"==typeof b.sensitivity?2:b.sensitivity,this.width="undefined"==typeof b.width?7:b.width,this.height="undefined"==typeof b.height?7:b.height,this.offsetDistance="undefined"==typeof b.offsetDistance?30:b.offsetDistance,this.offsetAngle=b.offsetAngle||0,this.opacity="undefined"==typeof b.opacity?.75:b.opacity,this.target=b.target||null,this.activated=!!b.activated,this.activatedColor=b.activatedColor||[255,255,255],this.borderRadius="undefined"==typeof b.borderRadius?100:b.borderRadius,this.borderWidth="undefined"==typeof b.borderWidth?2:b.borderWidth,this.borderStyle="solid",this.borderColor=[255,255,255]},k.prototype.step=function(){var a,b,c=!1,d=Burner.System._caches.Heat||{list:[]},e=Burner.System._caches.Cold||{list:[]},f=Burner.System._caches.Predators||{list:[]},g=Burner.System._caches.Light||{list:[]},h=Burner.System._caches.Oxygen||{list:[]},i=Burner.System._caches.Food||{list:[]};if("heat"===this.type&&d.list&&d.list.length>0)for(a=0,b=d.list.length;b>a;a++)this.isInside(this,d.list[a],this.sensitivity)&&(this.target=d.list[a],this.activated=!0,c=!0);else if("cold"===this.type&&e.list&&e.list.length>0)for(a=0,b=e.list.length;b>a;a++)this.isInside(this,e.list[a],this.sensitivity)&&(this.target=e.list[a],this.activated=!0,c=!0);else if("predator"===this.type&&f.list&&f.list.length>0)for(a=0,b=f.list.length;b>a;a+=1)this.isInside(this,f.list[a],this.sensitivity)&&(this.target=f.list[a],this.activated=!0,c=!0);else if("light"===this.type&&g.list&&g.list.length>0)for(a=0,b=g.list.length;b>a;a++)g.lookup[g.list[a].id]&&this.isInside(this,g.list[a],this.sensitivity)&&(this.target=g.list[a],this.activated=!0,c=!0);else if("oxygen"===this.type&&h.list&&h.list.length>0)for(a=0,b=h.list.length;b>a;a+=1)h.lookup[h.list[a].id]&&this.isInside(this,h.list[a],this.sensitivity)&&(this.target=h.list[a],this.activated=!0,c=!0);else if("food"===this.type&&i.list&&i.list.length>0)for(a=0,b=i.list.length;b>a;a+=1)i.lookup[i.list[a].id]&&this.isInside(this,i.list[a],this.sensitivity)&&(this.target=i.list[a],this.activated=!0,c=!0);c?this.color=this.activatedColor:(this.target=null,this.activated=!1,this.color="transparent"),this.afterStep&&this.afterStep.apply(this)},k.prototype.getActivationForce=function(a){var b,c,d,e,f;switch(this.behavior){case"AGGRESSIVE":return c=Burner.Vector.VectorSub(this.target.location,this.location),b=c.mag(),c.normalize(),d=b/a.maxSpeed,c.mult(d),c.sub(a.velocity),c.limit(a.maxSteeringForce),c;case"COWARD":return c=Burner.Vector.VectorSub(this.target.location,this.location),b=c.mag(),c.normalize(),d=b/a.maxSpeed,c.mult(-d),c.sub(a.velocity),c.limit(a.maxSteeringForce),c;case"LIKES":var g=Burner.Vector.VectorSub(this.target.location,this.location);return b=g.mag(),g.normalize(),d=b/a.maxSpeed,g.mult(d),f=Burner.Vector.VectorSub(g,a.velocity),f.limit(a.maxSteeringForce),f;case"LOVES":var h=Burner.Vector.VectorSub(this.target.location,this.location);return b=h.mag(),h.normalize(),b>this.width?(d=b/a.maxSpeed,h.mult(d),f=Burner.Vector.VectorSub(h,a.velocity),f.limit(a.maxSteeringForce),f):(a.velocity=new Burner.Vector,a.acceleration=new Burner.Vector,new Burner.Vector);case"EXPLORER":var i=Burner.Vector.VectorSub(this.target.location,this.location);return b=i.mag(),i.normalize(),d=b/a.maxSpeed,i.mult(-d),f=Burner.Vector.VectorSub(i,a.velocity),f.limit(.05*a.maxSteeringForce),f;case"ACCELERATE":return e=a.velocity.clone(),e.normalize(),e.mult(a.minSpeed);case"DECELERATE":return e=a.velocity.clone(),e.normalize(),e.mult(-a.minSpeed);default:return new Burner.Vector}},k.prototype.isInside=function(a,b,c){return a.location.x+a.width/2>b.location.x-b.width/2-c*b.width&&a.location.x-a.width/2<b.location.x+b.width/2+c*b.width&&a.location.y+a.height/2>b.location.y-b.height/2-c*b.height&&a.location.y-a.height/2<b.location.y+b.height/2+c*b.height?!0:!1},y.extend(l,Burner.Item),l.prototype.init=function(a){if(!a||!a.parentA||!a.parentB)throw new Error("Connector: both parentA and parentB are required.");this.parentA=a.parentA,this.parentB=a.parentB,this.opacity="undefined"==typeof a.opacity?1:a.opacity,this.zIndex=a.zIndex||0,this.borderWidth=1,this.borderRadius=0,this.borderStyle="dotted",this.borderColor="undefined"==typeof a.borderColor?[150,150,150]:a.borderColor,this.width=0,this.height=0,this.color="transparent"},l.prototype.step=function(){var a=this.parentA.location,b=this.parentB.location;this.width=Math.floor(Burner.Vector.VectorSub(this.parentA.location,this.parentB.location).mag()),this.location=Burner.Vector.VectorAdd(this.parentA.location,this.parentB.location).div(2),this.angle=y.radiansToDegrees(Math.atan2(b.y-a.y,b.x-a.x))},y.extend(m,h),m.prototype.init=function(a){var b=a||{};this.width="undefined"==typeof b.width?10:b.width,this.height="undefined"==typeof b.height?10:b.height,this.opacity="undefined"==typeof b.opacity?1:b.opacity,this.isStatic=b.isStatic===!1?!1:b.isStatic||!0,this.zIndex="undefined"==typeof b.zIndex?1:b.zIndex,this.color=b.color||[200,200,200],this.borderRadius="undefined"==typeof b.borderRadius?100:b.borderRadius,this.borderWidth="undefined"==typeof b.borderWidth?2:b.borderWidth,this.borderStyle=b.borderStyle||"solid",this.borderColor=b.borderColor||[60,60,60]
},y.extend(n,i),n.prototype.init=function(a){var b=a||{};n._superClass.prototype.init.call(this,b),this.width="undefined"==typeof b.width?20:b.width,this.height="undefined"==typeof b.height?20:b.height,this.lifespan="undefined"==typeof b.lifespan?50:b.lifespan,this.life=b.life||0,this.fade="undefined"==typeof b.fade?!0:!1,this.shrink="undefined"==typeof b.shrink?!0:!1,this.checkWorldEdges=!!b.checkWorldEdges,this.maxSpeed="undefined"==typeof b.maxSpeed?4:0,this.zIndex="undefined"==typeof b.zIndex?1:0,this.color=b.color||[200,200,200],this.borderWidth="undefined"==typeof b.borderWidth?this.width/4:0,this.borderStyle=b.borderStyle||"none",this.borderColor=b.borderColor||"transparent",this.borderRadius="undefined"==typeof b.borderRadius?100:0,this.boxShadowSpread="undefined"==typeof b.boxShadowSpread?this.width/4:0,this.boxShadowColor=b.boxShadowColor||"transparent",b.acceleration||(this.acceleration=new Burner.Vector(1,1),this.acceleration.normalize(),this.acceleration.mult(this.maxSpeed?this.maxSpeed:3),this.acceleration.rotate(y.getRandomNumber(0,2*Math.PI,!0))),b.velocity||(this.velocity=new Burner.Vector),this.initWidth=this.width,this.initHeight=this.height},n.prototype.step=function(){var a;this.world.c&&(a=y.clone(this.velocity),a.mult(-1),a.normalize(),a.mult(this.world.c),this.applyForce(a)),this.applyForce(this.world.gravity),this.applyForces&&this.applyForces(),this.checkEdges&&this._checkWorldEdges(),this.velocity.add(this.acceleration),this.maxSpeed&&this.velocity.limit(this.maxSpeed),this.minSpeed&&this.velocity.limit(null,this.minSpeed),this.location.add(this.velocity),this.fade&&(this.opacity=y.map(this.life,0,this.lifespan,1,0)),this.shrink&&(this.width=y.map(this.life,0,this.lifespan,this.initWidth,0),this.height=y.map(this.life,0,this.lifespan,this.initHeight,0)),this.acceleration.mult(0),this.life<this.lifespan?this.life+=1:-1!==this.lifespan&&Burner.System.destroyItem(this)},y.extend(o,i),o.prototype.init=function(a){var b=a||{};o._superClass.prototype.init.call(this,b),this.isStatic="undefined"==typeof b.isStatic?!0:b.isStatic,this.lifespan="undefined"==typeof b.lifespan?-1:b.lifespan,this.life=b.life||0,this.width=b.width||0,this.height=b.height||0,this.burst="undefined"==typeof b.burst?1:b.burst,this.burstRate="undefined"==typeof b.burstRate?4:b.burstRate,this.emitRadius="undefined"==typeof b.emitRadius?3:b.emitRadius,this.startColor=b.startColor||[100,20,20],this.endColor=b.endColor||[255,0,0],this.particleOptions=b.particleOptions||{width:15,height:15,lifespan:50,borderRadius:100,checkEdges:!1,acceleration:null,velocity:null,location:null,maxSpeed:3,fade:!0},this.borderWidth=b.borderWidth||0,this.borderStyle=b.borderStyle||"none",this.borderColor=b.borderColor||"transparent",this.borderRadius=b.borderRadius||0,this.clock=0,this.particleOptions.acceleration&&(this.initParticleAcceleration=new Burner.Vector(this.particleOptions.acceleration.x,this.particleOptions.acceleration.y));var c=new d;c.addColor({min:12,max:24,startColor:this.startColor,endColor:this.endColor}),this.beforeStep=function(){var a,b,d=this.initParticleAcceleration;if(this.life<this.lifespan)this.life+=1;else if(-1!==this.lifespan)return Burner.System.destroyItem(this),void 0;if(0===this.clock%this.burstRate){a=this.getLocation(),b=new Burner.Vector(1,1),b.normalize(),b.mult(this.emitRadius),b.rotate(y.getRandomNumber(0,2*Math.PI,!0)),a.add(b);for(var e=0;e<this.burst;e++)this.particleOptions.world=this.world,this.particleOptions.life=0,this.particleOptions.color=c.getColor(),this.particleOptions.borderStyle="solid",this.particleOptions.borderColor=c.getColor(),this.particleOptions.boxShadowColor=c.getColor(),d&&(this.particleOptions.acceleration=new Burner.Vector(d.x,d.y)),this.particleOptions.location=o.getParticleLocation(a),Burner.System.add("Particle",this.particleOptions)}this.clock++}},o.getParticleLocation=function(a){return function(){return new Burner.Vector(a.x,a.y)}()},y.extend(p,Burner.Item),p.prototype.init=function(a){var b=a||{};this.initialLocation=b.initialLocation||new Burner.Vector(this.world.bounds[1]/2,this.world.bounds[2]/2),this.lastLocation=new Burner.Vector,this.amplitude=b.amplitude||new Burner.Vector(this.world.bounds[1]/2-this.width,this.world.bounds[2]/2-this.height),this.acceleration=b.acceleration||new Burner.Vector(.01,0),this.aVelocity=b.aVelocity||new Burner.Vector,this.isStatic=!!b.isStatic,this.isPerlin=!!b.isPerlin,this.perlinSpeed="undefined"==typeof b.perlinSpeed?.005:b.perlinSpeed,this.perlinTime=b.perlinTime||0,this.perlinAccelLow="undefined"==typeof b.perlinAccelLow?-2:b.perlinAccelLow,this.perlinAccelHigh="undefined"==typeof b.perlinAccelHigh?2:b.perlinAccelHigh,this.perlinOffsetX="undefined"==typeof b.perlinOffsetX?1e4*Math.random():b.perlinOffsetX,this.perlinOffsetY="undefined"==typeof b.perlinOffsetY?1e4*Math.random():b.perlinOffsetY,this.width="undefined"==typeof b.width?20:b.width,this.height="undefined"==typeof b.height?20:b.height,this.color=b.color||[200,100,0],this.borderWidth=b.borderWidth||0,this.borderStyle=b.borderStyle||"solid",this.borderColor=b.borderColor||[255,150,50],this.borderRadius="undefined"==typeof b.borderRadius?100:b.borderRadius,this.boxShadowSpread=b.boxShadowSpread||0,this.boxShadowColor=b.boxShadowColor||[200,100,0]},p.prototype.step=function(){var a,b=this.world;this.beforeStep&&this.beforeStep.apply(this),this.isStatic||this.isPressed||(this.isPerlin?(this.perlinTime+=this.perlinSpeed,this.aVelocity.x=y.map(z.noise(this.perlinTime+this.perlinOffsetX,0,.1),-1,1,this.perlinAccelLow,this.perlinAccelHigh),this.aVelocity.y=y.map(z.noise(0,this.perlinTime+this.perlinOffsetY,.1),-1,1,this.perlinAccelLow,this.perlinAccelHigh)):this.aVelocity.add(this.acceleration),this.location.x=this.initialLocation.x+Math.sin(this.aVelocity.x)*this.amplitude.x,this.location.y=this.initialLocation.y+Math.sin(this.aVelocity.y)*this.amplitude.y,this.pointToDirection&&(a=Burner.Vector.VectorSub(this.location,this.lastLocation),this.angle=y.radiansToDegrees(Math.atan2(a.y,a.x))),this.controlCamera&&this._checkCameraEdges(),(this.checkWorldEdges||this.wrapWorldEdges)&&this._checkWorldEdges(b),this.lifespan>0&&(this.lifespan-=1),this.afterStep&&this.afterStep.apply(this),this.pointToDirection&&(this.lastLocation.x=this.location.x,this.lastLocation.y=this.location.y))},y.extend(q,i),q.prototype.init=function(a){var b=a||{};q._superClass.prototype.init.call(this,b),this.c="undefined"==typeof b.c?1:b.c,this.mass="undefined"==typeof b.mass?50:b.mass,this.isStatic="undefined"==typeof b.isStatic?!0:b.isStatic,this.width="undefined"==typeof b.width?100:b.width,this.height="undefined"==typeof b.height?100:b.height,this.opacity="undefined"==typeof b.opacity?.75:b.opacity,this.zIndex="undefined"==typeof b.zIndex?1:b.zIndex,this.color=b.color||[105,210,231],this.borderWidth="undefined"==typeof b.borderWidth?this.width/4:b.borderWidth,this.borderStyle=b.borderStyle||"double",this.borderColor=b.borderColor||[167,219,216],this.borderRadius="undefined"==typeof b.borderRadius?100:b.borderRadius,this.boxShadowSpread="undefined"==typeof b.boxShadowSpread?this.width/8:b.boxShadowSpread,this.boxShadowColor=b.boxShadowColor||[147,199,196],Burner.System.updateCache(this)},y.extend(r,i),r.prototype.init=function(a){var b=a||{};r._superClass.prototype.init.call(this,b),this.G="undefined"==typeof b.G?10:b.G,this.mass="undefined"==typeof b.mass?1e3:b.mass,this.isStatic="undefined"==typeof b.isStatic?!0:b.isStatic,this.width="undefined"==typeof b.width?100:b.width,this.height="undefined"==typeof b.height?100:b.height,this.opacity="undefined"==typeof b.opacity?.75:b.opacity,this.zIndex="undefined "==typeof b.zIndex?1:b.zIndex,this.color=b.color||[92,187,0],this.borderWidth="undefined"==typeof b.borderWidth?this.width/4:b.borderWidth,this.borderStyle=b.borderStyle||"double",this.borderColor=b.borderColor||[224,228,204],this.borderRadius="undefined"==typeof b.borderRadius?100:b.borderRadius,this.boxShadowSpread="undefined"==typeof b.boxShadowSpread?this.width/4:b.boxShadowSpread,this.boxShadowColor=b.boxShadowColor||[64,129,0],Burner.System.updateCache(this)},y.extend(s,i),s.prototype.init=function(a){var b=a||{};s._superClass.prototype.init.call(this,b),this.G="undefined"==typeof b.G?-10:b.G,this.mass="undefined"==typeof b.mass?1e3:b.mass,this.isStatic="undefined"==typeof b.isStatic?!0:b.isStatic,this.width="undefined"==typeof b.width?100:b.width,this.height="undefined"==typeof b.height?100:b.height,this.opacity="undefined"==typeof b.opacity?.75:b.opacity,this.zIndex="undefined"==typeof b.zIndex?10:b.zIndex,this.color=b.color||[250,105,0],this.borderWidth="undefined"==typeof b.borderWidth?this.width/4:b.borderWidth,this.borderStyle=b.borderStyle||"double",this.borderColor=b.borderColor||[224,228,204],this.borderRadius="undefined"==typeof b.borderRadius?100:b.borderRadius,this.boxShadowSpread="undefined"==typeof b.boxShadowSpread?this.width/4:b.boxShadowSpread,this.boxShadowColor=b.boxShadowColor||[250,105,0],Burner.System.updateCache(this)};var A,B,C,D,E,F,G={},H={},I={},J=["double","double","dotted","dashed"];for(A=0,B=w.defaultColorList.length;B>A;A++)D=w.defaultColorList[A],C=new d,C.addColor({min:20,max:200,startColor:D.startColor,endColor:D.endColor}),G[D.name]=C,H[D.name]=D.borderColor,I[D.name]=D.boxShadowColor;for(F=new c,A=0,B=J.length;B>A;A++)E=J[A],F.addBorder({min:2,max:10,style:E});y.extend(t,i),t.prototype.init=function(a){var b=a||{},c=this.name.toLowerCase();t._superClass.prototype.init.call(this,b),this.mass="undefined"==typeof b.mass?50:b.mass,this.isStatic="undefined"==typeof b.isStatic?!0:b.isStatic,this.width="undefined"==typeof b.width?50:b.width,this.height="undefined"==typeof b.height?50:b.height,this.opacity="undefined"==typeof b.opacity?.75:b.opacity,this.zIndex="undefined"==typeof b.zIndex?1:b.zIndex,this.color=b.color||G[c].getColor(),this.borderWidth="undefined"==typeof b.borderWidth?this.width/y.getRandomNumber(2,8):b.borderWidth,this.borderStyle="undefined"==typeof b.borderStyle?F.getBorder():b.borderStyle,this.borderColor="undefined"==typeof b.borderColor?G[c].getColor():b.borderColor,this.borderRadius="undefined"==typeof b.borderRadius?100:b.borderRadius,this.boxShadowSpread="undefined"==typeof b.boxShadowSpread?this.width/y.getRandomNumber(2,8):b.boxShadowSpread,this.boxShadowColor="undefined"==typeof b.boxShadowColor?I[c]:b.boxShadowColor,Burner.System.updateCache(this)},y.extend(u,Burner.Item),u.prototype.init=function(a){var b=a||{};this.resolution="undefined"==typeof b.resolution?50:b.resolution,this.perlinSpeed="undefined"==typeof b.perlinSpeed?.01:b.perlinSpeed,this.perlinTime="undefined"==typeof b.perlinTime?100:b.perlinTime,this.field=b.field||null,this.createMarkers=!!b.createMarkers,this.world=b.world||Burner.System.firstWorld()},u.prototype.build=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m={},n=this.world,o=Math.ceil(n.bounds[1]/parseFloat(this.resolution)),p=Math.ceil(n.bounds[2]/parseFloat(this.resolution)),q=this.perlinTime;for(a=0,b=o;b>a;a+=1){for(l=this.perlinTime,m[a]={},c=0,d=p;d>c;c+=1){if(e=a*this.resolution+this.resolution/2,f=c*this.resolution+this.resolution/2,g=y.map(z.noise(q,l,.1),0,1,0,2*Math.PI),h=Math.cos(g),i=Math.sin(g),j=new Burner.Vector(h,i),m[a][c]=j,k=y.radiansToDegrees(Math.atan2(i,h)),this.createMarkers){var r=new v({location:new Burner.Vector(e,f),scale:1,opacity:y.map(k,-360,360,.1,.75),width:this.resolution,height:this.resolution/2,field:j,angle:k,colorMode:"rgb",color:[200,100,50],borderRadius:0,zIndex:0});n.el.appendChild(r)}l+=parseFloat(this.perlinSpeed)}q+=parseFloat(this.perlinSpeed)}this.field=m},v.prototype.name="FlowFieldMarker",a.Config=w,a.Interface=x,a.Utils=y,a.SimplexNoise=z,a.BorderPalette=c,a.ColorPalette=d,a.ColorTable=e,a.Caption=f,a.InputMenu=g,a.Mover=h,a.Agent=i,a.Walker=j,a.Sensor=k,a.Connector=l,a.Point=m,a.Particle=n,a.ParticleSystem=o,a.Oscillator=p,a.Liquid=q,a.Attractor=r,a.Repeller=s,a.i=A,a.max=B,a.pal=C,a.color=D,a.palettes=G,a.border=E,a.borderPalette=F,a.borderColors=H,a.boxShadowColors=I,a.borderStyles=J,a.Stimulus=t,a.FlowField=u,a.FlowFieldMarker=v}({},function(){return this}());
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>FloraJS | Multiple agents: followMouse and seekTarget</title>
<link rel="stylesheet" href="Burner.min.css" type="text/css" charset="utf-8" />
<link rel="stylesheet" href="Flora.min.css" type="text/css" charset="utf-8" />
<script src="Burner.min.js" type="text/javascript" charset="utf-8"></script>
<script src="Flora.min.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<script type="text/javascript" charset="utf-8">
/**
* We'll create two groups of agents,
* GroupA will follow the mouse while
* GroupB will follow a Walker.
*/
var totalAgentsGroupA = 10,
totalAgentsGroupB = 5;
var world = new Burner.World(document.body, {
gravity: new Burner.Vector(),
c: 0
});
Burner.System.init(function() {
for (var i = 0; i < totalAgentsGroupA; i++) {
this.add('Agent', {
followMouse: true,
flocking: true
});
}
var walker = this.add('Walker');
for (var i = 0; i < totalAgentsGroupB; i++) {
this.add('Agent', {
flocking: true,
color: [255, 241, 198],
seekTarget: walker
});
}
this.add('Caption', {
text: 'Multiple agents: followMouse and seekTarget',
opacity: 0.4,
borderColor: 'transparent',
position: 'top center'
});
this.add('InputMenu', {
opacity: 0.4,
borderColor: 'transparent',
position: 'bottom center'
});
}, world);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment