raven-create
Version:
Creative coding framework
2 lines • 63 kB
JavaScript
"use strict";window.Raven={canvasSupport:!1,isMobile:null!==navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/),include:function(src){var base="../../src/";document.write('<script type="text/javascript" src="'+base+src+'"></script>')},instance:function(baseClass){var instance=new baseClass;return instance.proto=Object.create(baseClass.prototype),instance},element:function(domID){return document.getElementById(domID)},getFrame:function(startMS){var appFPS=60;return Math.round((Date.now()-startMS)/appFPS)}},Function.prototype.extends=function(parent,newClass){this.prototype=Object.create(parent.prototype),this.prototype=new parent,void 0!==newClass&&(this.prototype.constructor=newClass)},function(){for(var lastTime=0,vendors=["ms","moz","webkit","o"],x=0;x<vendors.length&&!window.requestAnimationFrame;++x)window.requestAnimationFrame=window[vendors[x]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[vendors[x]+"CancelAnimationFrame"]||window[vendors[x]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(callback){var currTime=(new Date).getTime(),timeToCall=Math.max(0,16-(currTime-lastTime)),id=window.setTimeout(function(){callback(currTime+timeToCall)},timeToCall);return lastTime=currTime+timeToCall,id}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(id){clearTimeout(id)})}(),function(){var _gl,world=document.createElement("canvas");try{_gl=world.getContext("webgl")}catch(x){_gl=null}if(null==_gl)try{_gl=world.getContext("experimental-webgl"),experimental=!0}catch(x){_gl=null}Raven.canvasSupport=null!==_gl}();var Raven=Raven||{};Raven.Vec=function(px,py,pz){return this.x=void 0!==px?px:0,this.y=void 0!==py?py:0,this.z=void 0!==pz?pz:0,this.set=function(vx,vy,vz){return void 0!==vx&&(this.x=vx),void 0!==vy&&(this.y=vy),void 0!==vz&&(this.z=vz),this},this.copy=function(){return new Raven.Vec(this.x,this.y,this.z)},this.round=function(){return new Raven.Vec(Math.round(this.x),Math.round(this.y),Math.round(this.z))},this.add=function(value){var v=this.copy();return isNaN(value)?(v.x+=value.x,v.y+=value.y,v.z+=value.z):(v.x+=value,v.y+=value,v.z+=value),v},this.divide=function(value){var v=this.copy();return isNaN(value)?(v.x/=value.x,v.y/=value.y,v.z/=value.z):(v.x/=value,v.y/=value,v.z/=value),v},this.multiply=function(value){var v=this.copy();return isNaN(value)?(v.x*=value.x,v.y*=value.y,v.z*=value.z):(v.x*=value,v.y*=value,v.z*=value),v},this.subtract=function(value){var v=this.copy();return isNaN(value)?(v.x-=value.x,v.y-=value.y,v.z-=value.z):(v.x-=value,v.y-=value,v.z-=value),v},this.equals=function(vec){return this.x==vec.x&&this.y==vec.y&&this.z==vec.z},this.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},this.normalize=function(length){var delimiter=void 0!==length?length:1,scale=delimiter/this.length();return this.x*=scale,this.y*=scale,this.z*=scale,this},this.leftNormal=function(){return new Raven.Vec(-this.y,this.x,0)},this.rightNormal=function(){return new Raven.Vec(this.y,-this.x,0)},this.dot=function(vec){return this.x*vec.x+this.y*vec.y+this.z*vec.z},this.difference=function(vec){return new Raven.Vec(this.x-vec.x,this.y-vec.y,this.z-vec.z)},this.distance=function(vec){return Raven.distance3D(this.x,this.y,this.z,vec.x,vec.y,vec.z)},this.angleRad=function(vec){return Raven.getAngleRad(this,vec)},this.angleDeg=function(vec){return Raven.getAngleDeg(this,vec)},this.lerp=function(value,min,max){return void 0!==min.x&&void 0!==max.x&&(this.x=Raven.lerp(value,min.x,max.x)),void 0!==min.y&&void 0!==max.y&&(this.y=Raven.lerp(value,min.y,max.y)),void 0!==min.z&&void 0!==max.z&&(this.z=Raven.lerp(value,min.z,max.z)),this},this},Raven.Vec.prototype.constructor=Raven.Vec,Raven.Vec.zero=function(){return new Raven.Vec(0,0,0)},Raven.Vec.one=function(){return new Raven.Vec(1,1,1)},Raven.Vec.random=function(px,py,pz){return new Raven.Vec(Math.random()*px,Math.random()*py,Math.random()*pz)},Raven.Vec.range=function(minV,maxV,value){return new Raven.Vec(Raven.range(minV.x,maxV.x,value),Raven.range(minV.y,maxV.y,value),Raven.range(minV.z,maxV.z,value))},Raven.Vec.randomRange=function(minX,minY,minZ,maxX,maxY,maxZ){return new Raven.Vec(Raven.randRange(minX,maxX),Raven.randRange(minY,maxY),Raven.randRange(minZ,maxZ))},Raven.Vec.lerp=function(value,min,max){return(new Raven.Vec).lerp(value,min,max)};var Raven=Raven||{};Raven.Rect=function(x,y,w,h){return this.x=x?x:0,this.y=y?y:0,this.width=w?w:0,this.height=h?h:0,this.left=function(){return this.x},this.top=function(){return this.y},this.right=function(){return this.x+this.width},this.bottom=function(){return this.y+this.height},this.hitTest=function(hx,hy){return Raven.inBounds(hx,hy,this.x,this.y,this.right(),this.bottom())},this.clone=function(){return new Raven.Rect(this.x,this.y,this.width,this.height)},this.overlap=function(rect){var l=rect.left(),t=rect.top(),r=rect.right(),b=rect.bottom(),resultX=Raven.between(this.x,this.right(),l)||Raven.between(this.x,this.right(),r),resultY=Raven.between(this.y,this.bottom(),t)||Raven.between(this.y,this.bottom(),b);return resultX&&resultY},this.mapToDiv=function(div){return this.x=div.offsetLeft,this.y=div.offsetTop,this.width=div.offsetWidth,this.height=div.offsetHeight,this},this.set=function(x,y,w,h){void 0!==x&&(this.x=x),void 0!==y&&(this.y=y),void 0!==w&&(this.width=w),void 0!==h&&(this.height=h)},this},Raven.Rect.prototype.constructor=Raven.Rect;var Raven=Raven||{},Key={A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,CMD:91,CTRL:17,SHIFT:16,CAPS:20,TAB:9,ENTER:13,SPACE:32,DELETE:46,BACKQUOTE:192,MINUS:189,EQUAL:187,LEFTBRACKET:219,RIGHTBRACKET:221,BACKSLASH:220,SEMICOLON:186,QUOTE:222,COMMA:188,PERIOD:190,SLASH:191,LEFT:37,UP:38,RIGHT:39,DOWN:40,NUMBER_0:48,NUMBER_1:49,NUMBER_2:50,NUMBER_3:51,NUMBER_4:52,NUMBER_5:53,NUMBER_6:54,NUMBER_7:55,NUMBER_8:56,NUMBER_9:57,getKey:function(keyCode){for(var obj in this)if(this[obj]==keyCode)return obj;return null}},Raven=Raven||{};Raven.fix=function(value,hundredth){return Number(value.toFixed(hundredth))},Raven.roundTo=function(value,ordinal){return Math.round(ordinal*value)*(1/ordinal)},Raven.DEGREES=180/Math.PI,Raven.RADIANS=Math.PI/180,Raven.resolveAngle=function(angle){var mod=angle%360;return 0>mod?360+mod:mod},Raven.degToRad=function(degrees){return degrees*Raven.RADIANS},Raven.radToDeg=function(radians){return radians*Raven.DEGREES},Raven.getAngleRad=function(p1,p2){return Math.atan2(p2.y-p1.y,p2.x-p1.x)},Raven.getAngleDeg=function(p1,p2){return Raven.radToDeg(Raven.getAngleRad(p1,p2))},Raven.distance=function(n1,n2){var dist=n1-n2;return Math.sqrt(dist*dist)},Raven.distance2D=function(x1,y1,x2,y2){var xd=(x1-x2)*(x1-x2),yd=(y1-y2)*(y1-y2);return Math.sqrt(xd+yd)},Raven.distance3D=function(x1,y1,z1,x2,y2,z2){var xd=(x1-x2)*(x1-x2),yd=(y1-y2)*(y1-y2),zd=(z1-z2)*(z1-z2);return Math.sqrt(xd+yd+zd)},Raven.difference=function(n1,n2){return n1-n2},Raven.range=function(n1,n2,percent){var diff=n2-n1;return diff*=percent,diff+n1},Raven.randRange=function(min,max){return Raven.range(min,max,Math.random())},Raven.cosRange=function(degrees,range,min){return.5*(1+Math.cos(Raven.degToRad(degrees)))*range+min},Raven.sinRange=function(degrees,range,min){return.5*(1+Math.sin(Raven.degToRad(degrees)))*range+min},Raven.between=function(min,max,value){return value>=min&&max>=value},Raven.inBounds=function(x,y,xMin,yMin,xMax,yMax){return Raven.between(xMin,xMax,x)&&Raven.between(yMin,yMax,y)},Raven.betweenVec=function(min,max,value){var x=Raven.between(min.x,max.x,value.x),y=Raven.between(min.y,max.y,value.y),z=Raven.between(min.z,max.z,value.z);return x&&y&&z},Raven.bezierPosition=function(t,p0,c0,c1,p1){return p0*(1-t)*(1-t)*(1-t)+3*c0*t*(1-t)*(1-t)+3*c1*t*t*(1-t)+p1*t*t*t},Raven.bezierVelocity=function(t,p0,c0,c1,p1){return 3*c0-3*p0+2*(3*p0-6*c0+3*c1)*t+3*(-p0+3*c0-3*c1+p1)*t*t},Raven.lerp=function(value,min,max){return(max-min)*value+min},Raven.normalize=function(value,min,max){return(value-min)/(max-min)},Raven.map=function(value,min1,max1,min2,max2){return Raven.lerp(Raven.normalize(value,min1,max1),min2,max2)},Raven.wrap=function(value,min,max){if(min>value){var range=max-min;value=max-Raven.distance(value,min)%range}else value>max&&(value=value%max+min);return value},Raven.wrap2=function(value,min,max){return value.x=Raven.wrap(value.x,min.x,max.x),value.y=Raven.wrap(value.y,min.y,max.y),value},Raven.wrap3=function(value,min,max){return value.x=Raven.wrap(value.x,min.x,max.x),value.y=Raven.wrap(value.y,min.y,max.y),value.z=Raven.wrap(value.z,min.z,max.z),value};var Raven=Raven||{};Raven.Timer=function(){return this.startMS=0,this.elapsedMS=0,this.running=!0,this.pauseStart=0,this.pauseElapsed=0,this.restart=function(){return this.startMS=Date.now(),this.elapsedMS=0,this.running=!0,this.pauseStart=0,this.pauseElapsed=0,this},this.restart(),this},Raven.Timer.prototype.pause=function(){return this.running?(this.running=!1,this.pauseStart=Date.now(),this.pauseElapsed=0,this):this},Raven.Timer.prototype.play=function(){return this.running?this:(this.pauseElapsed=Date.now()-this.pauseStart,this.startMS+=this.pauseElapsed,this.elapsedMS=Date.now()-this.startMS,this.pauseElapsed=0,this.running=!0,this)},Raven.Timer.prototype.update=function(){return this.running?this.elapsedMS=Date.now()-this.startMS+this.pauseElapsed:this.pauseElapsed=Date.now()-this.pauseStart,this},Raven.Timer.prototype.__defineGetter__("seconds",function(){return this.elapsedMS/1e3}),Raven.Timer.prototype.__defineGetter__("frameNum",function(){var appFPS=60;return Math.round(this.seconds*appFPS)});var Raven=Raven||{};Raven.Event=function(type,params){return this.type=type,this.params=params,this.target=void 0,this},Raven.Event.prototype.constructor=Raven.Event,Raven.Event.ADDED="ravenAdded",Raven.Event.REMOVED="ravenRemoved",Raven.Event.ENABLE="ravenEnable",Raven.Event.DISABLE="ravenDisable",Raven.Event.UPDATE="ravenUpdate",Raven.Event.DRAW="ravenDraw",Raven.Event.RESIZE="ravenResize",Raven.ActionEvent=function(type,x,y,index,pressure){return this.type=type,this.x=x,this.y=y,this.index=index,this.pressure=pressure,this.target=void 0,this},Raven.ActionEvent.prototype=new Raven.Event,Raven.ActionEvent.prototype.constructor=Raven.ActionEvent,Raven.ActionEvent.DOWN="ravenDown",Raven.ActionEvent.MOVE="ravenMove",Raven.ActionEvent.UP="ravenUp",Raven.ActionEvent.OVER="ravenOver",Raven.ActionEvent.OUT="ravenOut",Raven.ActionEvent.SCROLLED="ravenScrolled";var Raven=Raven||{};Raven.EventDispatcher=function(){this.listenerChain={}},Raven.EventDispatcher.prototype.constructor=Raven.EventDispatcher,Raven.EventDispatcher.prototype.buildListenerChain=function(){this.listenerChain||(this.listenerChain={})},Raven.EventDispatcher.prototype.addListener=function(type,listener){if(!listener instanceof Function)throw{message:"Listener isn't a function"};this.buildListenerChain(),this.listenerChain[type]?this.listenerChain[type].push(listener):this.listenerChain[type]=[listener]},Raven.EventDispatcher.prototype.hasListener=function(type){return"undefined"!=typeof this.listenerChain[type]},Raven.EventDispatcher.prototype.removeListener=function(type,listener){if(!this.hasListener(type))return!1;for(var totalListeners=this.listenerChain[type].length,i=0;totalListeners>i;i++)this.listenerChain[type][i]==listener&&this.listenerChain[type].splice(i,1)},Raven.EventDispatcher.prototype.dispatchEvent=function(evtObj){if(this.buildListenerChain(),!this.hasListener(evtObj.type))return!1;var types=this.listenerChain[evtObj.type],total=types.length;evtObj.target=this;for(var i=0;total>i;++i)types[i](evtObj);return!0},Raven._dispatcher=new Raven.EventDispatcher,Raven.addListener=function(type,listener){return Raven._dispatcher.addListener(type,listener)},Raven.hasListener=function(type){return Raven._dispatcher.hasListener(type)},Raven.removeListener=function(type,listener){return Raven._dispatcher.removeListener(type,listener)},Raven.dispatchEvent=function(evt){return Raven._dispatcher.dispatchEvent(evt)},Raven.dispatch=function(type,params){return Raven._dispatcher.dispatchEvent(new Raven.Event(type,params))};var Raven=Raven||{};Raven.DOM={TRANSFORM_PREFIX:"",RESIZE:"resize",SCROLL:window.addEventListener?"scroll":"onscroll",CLICK:"onclick",DBL_CLICK:"ondblclick",MOUSE_MOVE:"mousemove",MOUSE_DOWN:"mousedown",MOUSE_UP:"mouseup",MOUSE_OVER:"onmouseover",MOUSE_OUT:"onmouseout",KEY_DOWN:"keydown",KEY_PRESS:"keypress",KEY_UP:"keyup",TOUCH_DOWN:"touchstart",TOUCH_MOVE:"touchmove",TOUCH_UP:"touchend",GYRO:"deviceorientation",ACCELERATION:"devicemotion"},function(){var ua=navigator.userAgent.toLowerCase();/chrome/.test(ua)||/webkit/.test(ua)?Raven.DOM.TRANSFORM_PREFIX="-webkit-":/opera/.test(ua)?Raven.DOM.TRANSFORM_PREFIX="-o-":/msie/.test(ua)&&(Raven.DOM.TRANSFORM_PREFIX="-ms-")}(),Raven.bind=function(target,event,handler){target[event]=handler},Raven.unbind=function(target,event){target[event]=null},Raven.watch=function(target,event,handler){window.addEventListener?target.addEventListener(event,function(evt){handler(evt)},!1):window.attachEvent&&target.attachEvent(event,function(evt){handler(evt)})},Raven.unwatch=function(target,event,handler){target.removeEventListener(event,function(evt){handler(evt)})},Raven.viewable=function(target){var tb={t:target.offsetTop,l:target.offsetLeft,b:target.offsetTop+target.offsetHeight,r:target.offsetLeft+target.offsetWidth},wb={t:window.scrollY,l:window.scrollX,b:window.scrollY+window.innerHeight,r:window.scrollX+window.innerWidth},top=Raven.inBounds(tb.t,tb.l,wb.t,wb.l,wb.b,wb.r),bot=Raven.inBounds(tb.b,tb.r,wb.t,wb.l,wb.b,wb.r);return top||bot};var Raven=Raven||{};Raven.CSS={apply:function(target,key,value){var prefix="",suffix="";return"rotate"==key?(prefix="rotate(",suffix="deg)",Raven.CSS.transform(target,prefix+value.toString()+suffix),target):"scale"==key?(prefix="scale(",suffix=")",Raven.CSS.transform(target,prefix+value.toString()+suffix),target):(value.constructor==Number&&(suffix="px"),target.style[key]=prefix+value.toString()+suffix,target)},transform:function(target,style){target.style[Raven.DOM.TRANSFORM_PREFIX+"transform"]=style},translate:function(target,x,y){Raven.CSS.transform(target,"translate("+x+"px, "+y+"px)")}};var Raven=Raven||{};Raven.Spring=function(obj,pointer,onUpdate,onComplete){var start=0;return obj&&pointer&&(start=obj[pointer]),this.value=start,this.target=this.value,this.acc=0,this.vel=0,this.history=[],this.obj=obj,this.pointer=pointer,this.onUpdate=onUpdate,this.onComplete=onComplete,this.friction=.7,this.mass=8,this.bounce=.9,this},Raven.Spring.prototype.constructor=Raven.Spring,Raven.Spring.prototype.set=function(value){return this.value=value,this.target=this.value,void 0!==this.obj&&void 0!==this.pointer&&(this.obj[this.pointer]=this.value),this},Raven.Spring.prototype.update=function(){this.history.push(this.value),this.history.length>Raven.Spring.historyLength&&this.history.shift();var force=(this.value-this.target)*-this.bounce;return this.acc=force/this.mass,this.vel=(this.acc+this.vel)*this.friction,this.value+=this.vel,void 0!==this.obj&&void 0!==this.pointer&&(this.obj[this.pointer]=this.value),void 0!==this.onUpdate&&this.onUpdate(this.value),this},Raven.Spring.prototype.onCompletion=function(){return this.value=this.target,this.acc=0,this.vel=0,void 0!==this.obj&&void 0!==this.pointer&&(this.obj[this.pointer]=this.value),void 0!==this.onComplete&&this.onComplete(this.value),this},Raven.Spring.prototype.isComplete=function(){var vel=Math.abs(this.acc)+Math.abs(this.vel),isClose=vel<Raven.Spring.INTERPOLATION_PRECISION;return isClose?Raven.distance(this.value,this.target)<Raven.Spring.INTERPOLATION_PRECISION:!1},Raven.Spring.historyLength=10,Raven.Spring.INTERPOLATION_PRECISION=.002,Raven.SpringVec=function(obj,pointer,onUpdate,onComplete){var start=new Raven.Vec(0,0,0);return obj&&pointer&&(start=obj[pointer]),this.value=start,this.target=this.value.copy(),this.acc=new Raven.Vec(0,0),this.vel=new Raven.Vec(0,0),this.history=[],this.obj=obj,this.pointer=pointer,this.onUpdate=onUpdate,this.onComplete=onComplete,this.friction=.7,this.mass=8,this.bounce=.9,this},Raven.SpringVec.prototype.constructor=Raven.SpringVec,Raven.SpringVec.prototype.set=function(value){if(this.value=value.copy(),this.target=this.value.copy(),void 0!==this.obj&&void 0!==this.pointer){var obj=this.obj[this.pointer];obj.x=this.value.x,obj.y=this.value.y,obj.z=this.value.z}return this},Raven.SpringVec.prototype.update=function(){this.history.push(this.value.copy()),this.history.length>Raven.Spring.historyLength&&this.history.shift();var force=this.value.subtract(this.target).multiply(-this.bounce);if(this.acc=force.divide(this.mass),this.vel=this.acc.add(this.vel).multiply(this.friction),this.value=this.value.add(this.vel),void 0!==this.obj&&void 0!==this.pointer){var obj=this.obj[this.pointer];obj.x=this.value.x,obj.y=this.value.y,obj.z=this.value.z}return void 0!==this.onUpdate&&this.onUpdate(this.value),this},Raven.SpringVec.prototype.draw=function(g){g.setFillRGB(255,255,255);for(var total=this.history.length-1,alpha=255/total,i=0;total>i;++i){var _alpha=alpha*(i+1);g.setStrokeRGBA(255,255,255,_alpha);var a=this.history[i],b=this.history[i+1];g.drawLine(a.x,a.y,b.x,b.y),g.drawCircle(this.value.x,this.value.y,20,!0)}},Raven.SpringVec.prototype.onCompletion=function(){if(this.value=this.target,this.acc.set(0,0,0),this.vel.set(0,0,0),void 0!==this.obj&&void 0!==this.pointer){var obj=this.obj[this.pointer];obj.x=this.value.x,obj.y=this.value.y,obj.z=this.value.z}return void 0!==this.onComplete&&this.onComplete(this.value),this},Raven.SpringVec.prototype.isComplete=function(){var vel=Math.abs(this.acc.length())+Math.abs(this.vel.length()),isClose=vel<Raven.Spring.INTERPOLATION_PRECISION;return isClose?this.value.distance(this.target)<Raven.Spring.INTERPOLATION_PRECISION:vel<Raven.Spring.INTERPOLATION_PRECISION},Raven.SpringController=function(){return this.springs=[],this.springVecs=[],this},Raven.SpringController.prototype.constructor=Raven.SpringController,Raven.Springy=new Raven.SpringController,Raven.SpringController.prototype.clear=function(){this.springs=[],this.springVecs=[]},Raven.SpringController.prototype.update=function(){var i,sp;for(i=0;i<this.springs.length;++i)sp=this.springs[i],sp.update(),sp.isComplete()&&(sp.onCompletion(),this.springs.splice(i,1),--i);for(i=0;i<this.springVecs.length;++i)sp=this.springVecs[i],sp.update(),sp.isComplete()&&(sp.onCompletion(),this.springVecs.splice(i,1),--i)},Raven.SpringController.prototype.draw=function(g){if(void 0!==g){for(var i in this.springVecs)this.springVecs[i].draw(g);g.setFillRGB(255,255,255),g.drawFont("Total springs: "+(this.springs.length+this.springVecs.length).toString(),25,50)}},Raven.SpringController.prototype.to=function(vObj,vTarget,target,update,complete,spring,mass,friction){var sp;isNaN(target)?(sp=this.hasSpringVec(vObj,vTarget),null===sp&&(sp=new Raven.SpringVec(vObj,vTarget,update,complete),this.springVecs.push(sp))):(sp=this.hasSpring(vObj,vTarget),null===sp&&(sp=new Raven.Spring(vObj,vTarget,update,complete),this.springs.push(sp))),target&&(sp.target=target),spring&&(sp.bounce=spring),mass&&(sp.mass=mass),friction&&(sp.friction=friction),sp.onUpdate=update,sp.onComplete=complete},Raven.SpringController.prototype.override=function(spring,mass,friction){var i,total;for(total=this.springs.length,i=0;total>i;++i)this.springs[i].friction=friction,this.springs[i].mass=mass,this.springs[i].bounce=spring;for(total=this.springVecs.length,i=0;total>i;++i)this.springVecs[i].friction=friction,this.springVecs[i].mass=mass,this.springVecs[i].bounce=spring},Raven.SpringController.prototype.hasSpring=function(fObj){for(var i in this.springs){var sp=this.springs[i];if(sp.obj==fObj)return sp}return null},Raven.SpringController.prototype.hasSpringVec=function(vObj,vTarget){for(var i in this.springVecs){var sp=this.springVecs[i];if(sp.obj==vObj&&sp.pointer==vTarget)return sp}return null},Raven.Spritesheet=function(src,totalFrames,frameRate,loop){var _this=this;return this.frameRate=null!=frameRate?frameRate:60,this.currentFrame=0,this.totalFrames=totalFrames,this.loop=null==loop?!0:loop,this.columns=6>totalFrames?totalFrames:6,this.loaded=!1,this.onLoad=null,this.viewWidth=0,this.viewHeight=0,this.scaleX=1,this.scaleY=1,this.img=new Image,this.img.onload=function(){_this.loaded=!0;var rows=Math.ceil(_this.totalFrames/_this.columns);_this.viewWidth=Math.floor(this.width/_this.columns),_this.viewHeight=Math.floor(this.height/rows),null!=this.onLoad&&this.onLoad(this)},this.img.src=src,this.update=function(appCurrentFrame,appFrameRate){if(appCurrentFrame%Math.floor(appFrameRate/this.frameRate)==0){var next=this.currentFrame+1;this.loop?this.currentFrame=next:next<this.totalFrames&&++this.currentFrame}},this.render=function(renderer,pos){if(!this.loaded)return this;var cur=this.currentFrame%this.totalFrames,xOffset=cur%this.columns*this.viewWidth,yOffset=Math.floor(cur/this.columns)*this.viewHeight;renderer.context.drawImage(this.img,xOffset,yOffset,this.viewWidth,this.viewHeight,pos.x,pos.y,this.viewWidth,this.viewHeight)},this},Raven.Spritesheet.prototype.constructor=Raven.Spritesheet;var Raven=Raven||{};Raven.StopWatch=function(){return this.initTime=0,this.endTime=0,this.lastLap=0,this.ms=0,this.time=0,this},Raven.StopWatch.prototype.constructor=Raven.StopWatch,Raven.StopWatch.prototype={getTimer:function(){return(new Date).getTime()},start:function(){return this.initTime=this.getTimer(),this.lastLap=this.initTime,this.time=0,this.read()},stop:function(){return this.endTime=this.getTimer(),this.ms=this.endTime-this.initTime,this.time=this.ms,this.ms},lap:function(){var now=this.getTimer();return this.ms=now-this.lastLap,this.lastLap=now,this.time=now-this.initTime,this.ms},read:function(){return this.getTimer()-this.initTime}};var Raven=Raven||{};Raven.Ease={_2PI:6.283185307179586,_HALF_PI:1.5707963267948966,backIn:function(t,b,c,d,s){return void 0==s&&(s=1.70158),c*(t/=d)*t*((s+1)*t-s)+b},backOut:function(t,b,c,d,s){return void 0==s&&(s=1.70158),c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},backInOut:function(t,b,c,d,s){return void 0==s&&(s=1.70158),(t/=d/2)<1?c/2*t*t*(((s*=1.525)+1)*t-s)+b:c/2*((t-=2)*t*(((s*=1.525)+1)*t+s)+2)+b},bounceIn:function(t,b,c,d){return c-easeOut(d-t,0,c,d)+b},bounceOut:function(t,b,c,d){return(t/=d)<1/2.75?7.5625*c*t*t+b:2/2.75>t?c*(7.5625*(t-=1.5/2.75)*t+.75)+b:2.5/2.75>t?c*(7.5625*(t-=2.25/2.75)*t+.9375)+b:c*(7.5625*(t-=2.625/2.75)*t+.984375)+b},bounceInOut:function(t,b,c,d){return d/2>t?.5*easeIn(2*t,0,c,d)+b:.5*easeOut(2*t-d,0,c,d)+.5*c+b},circIn:function(t,b,c,d){return-c*(Math.sqrt(1-(t/=d)*t)-1)+b},circOut:function(t,b,c,d){return c*Math.sqrt(1-(t=t/d-1)*t)+b},circInOut:function(t,b,c,d){return(t/=d/2)<1?-c/2*(Math.sqrt(1-t*t)-1)+b:c/2*(Math.sqrt(1-(t-=2)*t)+1)+b},cubicIn:function(t,b,c,d){return c*(t/=d)*t*t+b},cubicOut:function(t,b,c,d){return c*((t=t/d-1)*t*t+1)+b},cubicInOut:function(t,b,c,d){return(t/=d/2)<1?c/2*t*t*t+b:c/2*((t-=2)*t*t+2)+b},elasticIn:function(t,b,c,d,a,p){void 0==a&&(a=0),void 0==p&&(p=0);var s;return 0==t?b:1==(t/=d)?b+c:(p||(p=.3*d),!a||a<Math.abs(c)?(a=c,s=p/4):s=p/Raven.Ease._2PI*Math.asin(c/a),-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*Raven.Ease._2PI/p))+b)},elasticOut:function(t,b,c,d,a,p){var s;return 0==t?b:1==(t/=d)?b+c:(p||(p=.3*d),!a||a<Math.abs(c)?(a=c,s=p/4):s=p/Raven.Ease._2PI*Math.asin(c/a),a*Math.pow(2,-10*t)*Math.sin((t*d-s)*Raven.Ease._2PI/p)+c+b)},elasticInOut:function(t,b,c,d,a,p){var s;return 0==t?b:2==(t/=d/2)?b+c:(p||(p=.3*d*1.5),!a||a<Math.abs(c)?(a=c,s=p/4):s=p/Raven.Ease._2PI*Math.asin(c/a),1>t?-.5*a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*Raven.Ease._2PI/p)+b:a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*Raven.Ease._2PI/p)*.5+c+b)},expoIn:function(t,b,c,d){return 0==t?b:c*Math.pow(2,10*(t/d-1))+b-.001*c},expoOut:function(t,b,c,d){return t==d?b+c:c*(-Math.pow(2,-10*t/d)+1)+b},expoInOut:function(t,b,c,d){return 0==t?b:t==d?b+c:(t/=d/2)<1?c/2*Math.pow(2,10*(t-1))+b:c/2*(-Math.pow(2,-10*--t)+2)+b},linear:function(t,b,c,d){return c*t/d+b},quadIn:function(t,b,c,d){return c*(t/=d)*t+b},quadOut:function(t,b,c,d){return-c*(t/=d)*(t-2)+b},quadInOut:function(t,b,c,d){return(t/=d/2)<1?c/2*t*t+b:-c/2*(--t*(t-2)-1)+b},quartIn:function(t,b,c,d){return c*(t/=d)*t*t*t+b},quartOut:function(t,b,c,d){return-c*((t=t/d-1)*t*t*t-1)+b},quartInOut:function(t,b,c,d){return(t/=d/2)<1?c/2*t*t*t*t+b:-c/2*((t-=2)*t*t*t-2)+b},quintIn:function(t,b,c,d){return c*(t/=d)*t*t*t*t+b},quintOut:function(t,b,c,d){return c*((t=t/d-1)*t*t*t*t+1)+b},quintInOut:function(t,b,c,d){return(t/=d/2)<1?c/2*t*t*t*t*t+b:c/2*((t-=2)*t*t*t*t+2)+b},sineIn:function(t,b,c,d){return-c*Math.cos(t/d*Raven.Ease._HALF_PI)+c+b},sineOut:function(t,b,c,d){return c*Math.sin(t/d*Raven.Ease._HALF_PI)+b},sineInOut:function(t,b,c,d){return-c/2*(Math.cos(Math.PI*t/d)-1)+b},strongIn:function(t,b,c,d){return c*(t/=d)*t*t*t*t+b},strongOut:function(t,b,c,d){return c*((t=t/d-1)*t*t*t*t+1)+b},strongInOut:function(t,b,c,d){return(t/=d/2)<1?c/2*t*t*t*t*t+b:c/2*((t-=2)*t*t*t*t+2)+b}},Raven.CubicEase=function(){var BEZIER_SEGMENTS=12,curves=[0,0,0,0,0,0];return this.set=function(x0,y0,x1,y1){var subdiv_step=1/BEZIER_SEGMENTS,subdiv_step2=subdiv_step*subdiv_step,subdiv_step3=subdiv_step2*subdiv_step,pre1=3*subdiv_step,pre2=3*subdiv_step2,pre4=6*subdiv_step2,pre5=6*subdiv_step3,tmp1x=2*-x0+x1,tmp1y=2*-y0+y1,tmp2x=3*(x0-x1)+1,tmp2y=3*(y0-y1)+1;return curves[0]=x0*pre1+tmp1x*pre2+tmp2x*subdiv_step3,curves[1]=y0*pre1+tmp1y*pre2+tmp2y*subdiv_step3,curves[2]=tmp1x*pre4+tmp2x*pre5,curves[3]=tmp1y*pre4+tmp2y*pre5,curves[4]=tmp2x*pre5,curves[5]=tmp2y*pre5,this},this.setLinear=function(){return curves[0]=0,this},this.setStepped=function(){return curves[0]=-1,this},this.setPenner=function(ease){var cEase=Raven.CubicEase.getPenner(ease);return this.set(cEase.x0,cEase.y0,cEase.x1,cEase.y1),this},this.getCurvePercent=function(percent){percent=0>percent?0:percent>1?1:percent;var dfx=curves[0];if(!dfx)return percent;if(-1==dfx)return 0;for(var dfy=curves[1],ddfx=curves[2],ddfy=curves[3],dddfx=curves[4],dddfy=curves[5],x=dfx,y=dfy,i=8;;){if(x>=percent){var lastX=x-dfx,lastY=y-dfy;return lastY+(y-lastY)*(percent-lastX)/(x-lastX)}if(0==i)break;i--,dfx+=ddfx,dfy+=ddfy,ddfx+=dddfx,ddfy+=dddfy,x+=dfx,y+=dfy}return y+(1-y)*(percent-x)/(1-x)},this},Raven.CubicEase.getPenner=function(ease){var cEase=new Raven.CubicEase;switch(ease){case"CircIn":cEase.set(.6,.04,.98,.335);break;case"CircInOut":cEase.set(.785,.135,.15,.86);break;case"CircOut":cEase.set(.075,.82,.165,1);break;case"CubicIn":cEase.set(.55,.055,.675,.19);break;case"CubicInOut":cEase.set(.645,.045,.355,1);break;case"CubicOut":cEase.set(.215,.61,.355,1);break;case"ExpoIn":cEase.set(.95,.05,.795,.035);break;case"ExpoInOut":cEase.set(1,0,0,1);break;case"ExpoOut":cEase.set(.19,1,.22,1);break;case"QuadIn":cEase.set(.55,.085,.68,.53);break;case"QuadInOut":cEase.set(.455,.03,.515,.955);break;case"QuadOut":cEase.set(.25,.46,.45,.94);break;case"QuartIn":cEase.set(.895,.03,.685,.22);break;case"QuartInOut":cEase.set(.86,0,.07,1);break;case"QuartOut":cEase.set(.23,1,.32,1);break;case"QuintIn":cEase.set(.755,.05,.855,.06);break;case"QuintInOut":cEase.set(.77,0,.175,1);break;case"QuintOut":cEase.set(.165,.84,.44,1);break;case"SineIn":cEase.set(.47,0,.745,.715);break;case"SineInOut":cEase.set(.445,.05,.55,.95);break;case"SineOut":cEase.set(.39,.575,.565,1);break;case"Linear":default:cEase.set(.333,.333,.667,.667)}return cEase},Raven.Tween=function(target,key,to,duration,ease,delay,updateHandler,completeHandler){var active=!1;return this.obj=target,this.to=to,this.from=0,this.duration=1e3*duration,this.timestamp=(new Date).getTime()+(delay?1e3*delay:0),this.updateHandler=void 0,this.completeHandler=void 0,void 0!==updateHandler&&(this.updateHandler=function(){updateHandler()}),void 0!==completeHandler&&(this.completeHandler=function(){completeHandler()}),this.start=function(){return this.from=target[key],this},this.complete=function(){return target[key]=to,void 0!==this.completeHandler&&this.completeHandler(),this},this.update=function(percent){if(!active)return active=!0,this.from=target[key],this;var newValue=ease.getCurvePercent(percent)*this.range()+this.from;return target[key]=newValue,void 0!==this.updateHandler&&this.updateHandler(),this},this.range=function(){return this.to-this.from},this.startTime=function(){return this.timestamp},this.endTime=function(){return this.timestamp+this.duration},this.betweenTime=function(ms){return Raven.between(this.timestamp,this.endTime(),ms)},this.setLinear=function(){return ease.setLinear(),this},this.setEase=function(x0,y0,x1,y1){return ease.set(x0,y0,x1,y1),this},this.setPenner=function(ease){return ease.setPenner(Raven.CubicEase.getPenner(ease)),this},this.setStepped=function(){return ease.setStepped(),this},this.start()},Raven.TweenCSS=function(target,key,to,duration,ease,delay,updateHandler,completeHandler){var active=!1;return this.obj=target,this.to=to,this.from=0,this.duration=1e3*duration,this.timestamp=(new Date).getTime()+(delay?1e3*delay:0),this.updateHandler=void 0,this.completeHandler=void 0,void 0!==updateHandler&&(this.updateHandler=function(){updateHandler()}),void 0!==completeHandler&&(this.completeHandler=function(){completeHandler()}),this.start=function(){return this.from=Number(target.style[key].split("px")[0]),this},this.complete=function(){return target.style[key]=to.toString()+"px",void 0!==this.completeHandler&&this.completeHandler(),this},this.update=function(percent){if(!active)return active=!0,this.from=Number(target.style[key].split("px")[0]),this;var newValue=ease.getCurvePercent(percent)*this.range()+this.from;return target.style[key]=newValue.toString()+"px",void 0!==this.updateHandler&&this.updateHandler(),this},this.range=function(){return this.to-this.from},this.startTime=function(){return this.timestamp},this.endTime=function(){return this.timestamp+this.duration},this.betweenTime=function(ms){return Raven.between(this.timestamp,this.endTime(),ms)},this.setLinear=function(){return ease.setLinear(),this},this.setEase=function(x0,y0,x1,y1){return ease.set(x0,y0,x1,y1),this},this.setPenner=function(ease){return ease.setPenner(Raven.CubicEase.getPenner(ease)),this},this.setStepped=function(){return ease.setStepped(),this},this},Raven.TweenController=function(){var tweens=[];return this.active=0,this.totalTweens=function(){return tweens.length},this.addTween=function(target,key,to,duration,x0,y0,x1,y1,delay,updateHandler,completeHandler){var ease=(new Raven.CubicEase).set(x0,y0,x1,y1);return tweens.push(new Raven.Tween(target,key,to,duration,ease,delay,updateHandler,completeHandler)),this},this.addPenner=function(target,key,to,duration,penner,delay,updateHandler,completeHandler){return tweens.push(new Raven.Tween(target,key,to,duration,Raven.CubicEase.getPenner(penner),delay,updateHandler,completeHandler)),this},this.addTweenCSS=function(target,key,to,duration,x0,y0,x1,y1,delay,updateHandler,completeHandler){var ease=(new Raven.CubicEase).set(x0,y0,x1,y1);return tweens.push(new Raven.TweenCSS(target,key,to,duration,ease,delay,updateHandler,completeHandler)),this},this.addPennerCSS=function(target,key,to,duration,penner,delay,updateHandler,completeHandler){return tweens.push(new Raven.TweenCSS(target,key,to,duration,Raven.CubicEase.getPenner(penner),delay,updateHandler,completeHandler)),this},this.removeTween=function(index){return tweens.splice(index,1),this},this.update=function(){var i,percent,now=(new Date).getTime();for(this.active=0,i=0;i<this.totalTweens();i)percent=(now-tweens[i].timestamp)/tweens[i].duration,percent>=0&&1>percent?(tweens[i].update(percent),++this.active,++i):percent>=1?(tweens[i].complete(),this.removeTween(i)):++i;return this},this},Raven.Ani=new Raven.TweenController;var Raven=Raven||{};Raven.DisplayObject=function(){return Raven.EventDispatcher.apply(this,arguments),this.name="Raven.DisplayObject_"+Raven.DisplayObject.count.toString(),this.alpha=1,this.visible=!0,this.position=new Raven.Vec(0,0,0),this.rotation=new Raven.Vec(0,0,0),this.scale=new Raven.Vec(1,1,1),this.size=new Raven.Vec(0,0,0),this.parent=null,this.children=[],++Raven.DisplayObject.count,this
},Raven.DisplayObject.extends(Raven.EventDispatcher,Raven.DisplayObject),Raven.DisplayObject.count=0,Raven.DisplayObject.prototype.setup=function(x,y,width,height){return this.position.x=x,this.position.y=y,this.size.x=width,this.size.y=height,this},Raven.DisplayObject.prototype.dispose=function(){this.parent=null;var i,total=this.numChildren-1;for(i=total;i>-1;--i)this.children[i].dispose();return delete this.children,this},Raven.DisplayObject.prototype.update=function(){return this.visible?(this.updateChildren(),this):this},Raven.DisplayObject.prototype.updateChildren=function(){var i,total=this.numChildren;for(i=0;total>i;++i)this.children[i].visible&&(this.children[i].update(),this.children[i].right>this.size.x&&(this.size.x=this.children[i].right),this.children[i].bottom>this.size.y&&(this.size.y=this.children[i].bottom),this.children[i].back>this.size.z&&(this.size.z=this.children[i].back));return this},Raven.DisplayObject.prototype.draw=function(view){return this.visible?(this.pushMatrix(view),this.render(view),this.drawChildren(view),this.popMatrix(view),this.drawAfter(view),this):this},Raven.DisplayObject.prototype.drawAfter=function(){return this},Raven.DisplayObject.prototype.drawBounds=function(view){return this.pushMatrix(view),view.setStrokeRGBA(255,0,0,255*this.opacity),view.drawRect(0,0,this.size.x,this.size.y,!1,!0),this.popMatrix(view),this},Raven.DisplayObject.prototype.drawChildren=function(view){var i,total=this.numChildren;for(i=0;total>i;++i)this.children[i].visible&&this.children[i].draw(view);return this},Raven.DisplayObject.prototype.render=function(){return this},Raven.DisplayObject.prototype.hitTest=function(x,y){return Raven.inBounds(x,y,this.absoluteLeft,this.absoluteTop,this.absoluteRight,this.absoluteBottom)},Raven.DisplayObject.prototype.pushMatrix=function(view){return view.pushMatrix(),view.translate(this.position.x,this.position.y,this.position.z),view.rotate(this.rotation.x,this.rotation.y,this.rotation.z),view.scale(this.scale.x,this.scale.y,this.scale.z),view.setFillRGBA(255,255,255,255*this.opacity),this},Raven.DisplayObject.prototype.popMatrix=function(view){return view.popMatrix(),this},Raven.DisplayObject.prototype.addChild=function(displayObject){return displayObject.parent==this?!1:(null!=displayObject.parent&&displayObject.parent.removeChild(displayObject),displayObject.parent=this,this.children.push(displayObject),!0)},Raven.DisplayObject.prototype.hasChild=function(displayObject){return this.getChildIndex(displayObject)>-1},Raven.DisplayObject.prototype.getChildAt=function(index){return index>-1&&index<this.numChildren?this.children[index]:null},Raven.DisplayObject.prototype.getChildByName=function(displayName){for(var total=this.numChildren,i=0;total>i;++i)if(this.children[i].name==displayName)return this.children[i];return null},Raven.DisplayObject.prototype.getChildIndex=function(displayObject){for(var total=this.numChildren,i=0;total>i;++i)if(this.children[i]==displayObject)return i;return-1},Raven.DisplayObject.prototype.getChildIndexByName=function(displayName){for(var total=this.numChildren,i=0;total>i;++i)if(this.children[i].name==displayName)return i;return-1},Raven.DisplayObject.prototype.removeChild=function(displayObject){var index=this.getChildIndex(displayObject);return this.removeChildAt(index)},Raven.DisplayObject.prototype.removeChildAt=function(index){return index>-1&&index<this.numChildren&&(this.children[index].dispose(),this.children.splice(index,1)),this},Raven.DisplayObject.prototype.removeAllChildren=function(){var i;for(i=this.numChildren-1;i>-1;--i)this.removeChildAt(i);return this.children=[],this},Raven.DisplayObject.prototype.__defineGetter__("numChildren",function(){return this.children.length}),Raven.DisplayObject.prototype.__defineGetter__("opacity",function(){return null!=this.parent?this.alpha*this.parent.alpha:this.alpha}),Raven.DisplayObject.prototype.__defineGetter__("width",function(){return this.size.x}),Raven.DisplayObject.prototype.__defineGetter__("height",function(){return this.size.y}),Raven.DisplayObject.prototype.__defineGetter__("depth",function(){return this.size.z}),Raven.DisplayObject.prototype.__defineGetter__("left",function(){return this.position.x}),Raven.DisplayObject.prototype.__defineGetter__("top",function(){return this.position.y}),Raven.DisplayObject.prototype.__defineGetter__("front",function(){return this.position.z}),Raven.DisplayObject.prototype.__defineGetter__("right",function(){return this.size.x+this.position.x}),Raven.DisplayObject.prototype.__defineGetter__("bottom",function(){return this.size.y+this.position.y}),Raven.DisplayObject.prototype.__defineGetter__("back",function(){return this.size.z+this.position.z}),Raven.DisplayObject.prototype.__defineGetter__("centerX",function(){return.5*this.size.x+this.position.x}),Raven.DisplayObject.prototype.__defineGetter__("centerY",function(){return.5*this.size.y+this.position.y}),Raven.DisplayObject.prototype.__defineGetter__("centerZ",function(){return.5*this.size.z+this.position.z}),Raven.DisplayObject.prototype.__defineGetter__("absoluteLeft",function(){return this.position.x+(null!==this.parent?this.parent.absoluteLeft:0)}),Raven.DisplayObject.prototype.__defineGetter__("absoluteTop",function(){return this.position.y+(null!==this.parent?this.parent.absoluteTop:0)}),Raven.DisplayObject.prototype.__defineGetter__("absoluteFront",function(){return this.position.z+(null!==this.parent?this.parent.absoluteFront:0)}),Raven.DisplayObject.prototype.__defineGetter__("absoluteRight",function(){return this.right+(null!==this.parent?this.parent.absoluteLeft:0)}),Raven.DisplayObject.prototype.__defineGetter__("absoluteBottom",function(){return this.bottom+(null!==this.parent?this.parent.absoluteTop:0)}),Raven.DisplayObject.prototype.__defineGetter__("absoluteBack",function(){return this.back+(null!==this.parent?this.parent.absoluteFront:0)}),Raven.DisplayObject.prototype.__defineGetter__("absoluteCenterX",function(){return.5*this.size.x+this.absoluteLeft}),Raven.DisplayObject.prototype.__defineGetter__("absoluteCenterY",function(){return.5*this.size.y+this.absoluteTop}),Raven.DisplayObject.prototype.__defineGetter__("absoluteCenterZ",function(){return.5*this.size.z+this.absoluteFront});var Raven=Raven||{};Raven.Button=function(){function evtHandler(evt){_this.handleEvent(evt)}Raven.DisplayObject.apply(this,arguments),this.name="Raven.Button_"+Raven.Button.count.toString(),this.isEnabled=!1,this.isDown=!1,this.isOver=!1,this.selectable=!1,this.selected=!1,this.touchOffset=new Raven.Vec(0,0);var _this=this;return this.enable=function(){return this.isEnabled?this:(this.isEnabled=!0,Raven.addListener(Raven.ActionEvent.DOWN,evtHandler),Raven.addListener(Raven.ActionEvent.MOVE,evtHandler),Raven.addListener(Raven.ActionEvent.UP,evtHandler),this)},this.disable=function(){return this.isEnabled?(this.isEnabled=!1,Raven.removeListener(Raven.ActionEvent.DOWN,evtHandler),Raven.removeListener(Raven.ActionEvent.MOVE,evtHandler),Raven.removeListener(Raven.ActionEvent.UP,evtHandler),this):this},this.enable(),++Raven.Button.count,this},Raven.Button.extends(Raven.DisplayObject,Raven.Button),Raven.Button.count=0,Raven.Button.CLICK="ravenClick",Raven.Button.prototype.handleEvent=function(evt){var wasOver=this.isOver;switch(this.isOver=this.hitTest(evt.x,evt.y),evt.type){case Raven.ActionEvent.DOWN:this.isOver&&(this.isDown=!0,this.onPress(),this.toggle(),this.dispatchEvent(new Raven.Event(Raven.Button.CLICK,this)));break;case Raven.ActionEvent.MOVE:this.isOver?(wasOver||this.onRollOver(),this.onMove()):wasOver&&this.onRollOut();break;case Raven.ActionEvent.UP:this.isDown=!1,this.isOver?this.onReleased():this.onReleasedOutside()}return this},Raven.Button.prototype.render=function(view){var a=this.isEnabled?255:102;return this.isDown?view.setFillRGBA(255,0,0,a):this.isOver?view.setFillRGBA(204,204,204,a):view.setFillRGBA(64,64,64,a),view.drawRect(0,0,this.width,this.height,!0),view.setFillB(255),this.selectable&&this.selected&&(view.setStrokeB(255),view.drawRect(0,0,this.width,this.height,!1,!0)),view.drawFont(this.name,10,18),this},Raven.Button.prototype.onMove=function(){return this},Raven.Button.prototype.onPress=function(){return this},Raven.Button.prototype.onRollOver=function(){return this},Raven.Button.prototype.onRollOut=function(){return this},Raven.Button.prototype.onReleased=function(){return this},Raven.Button.prototype.onReleasedOutside=function(){return this},Raven.Button.prototype.onSelect=function(){return this.selectable?this.selected?this:(this.selected=!0,this):this},Raven.Button.prototype.onDeselect=function(){return this.selectable&&this.selected?(this.selected=!1,this):this},Raven.Button.prototype.toggle=function(){return this.selected?this.onDeselect():this.onSelect(),this},Raven.Button.prototype.__defineGetter__("enabled",function(){return this.children.length});var Raven=Raven||{};Raven.SceneState={Scene_In:0,Scene_Idle:1,Scene_Out:2,Scene_Hidden:3},Raven.Scene=function(){return Raven.DisplayObject.apply(this,arguments),this.name="Raven.Scene_"+Raven.Scene.count.toString(),this.showing=!1,this.state=Raven.SceneState.Scene_Hidden,this.timer=new Raven.Timer,this.timeline=new Raven.TweenController,this.visible=!1,++Raven.Scene.count,this},Raven.Scene.extends(Raven.DisplayObject,Raven.Scene),Raven.Scene.count=0,Raven.Scene.prototype.show=function(){return this.showing?!1:(this.state=Raven.SceneState.Scene_In,this.showing=!0,this.visible=!0,this.animateIn(),!0)},Raven.Scene.prototype.hide=function(){return this.showing?(this.state=Raven.SceneState.Scene_Out,this.animateOut(),!0):!1},Raven.Scene.prototype.update=function(){return this.timeline.update(),this.timer.update(),Raven.DisplayObject.prototype.update.call(this),this},Raven.Scene.prototype.animateIn=function(){return this.animateInComplete(),this},Raven.Scene.prototype.animateInComplete=function(){return this.state=Raven.SceneState.Scene_Idle,this.dispatchEvent(new Raven.Event(Raven.Scene.SCENE_IN,this)),this},Raven.Scene.prototype.animateOut=function(){return this.animateOutComplete(),this},Raven.Scene.prototype.animateOutComplete=function(){return this.state=Raven.SceneState.Scene_Hidden,this.showing=!1,this.visible=!1,this.dispatchEvent(new Raven.Event(Raven.Scene.SCENE_OUT,this)),this},Raven.Scene.prototype.__defineGetter__("frameNum",function(){return this.timer.frameNum}),Raven.Scene.prototype.__defineGetter__("elapsedTime",function(){return this.timer.elapsedMS}),Raven.Scene.SCENE_IN="Scene::sceneIn",Raven.Scene.SCENE_OUT="Scene::sceneOut";var Raven=Raven||{};Raven.Stage=function(){return Raven.DisplayObject.apply(this,arguments),this.name="Raven.Stage",this.sceneIndex=-1,this.activeScene=null,this.nextScene=null,this.element=void 0,this.renderer=void 0,this},Raven.Stage.extends(Raven.DisplayObject,Raven.Stage),Raven.Stage.prototype.init=function(element){var domElement=Raven.element(element);return this.element=domElement,this},Raven.Stage.prototype.resize=function(){return this},Raven.Stage.prototype.setupScenes=function(){return this},Raven.Stage.prototype.addChild=function(displayObject){return Raven.DisplayObject.prototype.addChild.call(this,displayObject)?(displayObject.constructor==Raven.Scene.constructor&&(displayObject.visible=!1),!0):!1},Raven.Stage.prototype.showChild=function(displayName){var index=this.getChildIndexByName(displayName);return 0>index?!1:(this.children[index].visible=!0,!0)},Raven.Stage.prototype.hideChild=function(displayName){var index=this.getChildIndexByName(displayName);return 0>index?!1:(this.children[index].visible=!1,!0)},Raven.Stage.prototype.showScene=function(sceneName){return this.showSceneAt(this.getChildIndexByName(sceneName)),this},Raven.Stage.prototype.showSceneAt=function(displayIndex){return 0>displayIndex||displayIndex>=this.numChildren?!1:(this.nextScene=this.children[displayIndex],this.sceneIndex=displayIndex,null!==this.activeScene?this.hideCurrentScene():this.showNextScene(),this)},Raven.Stage.prototype.hideScene=function(){return null!==this.activeScene&&this.hideCurrentScene(),this},Raven.Stage.prototype.updateChildren=function(){var i,total=this.numChildren;for(i=0;total>i;++i)this.children[i].visible&&(this.children[i].update(),this.children[i].right>this.size.x&&(this.size.x=this.children[i].right),this.children[i].bottom>this.size.y&&(this.size.y=this.children[i].bottom),this.children[i].back>this.size.z&&(this.size.z=this.children[i].back));return this},Raven.Stage.prototype.showNextScene=function(){return this.activeScene=this.nextScene,this.activeScene.show(),this.nextScene=null,this},Raven.Stage.prototype.hideCurrentScene=function(){var _this=this,currentSceneHidden=function(){_this.activeScene.removeListener(Raven.Scene.SCENE_OUT,currentSceneHidden),_this.activeScene=null,null!==_this.nextScene&&_this.showNextScene()};return this.activeScene.addListener(Raven.Scene.SCENE_OUT,currentSceneHidden),this.activeScene.hide(),this};var Raven=Raven||{};Raven.Align={TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,CENTER_LEFT:3,CENTER:4,CENTER_RIGHT:5,BOTTOM_LEFT:6,BOTTOM_CENTER:7,BOTTOM_RIGHT:8,getOffset:function(x,y,width,height,view){var offset=new Raven.Vec(x,y);switch(view.align){default:case Raven.Align.TOP_LEFT:break;case Raven.Align.TOP_CENTER:offset.x-=.5*width;break;case Raven.Align.TOP_RIGHT:offset.x-=width;break;case Raven.Align.CENTER_LEFT:offset.y-=.5*height;break;case Raven.Align.CENTER:offset.x-=.5*width,offset.y-=.5*height;break;case Raven.Align.CENTER_RIGHT:offset.x-=width,offset.y-=.5*height;break;case Raven.Align.BOTTOM_LEFT:offset.y-=height;break;case Raven.Align.BOTTOM_CENTER:offset.x-=.5*width,offset.y-=height;break;case Raven.Align.BOTTOM_RIGHT:offset.x-=width,offset.y-=height}return offset}},Raven.Color=function(r,g,b,a){return this.r=r?r:0,this.g=g?g:0,this.b=b?b:0,this.a=a?a:255,this.copy=function(){return new Raven.Color(this.r,this.g,this.b,this.a)},this.css=function(){return"rgba("+Math.round(this.r)+","+Math.round(this.g)+","+Math.round(this.b)+","+this.a/255+")"},this.gl=function(){return[this.r/255,this.g/255,this.b/255,this.a/255]},this.set=function(r,g,b,a){return void 0!==r&&(this.r=r),void 0!==g&&(this.g=g),void 0!==b&&(this.b=b),void 0!==a&&(this.a=a),this},this.setColor=function(rColor){return this.r=rColor.r,this.g=rColor.g,this.b=rColor.b,this.a=rColor.a,this},this.fromHex=function(hex){var c=Raven.Color.fromHex(hex);return this.setColor(c),this},this.setHex=function(hex){var c=Raven.Color.hexToRGB(hex);return this.setColor(c),this},this},Raven.Color.fromHex=function(hex){var col=new Raven.Color;return col.r=hex>>16&255,col.g=hex>>8&255,col.b=255&hex,col},Raven.Color.getHex=function(hexCode){var n=parseInt(hexCode,10);return isNaN(n)?"00":(n=Math.max(0,Math.min(n,255)),"0123456789ABCDEF".charAt((n-n%16)/16)+"0123456789ABCDEF".charAt(n%16))},Raven.Color.hexToRGB=function(hex){var h="#"==hex.charAt(0)?hex.substring(1,7):hex,r=parseInt(h.substring(0,2),16),g=parseInt(h.substring(2,4),16),b=parseInt(h.substring(4,6),16),a=h.length>6?parseInt(h.substring(6,8),16):255;return new Raven.Color(r,g,b,a)},Raven.Color.rgbToHex=function(r,g,b){return Raven.Color.getHex(r)+Raven.Color.getHex(g)+Raven.Color.getHex(b)},Raven.Color.black=function(){return new Raven.Color(0,0,0)},Raven.Color.white=function(){return new Raven.Color(255,255,255)},Raven.Color.red=function(){return new Raven.Color(255,0,0)},Raven.Color.green=function(){return new Raven.Color(0,255,0)},Raven.Color.blue=function(){return new Raven.Color(0,0,255)},Raven.ViewMatrix=function(){return this.rotate=new Raven.Vec(0,0,0),this.scale=new Raven.Vec(1,1,1),this.translate=new Raven.Vec(0,0,0),this.transform={a:1,b:0,c:0,d:1,e:0,f:0},this},Raven.ViewMatrix.prototype.reset=function(){return this.rotate=new Raven.Vec(0,0,0),this.scale=new Raven.Vec(1,1,1),this.translate=new Raven.Vec(0,0,0),this.transform={a:1,b:0,c:0,d:1,e:0,f:0},this},Raven.VIEW_CANVAS="canvas",Raven.VIEW_WEBGL="webgl",Raven.View=function(){return this.align=Raven.Align.TOP_LEFT,this.autoClear=!0,this.background=Raven.Color.black(),this.element=null,this.context=null,this.pixelRatio=window.devicePixelRatio,this.width=0,this.height=0,this.type=-1,this.masking=!1,this},Raven.View.prototype={available:function(){return null!=this.context},retinaAvailable:function(){return this.pixelRatio>1},setup:function(cElement){this.align=Raven.Align.TOP_LEFT,this.element=Raven.element(cElement),this.width=this.element.width,this.height=this.element.height},clear:function(){},resize:function(w,h){this.element.width=w*this.pixelRatio,this.element.height=h*this.pixelRatio,this.width=w,this.height=h},begin:function(){},end:function(){},moveTo:function(){},lineTo:function(){},beginMask:function(){},endMask:function(){},stopMask:function(){},drawLine:function(){},drawRect:function(){},drawArc:function(){},drawBezier:function(){},drawCircle:function(){},drawPoly:function(){},drawFont:function(){},drawImage:function(){},getLineWidth:function(){return 0},setLineWidth:function(){},setFill:function(){},setFillB:function(){},setFillHex:function(){},setFillRGB:function(){},setFillRGBA:function(){},setStroke:function(){},setStrokeB:function(){},setStrokeHex:function(){},setStrokeRGB:function(){},setStrokeRGBA:function(){},pushMatrix:function(){},popMatrix:function(){},rotate:function(){},scale:function(){},transform:function(){},translate:function(){}};var Raven=Raven||{};Raven.CanvasView=function(){return Raven.View.apply(this,arguments),this.type=Raven.VIEW_CANVAS,this.matrix=new Raven.ViewMatrix,this.matrices=[this.matrix],this},Raven.CanvasView.extends(Raven.View,Raven.CanvasView),Raven.CanvasView.prototype.setup=function(cElement){return Raven.View.prototype.setup.call(this,cElement),this.context=this.element.getContext("2