diff --git a/build/amd/hilo-amd.js b/build/amd/hilo-amd.js index b609dd63..0a040648 100644 --- a/build/amd/hilo-amd.js +++ b/build/amd/hilo-amd.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -192,7 +192,7 @@ return browser; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -229,7 +229,7 @@ return util; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -257,7 +257,7 @@ var Hilo = { * Hilo version * @type String */ - version: '1.3.0', + version: '1.4.0', /** * @language=en * Gets a globally unique id. Such as Stage1, Bitmap2 etc. @@ -565,7 +565,7 @@ return Hilo; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -748,7 +748,7 @@ return Class; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -972,7 +972,7 @@ return Matrix; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1125,7 +1125,7 @@ return EventMixin; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1206,7 +1206,7 @@ return Drawable; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1300,7 +1300,7 @@ return Renderer; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1511,7 +1511,7 @@ return CanvasRenderer; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1693,7 +1693,7 @@ return DOMRenderer; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1750,7 +1750,13 @@ var WebGLRenderer = Class.create(/** @lends WebGLRenderer.prototype */{ } } return this._isSupported; - } + }, + /** + * WebGL context Options + * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getContextAttributes + * @type {Object} + */ + contextOptions: null }, renderType:'webgl', gl:null, @@ -1759,7 +1765,8 @@ var WebGLRenderer = Class.create(/** @lends WebGLRenderer.prototype */{ constructor: function(properties){ WebGLRenderer.superclass.constructor.call(this, properties); var that = this; - this.gl = this.canvas.getContext("webgl")||this.canvas.getContext('experimental-webgl'); + var contextOptions = WebGLRenderer.contextOptions || {}; + this.gl = this.canvas.getContext("webgl", contextOptions)||this.canvas.getContext('experimental-webgl', contextOptions); this.maxBatchNum = WebGLRenderer.MAX_BATCH_NUM; this.positionStride = WebGLRenderer.ATTRIBUTE_NUM * 4; @@ -2270,7 +2277,7 @@ return WebGLRenderer; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2767,7 +2774,7 @@ return View; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2833,7 +2840,7 @@ return CacheMixin; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3207,7 +3214,7 @@ return Container; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3474,7 +3481,7 @@ return Stage; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3552,7 +3559,7 @@ return Bitmap; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3823,7 +3830,7 @@ return Sprite; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3938,7 +3945,7 @@ return DOMElement; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3948,7 +3955,7 @@ define('hilo/view/Graphics', ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/view/Vi /** * @language=en - * + * *
* @class Graphics class contains a group of functions for creating vector graphics. * @augments View @@ -4500,7 +4507,7 @@ return Graphics; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4548,7 +4555,7 @@ var Text = Class.create(/** @lends Text.prototype */{ this._fontHeight = Text.measureFontHeight(this.font); }, - text: null, + text: '', color: '#000', textAlign: null, textVAlign: null, @@ -4753,7 +4760,7 @@ return Text; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4937,7 +4944,7 @@ return BitmapText; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5116,7 +5123,7 @@ return Button; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5353,7 +5360,7 @@ return TextureAtlas; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5582,7 +5589,7 @@ return Ticker; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5630,7 +5637,7 @@ if (!fnProto.bind) { }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5769,7 +5776,7 @@ return drag; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6219,7 +6226,7 @@ return Tween; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6491,7 +6498,7 @@ return Ease; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6539,7 +6546,7 @@ return ImageLoader; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6606,7 +6613,7 @@ return ScriptLoader; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6856,7 +6863,7 @@ return LoadQueue; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7059,7 +7066,7 @@ return HTMLAudio; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7376,7 +7383,7 @@ return WebAudio; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7479,7 +7486,7 @@ return WebSound; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7572,7 +7579,7 @@ return Camera; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7759,7 +7766,7 @@ return Camera3d; }); /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo-amd.min.js b/build/amd/hilo-amd.min.js index 6487ea21..6c5a467c 100644 --- a/build/amd/hilo-amd.min.js +++ b/build/amd/hilo-amd.min.js @@ -1,8 +1,8 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ -define("hilo/util/browser",function(){var t=function(){var t=navigator.userAgent,e=document,i=window,r=e.documentElement,n={iphone:/iphone/i.test(t),ipad:/ipad/i.test(t),ipod:/ipod/i.test(t),ios:/iphone|ipad|ipod/i.test(t),android:/android/i.test(t),webkit:/webkit/i.test(t),chrome:/chrome/i.test(t),safari:/safari/i.test(t),firefox:/firefox/i.test(t),ie:/msie/i.test(t),opera:/opera/i.test(t),supportTouch:"ontouchstart"in i,supportCanvas:null!=e.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in i||"orientation"in i.screen,supportDeviceMotion:"ondevicemotion"in i};try{var a="hilo";localStorage.setItem(a,a),localStorage.removeItem(a),n.supportStorage=!0}catch(o){}var s=n.jsVendor=n.webkit?"webkit":n.firefox?"webkit":n.opera?"o":n.ie?"ms":"",h=n.cssVendor="-"+s+"-",l=e.createElement("div"),c=l.style,u=void 0!=c[s+"Transform"],d=void 0!=c[s+"Perspective"];d&&(l.id="test3d",c=e.createElement("style"),c.textContent="@media ("+h+"transform-3d){#test3d{height:3px}}",e.head.appendChild(c),r.appendChild(l),d=3==l.offsetHeight,e.head.removeChild(c),r.removeChild(l)),n.supportTransform=u,n.supportTransform3D=d;var f=n.supportTouch,p=f?"touchstart":"mousedown",v=f?"touchmove":"mousemove",m=f?"touchend":"mouseup";return n.POINTER_START=p,n.POINTER_MOVE=v,n.POINTER_END=m,n}();return t}),define("hilo/util/util",function(){var t={copy:function(t,e,i){for(var r in e)i&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t}};return t}),define("hilo/core/Hilo",["hilo/util/browser","hilo/util/util"],function(t,e){var i=window,r=document,n=r.documentElement,a=0,o={},s={version:"1.3.0",getUid:function(t){var e=++a;if(t){var i=t.charCodeAt(t.length-1);return i>=48&&i<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,i=t;i;)e=e?i.id+"."+e:i.id,i=i.parent;return e},copy:function(t,i,r){return e.copy(t,i,r),o.copy||(o.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),t},browser:t,event:{POINTER_START:t.POINTER_START,POINTER_MOVE:t.POINTER_MOVE,POINTER_END:t.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(t){var e;try{e=t.getBoundingClientRect()}catch(r){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var a=(i.pageXOffset||n.scrollLeft)-(n.clientLeft||0)||0,o=(i.pageYOffset||n.scrollTop)-(n.clientTop||0)||0,s=i.getComputedStyle?getComputedStyle(t):t.currentStyle,h=parseInt,l=h(s.paddingLeft)+h(s.borderLeftWidth)||0,c=h(s.paddingTop)+h(s.borderTopWidth)||0,u=h(s.paddingRight)+h(s.borderRightWidth)||0,d=h(s.paddingBottom)+h(s.borderBottomWidth)||0,f=e.top||0,p=e.left||0,v=e.right||0,m=e.bottom||0;return{left:p+a+l,top:f+o+c,width:v-u-p-l,height:m-d-f-c}},createElement:function(t,e){var i,n,a,o=r.createElement(t);for(i in e)if(n=e[i],"style"===i)for(a in n)o.style[a]=n[a];else o[i]=n;return o},getElement:function(t){return r.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,i=e.domElement.style,r=t._stateCache||(t._stateCache={}),n=s.browser.jsVendor,a="px",o=!1;if(this.cacheStateIfChanged(t,["visible"],r)&&(i.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],r)&&(i.opacity=t.alpha),t.visible&&!(t.alpha<=0)){if(this.cacheStateIfChanged(t,["width"],r)&&(i.width=t.width+a),this.cacheStateIfChanged(t,["height"],r)&&(i.height=t.height+a),this.cacheStateIfChanged(t,["depth"],r)&&(i.zIndex=t.depth+1),t.transform){var h=t.transform;(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(i[n+"TransformOrigin"]="0 0"),i[n+"Transform"]="matrix3d("+h.a+", "+h.b+", 0, 0, "+h.c+", "+h.d+", 0, 0, 0, 0, 1, 0, "+h.tx+", "+h.ty+", 0, 1)"}else(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(i[n+"TransformOrigin"]=t.pivotX+a+" "+t.pivotY+a),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],r)||o)&&(i[n+"Transform"]=this.getTransformCSS(t));this.cacheStateIfChanged(t,["background"],r)&&(i.backgroundColor=t.background),i.pointerEvents||(i.pointerEvents="none");var l=e.image;if(l){var c=l.src;c!==r.image&&(r.image=c,i.backgroundImage="url("+c+")");var u=e.rect;if(u){var d=u[0],f=u[1];d!==r.sx&&(r.sx=d,i.backgroundPositionX=-d+a),f!==r.sy&&(r.sy=f,i.backgroundPositionY=-f+a)}}var p=t.mask;if(p){var v=p.drawable.domElement.style.backgroundImage;v!==r.maskImage&&(r.maskImage=v,i[n+"MaskImage"]=v,i[n+"MaskRepeat"]="no-repeat");var m=p.x,g=p.y;m===r.maskX&&g===r.maskY||(r.maskX=m,r.maskY=g,i[n+"MaskPosition"]=m+a+" "+g+a)}}},cacheStateIfChanged:function(t,e,i){var r,n,a,o,s=!1;for(r=0,n=e.length;r=6?(e=s[0],i=s[1],r=s[2],n=s[3],a=s[4],o=s[5]):(e=t.a,i=t.b,r=t.c,n=t.d,a=t.tx,o=t.ty),this.a=h*e+l*r,this.b=h*i+l*n,this.c=c*e+u*r,this.d=c*i+u*n,this.tx=d*e+f*r+a,this.ty=d*i+f*n+o,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),r=this.a,n=this.b,a=this.c,o=this.d,s=this.tx,h=this.ty;return this.a=r*i-n*e,this.b=r*e+n*i,this.c=a*i-o*e,this.d=a*e+o*i,this.tx=s*i-h*e,this.ty=s*e+h*i,this},scale:function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},translate:function(t,e){return this.tx+=t,this.ty+=e,this},identity:function(){return this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this},invert:function(){var t=this.a,e=this.b,i=this.c,r=this.d,n=this.tx,a=t*r-e*i;return this.a=r/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-r*n)/a,this.ty=-(t*this.ty-e*n)/a,this},transformPoint:function(t,e,i){var r=t.x*this.a+t.y*this.c+this.tx,n=t.x*this.b+t.y*this.d+this.ty;return e&&(r=r+.5>>0,n=n+.5>>0),i?{x:r,y:n}:(t.x=r,t.y=n,t)}});return e}),define("hilo/event/EventMixin",["hilo/core/Class"],function(t){var e={_listeners:null,on:function(t,e,i){for(var r=this._listeners=this._listeners||{},n=r[t]=r[t]||[],a=0,o=n.length;a-1&&o.splice(c,1)}}return 0==o.length&&delete a[n],!0}return!1}},i=t.create({constructor:function(t,e,i){this.type=t,this.target=e,this.detail=i,this.timeStamp=+new Date},type:null,target:null,detail:null,timeStamp:0,stopImmediatePropagation:function(){this._stopped=!0}}),r=window.Event;if(r){var n=r.prototype,a=n.stopImmediatePropagation;n.stopImmediatePropagation=function(){a&&a.call(this),this._stopped=!0}}return e}),define("hilo/view/Drawable",["hilo/core/Class","hilo/util/util"],function(t,e){var i=t.create({constructor:function(t){this.init(t)},image:null,rect:null,init:function(t){var r=this,n=r.image;i.isDrawable(t)?r.image=t:e.copy(r,t,!0);var a=r.image;if("string"==typeof a){if(!n||a!==n.getAttribute("src")){r.image=null;var o=new Image;return t.crossOrigin&&(o.crossOrigin=t.crossOrigin),o.onload=function(){o.onload=null,r.init(o)},void(o.src=a)}a=r.image=n}a&&!r.rect&&(r.rect=[0,0,a.width,a.height])},Statics:{isDrawable:function(t){if(!t||!t.tagName)return!1;var e=t.tagName.toLowerCase();return"img"===e||"canvas"===e||"video"===e}}});return i}),define("hilo/renderer/Renderer",["hilo/core/Class","hilo/util/util"],function(t,e){var i=t.create({constructor:function(t){t=t||{},e.copy(this,t,!0)},renderType:null,canvas:null,stage:null,blendMode:"source-over",startDraw:function(t){},draw:function(t){},endDraw:function(t){},transform:function(){},hide:function(){},remove:function(t){},clear:function(t,e,i,r){},resize:function(t,e){}});return i}),define("hilo/renderer/CanvasRenderer",["hilo/core/Class","hilo/core/Hilo","hilo/renderer/Renderer"],function(t,e,i){var r=t.create({Extends:i,constructor:function(t){r.superclass.constructor.call(this,t),this.context=this.canvas.getContext("2d")},renderType:"canvas",context:null,startDraw:function(t){return!!(t.visible&&t.alpha>0)&&(t===this.stage&&this.context.clearRect(0,0,t.width,t.height),t.blendMode!==this.blendMode&&(this.context.globalCompositeOperation=this.blendMode=t.blendMode),this.context.save(),!0)},draw:function(t){var e=this.context,i=t.width,r=t.height,n=t.background;n&&(e.fillStyle=n,e.fillRect(0,0,i,r));var a=t.drawable,o=a&&a.image;if(o){var s=a.rect,h=s[2],l=s[3],c=s[4],u=s[5];if(!h||!l)return;i||r||(i=t.width=h,r=t.height=l),(c||u)&&e.translate(c-.5*h,u-.5*l),e.drawImage(o,s[0],s[1],h,l,0,0,i,r)}},endDraw:function(t){this.context.restore()},transform:function(t){var i=t.drawable;if(i&&i.domElement)return void e.setElementStyleByView(t);var r=this.context,n=t.scaleX,a=t.scaleY;if(t===this.stage){var o=this.canvas.style,s=t._scaleX,h=t._scaleY,l=!1;(!s&&1!=n||s&&s!=n)&&(t._scaleX=n,o.width=n*t.width+"px",l=!0),(!h&&1!=a||h&&h!=a)&&(t._scaleY=a,o.height=a*t.height+"px",l=!0),l&&t.updateViewport()}else{var c=t.x,u=t.y,d=t.pivotX,f=t.pivotY,p=t.rotation%360,v=t.transform,m=t.mask;m&&(m._render(this),r.clip());var g=t.align;if(g){var _=t.getAlignPosition();c=_.x,u=_.y}v?r.transform(v.a,v.b,v.c,v.d,v.tx,v.ty):(0==c&&0==u||r.translate(c,u),0!=p&&r.rotate(p*Math.PI/180),1==n&&1==a||r.scale(n,a),0==d&&0==f||r.translate(-d,-f))}t.alpha>0&&(r.globalAlpha*=t.alpha)},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},clear:function(t,e,i,r){this.context.clearRect(t,e,i,r)},resize:function(t,e){var i=this.canvas,r=this.stage,n=i.style;i.width=t,i.height=e,n.width=r.width*r.scaleX+"px",n.height=r.height*r.scaleY+"px"}});return r}),define("hilo/renderer/DOMRenderer",["hilo/core/Class","hilo/core/Hilo","hilo/renderer/Renderer","hilo/view/Drawable"],function(t,e,i,r){var n=function(){function a(t,i){var r=t.tagName||"div",n=i.image,a=t.width||n&&n.width,o=t.height||n&&n.height,s=e.createElement(r),h=s.style;if(t.id&&(s.id=t.id),h.position="absolute",h.left=(t.left||0)+"px",h.top=(t.top||0)+"px",h.width=a+"px",h.height=o+"px","canvas"==r){if(s.width=a,s.height=o,n){var l=s.getContext("2d"),c=i.rect||[0,0,a,o];l.drawImage(n,c[0],c[1],c[2],c[3],t.x||0,t.y||0,t.width||c[2],t.height||c[3])}}else if(h.opacity=void 0!=t.alpha?t.alpha:1,(t===this.stage||t.clipChildren)&&(h.overflow="hidden"),n&&n.src){h.backgroundImage="url("+n.src+")";var u=t.rectX||0,d=t.rectY||0;h.backgroundPosition=-u+"px "+-d+"px"}return s}return t.create({Extends:i,constructor:function(t){n.superclass.constructor.call(this,t)},renderType:"dom",startDraw:function(t){var e=t.drawable=t.drawable||new r;return e.domElement=e.domElement||a(t,e),!0},draw:function(t){var e=t.parent,i=t.drawable.domElement,r=i.parentNode;if(e){var n=e.drawable.domElement;if(n!=r&&n.appendChild(i),!t.width&&!t.height){var a=t.drawable.rect;a&&(a[2]||a[3])&&(t.width=a[2],t.height=a[3])}}else t!==this.stage||r||(i.style.overflow="hidden",this.canvas.appendChild(i))},transform:function(t){if(e.setElementStyleByView(t),t===this.stage){var i=this.canvas.style,r=t._scaleX,n=t._scaleY,a=t.scaleX,o=t.scaleY;(!r&&1!=a||r&&r!=a)&&(t._scaleX=a,i.width=a*t.width+"px"),(!n&&1!=o||n&&n!=o)&&(t._scaleY=o,i.height=o*t.height+"px")}},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},hide:function(t){var e=t.drawable&&t.drawable.domElement;e&&(e.style.display="none")},resize:function(t,e){var i=this.canvas.style;i.width=t+"px",i.height=e+"px","absolute"!=i.position&&(i.position="relative")}})}();return n}),define("hilo/renderer/WebGLRenderer",["hilo/core/Class","hilo/core/Hilo","hilo/renderer/Renderer","hilo/geom/Matrix"],function(t,e,i,r){var n=Math.PI/180,a=t.create({Extends:i,Statics:{MAX_BATCH_NUM:2e3,ATTRIBUTE_NUM:5,isSupport:function(){if(void 0==this._isSupported){var t=document.createElement("canvas");t.getContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))?this._isSupported=!0:this._isSupported=!1}return this._isSupported}},renderType:"webgl",gl:null,_isContextLost:!1,_cacheTexture:{},constructor:function(t){a.superclass.constructor.call(this,t);var e=this;this.gl=this.canvas.getContext("webgl")||this.canvas.getContext("experimental-webgl"),this.maxBatchNum=a.MAX_BATCH_NUM,this.positionStride=4*a.ATTRIBUTE_NUM;var i=this.maxBatchNum*a.ATTRIBUTE_NUM*4,r=6*this.maxBatchNum;this.arrayBuffer=new ArrayBuffer(4*i),this.float32Array=new Float32Array(this.arrayBuffer),this.uint32Array=new Uint32Array(this.arrayBuffer),this.indexs=new Uint16Array(r);for(var n=0,o=0;n0)&&(t===this.stage&&this.clear(),!0)},draw:function(t){var e=t.width,i=t.height,r=(t.background,t.drawable),n=r&&r.image;if(n){var a=r.rect,o=a[2],s=a[3];e||i||(e=t.width=o,i=t.height=s),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(n,a[0],a[1],o,s,0,0,e,i),l=this.batchIndex*this.positionStride,c=this.float32Array,u=this.uint32Array,d=(t.tint>>16)+(65280&t.tint)+((255&t.tint)<<16)+(255*t.__webglRenderAlpha<<24);c[l+0]=h[0],c[l+1]=h[1],c[l+2]=h[2],c[l+3]=h[3],u[l+4]=d,c[l+5]=h[4],c[l+6]=h[5],c[l+7]=h[6],c[l+8]=h[7],u[l+9]=d,c[l+10]=h[8],c[l+11]=h[9],c[l+12]=h[10],c[l+13]=h[11],u[l+14]=d,c[l+15]=h[12],c[l+16]=h[13],c[l+17]=h[14],c[l+18]=h[15],u[l+19]=d;for(var f=t.__webglWorldMatrix,p=0;p<4;p++){var v=c[l+5*p],m=c[l+5*p+1];c[l+5*p]=f.a*v+f.c*m+f.tx,c[l+5*p+1]=f.b*v+f.d*m+f.ty}t.__textureImage=n,this.sprites[this.batchIndex++]=t}},endDraw:function(t){t===this.stage&&this._renderBatches()},transform:function(t){var i=t.drawable;if(i&&i.domElement)return void e.setElementStyleByView(t);var n=t.scaleX,a=t.scaleY;if(t===this.stage){var o=this.canvas.style,s=t._scaleX,h=t._scaleY,l=!1;(!s&&1!=n||s&&s!=n)&&(t._scaleX=n,o.width=n*t.width+"px",l=!0),(!h&&1!=a||h&&h!=a)&&(t._scaleY=a,o.height=a*t.height+"px",l=!0),l&&t.updateViewport(),t.__webglWorldMatrix=t.__webglWorldMatrix||new r(1,0,0,1,0,0)}else t.parent&&(t.__webglWorldMatrix=t.__webglWorldMatrix||new r(1,0,0,1,0,0),this._setConcatenatedMatrix(t,t.parent));t.alpha>0&&(t.parent&&t.parent.__webglRenderAlpha?t.__webglRenderAlpha=t.alpha*t.parent.__webglRenderAlpha:t.__webglRenderAlpha=t.alpha)},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},clear:function(t,e,i,r){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(t,e){if(this.width!==t||this.height!==e){var i=this.canvas,r=this.stage,n=i.style;this.width=i.width=t,this.height=i.height=e,n.width=r.width*r.scaleX+"px",n.height=r.height*r.scaleY+"px",this.gl.viewport(0,0,t,e),this.canvasHalfWidth=.5*t,this.canvasHalfHeight=.5*e,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var t=this.gl;t.bufferSubData(t.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var e=0,i=0,r=null,n=0;n0&&(i.bindTexture(i.TEXTURE_2D,this._getTexture(this.sprites[t])),i.drawElements(i.TRIANGLES,6*r,i.UNSIGNED_SHORT,6*t*2))},_uploadProjectionTransform:function(t){this._projectionTransformElements&&!t||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var t=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",e="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new o(this,{v:t,f:e},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(t,e,i,r,n,a,o,s,h){var l=this.__tempVertexs||[],c=t.width,u=t.height;r/=c,n/=u,e/=c,i/=u,s=s,h=h,a=a,o=o,r+e>1&&(r=1-e),n+i>1&&(n=1-i);var d=0;return l[d++]=a,l[d++]=o,l[d++]=e,l[d++]=i,l[d++]=a+s,l[d++]=o,l[d++]=e+r,l[d++]=i,l[d++]=a,l[d++]=o+h,l[d++]=e,l[d++]=i+n,l[d++]=a+s,l[d++]=o+h,l[d++]=e+r,l[d++]=i+n,l},_setConcatenatedMatrix:function(t,e){var i=t.__webglWorldMatrix,r=1,a=0,o=t.rotation%360,s=t.pivotX,h=t.pivotY,l=t.scaleX,c=t.scaleY,u=t.transform;if(u)i.copy(u);else{if(o){var d=o*n;r=Math.cos(d),a=Math.sin(d)}var f=t.getAlignPosition();i.a=r*l,i.b=a*l,i.c=-a*c,i.d=r*c,i.tx=f.x-i.a*s-i.c*h,i.ty=f.y-i.b*s-i.d*h}i.concat(e.__webglWorldMatrix)},_getTexture:function(t){var e=t.__textureImage,i=this._cacheTexture[e.src];return i||(i=this.activeShader.uploadTexture(e)),i}}),o=function(t,e,i){this.renderer=t,this.gl=t.gl,this.program=this._createProgram(this.gl,e.v,e.f),i=i||{},this.attributes=i.attributes||[],this.uniforms=i.uniforms||[]};return o.prototype={active:function(){var t=this,e=t.renderer,i=t.gl,r=t.program;r&&i&&(e.activeShader=t,i.useProgram(r),t.attributes.forEach(function(t){e[t]=i.getAttribLocation(r,t),i.enableVertexAttribArray(e[t])}),t.uniforms.forEach(function(t){e[t]=i.getUniformLocation(r,t)}),t.width===e.width&&t.height===e.height||(t.width=e.width,t.height=e.height,e._uploadProjectionTransform()))},uploadTexture:function(t){var e=this.gl,i=this.renderer,r=e.createTexture(),n=i.u_Sampler;return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,r),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(n,0),e.bindTexture(e.TEXTURE_2D,null),this.renderer._cacheTexture[t.src]=r,r},_createProgram:function(t,e,i){var r=this._createShader(t,t.VERTEX_SHADER,e),n=this._createShader(t,t.FRAGMENT_SHADER,i);if(!r||!n)return null;var a=t.createProgram();if(a){t.attachShader(a,r),t.attachShader(a,n),t.linkProgram(a),t.deleteShader(n),t.deleteShader(r);var o=t.getProgramParameter(a,t.LINK_STATUS);if(!o){var s=t.getProgramInfoLog(a);return console.log("Failed to link program: "+s),t.deleteProgram(a),null}}return a},_createShader:function(t,e,i){var r=t.createShader(e);if(r){t.shaderSource(r,i),t.compileShader(r);var n=t.getShaderParameter(r,t.COMPILE_STATUS);if(!n){var a=t.getShaderInfoLog(r);return console.log("Failed to compile shader: "+a),t.deleteShader(r),null}}return r}},a}),define("hilo/view/View",["hilo/core/Hilo","hilo/core/Class","hilo/event/EventMixin","hilo/geom/Matrix","hilo/util/util"],function(t,e,i,r,n){var a=function(){function a(t,e,i){for(var r,n,a,o,s=0,h=!1,l=0,c=i.length;ld.x?(r=d.x,n=u.x):(r=u.x,n=d.x),t>=r&&t<=n))h=!0;else if(u.y>d.y?(a=d.y,o=u.y):(a=u.y,o=d.y),!(eo)){var f=(e-u.y)*(d.x-u.x)/(d.y-u.y)+u.x;if(f>t?s++:f==t&&(h=!0),u.x>t&&u.y==e){var p=i[(c+l-1)%c];(p.ye||p.y>e&&d.ys?s=c:cl?l=c:c=0)return!1;u>i.overlap&&(i.overlap=u,i.normal.x=p.x,i.normal.y=p.y)}return i}return e.create({Mixes:i,constructor:function(e){e=e||{},this.id=this.id||e.id||t.getUid("View"),n.copy(this,e,!0)},tint:16777215,id:null,x:0,y:0,width:0,height:0,alpha:1,rotation:0,visible:!0,pivotX:0,pivotY:0,scaleX:1,scaleY:1,pointerEnabled:!0,background:null,mask:null,align:null,drawable:null,boundsArea:null,parent:null,depth:-1,transform:null,blendMode:"source-over",getStage:function(){for(var t,e=this;t=e.parent;)e=t;return e.canvas?e:null},getScaledWidth:function(){return this.width*this.scaleX},getScaledHeight:function(){return this.height*this.scaleY},addTo:function(t,e){return"number"==typeof e?t.addChildAt(this,e):t.addChild(this),this},removeFromParent:function(){var t=this.parent;return t&&t.removeChild(this),this},getBounds:function(){for(var t,e,i,r,n,a,o,s=this.width,h=this.height,l=this.getConcatenatedMatrix(),c=this.boundsArea||[{x:0,y:0},{x:s,y:0},{x:s,y:h},{x:0,y:h}],u=[],d=0,f=c.length;de?r=e:ni?a=i:o>1,r=0;break;case"TR":i=o-n,r=0;break;case"L":i=0,r=s-a>>1;break;case"C":i=o-n>>1,r=s-a>>1;break;case"R":i=o-n,r=s-a>>1;break;case"BL":i=0,r=s-a;break;case"B":i=o-n>>1,r=s-a;break;case"BR":i=o-n,r=s-a}}return{x:i,y:r}},hitTestPoint:function(t,e,i){var r=this.getBounds(),n=t>=r.x&&t<=r.x+r.width&&e>=r.y&&e<=r.y+r.height;return n&&i&&(n=a(t,e,r)),n},hitTestObject:function(t,e){var i=this.getBounds(),r=t.getBounds(),n=i.x<=r.x+r.width&&r.x<=i.x+i.width&&i.y<=r.y+r.height&&r.y<=i.y+i.height;return n&&e&&(n=o(i,r)),!!n},_render:function(t,e){this.onUpdate&&this.onUpdate(e)===!1||!t.startDraw(this)||(t.transform(this),this.render(t,e),t.endDraw(this))},_fireMouseEvent:function(t){if(t.eventCurrentTarget=this,this.fire(t),"mousemove"==t.type){if(!this.__mouseOver){this.__mouseOver=!0;var e=n.copy({},t);e.type="mouseover",this.fire(e)}}else"mouseout"==t.type&&(this.__mouseOver=!1);var i=this.parent;t._stopped||t._stopPropagationed||!i||("mouseout"==t.type||"touchout"==t.type?i.hitTestPoint(t.stageX,t.stageY,!0)||i._fireMouseEvent(t):i._fireMouseEvent(t))},onUpdate:null,render:function(t,e){t.draw(this)},toString:function(){return t.viewToString(this)}})}();return a}),define("hilo/view/CacheMixin",["hilo/view/Drawable","hilo/util/browser"],function(t,e){var i,r,n={_cacheDirty:!0,cache:function(t){(t||this._cacheDirty||!this.drawable)&&this.updateCache()},updateCache:function(){e.supportCanvas&&(i||(i=document.createElement("canvas"),r=i.getContext("2d")),i.width=this.width,i.height=this.height,this._draw(r),this.drawable=this.drawable||new t,this.drawable.init({image:i.toDataURL()}),this._cacheDirty=!1)},setCacheDirty:function(t){this._cacheDirty=t}};return n}),define("hilo/view/Container",["hilo/core/Hilo","hilo/core/Class","hilo/view/View"],function(t,e,i){var r=e.create({Extends:i,constructor:function(e){e=e||{},this.id=this.id||e.id||t.getUid("Container"),r.superclass.constructor.call(this,e),this.children?this._updateChildren():this.children=[]},children:null,pointerChildren:!0,clipChildren:!1,getNumChildren:function(){return this.children.length},addChildAt:function(t,e){var i=this.children,r=i.length,n=t.parent;e=e<0?0:e>r?r:e;var a=this.getChildIndex(t);if(a==e)return this;if(a>=0?(i.splice(a,1),e=e==r?r-1:e):n&&n.removeChild(t),i.splice(e,0,t),a<0)this._updateChildren(e);else{var o=a=e.length)return null;var i=e[t];if(i){if(!i.__renderer)for(var r=i;r=r.parent;){if(r.renderer){i.__renderer=r.renderer;break}if(r.__renderer){i.__renderer=r.__renderer;break}}i.__renderer&&i.__renderer.remove(i),i.parent=null,i.depth=-1}return e.splice(t,1),this._updateChildren(t),i},removeChild:function(t){return this.removeChildAt(this.getChildIndex(t))},removeChildById:function(t){for(var e,i=this.children,r=0,n=i.length;r=e.length?null:e[t]},getChildById:function(t){for(var e,i=this.children,r=0,n=i.length;r=0&&r!=e){var n=i.length;e=e<0?0:e>=n?n-1:e,i.splice(r,1),i.splice(e,0,t),this._updateChildren()}return this},swapChildren:function(t,e){var i=this.children,r=this.getChildIndex(t),n=this.getChildIndex(e);t.depth=n,i[n]=t,e.depth=r,i[r]=e},swapChildrenAt:function(t,e){var i=this.children,r=this.getChildAt(t),n=this.getChildAt(e);r.depth=e,i[e]=r,n.depth=t,i[t]=n},sortChildren:function(t){var e=t,i=this.children;if("string"==typeof e){var r=e;e=function(t,e){return e[r]-t[r]}}i.sort(e),this._updateChildren()},_updateChildren:function(t,e){var i,r=this.children;t=t||0,e=e||r.length;for(var n=t;n=0;l--)if(a=h[l],!(!a||!a.visible||a.alpha<=0||n&&!a.pointerEnabled))if(a.children&&a.children.length&&(!n||a.pointerChildren)&&(o=a.getViewAtPoint(t,e,i,r,n)),o){if(!r)return o;o.length&&(s=s.concat(o))}else if(a.hitTestPoint(t,e,i)){if(!r)return a;s.push(a)}return r&&s.length?s:null},render:function(t,e){r.superclass.render.call(this,t,e);var i,n,a,o=this.children.slice(0);for(i=0,n=o.length;ir?r:e,i[e]=t,t.name&&(this._frameNames[t.name]=t),(0!=e||this.width)&&this.height||(this.width=t.rect[2],this.height=t.rect[3]),this},getFrame:function(t){if("number"==typeof t){var e=this._frames;return t<0||t>=e.length?null:e[t]}return this._frameNames[t]},getFrameIndex:function(t){var e=this._frames,i=e.length,r=-1;if("number"==typeof t)r=t;else{var n="string"==typeof t?this._frameNames[t]:t;if(n)for(var a=0;a=i?i-1:r,this.paused=e,this._firstRender=!0,this},_render:function(t,e){var i,r=this.currentFrame;if(this._firstRender?(i=r,this._firstRender=!1):i=this._nextFrame(e),i!=r){this.currentFrame=i;var a=this._frames[i].callback;a&&a.call(this)}this.onEnterFrame&&this.onEnterFrame(i),this.drawable.init(this._frames[i]),n.superclass._render.call(this,t,e)},_nextFrame:function(t){var e=this._frames,i=e.length,r=this.currentFrame,n=e[r],a=n.duration||this.interval,o=this._frameElapsed,s=0!=r||this.drawable?o+(this.timeBased?t:1):0;return o=this._frameElapsed=s=i-1)&&this.stop(),this.paused||0!=o||(null!=n.next?r=this.getFrameIndex(n.next):r>=i-1?r=0:this.drawable&&r++),r},setFrameCallback:function(t,e){return t=this.getFrame(t),t&&(t.callback=e),this},onEnterFrame:null});return n}),define("hilo/view/DOMElement",["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/Drawable"],function(t,e,i,r){var n=e.create({Extends:i,constructor:function(e){e=e||{},this.id=this.id||e.id||t.getUid("DOMElement"),n.superclass.constructor.call(this,e),this.drawable=new r;var i=this.drawable.domElement=e.element||t.createElement("div");i.id=this.id,this.pointerEnabled&&!i.style.pointerEvents&&(i.style.pointerEvents="visible")},_render:function(t,e){this.onUpdate&&this.onUpdate(e)===!1||(t.transform(this),this.visible&&this.alpha>0&&this.render(t,e))},render:function(e,i){if("dom"!==e.renderType){var r=e.canvas,n=this.parent,a=e._domElementContainer;e._domElementContainer||(a=e._domElementContainer=t.createElement("div",{style:{position:"absolute",transform:"scale3d("+n.scaleX+","+n.scaleY+", 1)",transformOrigin:"0 0",zIndex:"1"}}),r.parentNode.insertBefore(e._domElementContainer,r.nextSibling));var o,s=this.drawable.domElement,h=this.depth,l=a.childNodes[0];if(s.parentNode)return;for(;l&&3!=l.nodeType&&(o=parseInt(l.style.zIndex)||0,!(o<=0||o>h));)l=l.nextSibling;a.insertBefore(this.drawable.domElement,l)}else e.draw(this)}});return n}),define("hilo/view/Graphics",["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/CacheMixin"],function(t,e,i,r){var n=function(){var a=document.createElement("canvas"),o=a.getContext&&a.getContext("2d");return e.create({Extends:i,Mixes:r,constructor:function(e){e=e||{},this.id=this.id||e.id||t.getUid("Graphics"),n.superclass.constructor.call(this,e),this._actions=[]},lineWidth:1,lineAlpha:1,lineCap:null,lineJoin:null,miterLimit:10,hasStroke:!1,strokeStyle:"0",hasFill:!1,fillStyle:"0",fillAlpha:0,lineStyle:function(t,e,i,r,n,a){var o=this,s=o._addAction;return s.call(o,["lineWidth",o.lineWidth=t||1]),s.call(o,["strokeStyle",o.strokeStyle=e||"0"]),s.call(o,["lineAlpha",o.lineAlpha=i||1]),void 0!=r&&s.call(o,["lineCap",o.lineCap=r]),void 0!=n&&s.call(o,["lineJoin",o.lineJoin=n]),void 0!=a&&s.call(o,["miterLimit",o.miterLimit=a]),o.hasStroke=!0,o},setLineDash:function(t){return this._addAction(["setLineDash",t])},beginFill:function(t,e){var i=this,r=i._addAction;return r.call(i,["fillStyle",i.fillStyle=t]),r.call(i,["fillAlpha",i.fillAlpha=e||1]),i.hasFill=!0,i},endFill:function(){var t=this,e=t._addAction;return t.hasStroke&&e.call(t,["stroke"]),t.hasFill&&e.call(t,["fill"]),t.setCacheDirty(!0),t},beginLinearGradientFill:function(t,e,i,r,n,a){for(var s=this,h=o.createLinearGradient(t,e,i,r),l=0,c=n.length;l1?a.slice(1):null;"function"==typeof t[o]?t[o].apply(t,s):t[o]=a[1]}},render:function(t,e){var i=this;"canvas"===t.renderType?i._draw(t.context):(i.cache(),t.draw(i))},clear:function(){var t=this;return t._actions.length=0,t.lineWidth=1,t.lineAlpha=1,t.lineCap=null,t.lineJoin=null,t.miterLimit=10,t.hasStroke=!1,t.strokeStyle="0",t.hasFill=!1,t.fillStyle="0",t.fillAlpha=1,t.setCacheDirty(!0),t},_addAction:function(t){var e=this;return e._actions.push(t),e}})}();return n}),define("hilo/view/Text",["hilo/core/Class","hilo/core/Hilo","hilo/view/View","hilo/view/CacheMixin"],function(t,e,i,r){var n=t.create({Extends:i,Mixes:r,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("Text"),n.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=n.measureFontHeight(this.font)},text:null,color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=n.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var r=i.drawable,n=r.domElement,a=n.style;a.font=i.font,a.textAlign=i.textAlign,a.color=i.color,a.width=i.width+"px",a.height=i.height+"px",a.lineHeight=i._fontHeight+i.lineSpacing+"px",n.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var r,n,a,o,s,h=i.split(/\r\n|\r|\n|/),l=0,c=0,u=e._fontHeight+e.lineSpacing,d=[];for(r=0,o=h.length;re.maxWidth?(d.push({text:m,y:c}),l>1;break;case"bottom":_=e.height-e.textHeight}var x=e.background;for(x&&(t.fillStyle=x,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,r=0;r>1;break;case"right":case"end":n=a}r.outline?t.strokeText(e,n,i):t.fillText(e,n,i)},Statics:{measureFontHeight:function(t){var i,r=document.documentElement,n=e.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return r.appendChild(n),i=n.offsetHeight,r.removeChild(n),i}}});return n}),define("hilo/view/BitmapText",["hilo/core/Class","hilo/core/Hilo","hilo/view/Container","hilo/view/Bitmap"],function(t,e,i,r){var n=t.create({Extends:i,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("BitmapText"),n.superclass.constructor.call(this,t);var i=t.text+"";i&&(this.text="",this.setText(i)),this.pointerChildren=!1},glyphs:null,letterSpacing:0,text:"",textAlign:"left",setText:function(t){var e=this,i=t.toString(),r=i.length;if(e.text!=i){e.text=i;var n,a,o,s,h=0,l=0,c=0;for(n=0;n0?e.letterSpacing:0),e.children[n]?(s=e.children[n],s.setImage(o.image,o.rect)):(s=e._createBitmap(o),e.addChild(s)),s.x=c,h=c+o.rect[2],l=Math.max(l,o.rect[3]));for(n=e.children.length-1;n>=r;n--)e._releaseBitmap(e.children[n]),e.children[n].removeFromParent();return e.width=h,e.height=l,this.setTextAlign(),e}},_createBitmap:function(t){var e;return n._pool.length?(e=n._pool.pop(),e.setImage(t.image,t.rect)):e=new r({image:t.image,rect:t.rect}),e},_releaseBitmap:function(t){n._pool.push(t)},setTextAlign:function(t){switch(this.textAlign=t||this.textAlign,this.textAlign){case"center":this.pivotX=.5*this.width;break;case"right":this.pivotX=this.width;break;case"left":default:this.pivotX=0}return this},hasGlyphs:function(t){var e=this.glyphs;if(!e)return!1;t=t.toString();var i,r=t.length;for(i=0;i=this._targetFPS?(this._measuredFPS=1e3/(this._tickTime/this._tickCount)+.5>>0,this._tickCount=0,this._tickTime=0):this._tickTime+=t-this._lastTime,this._lastTime=t;for(var r=i.slice(0),n=0,a=r.length;n=0&&e.splice(i,1)},nextTick:function(t){var e=this,i={tick:function(r){e.removeTick(i),t()}};return e.addTick(i),i},timeout:function(t,e){var i=this,r=(new Date).getTime()+e,n={tick:function(){var e=(new Date).getTime(),a=e-r;a>=0&&(i.removeTick(n),t())}};return i.addTick(n),n},interval:function(t,e){var i=this,r=(new Date).getTime()+e,n={tick:function(){var i=(new Date).getTime(),n=i-r;n>=0&&(n=r)return-1;for(e<0&&(e=r+e),i=e;i=1?1:s;var l=n.ease?n.ease(s):s;n.reverse&&(n._reverseFlag<0&&(s=1-s,l=1-l),s<1e-7&&(n.repeat>0&&n._repeatCount++>=n.repeat||0==n.repeat&&!n.loop?h=!0:(n._startTime=i(),n._pausedTime=0,n._reverseFlag*=-1))),n.isStart||(n.setProps(n._fromProps,n._toProps),n.isStart=!0,n.onStart&&n.onStart.call(n,n)),n.time=a,n._render(l),(o=n.onUpdate)&&o.call(n,s,n),s>=1&&(n.reverse?(n._startTime=i(),n._pausedTime=0,n._reverseFlag*=-1):n.loop||n.repeat>0&&n._repeatCount++0&&u<=t?(c._render(s),c.time=a,e.add(c)):h&&(u<0||u>t)&&c.start()}return h?((o=n.onComplete)&&o.call(n,n),!0):void 0}}},Statics:{_tweens:[],tick:function(){var t,r,n=e._tweens,a=n.length;for(r=0;r-1&&n.splice(i,1);else for(i=0;i=i)return void t.fire("complete");if(t._currentIndexe.z})},tick:function(){this.sortZ()}});return o}();return i}),define("hilo/game/ParticleSystem",["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/Container","hilo/view/Drawable","hilo/util/util"],function(t,e,i,r,n,a){var o=function(){function o(t,e){return e?t+2*(Math.random()-.5)*e:t}for(var s=["x","y","vx","vy","ax","ay","rotation","rotationV","scale","scaleV","alpha","alphaV","life"],h=[],l=0,c=s.length;l=this._emitTime&&(this._currentRunTime=0,this._emitTime=o(this.emitTime,this.emitTimeVar),this._emit()),this._totalRunTime>=this.totalTime&&this.stop())},_emit:function(){for(var t=o(this.emitNum,this.emitNumVar)>>0,e=0;e=0;e--)this.children[e].destroy()}}),v=e.create({Extends:i,constructor:function(e){this.id=this.id||e.id||t.getUid("Particle"),v.superclass.constructor.call(this,e),this.init(e)},onUpdate:function(t){if(t*=.001,this._died)return!1;var e=this.ax+this.system.gx,i=this.ay+this.system.gy;return this.vx+=e*t,this.vy+=i*t,this.x+=this.vx*t,this.y+=this.vy*t,this.rotation+=this.rotationV,this._time>.1&&(this.alpha+=this.alphaV),this.scale+=this.scaleV,this.scaleX=this.scaleY=this.scale,this._time+=t,this._time>=this.life||this.alpha<=0?(this.destroy(),!1):void 0},setImage:function(t,e){this.drawable=this.drawable||new n,e=e||[0,0,t.width,t.height],this.width=e[2],this.height=e[3],this.drawable.rect=e,this.drawable.image=t},destroy:function(){this._died=!0,this.alpha=0,this.removeFromParent(),f.push(this)},init:function(t){this.system=t.system,this._died=!1,this._time=0,this.alpha=1;for(var e=0,i=h.length;e>0]),this.setImage(t.image,a),void 0!==t.pivotX&&(this.pivotX=t.pivotX*a[2]),void 0!==t.pivotY&&(this.pivotY=t.pivotY*a[3])}},Statics:{create:function(t){if(f.length>0){var e=f.pop();return e.init(t),e}return new v(t)}}});return p}();return o}); \ No newline at end of file +define("hilo/util/browser",function(){var t=function(){var t=navigator.userAgent,e=document,i=window,r=e.documentElement,n={iphone:/iphone/i.test(t),ipad:/ipad/i.test(t),ipod:/ipod/i.test(t),ios:/iphone|ipad|ipod/i.test(t),android:/android/i.test(t),webkit:/webkit/i.test(t),chrome:/chrome/i.test(t),safari:/safari/i.test(t),firefox:/firefox/i.test(t),ie:/msie/i.test(t),opera:/opera/i.test(t),supportTouch:"ontouchstart"in i,supportCanvas:null!=e.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in i||"orientation"in i.screen,supportDeviceMotion:"ondevicemotion"in i};try{var a="hilo";localStorage.setItem(a,a),localStorage.removeItem(a),n.supportStorage=!0}catch(o){}var s=n.jsVendor=n.webkit?"webkit":n.firefox?"webkit":n.opera?"o":n.ie?"ms":"",h=n.cssVendor="-"+s+"-",l=e.createElement("div"),c=l.style,u=void 0!=c[s+"Transform"],d=void 0!=c[s+"Perspective"];d&&(l.id="test3d",c=e.createElement("style"),c.textContent="@media ("+h+"transform-3d){#test3d{height:3px}}",e.head.appendChild(c),r.appendChild(l),d=3==l.offsetHeight,e.head.removeChild(c),r.removeChild(l)),n.supportTransform=u,n.supportTransform3D=d;var f=n.supportTouch,p=f?"touchstart":"mousedown",v=f?"touchmove":"mousemove",m=f?"touchend":"mouseup";return n.POINTER_START=p,n.POINTER_MOVE=v,n.POINTER_END=m,n}();return t}),define("hilo/util/util",function(){var t={copy:function(t,e,i){for(var r in e)i&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t}};return t}),define("hilo/core/Hilo",["hilo/util/browser","hilo/util/util"],function(t,e){var i=window,r=document,n=r.documentElement,a=0,o={},s={version:"1.4.0",getUid:function(t){var e=++a;if(t){var i=t.charCodeAt(t.length-1);return i>=48&&i<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,i=t;i;)e=e?i.id+"."+e:i.id,i=i.parent;return e},copy:function(t,i,r){return e.copy(t,i,r),o.copy||(o.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),t},browser:t,event:{POINTER_START:t.POINTER_START,POINTER_MOVE:t.POINTER_MOVE,POINTER_END:t.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(t){var e;try{e=t.getBoundingClientRect()}catch(r){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var a=(i.pageXOffset||n.scrollLeft)-(n.clientLeft||0)||0,o=(i.pageYOffset||n.scrollTop)-(n.clientTop||0)||0,s=i.getComputedStyle?getComputedStyle(t):t.currentStyle,h=parseInt,l=h(s.paddingLeft)+h(s.borderLeftWidth)||0,c=h(s.paddingTop)+h(s.borderTopWidth)||0,u=h(s.paddingRight)+h(s.borderRightWidth)||0,d=h(s.paddingBottom)+h(s.borderBottomWidth)||0,f=e.top||0,p=e.left||0,v=e.right||0,m=e.bottom||0;return{left:p+a+l,top:f+o+c,width:v-u-p-l,height:m-d-f-c}},createElement:function(t,e){var i,n,a,o=r.createElement(t);for(i in e)if(n=e[i],"style"===i)for(a in n)o.style[a]=n[a];else o[i]=n;return o},getElement:function(t){return r.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,i=e.domElement.style,r=t._stateCache||(t._stateCache={}),n=s.browser.jsVendor,a="px",o=!1;if(this.cacheStateIfChanged(t,["visible"],r)&&(i.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],r)&&(i.opacity=t.alpha),t.visible&&!(t.alpha<=0)){if(this.cacheStateIfChanged(t,["width"],r)&&(i.width=t.width+a),this.cacheStateIfChanged(t,["height"],r)&&(i.height=t.height+a),this.cacheStateIfChanged(t,["depth"],r)&&(i.zIndex=t.depth+1),t.transform){var h=t.transform;(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(i[n+"TransformOrigin"]="0 0"),i[n+"Transform"]="matrix3d("+h.a+", "+h.b+", 0, 0, "+h.c+", "+h.d+", 0, 0, 0, 0, 1, 0, "+h.tx+", "+h.ty+", 0, 1)"}else(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(i[n+"TransformOrigin"]=t.pivotX+a+" "+t.pivotY+a),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],r)||o)&&(i[n+"Transform"]=this.getTransformCSS(t));this.cacheStateIfChanged(t,["background"],r)&&(i.backgroundColor=t.background),i.pointerEvents||(i.pointerEvents="none");var l=e.image;if(l){var c=l.src;c!==r.image&&(r.image=c,i.backgroundImage="url("+c+")");var u=e.rect;if(u){var d=u[0],f=u[1];d!==r.sx&&(r.sx=d,i.backgroundPositionX=-d+a),f!==r.sy&&(r.sy=f,i.backgroundPositionY=-f+a)}}var p=t.mask;if(p){var v=p.drawable.domElement.style.backgroundImage;v!==r.maskImage&&(r.maskImage=v,i[n+"MaskImage"]=v,i[n+"MaskRepeat"]="no-repeat");var m=p.x,g=p.y;m===r.maskX&&g===r.maskY||(r.maskX=m,r.maskY=g,i[n+"MaskPosition"]=m+a+" "+g+a)}}},cacheStateIfChanged:function(t,e,i){var r,n,a,o,s=!1;for(r=0,n=e.length;r=6?(e=s[0],i=s[1],r=s[2],n=s[3],a=s[4],o=s[5]):(e=t.a,i=t.b,r=t.c,n=t.d,a=t.tx,o=t.ty),this.a=h*e+l*r,this.b=h*i+l*n,this.c=c*e+u*r,this.d=c*i+u*n,this.tx=d*e+f*r+a,this.ty=d*i+f*n+o,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),r=this.a,n=this.b,a=this.c,o=this.d,s=this.tx,h=this.ty;return this.a=r*i-n*e,this.b=r*e+n*i,this.c=a*i-o*e,this.d=a*e+o*i,this.tx=s*i-h*e,this.ty=s*e+h*i,this},scale:function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},translate:function(t,e){return this.tx+=t,this.ty+=e,this},identity:function(){return this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this},invert:function(){var t=this.a,e=this.b,i=this.c,r=this.d,n=this.tx,a=t*r-e*i;return this.a=r/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-r*n)/a,this.ty=-(t*this.ty-e*n)/a,this},transformPoint:function(t,e,i){var r=t.x*this.a+t.y*this.c+this.tx,n=t.x*this.b+t.y*this.d+this.ty;return e&&(r=r+.5>>0,n=n+.5>>0),i?{x:r,y:n}:(t.x=r,t.y=n,t)}});return e}),define("hilo/event/EventMixin",["hilo/core/Class"],function(t){var e={_listeners:null,on:function(t,e,i){for(var r=this._listeners=this._listeners||{},n=r[t]=r[t]||[],a=0,o=n.length;a-1&&o.splice(c,1)}}return 0==o.length&&delete a[n],!0}return!1}},i=t.create({constructor:function(t,e,i){this.type=t,this.target=e,this.detail=i,this.timeStamp=+new Date},type:null,target:null,detail:null,timeStamp:0,stopImmediatePropagation:function(){this._stopped=!0}}),r=window.Event;if(r){var n=r.prototype,a=n.stopImmediatePropagation;n.stopImmediatePropagation=function(){a&&a.call(this),this._stopped=!0}}return e}),define("hilo/view/Drawable",["hilo/core/Class","hilo/util/util"],function(t,e){var i=t.create({constructor:function(t){this.init(t)},image:null,rect:null,init:function(t){var r=this,n=r.image;i.isDrawable(t)?r.image=t:e.copy(r,t,!0);var a=r.image;if("string"==typeof a){if(!n||a!==n.getAttribute("src")){r.image=null;var o=new Image;return t.crossOrigin&&(o.crossOrigin=t.crossOrigin),o.onload=function(){o.onload=null,r.init(o)},void(o.src=a)}a=r.image=n}a&&!r.rect&&(r.rect=[0,0,a.width,a.height])},Statics:{isDrawable:function(t){if(!t||!t.tagName)return!1;var e=t.tagName.toLowerCase();return"img"===e||"canvas"===e||"video"===e}}});return i}),define("hilo/renderer/Renderer",["hilo/core/Class","hilo/util/util"],function(t,e){var i=t.create({constructor:function(t){t=t||{},e.copy(this,t,!0)},renderType:null,canvas:null,stage:null,blendMode:"source-over",startDraw:function(t){},draw:function(t){},endDraw:function(t){},transform:function(){},hide:function(){},remove:function(t){},clear:function(t,e,i,r){},resize:function(t,e){}});return i}),define("hilo/renderer/CanvasRenderer",["hilo/core/Class","hilo/core/Hilo","hilo/renderer/Renderer"],function(t,e,i){var r=t.create({Extends:i,constructor:function(t){r.superclass.constructor.call(this,t),this.context=this.canvas.getContext("2d")},renderType:"canvas",context:null,startDraw:function(t){return!!(t.visible&&t.alpha>0)&&(t===this.stage&&this.context.clearRect(0,0,t.width,t.height),t.blendMode!==this.blendMode&&(this.context.globalCompositeOperation=this.blendMode=t.blendMode),this.context.save(),!0)},draw:function(t){var e=this.context,i=t.width,r=t.height,n=t.background;n&&(e.fillStyle=n,e.fillRect(0,0,i,r));var a=t.drawable,o=a&&a.image;if(o){var s=a.rect,h=s[2],l=s[3],c=s[4],u=s[5];if(!h||!l)return;i||r||(i=t.width=h,r=t.height=l),(c||u)&&e.translate(c-.5*h,u-.5*l),e.drawImage(o,s[0],s[1],h,l,0,0,i,r)}},endDraw:function(t){this.context.restore()},transform:function(t){var i=t.drawable;if(i&&i.domElement)return void e.setElementStyleByView(t);var r=this.context,n=t.scaleX,a=t.scaleY;if(t===this.stage){var o=this.canvas.style,s=t._scaleX,h=t._scaleY,l=!1;(!s&&1!=n||s&&s!=n)&&(t._scaleX=n,o.width=n*t.width+"px",l=!0),(!h&&1!=a||h&&h!=a)&&(t._scaleY=a,o.height=a*t.height+"px",l=!0),l&&t.updateViewport()}else{var c=t.x,u=t.y,d=t.pivotX,f=t.pivotY,p=t.rotation%360,v=t.transform,m=t.mask;m&&(m._render(this),r.clip());var g=t.align;if(g){var _=t.getAlignPosition();c=_.x,u=_.y}v?r.transform(v.a,v.b,v.c,v.d,v.tx,v.ty):(0==c&&0==u||r.translate(c,u),0!=p&&r.rotate(p*Math.PI/180),1==n&&1==a||r.scale(n,a),0==d&&0==f||r.translate(-d,-f))}t.alpha>0&&(r.globalAlpha*=t.alpha)},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},clear:function(t,e,i,r){this.context.clearRect(t,e,i,r)},resize:function(t,e){var i=this.canvas,r=this.stage,n=i.style;i.width=t,i.height=e,n.width=r.width*r.scaleX+"px",n.height=r.height*r.scaleY+"px"}});return r}),define("hilo/renderer/DOMRenderer",["hilo/core/Class","hilo/core/Hilo","hilo/renderer/Renderer","hilo/view/Drawable"],function(t,e,i,r){var n=function(){function a(t,i){var r=t.tagName||"div",n=i.image,a=t.width||n&&n.width,o=t.height||n&&n.height,s=e.createElement(r),h=s.style;if(t.id&&(s.id=t.id),h.position="absolute",h.left=(t.left||0)+"px",h.top=(t.top||0)+"px",h.width=a+"px",h.height=o+"px","canvas"==r){if(s.width=a,s.height=o,n){var l=s.getContext("2d"),c=i.rect||[0,0,a,o];l.drawImage(n,c[0],c[1],c[2],c[3],t.x||0,t.y||0,t.width||c[2],t.height||c[3])}}else if(h.opacity=void 0!=t.alpha?t.alpha:1,(t===this.stage||t.clipChildren)&&(h.overflow="hidden"),n&&n.src){h.backgroundImage="url("+n.src+")";var u=t.rectX||0,d=t.rectY||0;h.backgroundPosition=-u+"px "+-d+"px"}return s}return t.create({Extends:i,constructor:function(t){n.superclass.constructor.call(this,t)},renderType:"dom",startDraw:function(t){var e=t.drawable=t.drawable||new r;return e.domElement=e.domElement||a(t,e),!0},draw:function(t){var e=t.parent,i=t.drawable.domElement,r=i.parentNode;if(e){var n=e.drawable.domElement;if(n!=r&&n.appendChild(i),!t.width&&!t.height){var a=t.drawable.rect;a&&(a[2]||a[3])&&(t.width=a[2],t.height=a[3])}}else t!==this.stage||r||(i.style.overflow="hidden",this.canvas.appendChild(i))},transform:function(t){if(e.setElementStyleByView(t),t===this.stage){var i=this.canvas.style,r=t._scaleX,n=t._scaleY,a=t.scaleX,o=t.scaleY;(!r&&1!=a||r&&r!=a)&&(t._scaleX=a,i.width=a*t.width+"px"),(!n&&1!=o||n&&n!=o)&&(t._scaleY=o,i.height=o*t.height+"px")}},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},hide:function(t){var e=t.drawable&&t.drawable.domElement;e&&(e.style.display="none")},resize:function(t,e){var i=this.canvas.style;i.width=t+"px",i.height=e+"px","absolute"!=i.position&&(i.position="relative")}})}();return n}),define("hilo/renderer/WebGLRenderer",["hilo/core/Class","hilo/core/Hilo","hilo/renderer/Renderer","hilo/geom/Matrix"],function(t,e,i,r){var n=Math.PI/180,a=t.create({Extends:i,Statics:{MAX_BATCH_NUM:2e3,ATTRIBUTE_NUM:5,isSupport:function(){if(void 0==this._isSupported){var t=document.createElement("canvas");t.getContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))?this._isSupported=!0:this._isSupported=!1}return this._isSupported},contextOptions:null},renderType:"webgl",gl:null,_isContextLost:!1,_cacheTexture:{},constructor:function(t){a.superclass.constructor.call(this,t);var e=this,i=a.contextOptions||{};this.gl=this.canvas.getContext("webgl",i)||this.canvas.getContext("experimental-webgl",i),this.maxBatchNum=a.MAX_BATCH_NUM,this.positionStride=4*a.ATTRIBUTE_NUM;var r=this.maxBatchNum*a.ATTRIBUTE_NUM*4,n=6*this.maxBatchNum;this.arrayBuffer=new ArrayBuffer(4*r),this.float32Array=new Float32Array(this.arrayBuffer),this.uint32Array=new Uint32Array(this.arrayBuffer),this.indexs=new Uint16Array(n);for(var o=0,s=0;o0)&&(t===this.stage&&this.clear(),!0)},draw:function(t){var e=t.width,i=t.height,r=(t.background,t.drawable),n=r&&r.image;if(n){var a=r.rect,o=a[2],s=a[3];e||i||(e=t.width=o,i=t.height=s),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(n,a[0],a[1],o,s,0,0,e,i),l=this.batchIndex*this.positionStride,c=this.float32Array,u=this.uint32Array,d=(t.tint>>16)+(65280&t.tint)+((255&t.tint)<<16)+(255*t.__webglRenderAlpha<<24);c[l+0]=h[0],c[l+1]=h[1],c[l+2]=h[2],c[l+3]=h[3],u[l+4]=d,c[l+5]=h[4],c[l+6]=h[5],c[l+7]=h[6],c[l+8]=h[7],u[l+9]=d,c[l+10]=h[8],c[l+11]=h[9],c[l+12]=h[10],c[l+13]=h[11],u[l+14]=d,c[l+15]=h[12],c[l+16]=h[13],c[l+17]=h[14],c[l+18]=h[15],u[l+19]=d;for(var f=t.__webglWorldMatrix,p=0;p<4;p++){var v=c[l+5*p],m=c[l+5*p+1];c[l+5*p]=f.a*v+f.c*m+f.tx,c[l+5*p+1]=f.b*v+f.d*m+f.ty}t.__textureImage=n,this.sprites[this.batchIndex++]=t}},endDraw:function(t){t===this.stage&&this._renderBatches()},transform:function(t){var i=t.drawable;if(i&&i.domElement)return void e.setElementStyleByView(t);var n=t.scaleX,a=t.scaleY;if(t===this.stage){var o=this.canvas.style,s=t._scaleX,h=t._scaleY,l=!1;(!s&&1!=n||s&&s!=n)&&(t._scaleX=n,o.width=n*t.width+"px",l=!0),(!h&&1!=a||h&&h!=a)&&(t._scaleY=a,o.height=a*t.height+"px",l=!0),l&&t.updateViewport(),t.__webglWorldMatrix=t.__webglWorldMatrix||new r(1,0,0,1,0,0)}else t.parent&&(t.__webglWorldMatrix=t.__webglWorldMatrix||new r(1,0,0,1,0,0),this._setConcatenatedMatrix(t,t.parent));t.alpha>0&&(t.parent&&t.parent.__webglRenderAlpha?t.__webglRenderAlpha=t.alpha*t.parent.__webglRenderAlpha:t.__webglRenderAlpha=t.alpha)},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},clear:function(t,e,i,r){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(t,e){if(this.width!==t||this.height!==e){var i=this.canvas,r=this.stage,n=i.style;this.width=i.width=t,this.height=i.height=e,n.width=r.width*r.scaleX+"px",n.height=r.height*r.scaleY+"px",this.gl.viewport(0,0,t,e),this.canvasHalfWidth=.5*t,this.canvasHalfHeight=.5*e,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var t=this.gl;t.bufferSubData(t.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var e=0,i=0,r=null,n=0;n0&&(i.bindTexture(i.TEXTURE_2D,this._getTexture(this.sprites[t])),i.drawElements(i.TRIANGLES,6*r,i.UNSIGNED_SHORT,6*t*2))},_uploadProjectionTransform:function(t){this._projectionTransformElements&&!t||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var t=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",e="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new o(this,{v:t,f:e},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(t,e,i,r,n,a,o,s,h){var l=this.__tempVertexs||[],c=t.width,u=t.height;r/=c,n/=u,e/=c,i/=u,s=s,h=h,a=a,o=o,r+e>1&&(r=1-e),n+i>1&&(n=1-i);var d=0;return l[d++]=a,l[d++]=o,l[d++]=e,l[d++]=i,l[d++]=a+s,l[d++]=o,l[d++]=e+r,l[d++]=i,l[d++]=a,l[d++]=o+h,l[d++]=e,l[d++]=i+n,l[d++]=a+s,l[d++]=o+h,l[d++]=e+r,l[d++]=i+n,l},_setConcatenatedMatrix:function(t,e){var i=t.__webglWorldMatrix,r=1,a=0,o=t.rotation%360,s=t.pivotX,h=t.pivotY,l=t.scaleX,c=t.scaleY,u=t.transform;if(u)i.copy(u);else{if(o){var d=o*n;r=Math.cos(d),a=Math.sin(d)}var f=t.getAlignPosition();i.a=r*l,i.b=a*l,i.c=-a*c,i.d=r*c,i.tx=f.x-i.a*s-i.c*h,i.ty=f.y-i.b*s-i.d*h}i.concat(e.__webglWorldMatrix)},_getTexture:function(t){var e=t.__textureImage,i=this._cacheTexture[e.src];return i||(i=this.activeShader.uploadTexture(e)),i}}),o=function(t,e,i){this.renderer=t,this.gl=t.gl,this.program=this._createProgram(this.gl,e.v,e.f),i=i||{},this.attributes=i.attributes||[],this.uniforms=i.uniforms||[]};return o.prototype={active:function(){var t=this,e=t.renderer,i=t.gl,r=t.program;r&&i&&(e.activeShader=t,i.useProgram(r),t.attributes.forEach(function(t){e[t]=i.getAttribLocation(r,t),i.enableVertexAttribArray(e[t])}),t.uniforms.forEach(function(t){e[t]=i.getUniformLocation(r,t)}),t.width===e.width&&t.height===e.height||(t.width=e.width,t.height=e.height,e._uploadProjectionTransform()))},uploadTexture:function(t){var e=this.gl,i=this.renderer,r=e.createTexture(),n=i.u_Sampler;return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,r),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(n,0),e.bindTexture(e.TEXTURE_2D,null),this.renderer._cacheTexture[t.src]=r,r},_createProgram:function(t,e,i){var r=this._createShader(t,t.VERTEX_SHADER,e),n=this._createShader(t,t.FRAGMENT_SHADER,i);if(!r||!n)return null;var a=t.createProgram();if(a){t.attachShader(a,r),t.attachShader(a,n),t.linkProgram(a),t.deleteShader(n),t.deleteShader(r);var o=t.getProgramParameter(a,t.LINK_STATUS);if(!o){var s=t.getProgramInfoLog(a);return console.log("Failed to link program: "+s),t.deleteProgram(a),null}}return a},_createShader:function(t,e,i){var r=t.createShader(e);if(r){t.shaderSource(r,i),t.compileShader(r);var n=t.getShaderParameter(r,t.COMPILE_STATUS);if(!n){var a=t.getShaderInfoLog(r);return console.log("Failed to compile shader: "+a),t.deleteShader(r),null}}return r}},a}),define("hilo/view/View",["hilo/core/Hilo","hilo/core/Class","hilo/event/EventMixin","hilo/geom/Matrix","hilo/util/util"],function(t,e,i,r,n){var a=function(){function a(t,e,i){for(var r,n,a,o,s=0,h=!1,l=0,c=i.length;ld.x?(r=d.x,n=u.x):(r=u.x,n=d.x),t>=r&&t<=n))h=!0;else if(u.y>d.y?(a=d.y,o=u.y):(a=u.y,o=d.y),!(eo)){var f=(e-u.y)*(d.x-u.x)/(d.y-u.y)+u.x;if(f>t?s++:f==t&&(h=!0),u.x>t&&u.y==e){var p=i[(c+l-1)%c];(p.ye||p.y>e&&d.ys?s=c:cl?l=c:c=0)return!1;u>i.overlap&&(i.overlap=u,i.normal.x=p.x,i.normal.y=p.y)}return i}return e.create({Mixes:i,constructor:function(e){e=e||{},this.id=this.id||e.id||t.getUid("View"),n.copy(this,e,!0)},tint:16777215,id:null,x:0,y:0,width:0,height:0,alpha:1,rotation:0,visible:!0,pivotX:0,pivotY:0,scaleX:1,scaleY:1,pointerEnabled:!0,background:null,mask:null,align:null,drawable:null,boundsArea:null,parent:null,depth:-1,transform:null,blendMode:"source-over",getStage:function(){for(var t,e=this;t=e.parent;)e=t;return e.canvas?e:null},getScaledWidth:function(){return this.width*this.scaleX},getScaledHeight:function(){return this.height*this.scaleY},addTo:function(t,e){return"number"==typeof e?t.addChildAt(this,e):t.addChild(this),this},removeFromParent:function(){var t=this.parent;return t&&t.removeChild(this),this},getBounds:function(){for(var t,e,i,r,n,a,o,s=this.width,h=this.height,l=this.getConcatenatedMatrix(),c=this.boundsArea||[{x:0,y:0},{x:s,y:0},{x:s,y:h},{x:0,y:h}],u=[],d=0,f=c.length;de?r=e:ni?a=i:o>1,r=0;break;case"TR":i=o-n,r=0;break;case"L":i=0,r=s-a>>1;break;case"C":i=o-n>>1,r=s-a>>1;break;case"R":i=o-n,r=s-a>>1;break;case"BL":i=0,r=s-a;break;case"B":i=o-n>>1,r=s-a;break;case"BR":i=o-n,r=s-a}}return{x:i,y:r}},hitTestPoint:function(t,e,i){var r=this.getBounds(),n=t>=r.x&&t<=r.x+r.width&&e>=r.y&&e<=r.y+r.height;return n&&i&&(n=a(t,e,r)),n},hitTestObject:function(t,e){var i=this.getBounds(),r=t.getBounds(),n=i.x<=r.x+r.width&&r.x<=i.x+i.width&&i.y<=r.y+r.height&&r.y<=i.y+i.height;return n&&e&&(n=o(i,r)),!!n},_render:function(t,e){this.onUpdate&&this.onUpdate(e)===!1||!t.startDraw(this)||(t.transform(this),this.render(t,e),t.endDraw(this))},_fireMouseEvent:function(t){if(t.eventCurrentTarget=this,this.fire(t),"mousemove"==t.type){if(!this.__mouseOver){this.__mouseOver=!0;var e=n.copy({},t);e.type="mouseover",this.fire(e)}}else"mouseout"==t.type&&(this.__mouseOver=!1);var i=this.parent;t._stopped||t._stopPropagationed||!i||("mouseout"==t.type||"touchout"==t.type?i.hitTestPoint(t.stageX,t.stageY,!0)||i._fireMouseEvent(t):i._fireMouseEvent(t))},onUpdate:null,render:function(t,e){t.draw(this)},toString:function(){return t.viewToString(this)}})}();return a}),define("hilo/view/CacheMixin",["hilo/view/Drawable","hilo/util/browser"],function(t,e){var i,r,n={_cacheDirty:!0,cache:function(t){(t||this._cacheDirty||!this.drawable)&&this.updateCache()},updateCache:function(){e.supportCanvas&&(i||(i=document.createElement("canvas"),r=i.getContext("2d")),i.width=this.width,i.height=this.height,this._draw(r),this.drawable=this.drawable||new t,this.drawable.init({image:i.toDataURL()}),this._cacheDirty=!1)},setCacheDirty:function(t){this._cacheDirty=t}};return n}),define("hilo/view/Container",["hilo/core/Hilo","hilo/core/Class","hilo/view/View"],function(t,e,i){var r=e.create({Extends:i,constructor:function(e){e=e||{},this.id=this.id||e.id||t.getUid("Container"),r.superclass.constructor.call(this,e),this.children?this._updateChildren():this.children=[]},children:null,pointerChildren:!0,clipChildren:!1,getNumChildren:function(){return this.children.length},addChildAt:function(t,e){var i=this.children,r=i.length,n=t.parent;e=e<0?0:e>r?r:e;var a=this.getChildIndex(t);if(a==e)return this;if(a>=0?(i.splice(a,1),e=e==r?r-1:e):n&&n.removeChild(t),i.splice(e,0,t),a<0)this._updateChildren(e);else{var o=a=e.length)return null;var i=e[t];if(i){if(!i.__renderer)for(var r=i;r=r.parent;){if(r.renderer){i.__renderer=r.renderer;break}if(r.__renderer){i.__renderer=r.__renderer;break}}i.__renderer&&i.__renderer.remove(i),i.parent=null,i.depth=-1}return e.splice(t,1),this._updateChildren(t),i},removeChild:function(t){return this.removeChildAt(this.getChildIndex(t))},removeChildById:function(t){for(var e,i=this.children,r=0,n=i.length;r=e.length?null:e[t]},getChildById:function(t){for(var e,i=this.children,r=0,n=i.length;r=0&&r!=e){var n=i.length;e=e<0?0:e>=n?n-1:e,i.splice(r,1),i.splice(e,0,t),this._updateChildren()}return this},swapChildren:function(t,e){var i=this.children,r=this.getChildIndex(t),n=this.getChildIndex(e);t.depth=n,i[n]=t,e.depth=r,i[r]=e},swapChildrenAt:function(t,e){var i=this.children,r=this.getChildAt(t),n=this.getChildAt(e);r.depth=e,i[e]=r,n.depth=t,i[t]=n},sortChildren:function(t){var e=t,i=this.children;if("string"==typeof e){var r=e;e=function(t,e){return e[r]-t[r]}}i.sort(e),this._updateChildren()},_updateChildren:function(t,e){var i,r=this.children;t=t||0,e=e||r.length;for(var n=t;n=0;l--)if(a=h[l],!(!a||!a.visible||a.alpha<=0||n&&!a.pointerEnabled))if(a.children&&a.children.length&&(!n||a.pointerChildren)&&(o=a.getViewAtPoint(t,e,i,r,n)),o){if(!r)return o;o.length&&(s=s.concat(o))}else if(a.hitTestPoint(t,e,i)){if(!r)return a;s.push(a)}return r&&s.length?s:null},render:function(t,e){r.superclass.render.call(this,t,e);var i,n,a,o=this.children.slice(0);for(i=0,n=o.length;ir?r:e,i[e]=t,t.name&&(this._frameNames[t.name]=t),(0!=e||this.width)&&this.height||(this.width=t.rect[2],this.height=t.rect[3]),this},getFrame:function(t){if("number"==typeof t){var e=this._frames;return t<0||t>=e.length?null:e[t]}return this._frameNames[t]},getFrameIndex:function(t){var e=this._frames,i=e.length,r=-1;if("number"==typeof t)r=t;else{var n="string"==typeof t?this._frameNames[t]:t;if(n)for(var a=0;a=i?i-1:r,this.paused=e,this._firstRender=!0,this},_render:function(t,e){var i,r=this.currentFrame;if(this._firstRender?(i=r,this._firstRender=!1):i=this._nextFrame(e),i!=r){this.currentFrame=i;var a=this._frames[i].callback;a&&a.call(this)}this.onEnterFrame&&this.onEnterFrame(i),this.drawable.init(this._frames[i]),n.superclass._render.call(this,t,e)},_nextFrame:function(t){var e=this._frames,i=e.length,r=this.currentFrame,n=e[r],a=n.duration||this.interval,o=this._frameElapsed,s=0!=r||this.drawable?o+(this.timeBased?t:1):0;return o=this._frameElapsed=s=i-1)&&this.stop(),this.paused||0!=o||(null!=n.next?r=this.getFrameIndex(n.next):r>=i-1?r=0:this.drawable&&r++),r},setFrameCallback:function(t,e){return t=this.getFrame(t),t&&(t.callback=e),this},onEnterFrame:null});return n}),define("hilo/view/DOMElement",["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/Drawable"],function(t,e,i,r){var n=e.create({Extends:i,constructor:function(e){e=e||{},this.id=this.id||e.id||t.getUid("DOMElement"),n.superclass.constructor.call(this,e),this.drawable=new r;var i=this.drawable.domElement=e.element||t.createElement("div");i.id=this.id,this.pointerEnabled&&!i.style.pointerEvents&&(i.style.pointerEvents="visible")},_render:function(t,e){this.onUpdate&&this.onUpdate(e)===!1||(t.transform(this),this.visible&&this.alpha>0&&this.render(t,e))},render:function(e,i){if("dom"!==e.renderType){var r=e.canvas,n=this.parent,a=e._domElementContainer;e._domElementContainer||(a=e._domElementContainer=t.createElement("div",{style:{position:"absolute",transform:"scale3d("+n.scaleX+","+n.scaleY+", 1)",transformOrigin:"0 0",zIndex:"1"}}),r.parentNode.insertBefore(e._domElementContainer,r.nextSibling));var o,s=this.drawable.domElement,h=this.depth,l=a.childNodes[0];if(s.parentNode)return;for(;l&&3!=l.nodeType&&(o=parseInt(l.style.zIndex)||0,!(o<=0||o>h));)l=l.nextSibling;a.insertBefore(this.drawable.domElement,l)}else e.draw(this)}});return n}),define("hilo/view/Graphics",["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/CacheMixin"],function(t,e,i,r){var n=function(){var a=document.createElement("canvas"),o=a.getContext&&a.getContext("2d");return e.create({Extends:i,Mixes:r,constructor:function(e){e=e||{},this.id=this.id||e.id||t.getUid("Graphics"),n.superclass.constructor.call(this,e),this._actions=[]},lineWidth:1,lineAlpha:1,lineCap:null,lineJoin:null,miterLimit:10,hasStroke:!1,strokeStyle:"0",hasFill:!1,fillStyle:"0",fillAlpha:0,lineStyle:function(t,e,i,r,n,a){var o=this,s=o._addAction;return s.call(o,["lineWidth",o.lineWidth=t||1]),s.call(o,["strokeStyle",o.strokeStyle=e||"0"]),s.call(o,["lineAlpha",o.lineAlpha=i||1]),void 0!=r&&s.call(o,["lineCap",o.lineCap=r]),void 0!=n&&s.call(o,["lineJoin",o.lineJoin=n]),void 0!=a&&s.call(o,["miterLimit",o.miterLimit=a]),o.hasStroke=!0,o},setLineDash:function(t){return this._addAction(["setLineDash",t])},beginFill:function(t,e){var i=this,r=i._addAction;return r.call(i,["fillStyle",i.fillStyle=t]),r.call(i,["fillAlpha",i.fillAlpha=e||1]),i.hasFill=!0,i},endFill:function(){var t=this,e=t._addAction;return t.hasStroke&&e.call(t,["stroke"]),t.hasFill&&e.call(t,["fill"]),t.setCacheDirty(!0),t},beginLinearGradientFill:function(t,e,i,r,n,a){for(var s=this,h=o.createLinearGradient(t,e,i,r),l=0,c=n.length;l1?a.slice(1):null;"function"==typeof t[o]?t[o].apply(t,s):t[o]=a[1]}},render:function(t,e){var i=this;"canvas"===t.renderType?i._draw(t.context):(i.cache(),t.draw(i))},clear:function(){var t=this;return t._actions.length=0,t.lineWidth=1,t.lineAlpha=1,t.lineCap=null,t.lineJoin=null,t.miterLimit=10,t.hasStroke=!1,t.strokeStyle="0",t.hasFill=!1,t.fillStyle="0",t.fillAlpha=1,t.setCacheDirty(!0),t},_addAction:function(t){var e=this;return e._actions.push(t),e}})}();return n}),define("hilo/view/Text",["hilo/core/Class","hilo/core/Hilo","hilo/view/View","hilo/view/CacheMixin"],function(t,e,i,r){var n=t.create({Extends:i,Mixes:r,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("Text"),n.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=n.measureFontHeight(this.font)},text:"",color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=n.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var r=i.drawable,n=r.domElement,a=n.style;a.font=i.font,a.textAlign=i.textAlign,a.color=i.color,a.width=i.width+"px",a.height=i.height+"px",a.lineHeight=i._fontHeight+i.lineSpacing+"px",n.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var r,n,a,o,s,h=i.split(/\r\n|\r|\n|/),l=0,c=0,u=e._fontHeight+e.lineSpacing,d=[];for(r=0,o=h.length;re.maxWidth?(d.push({text:m,y:c}),l>1;break;case"bottom":_=e.height-e.textHeight}var x=e.background;for(x&&(t.fillStyle=x,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,r=0;r>1;break;case"right":case"end":n=a}r.outline?t.strokeText(e,n,i):t.fillText(e,n,i)},Statics:{measureFontHeight:function(t){var i,r=document.documentElement,n=e.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return r.appendChild(n),i=n.offsetHeight,r.removeChild(n),i}}});return n}),define("hilo/view/BitmapText",["hilo/core/Class","hilo/core/Hilo","hilo/view/Container","hilo/view/Bitmap"],function(t,e,i,r){var n=t.create({Extends:i,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("BitmapText"),n.superclass.constructor.call(this,t);var i=t.text+"";i&&(this.text="",this.setText(i)),this.pointerChildren=!1},glyphs:null,letterSpacing:0,text:"",textAlign:"left",setText:function(t){var e=this,i=t.toString(),r=i.length;if(e.text!=i){e.text=i;var n,a,o,s,h=0,l=0,c=0;for(n=0;n0?e.letterSpacing:0),e.children[n]?(s=e.children[n],s.setImage(o.image,o.rect)):(s=e._createBitmap(o),e.addChild(s)),s.x=c,h=c+o.rect[2],l=Math.max(l,o.rect[3]));for(n=e.children.length-1;n>=r;n--)e._releaseBitmap(e.children[n]),e.children[n].removeFromParent();return e.width=h,e.height=l,this.setTextAlign(),e}},_createBitmap:function(t){var e;return n._pool.length?(e=n._pool.pop(),e.setImage(t.image,t.rect)):e=new r({image:t.image,rect:t.rect}),e},_releaseBitmap:function(t){n._pool.push(t)},setTextAlign:function(t){switch(this.textAlign=t||this.textAlign,this.textAlign){case"center":this.pivotX=.5*this.width;break;case"right":this.pivotX=this.width;break;case"left":default:this.pivotX=0}return this},hasGlyphs:function(t){var e=this.glyphs;if(!e)return!1;t=t.toString();var i,r=t.length;for(i=0;i=this._targetFPS?(this._measuredFPS=1e3/(this._tickTime/this._tickCount)+.5>>0,this._tickCount=0,this._tickTime=0):this._tickTime+=t-this._lastTime,this._lastTime=t;for(var r=i.slice(0),n=0,a=r.length;n=0&&e.splice(i,1)},nextTick:function(t){var e=this,i={tick:function(r){e.removeTick(i),t()}};return e.addTick(i),i},timeout:function(t,e){var i=this,r=(new Date).getTime()+e,n={tick:function(){var e=(new Date).getTime(),a=e-r;a>=0&&(i.removeTick(n),t())}};return i.addTick(n),n},interval:function(t,e){var i=this,r=(new Date).getTime()+e,n={tick:function(){var i=(new Date).getTime(),n=i-r;n>=0&&(n=r)return-1;for(e<0&&(e=r+e),i=e;i=1?1:s;var l=n.ease?n.ease(s):s;n.reverse&&(n._reverseFlag<0&&(s=1-s,l=1-l),s<1e-7&&(n.repeat>0&&n._repeatCount++>=n.repeat||0==n.repeat&&!n.loop?h=!0:(n._startTime=i(),n._pausedTime=0,n._reverseFlag*=-1))),n.isStart||(n.setProps(n._fromProps,n._toProps),n.isStart=!0,n.onStart&&n.onStart.call(n,n)),n.time=a,n._render(l),(o=n.onUpdate)&&o.call(n,s,n),s>=1&&(n.reverse?(n._startTime=i(),n._pausedTime=0,n._reverseFlag*=-1):n.loop||n.repeat>0&&n._repeatCount++0&&u<=t?(c._render(s),c.time=a,e.add(c)):h&&(u<0||u>t)&&c.start()}return h?((o=n.onComplete)&&o.call(n,n),!0):void 0}}},Statics:{_tweens:[],tick:function(){var t,r,n=e._tweens,a=n.length;for(r=0;r-1&&n.splice(i,1);else for(i=0;i=i)return void t.fire("complete");if(t._currentIndexe.z})},tick:function(){this.sortZ()}});return o}();return i}),define("hilo/game/ParticleSystem",["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/Container","hilo/view/Drawable","hilo/util/util"],function(t,e,i,r,n,a){var o=function(){function o(t,e){return e?t+2*(Math.random()-.5)*e:t}for(var s=["x","y","vx","vy","ax","ay","rotation","rotationV","scale","scaleV","alpha","alphaV","life"],h=[],l=0,c=s.length;l=this._emitTime&&(this._currentRunTime=0,this._emitTime=o(this.emitTime,this.emitTimeVar),this._emit()),this._totalRunTime>=this.totalTime&&this.stop())},_emit:function(){for(var t=o(this.emitNum,this.emitNumVar)>>0,e=0;e=0;e--)this.children[e].destroy()}}),v=e.create({Extends:i,constructor:function(e){this.id=this.id||e.id||t.getUid("Particle"),v.superclass.constructor.call(this,e),this.init(e)},onUpdate:function(t){if(t*=.001,this._died)return!1;var e=this.ax+this.system.gx,i=this.ay+this.system.gy;return this.vx+=e*t,this.vy+=i*t,this.x+=this.vx*t,this.y+=this.vy*t,this.rotation+=this.rotationV,this._time>.1&&(this.alpha+=this.alphaV),this.scale+=this.scaleV,this.scaleX=this.scaleY=this.scale,this._time+=t,this._time>=this.life||this.alpha<=0?(this.destroy(),!1):void 0},setImage:function(t,e){this.drawable=this.drawable||new n,e=e||[0,0,t.width,t.height],this.width=e[2],this.height=e[3],this.drawable.rect=e,this.drawable.image=t},destroy:function(){this._died=!0,this.alpha=0,this.removeFromParent(),f.push(this)},init:function(t){this.system=t.system,this._died=!1,this._time=0,this.alpha=1;for(var e=0,i=h.length;e>0]),this.setImage(t.image,a),void 0!==t.pivotX&&(this.pivotX=t.pivotX*a[2]),void 0!==t.pivotY&&(this.pivotY=t.pivotY*a[3])}},Statics:{create:function(t){if(f.length>0){var e=f.pop();return e.init(t),e}return new v(t)}}});return p}();return o}); \ No newline at end of file diff --git a/build/amd/hilo-amd.zip b/build/amd/hilo-amd.zip index baf0b5bf..06dbea6c 100644 Binary files a/build/amd/hilo-amd.zip and b/build/amd/hilo-amd.zip differ diff --git a/build/amd/hilo/core/Class.js b/build/amd/hilo/core/Class.js index a6b9b3c2..ef34945f 100644 --- a/build/amd/hilo/core/Class.js +++ b/build/amd/hilo/core/Class.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/core/Class.min.js b/build/amd/hilo/core/Class.min.js index 04de6472..092152dc 100644 --- a/build/amd/hilo/core/Class.min.js +++ b/build/amd/hilo/core/Class.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/core/Hilo.js b/build/amd/hilo/core/Hilo.js index ea1a3e45..b72b71e0 100644 --- a/build/amd/hilo/core/Hilo.js +++ b/build/amd/hilo/core/Hilo.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -27,7 +27,7 @@ var Hilo = { * Hilo version * @type String */ - version: '1.3.0', + version: '1.4.0', /** * @language=en * Gets a globally unique id. Such as Stage1, Bitmap2 etc. diff --git a/build/amd/hilo/core/Hilo.min.js b/build/amd/hilo/core/Hilo.min.js index c5d9fd99..2a4ee37f 100644 --- a/build/amd/hilo/core/Hilo.min.js +++ b/build/amd/hilo/core/Hilo.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ -define("hilo/core/Hilo",["hilo/util/browser","hilo/util/util"],function(t,e){var a=window,o=document,r=o.documentElement,n=0,i={},s={version:"1.3.0",getUid:function(t){var e=++n;if(t){var a=t.charCodeAt(t.length-1);return a>=48&&a<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,a=t;a;)e=e?a.id+"."+e:a.id,a=a.parent;return e},copy:function(t,a,o){return e.copy(t,a,o),i.copy||(i.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),t},browser:t,event:{POINTER_START:t.POINTER_START,POINTER_MOVE:t.POINTER_MOVE,POINTER_END:t.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(t){var e;try{e=t.getBoundingClientRect()}catch(o){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var n=(a.pageXOffset||r.scrollLeft)-(r.clientLeft||0)||0,i=(a.pageYOffset||r.scrollTop)-(r.clientTop||0)||0,s=a.getComputedStyle?getComputedStyle(t):t.currentStyle,c=parseInt,h=c(s.paddingLeft)+c(s.borderLeftWidth)||0,f=c(s.paddingTop)+c(s.borderTopWidth)||0,d=c(s.paddingRight)+c(s.borderRightWidth)||0,l=c(s.paddingBottom)+c(s.borderBottomWidth)||0,g=e.top||0,p=e.left||0,m=e.right||0,T=e.bottom||0;return{left:p+n+h,top:g+i+f,width:m-d-p-h,height:T-l-g-f}},createElement:function(t,e){var a,r,n,i=o.createElement(t);for(a in e)if(r=e[a],"style"===a)for(n in r)i.style[n]=r[n];else i[a]=r;return i},getElement:function(t){return o.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,a=e.domElement.style,o=t._stateCache||(t._stateCache={}),r=s.browser.jsVendor,n="px",i=!1;if(this.cacheStateIfChanged(t,["visible"],o)&&(a.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],o)&&(a.opacity=t.alpha),t.visible&&!(t.alpha<=0)){if(this.cacheStateIfChanged(t,["width"],o)&&(a.width=t.width+n),this.cacheStateIfChanged(t,["height"],o)&&(a.height=t.height+n),this.cacheStateIfChanged(t,["depth"],o)&&(a.zIndex=t.depth+1),t.transform){var c=t.transform;(i=this.cacheStateIfChanged(t,["pivotX","pivotY"],o))&&(a[r+"TransformOrigin"]="0 0"),a[r+"Transform"]="matrix3d("+c.a+", "+c.b+", 0, 0, "+c.c+", "+c.d+", 0, 0, 0, 0, 1, 0, "+c.tx+", "+c.ty+", 0, 1)"}else(i=this.cacheStateIfChanged(t,["pivotX","pivotY"],o))&&(a[r+"TransformOrigin"]=t.pivotX+n+" "+t.pivotY+n),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],o)||i)&&(a[r+"Transform"]=this.getTransformCSS(t));this.cacheStateIfChanged(t,["background"],o)&&(a.backgroundColor=t.background),a.pointerEvents||(a.pointerEvents="none");var h=e.image;if(h){var f=h.src;f!==o.image&&(o.image=f,a.backgroundImage="url("+f+")");var d=e.rect;if(d){var l=d[0],g=d[1];l!==o.sx&&(o.sx=l,a.backgroundPositionX=-l+n),g!==o.sy&&(o.sy=g,a.backgroundPositionY=-g+n)}}var p=t.mask;if(p){var m=p.drawable.domElement.style.backgroundImage;m!==o.maskImage&&(o.maskImage=m,a[r+"MaskImage"]=m,a[r+"MaskRepeat"]="no-repeat");var T=p.x,u=p.y;T===o.maskX&&u===o.maskY||(o.maskX=T,o.maskY=u,a[r+"MaskPosition"]=T+n+" "+u+n)}}},cacheStateIfChanged:function(t,e,a){var o,r,n,i,s=!1;for(o=0,r=e.length;o=48&&a<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,a=t;a;)e=e?a.id+"."+e:a.id,a=a.parent;return e},copy:function(t,a,o){return e.copy(t,a,o),i.copy||(i.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),t},browser:t,event:{POINTER_START:t.POINTER_START,POINTER_MOVE:t.POINTER_MOVE,POINTER_END:t.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(t){var e;try{e=t.getBoundingClientRect()}catch(o){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var n=(a.pageXOffset||r.scrollLeft)-(r.clientLeft||0)||0,i=(a.pageYOffset||r.scrollTop)-(r.clientTop||0)||0,s=a.getComputedStyle?getComputedStyle(t):t.currentStyle,c=parseInt,h=c(s.paddingLeft)+c(s.borderLeftWidth)||0,f=c(s.paddingTop)+c(s.borderTopWidth)||0,d=c(s.paddingRight)+c(s.borderRightWidth)||0,l=c(s.paddingBottom)+c(s.borderBottomWidth)||0,g=e.top||0,p=e.left||0,m=e.right||0,T=e.bottom||0;return{left:p+n+h,top:g+i+f,width:m-d-p-h,height:T-l-g-f}},createElement:function(t,e){var a,r,n,i=o.createElement(t);for(a in e)if(r=e[a],"style"===a)for(n in r)i.style[n]=r[n];else i[a]=r;return i},getElement:function(t){return o.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,a=e.domElement.style,o=t._stateCache||(t._stateCache={}),r=s.browser.jsVendor,n="px",i=!1;if(this.cacheStateIfChanged(t,["visible"],o)&&(a.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],o)&&(a.opacity=t.alpha),t.visible&&!(t.alpha<=0)){if(this.cacheStateIfChanged(t,["width"],o)&&(a.width=t.width+n),this.cacheStateIfChanged(t,["height"],o)&&(a.height=t.height+n),this.cacheStateIfChanged(t,["depth"],o)&&(a.zIndex=t.depth+1),t.transform){var c=t.transform;(i=this.cacheStateIfChanged(t,["pivotX","pivotY"],o))&&(a[r+"TransformOrigin"]="0 0"),a[r+"Transform"]="matrix3d("+c.a+", "+c.b+", 0, 0, "+c.c+", "+c.d+", 0, 0, 0, 0, 1, 0, "+c.tx+", "+c.ty+", 0, 1)"}else(i=this.cacheStateIfChanged(t,["pivotX","pivotY"],o))&&(a[r+"TransformOrigin"]=t.pivotX+n+" "+t.pivotY+n),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],o)||i)&&(a[r+"Transform"]=this.getTransformCSS(t));this.cacheStateIfChanged(t,["background"],o)&&(a.backgroundColor=t.background),a.pointerEvents||(a.pointerEvents="none");var h=e.image;if(h){var f=h.src;f!==o.image&&(o.image=f,a.backgroundImage="url("+f+")");var d=e.rect;if(d){var l=d[0],g=d[1];l!==o.sx&&(o.sx=l,a.backgroundPositionX=-l+n),g!==o.sy&&(o.sy=g,a.backgroundPositionY=-g+n)}}var p=t.mask;if(p){var m=p.drawable.domElement.style.backgroundImage;m!==o.maskImage&&(o.maskImage=m,a[r+"MaskImage"]=m,a[r+"MaskRepeat"]="no-repeat");var T=p.x,u=p.y;T===o.maskX&&u===o.maskY||(o.maskX=T,o.maskY=u,a[r+"MaskPosition"]=T+n+" "+u+n)}}},cacheStateIfChanged:function(t,e,a){var o,r,n,i,s=!1;for(o=0,r=e.length;o0)&&(t===this.stage&&this.clear(),!0)},draw:function(t){var e=t.width,r=t.height,i=(t.background,t.drawable),a=i&&i.image;if(a){var n=i.rect,s=n[2],o=n[3];e||r||(e=t.width=s,r=t.height=o),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(a,n[0],n[1],s,o,0,0,e,r),c=this.batchIndex*this.positionStride,_=this.float32Array,l=this.uint32Array,d=(t.tint>>16)+(65280&t.tint)+((255&t.tint)<<16)+(255*t.__webglRenderAlpha<<24);_[c+0]=h[0],_[c+1]=h[1],_[c+2]=h[2],_[c+3]=h[3],l[c+4]=d,_[c+5]=h[4],_[c+6]=h[5],_[c+7]=h[6],_[c+8]=h[7],l[c+9]=d,_[c+10]=h[8],_[c+11]=h[9],_[c+12]=h[10],_[c+13]=h[11],l[c+14]=d,_[c+15]=h[12],_[c+16]=h[13],_[c+17]=h[14],_[c+18]=h[15],l[c+19]=d;for(var u=t.__webglWorldMatrix,f=0;f<4;f++){var g=_[c+5*f],T=_[c+5*f+1];_[c+5*f]=u.a*g+u.c*T+u.tx,_[c+5*f+1]=u.b*g+u.d*T+u.ty}t.__textureImage=a,this.sprites[this.batchIndex++]=t}},endDraw:function(t){t===this.stage&&this._renderBatches()},transform:function(t){var r=t.drawable;if(r&&r.domElement)return void e.setElementStyleByView(t);var a=t.scaleX,n=t.scaleY;if(t===this.stage){var s=this.canvas.style,o=t._scaleX,h=t._scaleY,c=!1;(!o&&1!=a||o&&o!=a)&&(t._scaleX=a,s.width=a*t.width+"px",c=!0),(!h&&1!=n||h&&h!=n)&&(t._scaleY=n,s.height=n*t.height+"px",c=!0),c&&t.updateViewport(),t.__webglWorldMatrix=t.__webglWorldMatrix||new i(1,0,0,1,0,0)}else t.parent&&(t.__webglWorldMatrix=t.__webglWorldMatrix||new i(1,0,0,1,0,0),this._setConcatenatedMatrix(t,t.parent));t.alpha>0&&(t.parent&&t.parent.__webglRenderAlpha?t.__webglRenderAlpha=t.alpha*t.parent.__webglRenderAlpha:t.__webglRenderAlpha=t.alpha)},remove:function(t){var e=t.drawable,r=e&&e.domElement;if(r){var i=r.parentNode;i&&i.removeChild(r)}},clear:function(t,e,r,i){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(t,e){if(this.width!==t||this.height!==e){var r=this.canvas,i=this.stage,a=r.style;this.width=r.width=t,this.height=r.height=e,a.width=i.width*i.scaleX+"px",a.height=i.height*i.scaleY+"px",this.gl.viewport(0,0,t,e),this.canvasHalfWidth=.5*t,this.canvasHalfHeight=.5*e,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var t=this.gl;t.bufferSubData(t.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var e=0,r=0,i=null,a=0;a0&&(r.bindTexture(r.TEXTURE_2D,this._getTexture(this.sprites[t])),r.drawElements(r.TRIANGLES,6*i,r.UNSIGNED_SHORT,6*t*2))},_uploadProjectionTransform:function(t){this._projectionTransformElements&&!t||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var t=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",e="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new s(this,{v:t,f:e},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(t,e,r,i,a,n,s,o,h){var c=this.__tempVertexs||[],_=t.width,l=t.height;i/=_,a/=l,e/=_,r/=l,o=o,h=h,n=n,s=s,i+e>1&&(i=1-e),a+r>1&&(a=1-r);var d=0;return c[d++]=n,c[d++]=s,c[d++]=e,c[d++]=r,c[d++]=n+o,c[d++]=s,c[d++]=e+i,c[d++]=r,c[d++]=n,c[d++]=s+h,c[d++]=e,c[d++]=r+a,c[d++]=n+o,c[d++]=s+h,c[d++]=e+i,c[d++]=r+a,c},_setConcatenatedMatrix:function(t,e){var r=t.__webglWorldMatrix,i=1,n=0,s=t.rotation%360,o=t.pivotX,h=t.pivotY,c=t.scaleX,_=t.scaleY,l=t.transform;if(l)r.copy(l);else{if(s){var d=s*a;i=Math.cos(d),n=Math.sin(d)}var u=t.getAlignPosition();r.a=i*c,r.b=n*c,r.c=-n*_,r.d=i*_,r.tx=u.x-r.a*o-r.c*h,r.ty=u.y-r.b*o-r.d*h}r.concat(e.__webglWorldMatrix)},_getTexture:function(t){var e=t.__textureImage,r=this._cacheTexture[e.src];return r||(r=this.activeShader.uploadTexture(e)),r}}),s=function(t,e,r){this.renderer=t,this.gl=t.gl,this.program=this._createProgram(this.gl,e.v,e.f),r=r||{},this.attributes=r.attributes||[],this.uniforms=r.uniforms||[]};return s.prototype={active:function(){var t=this,e=t.renderer,r=t.gl,i=t.program;i&&r&&(e.activeShader=t,r.useProgram(i),t.attributes.forEach(function(t){e[t]=r.getAttribLocation(i,t),r.enableVertexAttribArray(e[t])}),t.uniforms.forEach(function(t){e[t]=r.getUniformLocation(i,t)}),t.width===e.width&&t.height===e.height||(t.width=e.width,t.height=e.height,e._uploadProjectionTransform()))},uploadTexture:function(t){var e=this.gl,r=this.renderer,i=e.createTexture(),a=r.u_Sampler;return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,i),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(a,0),e.bindTexture(e.TEXTURE_2D,null),this.renderer._cacheTexture[t.src]=i,i},_createProgram:function(t,e,r){var i=this._createShader(t,t.VERTEX_SHADER,e),a=this._createShader(t,t.FRAGMENT_SHADER,r);if(!i||!a)return null;var n=t.createProgram();if(n){t.attachShader(n,i),t.attachShader(n,a),t.linkProgram(n),t.deleteShader(a),t.deleteShader(i);var s=t.getProgramParameter(n,t.LINK_STATUS);if(!s){var o=t.getProgramInfoLog(n);return console.log("Failed to link program: "+o),t.deleteProgram(n),null}}return n},_createShader:function(t,e,r){var i=t.createShader(e);if(i){t.shaderSource(i,r),t.compileShader(i);var a=t.getShaderParameter(i,t.COMPILE_STATUS);if(!a){var n=t.getShaderInfoLog(i);return console.log("Failed to compile shader: "+n),t.deleteShader(i),null}}return i}},n}); \ No newline at end of file +define("hilo/renderer/WebGLRenderer",["hilo/core/Class","hilo/core/Hilo","hilo/renderer/Renderer","hilo/geom/Matrix"],function(t,e,r,i){var a=Math.PI/180,n=t.create({Extends:r,Statics:{MAX_BATCH_NUM:2e3,ATTRIBUTE_NUM:5,isSupport:function(){if(void 0==this._isSupported){var t=document.createElement("canvas");t.getContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))?this._isSupported=!0:this._isSupported=!1}return this._isSupported},contextOptions:null},renderType:"webgl",gl:null,_isContextLost:!1,_cacheTexture:{},constructor:function(t){n.superclass.constructor.call(this,t);var e=this,r=n.contextOptions||{};this.gl=this.canvas.getContext("webgl",r)||this.canvas.getContext("experimental-webgl",r),this.maxBatchNum=n.MAX_BATCH_NUM,this.positionStride=4*n.ATTRIBUTE_NUM;var i=this.maxBatchNum*n.ATTRIBUTE_NUM*4,a=6*this.maxBatchNum;this.arrayBuffer=new ArrayBuffer(4*i),this.float32Array=new Float32Array(this.arrayBuffer),this.uint32Array=new Uint32Array(this.arrayBuffer),this.indexs=new Uint16Array(a);for(var s=0,o=0;s0)&&(t===this.stage&&this.clear(),!0)},draw:function(t){var e=t.width,r=t.height,i=(t.background,t.drawable),a=i&&i.image;if(a){var n=i.rect,s=n[2],o=n[3];e||r||(e=t.width=s,r=t.height=o),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(a,n[0],n[1],s,o,0,0,e,r),c=this.batchIndex*this.positionStride,_=this.float32Array,l=this.uint32Array,d=(t.tint>>16)+(65280&t.tint)+((255&t.tint)<<16)+(255*t.__webglRenderAlpha<<24);_[c+0]=h[0],_[c+1]=h[1],_[c+2]=h[2],_[c+3]=h[3],l[c+4]=d,_[c+5]=h[4],_[c+6]=h[5],_[c+7]=h[6],_[c+8]=h[7],l[c+9]=d,_[c+10]=h[8],_[c+11]=h[9],_[c+12]=h[10],_[c+13]=h[11],l[c+14]=d,_[c+15]=h[12],_[c+16]=h[13],_[c+17]=h[14],_[c+18]=h[15],l[c+19]=d;for(var u=t.__webglWorldMatrix,f=0;f<4;f++){var g=_[c+5*f],x=_[c+5*f+1];_[c+5*f]=u.a*g+u.c*x+u.tx,_[c+5*f+1]=u.b*g+u.d*x+u.ty}t.__textureImage=a,this.sprites[this.batchIndex++]=t}},endDraw:function(t){t===this.stage&&this._renderBatches()},transform:function(t){var r=t.drawable;if(r&&r.domElement)return void e.setElementStyleByView(t);var a=t.scaleX,n=t.scaleY;if(t===this.stage){var s=this.canvas.style,o=t._scaleX,h=t._scaleY,c=!1;(!o&&1!=a||o&&o!=a)&&(t._scaleX=a,s.width=a*t.width+"px",c=!0),(!h&&1!=n||h&&h!=n)&&(t._scaleY=n,s.height=n*t.height+"px",c=!0),c&&t.updateViewport(),t.__webglWorldMatrix=t.__webglWorldMatrix||new i(1,0,0,1,0,0)}else t.parent&&(t.__webglWorldMatrix=t.__webglWorldMatrix||new i(1,0,0,1,0,0),this._setConcatenatedMatrix(t,t.parent));t.alpha>0&&(t.parent&&t.parent.__webglRenderAlpha?t.__webglRenderAlpha=t.alpha*t.parent.__webglRenderAlpha:t.__webglRenderAlpha=t.alpha)},remove:function(t){var e=t.drawable,r=e&&e.domElement;if(r){var i=r.parentNode;i&&i.removeChild(r)}},clear:function(t,e,r,i){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(t,e){if(this.width!==t||this.height!==e){var r=this.canvas,i=this.stage,a=r.style;this.width=r.width=t,this.height=r.height=e,a.width=i.width*i.scaleX+"px",a.height=i.height*i.scaleY+"px",this.gl.viewport(0,0,t,e),this.canvasHalfWidth=.5*t,this.canvasHalfHeight=.5*e,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var t=this.gl;t.bufferSubData(t.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var e=0,r=0,i=null,a=0;a0&&(r.bindTexture(r.TEXTURE_2D,this._getTexture(this.sprites[t])),r.drawElements(r.TRIANGLES,6*i,r.UNSIGNED_SHORT,6*t*2))},_uploadProjectionTransform:function(t){this._projectionTransformElements&&!t||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var t=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",e="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new s(this,{v:t,f:e},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(t,e,r,i,a,n,s,o,h){var c=this.__tempVertexs||[],_=t.width,l=t.height;i/=_,a/=l,e/=_,r/=l,o=o,h=h,n=n,s=s,i+e>1&&(i=1-e),a+r>1&&(a=1-r);var d=0;return c[d++]=n,c[d++]=s,c[d++]=e,c[d++]=r,c[d++]=n+o,c[d++]=s,c[d++]=e+i,c[d++]=r,c[d++]=n,c[d++]=s+h,c[d++]=e,c[d++]=r+a,c[d++]=n+o,c[d++]=s+h,c[d++]=e+i,c[d++]=r+a,c},_setConcatenatedMatrix:function(t,e){var r=t.__webglWorldMatrix,i=1,n=0,s=t.rotation%360,o=t.pivotX,h=t.pivotY,c=t.scaleX,_=t.scaleY,l=t.transform;if(l)r.copy(l);else{if(s){var d=s*a;i=Math.cos(d),n=Math.sin(d)}var u=t.getAlignPosition();r.a=i*c,r.b=n*c,r.c=-n*_,r.d=i*_,r.tx=u.x-r.a*o-r.c*h,r.ty=u.y-r.b*o-r.d*h}r.concat(e.__webglWorldMatrix)},_getTexture:function(t){var e=t.__textureImage,r=this._cacheTexture[e.src];return r||(r=this.activeShader.uploadTexture(e)),r}}),s=function(t,e,r){this.renderer=t,this.gl=t.gl,this.program=this._createProgram(this.gl,e.v,e.f),r=r||{},this.attributes=r.attributes||[],this.uniforms=r.uniforms||[]};return s.prototype={active:function(){var t=this,e=t.renderer,r=t.gl,i=t.program;i&&r&&(e.activeShader=t,r.useProgram(i),t.attributes.forEach(function(t){e[t]=r.getAttribLocation(i,t),r.enableVertexAttribArray(e[t])}),t.uniforms.forEach(function(t){e[t]=r.getUniformLocation(i,t)}),t.width===e.width&&t.height===e.height||(t.width=e.width,t.height=e.height,e._uploadProjectionTransform()))},uploadTexture:function(t){var e=this.gl,r=this.renderer,i=e.createTexture(),a=r.u_Sampler;return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,i),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(a,0),e.bindTexture(e.TEXTURE_2D,null),this.renderer._cacheTexture[t.src]=i,i},_createProgram:function(t,e,r){var i=this._createShader(t,t.VERTEX_SHADER,e),a=this._createShader(t,t.FRAGMENT_SHADER,r);if(!i||!a)return null;var n=t.createProgram();if(n){t.attachShader(n,i),t.attachShader(n,a),t.linkProgram(n),t.deleteShader(a),t.deleteShader(i);var s=t.getProgramParameter(n,t.LINK_STATUS);if(!s){var o=t.getProgramInfoLog(n);return console.log("Failed to link program: "+o),t.deleteProgram(n),null}}return n},_createShader:function(t,e,r){var i=t.createShader(e);if(i){t.shaderSource(i,r),t.compileShader(i);var a=t.getShaderParameter(i,t.COMPILE_STATUS);if(!a){var n=t.getShaderInfoLog(i);return console.log("Failed to compile shader: "+n),t.deleteShader(i),null}}return i}},n}); \ No newline at end of file diff --git a/build/amd/hilo/tween/Ease.js b/build/amd/hilo/tween/Ease.js index c116f6cc..ee6ee03a 100644 --- a/build/amd/hilo/tween/Ease.js +++ b/build/amd/hilo/tween/Ease.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/tween/Ease.min.js b/build/amd/hilo/tween/Ease.min.js index 88b267de..f8cf1fcd 100644 --- a/build/amd/hilo/tween/Ease.min.js +++ b/build/amd/hilo/tween/Ease.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/tween/Tween.js b/build/amd/hilo/tween/Tween.js index cd8ba4d2..be1849fc 100644 --- a/build/amd/hilo/tween/Tween.js +++ b/build/amd/hilo/tween/Tween.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/tween/Tween.min.js b/build/amd/hilo/tween/Tween.min.js index 88cda3ed..c64dd506 100644 --- a/build/amd/hilo/tween/Tween.min.js +++ b/build/amd/hilo/tween/Tween.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/util/TextureAtlas.js b/build/amd/hilo/util/TextureAtlas.js index 7d310c2f..0662ab6c 100644 --- a/build/amd/hilo/util/TextureAtlas.js +++ b/build/amd/hilo/util/TextureAtlas.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/util/TextureAtlas.min.js b/build/amd/hilo/util/TextureAtlas.min.js index d22ac898..bdf594f8 100644 --- a/build/amd/hilo/util/TextureAtlas.min.js +++ b/build/amd/hilo/util/TextureAtlas.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/util/Ticker.js b/build/amd/hilo/util/Ticker.js index cc82713b..3ca114bd 100644 --- a/build/amd/hilo/util/Ticker.js +++ b/build/amd/hilo/util/Ticker.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/util/Ticker.min.js b/build/amd/hilo/util/Ticker.min.js index e067f980..d104abf5 100644 --- a/build/amd/hilo/util/Ticker.min.js +++ b/build/amd/hilo/util/Ticker.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/util/browser.js b/build/amd/hilo/util/browser.js index 06c887bd..fa8d9cee 100644 --- a/build/amd/hilo/util/browser.js +++ b/build/amd/hilo/util/browser.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/util/browser.min.js b/build/amd/hilo/util/browser.min.js index 9429296a..e783667b 100644 --- a/build/amd/hilo/util/browser.min.js +++ b/build/amd/hilo/util/browser.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/util/drag.js b/build/amd/hilo/util/drag.js index 2b5d1219..5bc7ef7e 100644 --- a/build/amd/hilo/util/drag.js +++ b/build/amd/hilo/util/drag.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/util/drag.min.js b/build/amd/hilo/util/drag.min.js index 926d8770..40969d19 100644 --- a/build/amd/hilo/util/drag.min.js +++ b/build/amd/hilo/util/drag.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/util/polyfill.js b/build/amd/hilo/util/polyfill.js index 7521779c..36c8ad2f 100644 --- a/build/amd/hilo/util/polyfill.js +++ b/build/amd/hilo/util/polyfill.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/util/polyfill.min.js b/build/amd/hilo/util/polyfill.min.js index 14c06a6b..80a189d9 100644 --- a/build/amd/hilo/util/polyfill.min.js +++ b/build/amd/hilo/util/polyfill.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/util/util.js b/build/amd/hilo/util/util.js index d348296a..ea67d3d1 100644 --- a/build/amd/hilo/util/util.js +++ b/build/amd/hilo/util/util.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/util/util.min.js b/build/amd/hilo/util/util.min.js index 7840e77b..10213a81 100644 --- a/build/amd/hilo/util/util.min.js +++ b/build/amd/hilo/util/util.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/Bitmap.js b/build/amd/hilo/view/Bitmap.js index d5c6cb29..7682d91a 100644 --- a/build/amd/hilo/view/Bitmap.js +++ b/build/amd/hilo/view/Bitmap.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/Bitmap.min.js b/build/amd/hilo/view/Bitmap.min.js index 07f8eab9..5295f4b7 100644 --- a/build/amd/hilo/view/Bitmap.min.js +++ b/build/amd/hilo/view/Bitmap.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/BitmapText.js b/build/amd/hilo/view/BitmapText.js index 354c95df..b8f9bc3d 100644 --- a/build/amd/hilo/view/BitmapText.js +++ b/build/amd/hilo/view/BitmapText.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/BitmapText.min.js b/build/amd/hilo/view/BitmapText.min.js index ecb21687..3642d4b9 100644 --- a/build/amd/hilo/view/BitmapText.min.js +++ b/build/amd/hilo/view/BitmapText.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/Button.js b/build/amd/hilo/view/Button.js index 7c360958..48a97e78 100644 --- a/build/amd/hilo/view/Button.js +++ b/build/amd/hilo/view/Button.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/Button.min.js b/build/amd/hilo/view/Button.min.js index a9b3c981..f3f8b709 100644 --- a/build/amd/hilo/view/Button.min.js +++ b/build/amd/hilo/view/Button.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/CacheMixin.js b/build/amd/hilo/view/CacheMixin.js index e167b928..80d81c8c 100644 --- a/build/amd/hilo/view/CacheMixin.js +++ b/build/amd/hilo/view/CacheMixin.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/CacheMixin.min.js b/build/amd/hilo/view/CacheMixin.min.js index 81e7c465..fa53d8c2 100644 --- a/build/amd/hilo/view/CacheMixin.min.js +++ b/build/amd/hilo/view/CacheMixin.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/Container.js b/build/amd/hilo/view/Container.js index 10a78f29..37585651 100644 --- a/build/amd/hilo/view/Container.js +++ b/build/amd/hilo/view/Container.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/Container.min.js b/build/amd/hilo/view/Container.min.js index 1fbba521..36285715 100644 --- a/build/amd/hilo/view/Container.min.js +++ b/build/amd/hilo/view/Container.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/DOMElement.js b/build/amd/hilo/view/DOMElement.js index 3e5fa466..6ecb9c5e 100644 --- a/build/amd/hilo/view/DOMElement.js +++ b/build/amd/hilo/view/DOMElement.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/DOMElement.min.js b/build/amd/hilo/view/DOMElement.min.js index c4a86f15..9a7c7f52 100644 --- a/build/amd/hilo/view/DOMElement.min.js +++ b/build/amd/hilo/view/DOMElement.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/Drawable.js b/build/amd/hilo/view/Drawable.js index e5c5e06c..b4c5e233 100644 --- a/build/amd/hilo/view/Drawable.js +++ b/build/amd/hilo/view/Drawable.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/Drawable.min.js b/build/amd/hilo/view/Drawable.min.js index a51d2bbf..45987ea7 100644 --- a/build/amd/hilo/view/Drawable.min.js +++ b/build/amd/hilo/view/Drawable.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/Graphics.js b/build/amd/hilo/view/Graphics.js index 162b2a9c..d5795d78 100644 --- a/build/amd/hilo/view/Graphics.js +++ b/build/amd/hilo/view/Graphics.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -9,7 +9,7 @@ define('hilo/view/Graphics', ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/view/Vi /** * @language=en - * + * *
* @class Graphics class contains a group of functions for creating vector graphics. * @augments View diff --git a/build/amd/hilo/view/Graphics.min.js b/build/amd/hilo/view/Graphics.min.js index b9e9f9bf..654c4cb4 100644 --- a/build/amd/hilo/view/Graphics.min.js +++ b/build/amd/hilo/view/Graphics.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/Sprite.js b/build/amd/hilo/view/Sprite.js index 89af2b00..fe5d4552 100644 --- a/build/amd/hilo/view/Sprite.js +++ b/build/amd/hilo/view/Sprite.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/Sprite.min.js b/build/amd/hilo/view/Sprite.min.js index 7156a2d7..944a963e 100644 --- a/build/amd/hilo/view/Sprite.min.js +++ b/build/amd/hilo/view/Sprite.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/Stage.js b/build/amd/hilo/view/Stage.js index d1262823..77684a38 100644 --- a/build/amd/hilo/view/Stage.js +++ b/build/amd/hilo/view/Stage.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/Stage.min.js b/build/amd/hilo/view/Stage.min.js index 7b62827b..a5ab675c 100644 --- a/build/amd/hilo/view/Stage.min.js +++ b/build/amd/hilo/view/Stage.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/Text.js b/build/amd/hilo/view/Text.js index a60bee37..1c72e477 100644 --- a/build/amd/hilo/view/Text.js +++ b/build/amd/hilo/view/Text.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -47,7 +47,7 @@ var Text = Class.create(/** @lends Text.prototype */{ this._fontHeight = Text.measureFontHeight(this.font); }, - text: null, + text: '', color: '#000', textAlign: null, textVAlign: null, diff --git a/build/amd/hilo/view/Text.min.js b/build/amd/hilo/view/Text.min.js index c08e92d8..ab5280a2 100644 --- a/build/amd/hilo/view/Text.min.js +++ b/build/amd/hilo/view/Text.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ -define("hilo/view/Text",["hilo/core/Class","hilo/core/Hilo","hilo/view/View","hilo/view/CacheMixin"],function(t,e,i,n){var o=t.create({Extends:i,Mixes:n,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("Text"),o.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=o.measureFontHeight(this.font)},text:null,color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=o.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var n=i.drawable,o=n.domElement,h=o.style;h.font=i.font,h.textAlign=i.textAlign,h.color=i.color,h.width=i.width+"px",h.height=i.height+"px",h.lineHeight=i._fontHeight+i.lineSpacing+"px",o.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var n,o,h,l,r,a=i.split(/\r\n|\r|\n|/),s=0,c=0,d=e._fontHeight+e.lineSpacing,x=[];for(n=0,l=a.length;ne.maxWidth?(x.push({text:w,y:c}),s>1;break;case"bottom":p=e.height-e.textHeight}var v=e.background;for(v&&(t.fillStyle=v,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,n=0;n>1;break;case"right":case"end":o=h}n.outline?t.strokeText(e,o,i):t.fillText(e,o,i)},Statics:{measureFontHeight:function(t){var i,n=document.documentElement,o=e.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return n.appendChild(o),i=o.offsetHeight,n.removeChild(o),i}}});return o}); \ No newline at end of file +define("hilo/view/Text",["hilo/core/Class","hilo/core/Hilo","hilo/view/View","hilo/view/CacheMixin"],function(t,e,i,n){var o=t.create({Extends:i,Mixes:n,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("Text"),o.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=o.measureFontHeight(this.font)},text:"",color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=o.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var n=i.drawable,o=n.domElement,h=o.style;h.font=i.font,h.textAlign=i.textAlign,h.color=i.color,h.width=i.width+"px",h.height=i.height+"px",h.lineHeight=i._fontHeight+i.lineSpacing+"px",o.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var n,o,h,r,l,a=i.split(/\r\n|\r|\n|/),s=0,c=0,d=e._fontHeight+e.lineSpacing,x=[];for(n=0,r=a.length;ne.maxWidth?(x.push({text:w,y:c}),s>1;break;case"bottom":p=e.height-e.textHeight}var v=e.background;for(v&&(t.fillStyle=v,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,n=0;n>1;break;case"right":case"end":o=h}n.outline?t.strokeText(e,o,i):t.fillText(e,o,i)},Statics:{measureFontHeight:function(t){var i,n=document.documentElement,o=e.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return n.appendChild(o),i=o.offsetHeight,n.removeChild(o),i}}});return o}); \ No newline at end of file diff --git a/build/amd/hilo/view/View.js b/build/amd/hilo/view/View.js index 63e8d660..995f6533 100644 --- a/build/amd/hilo/view/View.js +++ b/build/amd/hilo/view/View.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/View.min.js b/build/amd/hilo/view/View.min.js index bc609364..d62ecbaf 100644 --- a/build/amd/hilo/view/View.min.js +++ b/build/amd/hilo/view/View.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for amd + * Hilo 1.4.0 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo-cmd.js b/build/cmd/hilo-cmd.js index 2a51d92c..1b8fbf01 100644 --- a/build/cmd/hilo-cmd.js +++ b/build/cmd/hilo-cmd.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -192,7 +192,7 @@ return browser; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -229,7 +229,7 @@ return util; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -260,7 +260,7 @@ var Hilo = { * Hilo version * @type String */ - version: '1.3.0', + version: '1.4.0', /** * @language=en * Gets a globally unique id. Such as Stage1, Bitmap2 etc. @@ -568,7 +568,7 @@ return Hilo; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -751,7 +751,7 @@ return Class; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -977,7 +977,7 @@ return Matrix; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1132,7 +1132,7 @@ return EventMixin; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1216,7 +1216,7 @@ return Drawable; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1313,7 +1313,7 @@ return Renderer; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1528,7 +1528,7 @@ return CanvasRenderer; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1715,7 +1715,7 @@ return DOMRenderer; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1777,7 +1777,13 @@ var WebGLRenderer = Class.create(/** @lends WebGLRenderer.prototype */{ } } return this._isSupported; - } + }, + /** + * WebGL context Options + * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getContextAttributes + * @type {Object} + */ + contextOptions: null }, renderType:'webgl', gl:null, @@ -1786,7 +1792,8 @@ var WebGLRenderer = Class.create(/** @lends WebGLRenderer.prototype */{ constructor: function(properties){ WebGLRenderer.superclass.constructor.call(this, properties); var that = this; - this.gl = this.canvas.getContext("webgl")||this.canvas.getContext('experimental-webgl'); + var contextOptions = WebGLRenderer.contextOptions || {}; + this.gl = this.canvas.getContext("webgl", contextOptions)||this.canvas.getContext('experimental-webgl', contextOptions); this.maxBatchNum = WebGLRenderer.MAX_BATCH_NUM; this.positionStride = WebGLRenderer.ATTRIBUTE_NUM * 4; @@ -2297,7 +2304,7 @@ return WebGLRenderer; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2800,7 +2807,7 @@ return View; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2869,7 +2876,7 @@ return CacheMixin; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3247,7 +3254,7 @@ return Container; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3523,7 +3530,7 @@ return Stage; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3606,7 +3613,7 @@ return Bitmap; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3882,7 +3889,7 @@ return Sprite; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4002,7 +4009,7 @@ return DOMElement; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4017,7 +4024,7 @@ var CacheMixin = require('hilo/view/CacheMixin'); /** * @language=en - * + * *
* @class Graphics class contains a group of functions for creating vector graphics. * @augments View @@ -4569,7 +4576,7 @@ return Graphics; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4622,7 +4629,7 @@ var Text = Class.create(/** @lends Text.prototype */{ this._fontHeight = Text.measureFontHeight(this.font); }, - text: null, + text: '', color: '#000', textAlign: null, textVAlign: null, @@ -4827,7 +4834,7 @@ return Text; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5016,7 +5023,7 @@ return BitmapText; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5201,7 +5208,7 @@ return Button; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5440,7 +5447,7 @@ return TextureAtlas; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5672,7 +5679,7 @@ return Ticker; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5720,7 +5727,7 @@ if (!fnProto.bind) { }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5861,7 +5868,7 @@ return drag; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6313,7 +6320,7 @@ return Tween; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6585,7 +6592,7 @@ return Ease; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6635,7 +6642,7 @@ return ImageLoader; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6704,7 +6711,7 @@ return ScriptLoader; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6959,7 +6966,7 @@ return LoadQueue; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7166,7 +7173,7 @@ return HTMLAudio; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7487,7 +7494,7 @@ return WebAudio; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7594,7 +7601,7 @@ return WebSound; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7690,7 +7697,7 @@ return Camera; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7880,7 +7887,7 @@ return Camera3d; }); /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo-cmd.min.js b/build/cmd/hilo-cmd.min.js index e91414cd..b8f93a60 100644 --- a/build/cmd/hilo-cmd.min.js +++ b/build/cmd/hilo-cmd.min.js @@ -1,8 +1,8 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ -define(function(t,e,i){var r=function(){var t=navigator.userAgent,e=document,i=window,r=e.documentElement,n={iphone:/iphone/i.test(t),ipad:/ipad/i.test(t),ipod:/ipod/i.test(t),ios:/iphone|ipad|ipod/i.test(t),android:/android/i.test(t),webkit:/webkit/i.test(t),chrome:/chrome/i.test(t),safari:/safari/i.test(t),firefox:/firefox/i.test(t),ie:/msie/i.test(t),opera:/opera/i.test(t),supportTouch:"ontouchstart"in i,supportCanvas:null!=e.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in i||"orientation"in i.screen,supportDeviceMotion:"ondevicemotion"in i};try{var a="hilo";localStorage.setItem(a,a),localStorage.removeItem(a),n.supportStorage=!0}catch(o){}var s=n.jsVendor=n.webkit?"webkit":n.firefox?"webkit":n.opera?"o":n.ie?"ms":"",h=n.cssVendor="-"+s+"-",l=e.createElement("div"),c=l.style,u=void 0!=c[s+"Transform"],d=void 0!=c[s+"Perspective"];d&&(l.id="test3d",c=e.createElement("style"),c.textContent="@media ("+h+"transform-3d){#test3d{height:3px}}",e.head.appendChild(c),r.appendChild(l),d=3==l.offsetHeight,e.head.removeChild(c),r.removeChild(l)),n.supportTransform=u,n.supportTransform3D=d;var f=n.supportTouch,p=f?"touchstart":"mousedown",v=f?"touchmove":"mousemove",m=f?"touchend":"mouseup";return n.POINTER_START=p,n.POINTER_MOVE=v,n.POINTER_END=m,n}();return r}),define(function(t,e,i){var r={copy:function(t,e,i){for(var r in e)i&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t}};return r}),define(function(t,e,i){var r=t("hilo/util/browser"),n=t("hilo/util/util"),a=window,o=document,s=o.documentElement,h=0,l={},c={version:"1.3.0",getUid:function(t){var e=++h;if(t){var i=t.charCodeAt(t.length-1);return i>=48&&i<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,i=t;i;)e=e?i.id+"."+e:i.id,i=i.parent;return e},copy:function(t,e,i){return n.copy(t,e,i),l.copy||(l.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),t},browser:r,event:{POINTER_START:r.POINTER_START,POINTER_MOVE:r.POINTER_MOVE,POINTER_END:r.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(t){var e;try{e=t.getBoundingClientRect()}catch(i){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var r=(a.pageXOffset||s.scrollLeft)-(s.clientLeft||0)||0,n=(a.pageYOffset||s.scrollTop)-(s.clientTop||0)||0,o=a.getComputedStyle?getComputedStyle(t):t.currentStyle,h=parseInt,l=h(o.paddingLeft)+h(o.borderLeftWidth)||0,c=h(o.paddingTop)+h(o.borderTopWidth)||0,u=h(o.paddingRight)+h(o.borderRightWidth)||0,d=h(o.paddingBottom)+h(o.borderBottomWidth)||0,f=e.top||0,p=e.left||0,v=e.right||0,m=e.bottom||0;return{left:p+r+l,top:f+n+c,width:v-u-p-l,height:m-d-f-c}},createElement:function(t,e){var i,r,n,a=o.createElement(t);for(i in e)if(r=e[i],"style"===i)for(n in r)a.style[n]=r[n];else a[i]=r;return a},getElement:function(t){return o.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,i=e.domElement.style,r=t._stateCache||(t._stateCache={}),n=c.browser.jsVendor,a="px",o=!1;if(this.cacheStateIfChanged(t,["visible"],r)&&(i.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],r)&&(i.opacity=t.alpha),t.visible&&!(t.alpha<=0)){if(this.cacheStateIfChanged(t,["width"],r)&&(i.width=t.width+a),this.cacheStateIfChanged(t,["height"],r)&&(i.height=t.height+a),this.cacheStateIfChanged(t,["depth"],r)&&(i.zIndex=t.depth+1),t.transform){var s=t.transform;(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(i[n+"TransformOrigin"]="0 0"),i[n+"Transform"]="matrix3d("+s.a+", "+s.b+", 0, 0, "+s.c+", "+s.d+", 0, 0, 0, 0, 1, 0, "+s.tx+", "+s.ty+", 0, 1)"}else(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(i[n+"TransformOrigin"]=t.pivotX+a+" "+t.pivotY+a),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],r)||o)&&(i[n+"Transform"]=this.getTransformCSS(t));this.cacheStateIfChanged(t,["background"],r)&&(i.backgroundColor=t.background),i.pointerEvents||(i.pointerEvents="none");var h=e.image;if(h){var l=h.src;l!==r.image&&(r.image=l,i.backgroundImage="url("+l+")");var u=e.rect;if(u){var d=u[0],f=u[1];d!==r.sx&&(r.sx=d,i.backgroundPositionX=-d+a),f!==r.sy&&(r.sy=f,i.backgroundPositionY=-f+a)}}var p=t.mask;if(p){var v=p.drawable.domElement.style.backgroundImage;v!==r.maskImage&&(r.maskImage=v,i[n+"MaskImage"]=v,i[n+"MaskRepeat"]="no-repeat");var m=p.x,g=p.y;m===r.maskX&&g===r.maskY||(r.maskX=m,r.maskY=g,i[n+"MaskPosition"]=m+a+" "+g+a)}}},cacheStateIfChanged:function(t,e,i){var r,n,a,o,s=!1;for(r=0,n=e.length;r=6?(e=s[0],i=s[1],r=s[2],n=s[3],a=s[4],o=s[5]):(e=t.a,i=t.b,r=t.c,n=t.d,a=t.tx,o=t.ty),this.a=h*e+l*r,this.b=h*i+l*n,this.c=c*e+u*r,this.d=c*i+u*n,this.tx=d*e+f*r+a,this.ty=d*i+f*n+o,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),r=this.a,n=this.b,a=this.c,o=this.d,s=this.tx,h=this.ty;return this.a=r*i-n*e,this.b=r*e+n*i,this.c=a*i-o*e,this.d=a*e+o*i,this.tx=s*i-h*e,this.ty=s*e+h*i,this},scale:function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},translate:function(t,e){return this.tx+=t,this.ty+=e,this},identity:function(){return this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this},invert:function(){var t=this.a,e=this.b,i=this.c,r=this.d,n=this.tx,a=t*r-e*i;return this.a=r/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-r*n)/a,this.ty=-(t*this.ty-e*n)/a,this},transformPoint:function(t,e,i){var r=t.x*this.a+t.y*this.c+this.tx,n=t.x*this.b+t.y*this.d+this.ty;return e&&(r=r+.5>>0,n=n+.5>>0),i?{x:r,y:n}:(t.x=r,t.y=n,t)}});return n}),define(function(t,e,i){var r=t("hilo/core/Class"),n={_listeners:null,on:function(t,e,i){for(var r=this._listeners=this._listeners||{},n=r[t]=r[t]||[],a=0,o=n.length;a-1&&o.splice(c,1)}}return 0==o.length&&delete n[r],!0}return!1}},a=r.create({constructor:function(t,e,i){this.type=t,this.target=e,this.detail=i,this.timeStamp=+new Date},type:null,target:null,detail:null,timeStamp:0,stopImmediatePropagation:function(){this._stopped=!0}}),o=window.Event;if(o){var s=o.prototype,h=s.stopImmediatePropagation;s.stopImmediatePropagation=function(){h&&h.call(this),this._stopped=!0}}return n}),define(function(t,e,i){var r=t("hilo/core/Class"),n=t("hilo/util/util"),a=r.create({constructor:function(t){this.init(t)},image:null,rect:null,init:function(t){var e=this,i=e.image;a.isDrawable(t)?e.image=t:n.copy(e,t,!0);var r=e.image;if("string"==typeof r){if(!i||r!==i.getAttribute("src")){e.image=null;var o=new Image;return t.crossOrigin&&(o.crossOrigin=t.crossOrigin),o.onload=function(){o.onload=null,e.init(o)},void(o.src=r)}r=e.image=i}r&&!e.rect&&(e.rect=[0,0,r.width,r.height])},Statics:{isDrawable:function(t){if(!t||!t.tagName)return!1;var e=t.tagName.toLowerCase();return"img"===e||"canvas"===e||"video"===e}}});return a}),define(function(t,e,i){var r=t("hilo/core/Class"),n=t("hilo/util/util"),a=r.create({constructor:function(t){t=t||{},n.copy(this,t,!0)},renderType:null,canvas:null,stage:null,blendMode:"source-over",startDraw:function(t){},draw:function(t){},endDraw:function(t){},transform:function(){},hide:function(){},remove:function(t){},clear:function(t,e,i,r){},resize:function(t,e){}});return a}),define(function(t,e,i){var r=t("hilo/core/Class"),n=t("hilo/core/Hilo"),a=t("hilo/renderer/Renderer"),o=r.create({Extends:a,constructor:function(t){o.superclass.constructor.call(this,t),this.context=this.canvas.getContext("2d")},renderType:"canvas",context:null,startDraw:function(t){return!!(t.visible&&t.alpha>0)&&(t===this.stage&&this.context.clearRect(0,0,t.width,t.height),t.blendMode!==this.blendMode&&(this.context.globalCompositeOperation=this.blendMode=t.blendMode),this.context.save(),!0)},draw:function(t){var e=this.context,i=t.width,r=t.height,n=t.background;n&&(e.fillStyle=n,e.fillRect(0,0,i,r));var a=t.drawable,o=a&&a.image;if(o){var s=a.rect,h=s[2],l=s[3],c=s[4],u=s[5];if(!h||!l)return;i||r||(i=t.width=h,r=t.height=l),(c||u)&&e.translate(c-.5*h,u-.5*l),e.drawImage(o,s[0],s[1],h,l,0,0,i,r)}},endDraw:function(t){this.context.restore()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void n.setElementStyleByView(t);var i=this.context,r=t.scaleX,a=t.scaleY;if(t===this.stage){var o=this.canvas.style,s=t._scaleX,h=t._scaleY,l=!1;(!s&&1!=r||s&&s!=r)&&(t._scaleX=r,o.width=r*t.width+"px",l=!0),(!h&&1!=a||h&&h!=a)&&(t._scaleY=a,o.height=a*t.height+"px",l=!0),l&&t.updateViewport()}else{var c=t.x,u=t.y,d=t.pivotX,f=t.pivotY,p=t.rotation%360,v=t.transform,m=t.mask;m&&(m._render(this),i.clip());var g=t.align;if(g){var _=t.getAlignPosition();c=_.x,u=_.y}v?i.transform(v.a,v.b,v.c,v.d,v.tx,v.ty):(0==c&&0==u||i.translate(c,u),0!=p&&i.rotate(p*Math.PI/180),1==r&&1==a||i.scale(r,a),0==d&&0==f||i.translate(-d,-f))}t.alpha>0&&(i.globalAlpha*=t.alpha)},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},clear:function(t,e,i,r){this.context.clearRect(t,e,i,r)},resize:function(t,e){var i=this.canvas,r=this.stage,n=i.style;i.width=t,i.height=e,n.width=r.width*r.scaleX+"px",n.height=r.height*r.scaleY+"px"}});return o}),define(function(t,e,i){var r=t("hilo/core/Class"),n=t("hilo/core/Hilo"),a=t("hilo/renderer/Renderer"),o=t("hilo/view/Drawable"),s=function(){function t(t,e){var i=t.tagName||"div",r=e.image,a=t.width||r&&r.width,o=t.height||r&&r.height,s=n.createElement(i),h=s.style;if(t.id&&(s.id=t.id),h.position="absolute",h.left=(t.left||0)+"px",h.top=(t.top||0)+"px",h.width=a+"px",h.height=o+"px","canvas"==i){if(s.width=a,s.height=o,r){var l=s.getContext("2d"),c=e.rect||[0,0,a,o];l.drawImage(r,c[0],c[1],c[2],c[3],t.x||0,t.y||0,t.width||c[2],t.height||c[3])}}else if(h.opacity=void 0!=t.alpha?t.alpha:1,(t===this.stage||t.clipChildren)&&(h.overflow="hidden"),r&&r.src){h.backgroundImage="url("+r.src+")";var u=t.rectX||0,d=t.rectY||0;h.backgroundPosition=-u+"px "+-d+"px"}return s}return r.create({Extends:a,constructor:function(t){s.superclass.constructor.call(this,t)},renderType:"dom",startDraw:function(e){var i=e.drawable=e.drawable||new o;return i.domElement=i.domElement||t(e,i),!0},draw:function(t){var e=t.parent,i=t.drawable.domElement,r=i.parentNode;if(e){var n=e.drawable.domElement;if(n!=r&&n.appendChild(i),!t.width&&!t.height){var a=t.drawable.rect;a&&(a[2]||a[3])&&(t.width=a[2],t.height=a[3])}}else t!==this.stage||r||(i.style.overflow="hidden",this.canvas.appendChild(i))},transform:function(t){if(n.setElementStyleByView(t),t===this.stage){var e=this.canvas.style,i=t._scaleX,r=t._scaleY,a=t.scaleX,o=t.scaleY;(!i&&1!=a||i&&i!=a)&&(t._scaleX=a,e.width=a*t.width+"px"),(!r&&1!=o||r&&r!=o)&&(t._scaleY=o,e.height=o*t.height+"px")}},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},hide:function(t){var e=t.drawable&&t.drawable.domElement;e&&(e.style.display="none")},resize:function(t,e){var i=this.canvas.style;i.width=t+"px",i.height=e+"px","absolute"!=i.position&&(i.position="relative")}})}();return s}),define(function(t,e,i){var r=t("hilo/core/Class"),n=t("hilo/core/Hilo"),a=t("hilo/renderer/Renderer"),o=t("hilo/geom/Matrix"),s=Math.PI/180,h=r.create({Extends:a,Statics:{MAX_BATCH_NUM:2e3,ATTRIBUTE_NUM:5,isSupport:function(){if(void 0==this._isSupported){var t=document.createElement("canvas");t.getContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))?this._isSupported=!0:this._isSupported=!1}return this._isSupported}},renderType:"webgl",gl:null,_isContextLost:!1,_cacheTexture:{},constructor:function(t){h.superclass.constructor.call(this,t);var e=this;this.gl=this.canvas.getContext("webgl")||this.canvas.getContext("experimental-webgl"),this.maxBatchNum=h.MAX_BATCH_NUM,this.positionStride=4*h.ATTRIBUTE_NUM;var i=this.maxBatchNum*h.ATTRIBUTE_NUM*4,r=6*this.maxBatchNum;this.arrayBuffer=new ArrayBuffer(4*i),this.float32Array=new Float32Array(this.arrayBuffer),this.uint32Array=new Uint32Array(this.arrayBuffer),this.indexs=new Uint16Array(r);for(var n=0,a=0;n0)&&(t===this.stage&&this.clear(),!0)},draw:function(t){var e=t.width,i=t.height,r=(t.background,t.drawable),n=r&&r.image;if(n){var a=r.rect,o=a[2],s=a[3];e||i||(e=t.width=o,i=t.height=s),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(n,a[0],a[1],o,s,0,0,e,i),l=this.batchIndex*this.positionStride,c=this.float32Array,u=this.uint32Array,d=(t.tint>>16)+(65280&t.tint)+((255&t.tint)<<16)+(255*t.__webglRenderAlpha<<24);c[l+0]=h[0],c[l+1]=h[1],c[l+2]=h[2],c[l+3]=h[3],u[l+4]=d,c[l+5]=h[4],c[l+6]=h[5],c[l+7]=h[6],c[l+8]=h[7],u[l+9]=d,c[l+10]=h[8],c[l+11]=h[9],c[l+12]=h[10],c[l+13]=h[11],u[l+14]=d,c[l+15]=h[12],c[l+16]=h[13],c[l+17]=h[14],c[l+18]=h[15],u[l+19]=d;for(var f=t.__webglWorldMatrix,p=0;p<4;p++){var v=c[l+5*p],m=c[l+5*p+1];c[l+5*p]=f.a*v+f.c*m+f.tx,c[l+5*p+1]=f.b*v+f.d*m+f.ty}t.__textureImage=n,this.sprites[this.batchIndex++]=t}},endDraw:function(t){t===this.stage&&this._renderBatches()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void n.setElementStyleByView(t);var i=t.scaleX,r=t.scaleY;if(t===this.stage){var a=this.canvas.style,s=t._scaleX,h=t._scaleY,l=!1;(!s&&1!=i||s&&s!=i)&&(t._scaleX=i,a.width=i*t.width+"px",l=!0),(!h&&1!=r||h&&h!=r)&&(t._scaleY=r,a.height=r*t.height+"px",l=!0),l&&t.updateViewport(),t.__webglWorldMatrix=t.__webglWorldMatrix||new o(1,0,0,1,0,0)}else t.parent&&(t.__webglWorldMatrix=t.__webglWorldMatrix||new o(1,0,0,1,0,0),this._setConcatenatedMatrix(t,t.parent));t.alpha>0&&(t.parent&&t.parent.__webglRenderAlpha?t.__webglRenderAlpha=t.alpha*t.parent.__webglRenderAlpha:t.__webglRenderAlpha=t.alpha)},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},clear:function(t,e,i,r){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(t,e){if(this.width!==t||this.height!==e){var i=this.canvas,r=this.stage,n=i.style;this.width=i.width=t,this.height=i.height=e,n.width=r.width*r.scaleX+"px",n.height=r.height*r.scaleY+"px",this.gl.viewport(0,0,t,e),this.canvasHalfWidth=.5*t,this.canvasHalfHeight=.5*e,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var t=this.gl;t.bufferSubData(t.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var e=0,i=0,r=null,n=0;n0&&(i.bindTexture(i.TEXTURE_2D,this._getTexture(this.sprites[t])),i.drawElements(i.TRIANGLES,6*r,i.UNSIGNED_SHORT,6*t*2))},_uploadProjectionTransform:function(t){this._projectionTransformElements&&!t||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var t=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",e="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new l(this,{v:t,f:e},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(t,e,i,r,n,a,o,s,h){var l=this.__tempVertexs||[],c=t.width,u=t.height;r/=c,n/=u,e/=c,i/=u,s=s,h=h,a=a,o=o,r+e>1&&(r=1-e),n+i>1&&(n=1-i);var d=0;return l[d++]=a,l[d++]=o,l[d++]=e,l[d++]=i,l[d++]=a+s,l[d++]=o,l[d++]=e+r,l[d++]=i,l[d++]=a,l[d++]=o+h,l[d++]=e,l[d++]=i+n,l[d++]=a+s,l[d++]=o+h,l[d++]=e+r,l[d++]=i+n,l},_setConcatenatedMatrix:function(t,e){var i=t.__webglWorldMatrix,r=1,n=0,a=t.rotation%360,o=t.pivotX,h=t.pivotY,l=t.scaleX,c=t.scaleY,u=t.transform;if(u)i.copy(u);else{if(a){var d=a*s;r=Math.cos(d),n=Math.sin(d)}var f=t.getAlignPosition();i.a=r*l,i.b=n*l,i.c=-n*c,i.d=r*c,i.tx=f.x-i.a*o-i.c*h,i.ty=f.y-i.b*o-i.d*h}i.concat(e.__webglWorldMatrix)},_getTexture:function(t){var e=t.__textureImage,i=this._cacheTexture[e.src];return i||(i=this.activeShader.uploadTexture(e)),i}}),l=function(t,e,i){this.renderer=t,this.gl=t.gl,this.program=this._createProgram(this.gl,e.v,e.f),i=i||{},this.attributes=i.attributes||[],this.uniforms=i.uniforms||[]};return l.prototype={active:function(){var t=this,e=t.renderer,i=t.gl,r=t.program;r&&i&&(e.activeShader=t,i.useProgram(r),t.attributes.forEach(function(t){e[t]=i.getAttribLocation(r,t),i.enableVertexAttribArray(e[t])}),t.uniforms.forEach(function(t){e[t]=i.getUniformLocation(r,t)}),t.width===e.width&&t.height===e.height||(t.width=e.width,t.height=e.height,e._uploadProjectionTransform()))},uploadTexture:function(t){var e=this.gl,i=this.renderer,r=e.createTexture(),n=i.u_Sampler;return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,r),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(n,0),e.bindTexture(e.TEXTURE_2D,null),this.renderer._cacheTexture[t.src]=r,r},_createProgram:function(t,e,i){var r=this._createShader(t,t.VERTEX_SHADER,e),n=this._createShader(t,t.FRAGMENT_SHADER,i);if(!r||!n)return null;var a=t.createProgram();if(a){t.attachShader(a,r),t.attachShader(a,n),t.linkProgram(a),t.deleteShader(n),t.deleteShader(r);var o=t.getProgramParameter(a,t.LINK_STATUS);if(!o){var s=t.getProgramInfoLog(a);return console.log("Failed to link program: "+s),t.deleteProgram(a),null}}return a},_createShader:function(t,e,i){var r=t.createShader(e);if(r){t.shaderSource(r,i),t.compileShader(r);var n=t.getShaderParameter(r,t.COMPILE_STATUS);if(!n){var a=t.getShaderInfoLog(r);return console.log("Failed to compile shader: "+a),t.deleteShader(r),null}}return r}},h}),define(function(t,e,i){var r=t("hilo/core/Hilo"),n=t("hilo/core/Class"),a=t("hilo/event/EventMixin"),o=t("hilo/geom/Matrix"),s=t("hilo/util/util"),h=function(){function t(t,e,i){for(var r,n,a,o,s=0,h=!1,l=0,c=i.length;ld.x?(r=d.x,n=u.x):(r=u.x,n=d.x),t>=r&&t<=n))h=!0;else if(u.y>d.y?(a=d.y,o=u.y):(a=u.y,o=d.y),!(eo)){var f=(e-u.y)*(d.x-u.x)/(d.y-u.y)+u.x;if(f>t?s++:f==t&&(h=!0),u.x>t&&u.y==e){var p=i[(c+l-1)%c];(p.ye||p.y>e&&d.ys?s=c:cl?l=c:c=0)return!1;u>i.overlap&&(i.overlap=u,i.normal.x=p.x,i.normal.y=p.y)}return i}return n.create({Mixes:a,constructor:function(t){t=t||{},this.id=this.id||t.id||r.getUid("View"),s.copy(this,t,!0)},tint:16777215,id:null,x:0,y:0,width:0,height:0,alpha:1,rotation:0,visible:!0,pivotX:0,pivotY:0,scaleX:1,scaleY:1,pointerEnabled:!0,background:null,mask:null,align:null,drawable:null,boundsArea:null,parent:null,depth:-1,transform:null,blendMode:"source-over",getStage:function(){for(var t,e=this;t=e.parent;)e=t;return e.canvas?e:null},getScaledWidth:function(){return this.width*this.scaleX},getScaledHeight:function(){return this.height*this.scaleY},addTo:function(t,e){return"number"==typeof e?t.addChildAt(this,e):t.addChild(this),this},removeFromParent:function(){var t=this.parent;return t&&t.removeChild(this),this},getBounds:function(){for(var t,e,i,r,n,a,o,s=this.width,h=this.height,l=this.getConcatenatedMatrix(),c=this.boundsArea||[{x:0,y:0},{x:s,y:0},{x:s,y:h},{x:0,y:h}],u=[],d=0,f=c.length;de?r=e:ni?a=i:o>1,r=0;break;case"TR":i=o-n,r=0;break;case"L":i=0,r=s-a>>1;break;case"C":i=o-n>>1,r=s-a>>1;break;case"R":i=o-n,r=s-a>>1;break;case"BL":i=0,r=s-a;break;case"B":i=o-n>>1,r=s-a;break;case"BR":i=o-n,r=s-a}}return{x:i,y:r}},hitTestPoint:function(e,i,r){var n=this.getBounds(),a=e>=n.x&&e<=n.x+n.width&&i>=n.y&&i<=n.y+n.height;return a&&r&&(a=t(e,i,n)),a},hitTestObject:function(t,i){var r=this.getBounds(),n=t.getBounds(),a=r.x<=n.x+n.width&&n.x<=r.x+r.width&&r.y<=n.y+n.height&&n.y<=r.y+r.height;return a&&i&&(a=e(r,n)),!!a},_render:function(t,e){this.onUpdate&&this.onUpdate(e)===!1||!t.startDraw(this)||(t.transform(this),this.render(t,e),t.endDraw(this))},_fireMouseEvent:function(t){if(t.eventCurrentTarget=this,this.fire(t),"mousemove"==t.type){if(!this.__mouseOver){this.__mouseOver=!0;var e=s.copy({},t);e.type="mouseover",this.fire(e)}}else"mouseout"==t.type&&(this.__mouseOver=!1);var i=this.parent;t._stopped||t._stopPropagationed||!i||("mouseout"==t.type||"touchout"==t.type?i.hitTestPoint(t.stageX,t.stageY,!0)||i._fireMouseEvent(t):i._fireMouseEvent(t))},onUpdate:null,render:function(t,e){t.draw(this)},toString:function(){return r.viewToString(this)}})}();return h}),define(function(t,e,i){var r,n,a=t("hilo/view/Drawable"),o=t("hilo/util/browser"),s={_cacheDirty:!0,cache:function(t){(t||this._cacheDirty||!this.drawable)&&this.updateCache()},updateCache:function(){o.supportCanvas&&(r||(r=document.createElement("canvas"),n=r.getContext("2d")),r.width=this.width,r.height=this.height,this._draw(n),this.drawable=this.drawable||new a,this.drawable.init({image:r.toDataURL()}),this._cacheDirty=!1)},setCacheDirty:function(t){this._cacheDirty=t}};return s}),define(function(t,e,i){var r=t("hilo/core/Hilo"),n=t("hilo/core/Class"),a=t("hilo/view/View"),o=n.create({Extends:a,constructor:function(t){t=t||{},this.id=this.id||t.id||r.getUid("Container"),o.superclass.constructor.call(this,t),this.children?this._updateChildren():this.children=[]},children:null,pointerChildren:!0,clipChildren:!1,getNumChildren:function(){return this.children.length},addChildAt:function(t,e){var i=this.children,r=i.length,n=t.parent;e=e<0?0:e>r?r:e;var a=this.getChildIndex(t);if(a==e)return this;if(a>=0?(i.splice(a,1),e=e==r?r-1:e):n&&n.removeChild(t),i.splice(e,0,t),a<0)this._updateChildren(e);else{var o=a=e.length)return null;var i=e[t];if(i){if(!i.__renderer)for(var r=i;r=r.parent;){if(r.renderer){i.__renderer=r.renderer;break}if(r.__renderer){i.__renderer=r.__renderer;break}}i.__renderer&&i.__renderer.remove(i),i.parent=null,i.depth=-1}return e.splice(t,1),this._updateChildren(t),i},removeChild:function(t){return this.removeChildAt(this.getChildIndex(t))},removeChildById:function(t){for(var e,i=this.children,r=0,n=i.length;r=e.length?null:e[t]},getChildById:function(t){for(var e,i=this.children,r=0,n=i.length;r=0&&r!=e){var n=i.length;e=e<0?0:e>=n?n-1:e,i.splice(r,1),i.splice(e,0,t),this._updateChildren()}return this},swapChildren:function(t,e){var i=this.children,r=this.getChildIndex(t),n=this.getChildIndex(e);t.depth=n,i[n]=t,e.depth=r,i[r]=e},swapChildrenAt:function(t,e){var i=this.children,r=this.getChildAt(t),n=this.getChildAt(e);r.depth=e,i[e]=r,n.depth=t,i[t]=n},sortChildren:function(t){var e=t,i=this.children;if("string"==typeof e){var r=e;e=function(t,e){return e[r]-t[r]}}i.sort(e),this._updateChildren()},_updateChildren:function(t,e){var i,r=this.children;t=t||0,e=e||r.length;for(var n=t;n=0;l--)if(a=h[l],!(!a||!a.visible||a.alpha<=0||n&&!a.pointerEnabled))if(a.children&&a.children.length&&(!n||a.pointerChildren)&&(o=a.getViewAtPoint(t,e,i,r,n)),o){if(!r)return o;o.length&&(s=s.concat(o))}else if(a.hitTestPoint(t,e,i)){if(!r)return a;s.push(a)}return r&&s.length?s:null},render:function(t,e){o.superclass.render.call(this,t,e);var i,r,n,a=this.children.slice(0);for(i=0,r=a.length;ir?r:e,i[e]=t,t.name&&(this._frameNames[t.name]=t),(0!=e||this.width)&&this.height||(this.width=t.rect[2],this.height=t.rect[3]),this},getFrame:function(t){if("number"==typeof t){var e=this._frames;return t<0||t>=e.length?null:e[t]}return this._frameNames[t]},getFrameIndex:function(t){var e=this._frames,i=e.length,r=-1;if("number"==typeof t)r=t;else{var n="string"==typeof t?this._frameNames[t]:t;if(n)for(var a=0;a=i?i-1:r,this.paused=e,this._firstRender=!0,this},_render:function(t,e){var i,r=this.currentFrame;if(this._firstRender?(i=r,this._firstRender=!1):i=this._nextFrame(e),i!=r){this.currentFrame=i;var n=this._frames[i].callback;n&&n.call(this)}this.onEnterFrame&&this.onEnterFrame(i),this.drawable.init(this._frames[i]),s.superclass._render.call(this,t,e)},_nextFrame:function(t){var e=this._frames,i=e.length,r=this.currentFrame,n=e[r],a=n.duration||this.interval,o=this._frameElapsed,s=0!=r||this.drawable?o+(this.timeBased?t:1):0;return o=this._frameElapsed=s=i-1)&&this.stop(),this.paused||0!=o||(null!=n.next?r=this.getFrameIndex(n.next):r>=i-1?r=0:this.drawable&&r++),r},setFrameCallback:function(t,e){return t=this.getFrame(t),t&&(t.callback=e),this},onEnterFrame:null});return s}),define(function(t,e,i){var r=t("hilo/core/Hilo"),n=t("hilo/core/Class"),a=t("hilo/view/View"),o=t("hilo/view/Drawable"),s=n.create({Extends:a,constructor:function(t){t=t||{},this.id=this.id||t.id||r.getUid("DOMElement"),s.superclass.constructor.call(this,t),this.drawable=new o;var e=this.drawable.domElement=t.element||r.createElement("div");e.id=this.id,this.pointerEnabled&&!e.style.pointerEvents&&(e.style.pointerEvents="visible")},_render:function(t,e){this.onUpdate&&this.onUpdate(e)===!1||(t.transform(this),this.visible&&this.alpha>0&&this.render(t,e))},render:function(t,e){if("dom"!==t.renderType){var i=t.canvas,n=this.parent,a=t._domElementContainer;t._domElementContainer||(a=t._domElementContainer=r.createElement("div",{style:{position:"absolute",transform:"scale3d("+n.scaleX+","+n.scaleY+", 1)",transformOrigin:"0 0",zIndex:"1"}}),i.parentNode.insertBefore(t._domElementContainer,i.nextSibling));var o,s=this.drawable.domElement,h=this.depth,l=a.childNodes[0];if(s.parentNode)return;for(;l&&3!=l.nodeType&&(o=parseInt(l.style.zIndex)||0,!(o<=0||o>h));)l=l.nextSibling;a.insertBefore(this.drawable.domElement,l)}else t.draw(this)}});return s}),define(function(t,e,i){var r=t("hilo/core/Hilo"),n=t("hilo/core/Class"),a=t("hilo/view/View"),o=t("hilo/view/CacheMixin"),s=function(){var t=document.createElement("canvas"),e=t.getContext&&t.getContext("2d");return n.create({Extends:a,Mixes:o,constructor:function(t){t=t||{},this.id=this.id||t.id||r.getUid("Graphics"),s.superclass.constructor.call(this,t),this._actions=[]},lineWidth:1,lineAlpha:1,lineCap:null,lineJoin:null,miterLimit:10,hasStroke:!1,strokeStyle:"0",hasFill:!1,fillStyle:"0",fillAlpha:0,lineStyle:function(t,e,i,r,n,a){var o=this,s=o._addAction;return s.call(o,["lineWidth",o.lineWidth=t||1]),s.call(o,["strokeStyle",o.strokeStyle=e||"0"]),s.call(o,["lineAlpha",o.lineAlpha=i||1]),void 0!=r&&s.call(o,["lineCap",o.lineCap=r]),void 0!=n&&s.call(o,["lineJoin",o.lineJoin=n]),void 0!=a&&s.call(o,["miterLimit",o.miterLimit=a]),o.hasStroke=!0,o},setLineDash:function(t){return this._addAction(["setLineDash",t])},beginFill:function(t,e){var i=this,r=i._addAction;return r.call(i,["fillStyle",i.fillStyle=t]),r.call(i,["fillAlpha",i.fillAlpha=e||1]),i.hasFill=!0,i},endFill:function(){var t=this,e=t._addAction;return t.hasStroke&&e.call(t,["stroke"]),t.hasFill&&e.call(t,["fill"]),t.setCacheDirty(!0),t},beginLinearGradientFill:function(t,i,r,n,a,o){for(var s=this,h=e.createLinearGradient(t,i,r,n),l=0,c=a.length;l1?a.slice(1):null;"function"==typeof t[o]?t[o].apply(t,s):t[o]=a[1]}},render:function(t,e){var i=this;"canvas"===t.renderType?i._draw(t.context):(i.cache(),t.draw(i))},clear:function(){var t=this;return t._actions.length=0,t.lineWidth=1,t.lineAlpha=1,t.lineCap=null,t.lineJoin=null,t.miterLimit=10,t.hasStroke=!1,t.strokeStyle="0",t.hasFill=!1,t.fillStyle="0",t.fillAlpha=1,t.setCacheDirty(!0),t},_addAction:function(t){var e=this;return e._actions.push(t),e}})}();return s}),define(function(t,e,i){var r=t("hilo/core/Class"),n=t("hilo/core/Hilo"),a=t("hilo/view/View"),o=t("hilo/view/CacheMixin"),s=r.create({Extends:a,Mixes:o,constructor:function(t){t=t||{},this.id=this.id||t.id||n.getUid("Text"),s.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=s.measureFontHeight(this.font)},text:null,color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=s.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var r=i.drawable,n=r.domElement,a=n.style;a.font=i.font,a.textAlign=i.textAlign,a.color=i.color,a.width=i.width+"px",a.height=i.height+"px",a.lineHeight=i._fontHeight+i.lineSpacing+"px",n.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var r,n,a,o,s,h=i.split(/\r\n|\r|\n|/),l=0,c=0,u=e._fontHeight+e.lineSpacing,d=[];for(r=0,o=h.length;re.maxWidth?(d.push({text:m,y:c}),l>1;break;case"bottom":_=e.height-e.textHeight}var x=e.background;for(x&&(t.fillStyle=x,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,r=0;r>1;break;case"right":case"end":n=a}r.outline?t.strokeText(e,n,i):t.fillText(e,n,i)},Statics:{measureFontHeight:function(t){var e,i=document.documentElement,r=n.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return i.appendChild(r),e=r.offsetHeight,i.removeChild(r),e}}});return s}),define(function(t,e,i){var r=t("hilo/core/Class"),n=t("hilo/core/Hilo"),a=t("hilo/view/Container"),o=t("hilo/view/Bitmap"),s=r.create({Extends:a,constructor:function(t){t=t||{},this.id=this.id||t.id||n.getUid("BitmapText"),s.superclass.constructor.call(this,t);var e=t.text+"";e&&(this.text="",this.setText(e)),this.pointerChildren=!1},glyphs:null,letterSpacing:0,text:"",textAlign:"left",setText:function(t){var e=this,i=t.toString(),r=i.length;if(e.text!=i){e.text=i;var n,a,o,s,h=0,l=0,c=0;for(n=0;n0?e.letterSpacing:0),e.children[n]?(s=e.children[n],s.setImage(o.image,o.rect)):(s=e._createBitmap(o),e.addChild(s)),s.x=c,h=c+o.rect[2],l=Math.max(l,o.rect[3]));for(n=e.children.length-1;n>=r;n--)e._releaseBitmap(e.children[n]),e.children[n].removeFromParent();return e.width=h,e.height=l,this.setTextAlign(),e}},_createBitmap:function(t){var e;return s._pool.length?(e=s._pool.pop(),e.setImage(t.image,t.rect)):e=new o({image:t.image,rect:t.rect}),e},_releaseBitmap:function(t){s._pool.push(t)},setTextAlign:function(t){switch(this.textAlign=t||this.textAlign,this.textAlign){case"center":this.pivotX=.5*this.width;break;case"right":this.pivotX=this.width;break;case"left":default:this.pivotX=0}return this},hasGlyphs:function(t){var e=this.glyphs;if(!e)return!1;t=t.toString();var i,r=t.length;for(i=0;i=this._targetFPS?(this._measuredFPS=1e3/(this._tickTime/this._tickCount)+.5>>0,this._tickCount=0,this._tickTime=0):this._tickTime+=t-this._lastTime,this._lastTime=t;for(var r=i.slice(0),n=0,a=r.length;n=0&&e.splice(i,1)},nextTick:function(t){var e=this,i={tick:function(r){e.removeTick(i),t()}};return e.addTick(i),i},timeout:function(t,e){var i=this,r=(new Date).getTime()+e,n={tick:function(){var e=(new Date).getTime(),a=e-r;a>=0&&(i.removeTick(n),t())}};return i.addTick(n),n},interval:function(t,e){var i=this,r=(new Date).getTime()+e,n={tick:function(){var i=(new Date).getTime(),n=i-r;n>=0&&(n=r)return-1;for(e<0&&(e=r+e),i=e;i=1?1:s;var l=r.ease?r.ease(s):s;r.reverse&&(r._reverseFlag<0&&(s=1-s,l=1-l),s<1e-7&&(r.repeat>0&&r._repeatCount++>=r.repeat||0==r.repeat&&!r.loop?h=!0:(r._startTime=t(),r._pausedTime=0,r._reverseFlag*=-1))),r.isStart||(r.setProps(r._fromProps,r._toProps),r.isStart=!0,r.onStart&&r.onStart.call(r,r)),r.time=a,r._render(l),(o=r.onUpdate)&&o.call(r,s,r),s>=1&&(r.reverse?(r._startTime=t(),r._pausedTime=0,r._reverseFlag*=-1):r.loop||r.repeat>0&&r._repeatCount++0&&u<=e?(c._render(s),c.time=a,n.add(c)):h&&(u<0||u>e)&&c.start()}return h?((o=r.onComplete)&&o.call(r,r),!0):void 0}}},Statics:{_tweens:[],tick:function(){var e,i,r=n._tweens,a=r.length;for(i=0;i-1&&r.splice(e,1);else for(e=0;e=i)return void t.fire("complete");if(t._currentIndex=48&&i<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,i=t;i;)e=e?i.id+"."+e:i.id,i=i.parent;return e},copy:function(t,e,i){return n.copy(t,e,i),l.copy||(l.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),t},browser:r,event:{POINTER_START:r.POINTER_START,POINTER_MOVE:r.POINTER_MOVE,POINTER_END:r.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(t){var e;try{e=t.getBoundingClientRect()}catch(i){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var r=(a.pageXOffset||s.scrollLeft)-(s.clientLeft||0)||0,n=(a.pageYOffset||s.scrollTop)-(s.clientTop||0)||0,o=a.getComputedStyle?getComputedStyle(t):t.currentStyle,h=parseInt,l=h(o.paddingLeft)+h(o.borderLeftWidth)||0,c=h(o.paddingTop)+h(o.borderTopWidth)||0,u=h(o.paddingRight)+h(o.borderRightWidth)||0,d=h(o.paddingBottom)+h(o.borderBottomWidth)||0,f=e.top||0,p=e.left||0,v=e.right||0,m=e.bottom||0;return{left:p+r+l,top:f+n+c,width:v-u-p-l,height:m-d-f-c}},createElement:function(t,e){var i,r,n,a=o.createElement(t);for(i in e)if(r=e[i],"style"===i)for(n in r)a.style[n]=r[n];else a[i]=r;return a},getElement:function(t){return o.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,i=e.domElement.style,r=t._stateCache||(t._stateCache={}),n=c.browser.jsVendor,a="px",o=!1;if(this.cacheStateIfChanged(t,["visible"],r)&&(i.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],r)&&(i.opacity=t.alpha),t.visible&&!(t.alpha<=0)){if(this.cacheStateIfChanged(t,["width"],r)&&(i.width=t.width+a),this.cacheStateIfChanged(t,["height"],r)&&(i.height=t.height+a),this.cacheStateIfChanged(t,["depth"],r)&&(i.zIndex=t.depth+1),t.transform){var s=t.transform;(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(i[n+"TransformOrigin"]="0 0"),i[n+"Transform"]="matrix3d("+s.a+", "+s.b+", 0, 0, "+s.c+", "+s.d+", 0, 0, 0, 0, 1, 0, "+s.tx+", "+s.ty+", 0, 1)"}else(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(i[n+"TransformOrigin"]=t.pivotX+a+" "+t.pivotY+a),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],r)||o)&&(i[n+"Transform"]=this.getTransformCSS(t));this.cacheStateIfChanged(t,["background"],r)&&(i.backgroundColor=t.background),i.pointerEvents||(i.pointerEvents="none");var h=e.image;if(h){var l=h.src;l!==r.image&&(r.image=l,i.backgroundImage="url("+l+")");var u=e.rect;if(u){var d=u[0],f=u[1];d!==r.sx&&(r.sx=d,i.backgroundPositionX=-d+a),f!==r.sy&&(r.sy=f,i.backgroundPositionY=-f+a)}}var p=t.mask;if(p){var v=p.drawable.domElement.style.backgroundImage;v!==r.maskImage&&(r.maskImage=v,i[n+"MaskImage"]=v,i[n+"MaskRepeat"]="no-repeat");var m=p.x,g=p.y;m===r.maskX&&g===r.maskY||(r.maskX=m,r.maskY=g,i[n+"MaskPosition"]=m+a+" "+g+a)}}},cacheStateIfChanged:function(t,e,i){var r,n,a,o,s=!1;for(r=0,n=e.length;r=6?(e=s[0],i=s[1],r=s[2],n=s[3],a=s[4],o=s[5]):(e=t.a,i=t.b,r=t.c,n=t.d,a=t.tx,o=t.ty),this.a=h*e+l*r,this.b=h*i+l*n,this.c=c*e+u*r,this.d=c*i+u*n,this.tx=d*e+f*r+a,this.ty=d*i+f*n+o,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),r=this.a,n=this.b,a=this.c,o=this.d,s=this.tx,h=this.ty;return this.a=r*i-n*e,this.b=r*e+n*i,this.c=a*i-o*e,this.d=a*e+o*i,this.tx=s*i-h*e,this.ty=s*e+h*i,this},scale:function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},translate:function(t,e){return this.tx+=t,this.ty+=e,this},identity:function(){return this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this},invert:function(){var t=this.a,e=this.b,i=this.c,r=this.d,n=this.tx,a=t*r-e*i;return this.a=r/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-r*n)/a,this.ty=-(t*this.ty-e*n)/a,this},transformPoint:function(t,e,i){var r=t.x*this.a+t.y*this.c+this.tx,n=t.x*this.b+t.y*this.d+this.ty;return e&&(r=r+.5>>0,n=n+.5>>0),i?{x:r,y:n}:(t.x=r,t.y=n,t)}});return n}),define(function(t,e,i){var r=t("hilo/core/Class"),n={_listeners:null,on:function(t,e,i){for(var r=this._listeners=this._listeners||{},n=r[t]=r[t]||[],a=0,o=n.length;a-1&&o.splice(c,1)}}return 0==o.length&&delete n[r],!0}return!1}},a=r.create({constructor:function(t,e,i){this.type=t,this.target=e,this.detail=i,this.timeStamp=+new Date},type:null,target:null,detail:null,timeStamp:0,stopImmediatePropagation:function(){this._stopped=!0}}),o=window.Event;if(o){var s=o.prototype,h=s.stopImmediatePropagation;s.stopImmediatePropagation=function(){h&&h.call(this),this._stopped=!0}}return n}),define(function(t,e,i){var r=t("hilo/core/Class"),n=t("hilo/util/util"),a=r.create({constructor:function(t){this.init(t)},image:null,rect:null,init:function(t){var e=this,i=e.image;a.isDrawable(t)?e.image=t:n.copy(e,t,!0);var r=e.image;if("string"==typeof r){if(!i||r!==i.getAttribute("src")){e.image=null;var o=new Image;return t.crossOrigin&&(o.crossOrigin=t.crossOrigin),o.onload=function(){o.onload=null,e.init(o)},void(o.src=r)}r=e.image=i}r&&!e.rect&&(e.rect=[0,0,r.width,r.height])},Statics:{isDrawable:function(t){if(!t||!t.tagName)return!1;var e=t.tagName.toLowerCase();return"img"===e||"canvas"===e||"video"===e}}});return a}),define(function(t,e,i){var r=t("hilo/core/Class"),n=t("hilo/util/util"),a=r.create({constructor:function(t){t=t||{},n.copy(this,t,!0)},renderType:null,canvas:null,stage:null,blendMode:"source-over",startDraw:function(t){},draw:function(t){},endDraw:function(t){},transform:function(){},hide:function(){},remove:function(t){},clear:function(t,e,i,r){},resize:function(t,e){}});return a}),define(function(t,e,i){var r=t("hilo/core/Class"),n=t("hilo/core/Hilo"),a=t("hilo/renderer/Renderer"),o=r.create({Extends:a,constructor:function(t){o.superclass.constructor.call(this,t),this.context=this.canvas.getContext("2d")},renderType:"canvas",context:null,startDraw:function(t){return!!(t.visible&&t.alpha>0)&&(t===this.stage&&this.context.clearRect(0,0,t.width,t.height),t.blendMode!==this.blendMode&&(this.context.globalCompositeOperation=this.blendMode=t.blendMode),this.context.save(),!0)},draw:function(t){var e=this.context,i=t.width,r=t.height,n=t.background;n&&(e.fillStyle=n,e.fillRect(0,0,i,r));var a=t.drawable,o=a&&a.image;if(o){var s=a.rect,h=s[2],l=s[3],c=s[4],u=s[5];if(!h||!l)return;i||r||(i=t.width=h,r=t.height=l),(c||u)&&e.translate(c-.5*h,u-.5*l),e.drawImage(o,s[0],s[1],h,l,0,0,i,r)}},endDraw:function(t){this.context.restore()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void n.setElementStyleByView(t);var i=this.context,r=t.scaleX,a=t.scaleY;if(t===this.stage){var o=this.canvas.style,s=t._scaleX,h=t._scaleY,l=!1;(!s&&1!=r||s&&s!=r)&&(t._scaleX=r,o.width=r*t.width+"px",l=!0),(!h&&1!=a||h&&h!=a)&&(t._scaleY=a,o.height=a*t.height+"px",l=!0),l&&t.updateViewport()}else{var c=t.x,u=t.y,d=t.pivotX,f=t.pivotY,p=t.rotation%360,v=t.transform,m=t.mask;m&&(m._render(this),i.clip());var g=t.align;if(g){var _=t.getAlignPosition();c=_.x,u=_.y}v?i.transform(v.a,v.b,v.c,v.d,v.tx,v.ty):(0==c&&0==u||i.translate(c,u),0!=p&&i.rotate(p*Math.PI/180),1==r&&1==a||i.scale(r,a),0==d&&0==f||i.translate(-d,-f))}t.alpha>0&&(i.globalAlpha*=t.alpha)},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},clear:function(t,e,i,r){this.context.clearRect(t,e,i,r)},resize:function(t,e){var i=this.canvas,r=this.stage,n=i.style;i.width=t,i.height=e,n.width=r.width*r.scaleX+"px",n.height=r.height*r.scaleY+"px"}});return o}),define(function(t,e,i){var r=t("hilo/core/Class"),n=t("hilo/core/Hilo"),a=t("hilo/renderer/Renderer"),o=t("hilo/view/Drawable"),s=function(){function t(t,e){var i=t.tagName||"div",r=e.image,a=t.width||r&&r.width,o=t.height||r&&r.height,s=n.createElement(i),h=s.style;if(t.id&&(s.id=t.id),h.position="absolute",h.left=(t.left||0)+"px",h.top=(t.top||0)+"px",h.width=a+"px",h.height=o+"px","canvas"==i){if(s.width=a,s.height=o,r){var l=s.getContext("2d"),c=e.rect||[0,0,a,o];l.drawImage(r,c[0],c[1],c[2],c[3],t.x||0,t.y||0,t.width||c[2],t.height||c[3])}}else if(h.opacity=void 0!=t.alpha?t.alpha:1,(t===this.stage||t.clipChildren)&&(h.overflow="hidden"),r&&r.src){h.backgroundImage="url("+r.src+")";var u=t.rectX||0,d=t.rectY||0;h.backgroundPosition=-u+"px "+-d+"px"}return s}return r.create({Extends:a,constructor:function(t){s.superclass.constructor.call(this,t)},renderType:"dom",startDraw:function(e){var i=e.drawable=e.drawable||new o;return i.domElement=i.domElement||t(e,i),!0},draw:function(t){var e=t.parent,i=t.drawable.domElement,r=i.parentNode;if(e){var n=e.drawable.domElement;if(n!=r&&n.appendChild(i),!t.width&&!t.height){var a=t.drawable.rect;a&&(a[2]||a[3])&&(t.width=a[2],t.height=a[3])}}else t!==this.stage||r||(i.style.overflow="hidden",this.canvas.appendChild(i))},transform:function(t){if(n.setElementStyleByView(t),t===this.stage){var e=this.canvas.style,i=t._scaleX,r=t._scaleY,a=t.scaleX,o=t.scaleY;(!i&&1!=a||i&&i!=a)&&(t._scaleX=a,e.width=a*t.width+"px"),(!r&&1!=o||r&&r!=o)&&(t._scaleY=o,e.height=o*t.height+"px")}},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},hide:function(t){var e=t.drawable&&t.drawable.domElement;e&&(e.style.display="none")},resize:function(t,e){var i=this.canvas.style;i.width=t+"px",i.height=e+"px","absolute"!=i.position&&(i.position="relative")}})}();return s}),define(function(t,e,i){var r=t("hilo/core/Class"),n=t("hilo/core/Hilo"),a=t("hilo/renderer/Renderer"),o=t("hilo/geom/Matrix"),s=Math.PI/180,h=r.create({Extends:a,Statics:{MAX_BATCH_NUM:2e3,ATTRIBUTE_NUM:5,isSupport:function(){if(void 0==this._isSupported){var t=document.createElement("canvas");t.getContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))?this._isSupported=!0:this._isSupported=!1}return this._isSupported},contextOptions:null},renderType:"webgl",gl:null,_isContextLost:!1,_cacheTexture:{},constructor:function(t){h.superclass.constructor.call(this,t);var e=this,i=h.contextOptions||{};this.gl=this.canvas.getContext("webgl",i)||this.canvas.getContext("experimental-webgl",i),this.maxBatchNum=h.MAX_BATCH_NUM,this.positionStride=4*h.ATTRIBUTE_NUM;var r=this.maxBatchNum*h.ATTRIBUTE_NUM*4,n=6*this.maxBatchNum;this.arrayBuffer=new ArrayBuffer(4*r),this.float32Array=new Float32Array(this.arrayBuffer),this.uint32Array=new Uint32Array(this.arrayBuffer),this.indexs=new Uint16Array(n);for(var a=0,o=0;a0)&&(t===this.stage&&this.clear(),!0)},draw:function(t){var e=t.width,i=t.height,r=(t.background,t.drawable),n=r&&r.image;if(n){var a=r.rect,o=a[2],s=a[3];e||i||(e=t.width=o,i=t.height=s),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(n,a[0],a[1],o,s,0,0,e,i),l=this.batchIndex*this.positionStride,c=this.float32Array,u=this.uint32Array,d=(t.tint>>16)+(65280&t.tint)+((255&t.tint)<<16)+(255*t.__webglRenderAlpha<<24);c[l+0]=h[0],c[l+1]=h[1],c[l+2]=h[2],c[l+3]=h[3],u[l+4]=d,c[l+5]=h[4],c[l+6]=h[5],c[l+7]=h[6],c[l+8]=h[7],u[l+9]=d,c[l+10]=h[8],c[l+11]=h[9],c[l+12]=h[10],c[l+13]=h[11],u[l+14]=d,c[l+15]=h[12],c[l+16]=h[13],c[l+17]=h[14],c[l+18]=h[15],u[l+19]=d;for(var f=t.__webglWorldMatrix,p=0;p<4;p++){var v=c[l+5*p],m=c[l+5*p+1];c[l+5*p]=f.a*v+f.c*m+f.tx,c[l+5*p+1]=f.b*v+f.d*m+f.ty}t.__textureImage=n,this.sprites[this.batchIndex++]=t}},endDraw:function(t){t===this.stage&&this._renderBatches()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void n.setElementStyleByView(t);var i=t.scaleX,r=t.scaleY;if(t===this.stage){var a=this.canvas.style,s=t._scaleX,h=t._scaleY,l=!1;(!s&&1!=i||s&&s!=i)&&(t._scaleX=i,a.width=i*t.width+"px",l=!0),(!h&&1!=r||h&&h!=r)&&(t._scaleY=r,a.height=r*t.height+"px",l=!0),l&&t.updateViewport(),t.__webglWorldMatrix=t.__webglWorldMatrix||new o(1,0,0,1,0,0)}else t.parent&&(t.__webglWorldMatrix=t.__webglWorldMatrix||new o(1,0,0,1,0,0),this._setConcatenatedMatrix(t,t.parent));t.alpha>0&&(t.parent&&t.parent.__webglRenderAlpha?t.__webglRenderAlpha=t.alpha*t.parent.__webglRenderAlpha:t.__webglRenderAlpha=t.alpha)},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},clear:function(t,e,i,r){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(t,e){if(this.width!==t||this.height!==e){var i=this.canvas,r=this.stage,n=i.style;this.width=i.width=t,this.height=i.height=e,n.width=r.width*r.scaleX+"px",n.height=r.height*r.scaleY+"px",this.gl.viewport(0,0,t,e),this.canvasHalfWidth=.5*t,this.canvasHalfHeight=.5*e,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var t=this.gl;t.bufferSubData(t.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var e=0,i=0,r=null,n=0;n0&&(i.bindTexture(i.TEXTURE_2D,this._getTexture(this.sprites[t])),i.drawElements(i.TRIANGLES,6*r,i.UNSIGNED_SHORT,6*t*2))},_uploadProjectionTransform:function(t){this._projectionTransformElements&&!t||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var t=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",e="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new l(this,{v:t,f:e},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(t,e,i,r,n,a,o,s,h){var l=this.__tempVertexs||[],c=t.width,u=t.height;r/=c,n/=u,e/=c,i/=u,s=s,h=h,a=a,o=o,r+e>1&&(r=1-e),n+i>1&&(n=1-i);var d=0;return l[d++]=a,l[d++]=o,l[d++]=e,l[d++]=i,l[d++]=a+s,l[d++]=o,l[d++]=e+r,l[d++]=i,l[d++]=a,l[d++]=o+h,l[d++]=e,l[d++]=i+n,l[d++]=a+s,l[d++]=o+h,l[d++]=e+r,l[d++]=i+n,l},_setConcatenatedMatrix:function(t,e){var i=t.__webglWorldMatrix,r=1,n=0,a=t.rotation%360,o=t.pivotX,h=t.pivotY,l=t.scaleX,c=t.scaleY,u=t.transform;if(u)i.copy(u);else{if(a){var d=a*s;r=Math.cos(d),n=Math.sin(d)}var f=t.getAlignPosition();i.a=r*l,i.b=n*l,i.c=-n*c,i.d=r*c,i.tx=f.x-i.a*o-i.c*h,i.ty=f.y-i.b*o-i.d*h}i.concat(e.__webglWorldMatrix)},_getTexture:function(t){var e=t.__textureImage,i=this._cacheTexture[e.src];return i||(i=this.activeShader.uploadTexture(e)),i}}),l=function(t,e,i){this.renderer=t,this.gl=t.gl,this.program=this._createProgram(this.gl,e.v,e.f),i=i||{},this.attributes=i.attributes||[],this.uniforms=i.uniforms||[]};return l.prototype={active:function(){var t=this,e=t.renderer,i=t.gl,r=t.program;r&&i&&(e.activeShader=t,i.useProgram(r),t.attributes.forEach(function(t){e[t]=i.getAttribLocation(r,t),i.enableVertexAttribArray(e[t])}),t.uniforms.forEach(function(t){e[t]=i.getUniformLocation(r,t)}),t.width===e.width&&t.height===e.height||(t.width=e.width,t.height=e.height,e._uploadProjectionTransform()))},uploadTexture:function(t){var e=this.gl,i=this.renderer,r=e.createTexture(),n=i.u_Sampler;return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,r),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(n,0),e.bindTexture(e.TEXTURE_2D,null),this.renderer._cacheTexture[t.src]=r,r},_createProgram:function(t,e,i){var r=this._createShader(t,t.VERTEX_SHADER,e),n=this._createShader(t,t.FRAGMENT_SHADER,i);if(!r||!n)return null;var a=t.createProgram();if(a){t.attachShader(a,r),t.attachShader(a,n),t.linkProgram(a),t.deleteShader(n),t.deleteShader(r);var o=t.getProgramParameter(a,t.LINK_STATUS);if(!o){var s=t.getProgramInfoLog(a);return console.log("Failed to link program: "+s),t.deleteProgram(a),null}}return a},_createShader:function(t,e,i){var r=t.createShader(e);if(r){t.shaderSource(r,i),t.compileShader(r);var n=t.getShaderParameter(r,t.COMPILE_STATUS);if(!n){var a=t.getShaderInfoLog(r);return console.log("Failed to compile shader: "+a),t.deleteShader(r),null}}return r}},h}),define(function(t,e,i){var r=t("hilo/core/Hilo"),n=t("hilo/core/Class"),a=t("hilo/event/EventMixin"),o=t("hilo/geom/Matrix"),s=t("hilo/util/util"),h=function(){function t(t,e,i){for(var r,n,a,o,s=0,h=!1,l=0,c=i.length;ld.x?(r=d.x,n=u.x):(r=u.x,n=d.x),t>=r&&t<=n))h=!0;else if(u.y>d.y?(a=d.y,o=u.y):(a=u.y,o=d.y),!(eo)){var f=(e-u.y)*(d.x-u.x)/(d.y-u.y)+u.x;if(f>t?s++:f==t&&(h=!0),u.x>t&&u.y==e){var p=i[(c+l-1)%c];(p.ye||p.y>e&&d.ys?s=c:cl?l=c:c=0)return!1;u>i.overlap&&(i.overlap=u,i.normal.x=p.x,i.normal.y=p.y)}return i}return n.create({Mixes:a,constructor:function(t){t=t||{},this.id=this.id||t.id||r.getUid("View"),s.copy(this,t,!0)},tint:16777215,id:null,x:0,y:0,width:0,height:0,alpha:1,rotation:0,visible:!0,pivotX:0,pivotY:0,scaleX:1,scaleY:1,pointerEnabled:!0,background:null,mask:null,align:null,drawable:null,boundsArea:null,parent:null,depth:-1,transform:null,blendMode:"source-over",getStage:function(){for(var t,e=this;t=e.parent;)e=t;return e.canvas?e:null},getScaledWidth:function(){return this.width*this.scaleX},getScaledHeight:function(){return this.height*this.scaleY},addTo:function(t,e){return"number"==typeof e?t.addChildAt(this,e):t.addChild(this),this},removeFromParent:function(){var t=this.parent;return t&&t.removeChild(this),this},getBounds:function(){for(var t,e,i,r,n,a,o,s=this.width,h=this.height,l=this.getConcatenatedMatrix(),c=this.boundsArea||[{x:0,y:0},{x:s,y:0},{x:s,y:h},{x:0,y:h}],u=[],d=0,f=c.length;de?r=e:ni?a=i:o>1,r=0;break;case"TR":i=o-n,r=0;break;case"L":i=0,r=s-a>>1;break;case"C":i=o-n>>1,r=s-a>>1;break;case"R":i=o-n,r=s-a>>1;break;case"BL":i=0,r=s-a;break;case"B":i=o-n>>1,r=s-a;break;case"BR":i=o-n,r=s-a}}return{x:i,y:r}},hitTestPoint:function(e,i,r){var n=this.getBounds(),a=e>=n.x&&e<=n.x+n.width&&i>=n.y&&i<=n.y+n.height;return a&&r&&(a=t(e,i,n)),a},hitTestObject:function(t,i){var r=this.getBounds(),n=t.getBounds(),a=r.x<=n.x+n.width&&n.x<=r.x+r.width&&r.y<=n.y+n.height&&n.y<=r.y+r.height;return a&&i&&(a=e(r,n)),!!a},_render:function(t,e){this.onUpdate&&this.onUpdate(e)===!1||!t.startDraw(this)||(t.transform(this),this.render(t,e),t.endDraw(this))},_fireMouseEvent:function(t){if(t.eventCurrentTarget=this,this.fire(t),"mousemove"==t.type){if(!this.__mouseOver){this.__mouseOver=!0;var e=s.copy({},t);e.type="mouseover",this.fire(e)}}else"mouseout"==t.type&&(this.__mouseOver=!1);var i=this.parent;t._stopped||t._stopPropagationed||!i||("mouseout"==t.type||"touchout"==t.type?i.hitTestPoint(t.stageX,t.stageY,!0)||i._fireMouseEvent(t):i._fireMouseEvent(t))},onUpdate:null,render:function(t,e){t.draw(this)},toString:function(){return r.viewToString(this)}})}();return h}),define(function(t,e,i){var r,n,a=t("hilo/view/Drawable"),o=t("hilo/util/browser"),s={_cacheDirty:!0,cache:function(t){(t||this._cacheDirty||!this.drawable)&&this.updateCache()},updateCache:function(){o.supportCanvas&&(r||(r=document.createElement("canvas"),n=r.getContext("2d")),r.width=this.width,r.height=this.height,this._draw(n),this.drawable=this.drawable||new a,this.drawable.init({image:r.toDataURL()}),this._cacheDirty=!1)},setCacheDirty:function(t){this._cacheDirty=t}};return s}),define(function(t,e,i){var r=t("hilo/core/Hilo"),n=t("hilo/core/Class"),a=t("hilo/view/View"),o=n.create({Extends:a,constructor:function(t){t=t||{},this.id=this.id||t.id||r.getUid("Container"),o.superclass.constructor.call(this,t),this.children?this._updateChildren():this.children=[]},children:null,pointerChildren:!0,clipChildren:!1,getNumChildren:function(){return this.children.length},addChildAt:function(t,e){var i=this.children,r=i.length,n=t.parent;e=e<0?0:e>r?r:e;var a=this.getChildIndex(t);if(a==e)return this;if(a>=0?(i.splice(a,1),e=e==r?r-1:e):n&&n.removeChild(t),i.splice(e,0,t),a<0)this._updateChildren(e);else{var o=a=e.length)return null;var i=e[t];if(i){if(!i.__renderer)for(var r=i;r=r.parent;){if(r.renderer){i.__renderer=r.renderer;break}if(r.__renderer){i.__renderer=r.__renderer;break}}i.__renderer&&i.__renderer.remove(i),i.parent=null,i.depth=-1}return e.splice(t,1),this._updateChildren(t),i},removeChild:function(t){return this.removeChildAt(this.getChildIndex(t))},removeChildById:function(t){for(var e,i=this.children,r=0,n=i.length;r=e.length?null:e[t]},getChildById:function(t){for(var e,i=this.children,r=0,n=i.length;r=0&&r!=e){var n=i.length;e=e<0?0:e>=n?n-1:e,i.splice(r,1),i.splice(e,0,t),this._updateChildren()}return this},swapChildren:function(t,e){var i=this.children,r=this.getChildIndex(t),n=this.getChildIndex(e);t.depth=n,i[n]=t,e.depth=r,i[r]=e},swapChildrenAt:function(t,e){var i=this.children,r=this.getChildAt(t),n=this.getChildAt(e);r.depth=e,i[e]=r,n.depth=t,i[t]=n},sortChildren:function(t){var e=t,i=this.children;if("string"==typeof e){var r=e;e=function(t,e){return e[r]-t[r]}}i.sort(e),this._updateChildren()},_updateChildren:function(t,e){var i,r=this.children;t=t||0,e=e||r.length;for(var n=t;n=0;l--)if(a=h[l],!(!a||!a.visible||a.alpha<=0||n&&!a.pointerEnabled))if(a.children&&a.children.length&&(!n||a.pointerChildren)&&(o=a.getViewAtPoint(t,e,i,r,n)),o){if(!r)return o;o.length&&(s=s.concat(o))}else if(a.hitTestPoint(t,e,i)){if(!r)return a;s.push(a)}return r&&s.length?s:null},render:function(t,e){o.superclass.render.call(this,t,e);var i,r,n,a=this.children.slice(0);for(i=0,r=a.length;ir?r:e,i[e]=t,t.name&&(this._frameNames[t.name]=t),(0!=e||this.width)&&this.height||(this.width=t.rect[2],this.height=t.rect[3]),this},getFrame:function(t){if("number"==typeof t){var e=this._frames;return t<0||t>=e.length?null:e[t]}return this._frameNames[t]},getFrameIndex:function(t){var e=this._frames,i=e.length,r=-1;if("number"==typeof t)r=t;else{var n="string"==typeof t?this._frameNames[t]:t;if(n)for(var a=0;a=i?i-1:r,this.paused=e,this._firstRender=!0,this},_render:function(t,e){var i,r=this.currentFrame;if(this._firstRender?(i=r,this._firstRender=!1):i=this._nextFrame(e),i!=r){this.currentFrame=i;var n=this._frames[i].callback;n&&n.call(this)}this.onEnterFrame&&this.onEnterFrame(i),this.drawable.init(this._frames[i]),s.superclass._render.call(this,t,e)},_nextFrame:function(t){var e=this._frames,i=e.length,r=this.currentFrame,n=e[r],a=n.duration||this.interval,o=this._frameElapsed,s=0!=r||this.drawable?o+(this.timeBased?t:1):0;return o=this._frameElapsed=s=i-1)&&this.stop(),this.paused||0!=o||(null!=n.next?r=this.getFrameIndex(n.next):r>=i-1?r=0:this.drawable&&r++),r},setFrameCallback:function(t,e){return t=this.getFrame(t),t&&(t.callback=e),this},onEnterFrame:null});return s}),define(function(t,e,i){var r=t("hilo/core/Hilo"),n=t("hilo/core/Class"),a=t("hilo/view/View"),o=t("hilo/view/Drawable"),s=n.create({Extends:a,constructor:function(t){t=t||{},this.id=this.id||t.id||r.getUid("DOMElement"),s.superclass.constructor.call(this,t),this.drawable=new o;var e=this.drawable.domElement=t.element||r.createElement("div");e.id=this.id,this.pointerEnabled&&!e.style.pointerEvents&&(e.style.pointerEvents="visible")},_render:function(t,e){this.onUpdate&&this.onUpdate(e)===!1||(t.transform(this),this.visible&&this.alpha>0&&this.render(t,e))},render:function(t,e){if("dom"!==t.renderType){var i=t.canvas,n=this.parent,a=t._domElementContainer;t._domElementContainer||(a=t._domElementContainer=r.createElement("div",{style:{position:"absolute",transform:"scale3d("+n.scaleX+","+n.scaleY+", 1)",transformOrigin:"0 0",zIndex:"1"}}),i.parentNode.insertBefore(t._domElementContainer,i.nextSibling));var o,s=this.drawable.domElement,h=this.depth,l=a.childNodes[0];if(s.parentNode)return;for(;l&&3!=l.nodeType&&(o=parseInt(l.style.zIndex)||0,!(o<=0||o>h));)l=l.nextSibling;a.insertBefore(this.drawable.domElement,l)}else t.draw(this)}});return s}),define(function(t,e,i){var r=t("hilo/core/Hilo"),n=t("hilo/core/Class"),a=t("hilo/view/View"),o=t("hilo/view/CacheMixin"),s=function(){var t=document.createElement("canvas"),e=t.getContext&&t.getContext("2d");return n.create({Extends:a,Mixes:o,constructor:function(t){t=t||{},this.id=this.id||t.id||r.getUid("Graphics"),s.superclass.constructor.call(this,t),this._actions=[]},lineWidth:1,lineAlpha:1,lineCap:null,lineJoin:null,miterLimit:10,hasStroke:!1,strokeStyle:"0",hasFill:!1,fillStyle:"0",fillAlpha:0,lineStyle:function(t,e,i,r,n,a){var o=this,s=o._addAction;return s.call(o,["lineWidth",o.lineWidth=t||1]),s.call(o,["strokeStyle",o.strokeStyle=e||"0"]),s.call(o,["lineAlpha",o.lineAlpha=i||1]),void 0!=r&&s.call(o,["lineCap",o.lineCap=r]),void 0!=n&&s.call(o,["lineJoin",o.lineJoin=n]),void 0!=a&&s.call(o,["miterLimit",o.miterLimit=a]),o.hasStroke=!0,o},setLineDash:function(t){return this._addAction(["setLineDash",t])},beginFill:function(t,e){var i=this,r=i._addAction;return r.call(i,["fillStyle",i.fillStyle=t]),r.call(i,["fillAlpha",i.fillAlpha=e||1]),i.hasFill=!0,i},endFill:function(){var t=this,e=t._addAction;return t.hasStroke&&e.call(t,["stroke"]),t.hasFill&&e.call(t,["fill"]),t.setCacheDirty(!0),t},beginLinearGradientFill:function(t,i,r,n,a,o){for(var s=this,h=e.createLinearGradient(t,i,r,n),l=0,c=a.length;l1?a.slice(1):null;"function"==typeof t[o]?t[o].apply(t,s):t[o]=a[1]}},render:function(t,e){var i=this;"canvas"===t.renderType?i._draw(t.context):(i.cache(),t.draw(i))},clear:function(){var t=this;return t._actions.length=0,t.lineWidth=1,t.lineAlpha=1,t.lineCap=null,t.lineJoin=null,t.miterLimit=10,t.hasStroke=!1,t.strokeStyle="0",t.hasFill=!1,t.fillStyle="0",t.fillAlpha=1,t.setCacheDirty(!0),t},_addAction:function(t){var e=this;return e._actions.push(t),e}})}();return s}),define(function(t,e,i){var r=t("hilo/core/Class"),n=t("hilo/core/Hilo"),a=t("hilo/view/View"),o=t("hilo/view/CacheMixin"),s=r.create({Extends:a,Mixes:o,constructor:function(t){t=t||{},this.id=this.id||t.id||n.getUid("Text"),s.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=s.measureFontHeight(this.font)},text:"",color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=s.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var r=i.drawable,n=r.domElement,a=n.style;a.font=i.font,a.textAlign=i.textAlign,a.color=i.color,a.width=i.width+"px",a.height=i.height+"px",a.lineHeight=i._fontHeight+i.lineSpacing+"px",n.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var r,n,a,o,s,h=i.split(/\r\n|\r|\n|/),l=0,c=0,u=e._fontHeight+e.lineSpacing,d=[];for(r=0,o=h.length;re.maxWidth?(d.push({text:m,y:c}),l>1;break;case"bottom":_=e.height-e.textHeight}var x=e.background;for(x&&(t.fillStyle=x,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,r=0;r>1;break;case"right":case"end":n=a}r.outline?t.strokeText(e,n,i):t.fillText(e,n,i)},Statics:{measureFontHeight:function(t){var e,i=document.documentElement,r=n.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return i.appendChild(r),e=r.offsetHeight,i.removeChild(r),e}}});return s}),define(function(t,e,i){var r=t("hilo/core/Class"),n=t("hilo/core/Hilo"),a=t("hilo/view/Container"),o=t("hilo/view/Bitmap"),s=r.create({Extends:a,constructor:function(t){t=t||{},this.id=this.id||t.id||n.getUid("BitmapText"),s.superclass.constructor.call(this,t);var e=t.text+"";e&&(this.text="",this.setText(e)),this.pointerChildren=!1},glyphs:null,letterSpacing:0,text:"",textAlign:"left",setText:function(t){var e=this,i=t.toString(),r=i.length;if(e.text!=i){e.text=i;var n,a,o,s,h=0,l=0,c=0;for(n=0;n0?e.letterSpacing:0),e.children[n]?(s=e.children[n],s.setImage(o.image,o.rect)):(s=e._createBitmap(o),e.addChild(s)),s.x=c,h=c+o.rect[2],l=Math.max(l,o.rect[3]));for(n=e.children.length-1;n>=r;n--)e._releaseBitmap(e.children[n]),e.children[n].removeFromParent();return e.width=h,e.height=l,this.setTextAlign(),e}},_createBitmap:function(t){var e;return s._pool.length?(e=s._pool.pop(),e.setImage(t.image,t.rect)):e=new o({image:t.image,rect:t.rect}),e},_releaseBitmap:function(t){s._pool.push(t)},setTextAlign:function(t){switch(this.textAlign=t||this.textAlign,this.textAlign){case"center":this.pivotX=.5*this.width;break;case"right":this.pivotX=this.width;break;case"left":default:this.pivotX=0}return this},hasGlyphs:function(t){var e=this.glyphs;if(!e)return!1;t=t.toString();var i,r=t.length;for(i=0;i=this._targetFPS?(this._measuredFPS=1e3/(this._tickTime/this._tickCount)+.5>>0,this._tickCount=0,this._tickTime=0):this._tickTime+=t-this._lastTime,this._lastTime=t;for(var r=i.slice(0),n=0,a=r.length;n=0&&e.splice(i,1)},nextTick:function(t){var e=this,i={tick:function(r){e.removeTick(i),t()}};return e.addTick(i),i},timeout:function(t,e){var i=this,r=(new Date).getTime()+e,n={tick:function(){var e=(new Date).getTime(),a=e-r;a>=0&&(i.removeTick(n),t())}};return i.addTick(n),n},interval:function(t,e){var i=this,r=(new Date).getTime()+e,n={tick:function(){var i=(new Date).getTime(),n=i-r;n>=0&&(n=r)return-1;for(e<0&&(e=r+e),i=e;i=1?1:s;var l=r.ease?r.ease(s):s;r.reverse&&(r._reverseFlag<0&&(s=1-s,l=1-l),s<1e-7&&(r.repeat>0&&r._repeatCount++>=r.repeat||0==r.repeat&&!r.loop?h=!0:(r._startTime=t(),r._pausedTime=0,r._reverseFlag*=-1))),r.isStart||(r.setProps(r._fromProps,r._toProps),r.isStart=!0,r.onStart&&r.onStart.call(r,r)),r.time=a,r._render(l),(o=r.onUpdate)&&o.call(r,s,r),s>=1&&(r.reverse?(r._startTime=t(),r._pausedTime=0,r._reverseFlag*=-1):r.loop||r.repeat>0&&r._repeatCount++0&&u<=e?(c._render(s),c.time=a,n.add(c)):h&&(u<0||u>e)&&c.start()}return h?((o=r.onComplete)&&o.call(r,r),!0):void 0}}},Statics:{_tweens:[],tick:function(){var e,i,r=n._tweens,a=r.length;for(i=0;i-1&&r.splice(e,1);else for(e=0;e=i)return void t.fire("complete");if(t._currentIndexe.z})},tick:function(){this.sortZ()}});return o}();return a}),define(function(t,e,i){var r=t("hilo/core/Hilo"),n=t("hilo/core/Class"),a=t("hilo/view/View"),o=t("hilo/view/Container"),s=t("hilo/view/Drawable"),h=t("hilo/util/util"),l=function(){function t(t,e){return e?t+2*(Math.random()-.5)*e:t}for(var e=["x","y","vx","vy","ax","ay","rotation","rotationV","scale","scaleV","alpha","alphaV","life"],i=[],l=0,c=e.length;l=this._emitTime&&(this._currentRunTime=0,this._emitTime=t(this.emitTime,this.emitTimeVar),this._emit()),this._totalRunTime>=this.totalTime&&this.stop())},_emit:function(){for(var e=t(this.emitNum,this.emitNumVar)>>0,i=0;i=0;e--)this.children[e].destroy()}}),v=n.create({Extends:a,constructor:function(t){this.id=this.id||t.id||r.getUid("Particle"),v.superclass.constructor.call(this,t),this.init(t)},onUpdate:function(t){if(t*=.001,this._died)return!1;var e=this.ax+this.system.gx,i=this.ay+this.system.gy;return this.vx+=e*t,this.vy+=i*t,this.x+=this.vx*t,this.y+=this.vy*t,this.rotation+=this.rotationV,this._time>.1&&(this.alpha+=this.alphaV),this.scale+=this.scaleV,this.scaleX=this.scaleY=this.scale,this._time+=t,this._time>=this.life||this.alpha<=0?(this.destroy(),!1):void 0},setImage:function(t,e){this.drawable=this.drawable||new s,e=e||[0,0,t.width,t.height],this.width=e[2],this.height=e[3],this.drawable.rect=e,this.drawable.image=t},destroy:function(){this._died=!0,this.alpha=0,this.removeFromParent(),f.push(this)},init:function(e){this.system=e.system,this._died=!1,this._time=0,this.alpha=1;for(var r=0,n=i.length;r>0]),this.setImage(e.image,s),void 0!==e.pivotX&&(this.pivotX=e.pivotX*s[2]),void 0!==e.pivotY&&(this.pivotY=e.pivotY*s[3])}},Statics:{create:function(t){if(f.length>0){var e=f.pop();return e.init(t),e}return new v(t)}}});return p}();return l}); \ No newline at end of file diff --git a/build/cmd/hilo-cmd.zip b/build/cmd/hilo-cmd.zip index fe2ab959..11e076d5 100644 Binary files a/build/cmd/hilo-cmd.zip and b/build/cmd/hilo-cmd.zip differ diff --git a/build/cmd/hilo/core/Class.js b/build/cmd/hilo/core/Class.js index 611e7079..342819cc 100644 --- a/build/cmd/hilo/core/Class.js +++ b/build/cmd/hilo/core/Class.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/core/Class.min.js b/build/cmd/hilo/core/Class.min.js index 85c94d55..79e3bdf7 100644 --- a/build/cmd/hilo/core/Class.min.js +++ b/build/cmd/hilo/core/Class.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/core/Hilo.js b/build/cmd/hilo/core/Hilo.js index 8d6fea7b..e9d3ca9f 100644 --- a/build/cmd/hilo/core/Hilo.js +++ b/build/cmd/hilo/core/Hilo.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -30,7 +30,7 @@ var Hilo = { * Hilo version * @type String */ - version: '1.3.0', + version: '1.4.0', /** * @language=en * Gets a globally unique id. Such as Stage1, Bitmap2 etc. diff --git a/build/cmd/hilo/core/Hilo.min.js b/build/cmd/hilo/core/Hilo.min.js index 5ed09175..577530b8 100644 --- a/build/cmd/hilo/core/Hilo.min.js +++ b/build/cmd/hilo/core/Hilo.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ -define(function(t,e,a){var r=t("hilo/util/browser"),o=t("hilo/util/util"),n=window,i=document,s=i.documentElement,c=0,h={},f={version:"1.3.0",getUid:function(t){var e=++c;if(t){var a=t.charCodeAt(t.length-1);return a>=48&&a<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,a=t;a;)e=e?a.id+"."+e:a.id,a=a.parent;return e},copy:function(t,e,a){return o.copy(t,e,a),h.copy||(h.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),t},browser:r,event:{POINTER_START:r.POINTER_START,POINTER_MOVE:r.POINTER_MOVE,POINTER_END:r.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(t){var e;try{e=t.getBoundingClientRect()}catch(a){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var r=(n.pageXOffset||s.scrollLeft)-(s.clientLeft||0)||0,o=(n.pageYOffset||s.scrollTop)-(s.clientTop||0)||0,i=n.getComputedStyle?getComputedStyle(t):t.currentStyle,c=parseInt,h=c(i.paddingLeft)+c(i.borderLeftWidth)||0,f=c(i.paddingTop)+c(i.borderTopWidth)||0,d=c(i.paddingRight)+c(i.borderRightWidth)||0,l=c(i.paddingBottom)+c(i.borderBottomWidth)||0,g=e.top||0,p=e.left||0,m=e.right||0,T=e.bottom||0;return{left:p+r+h,top:g+o+f,width:m-d-p-h,height:T-l-g-f}},createElement:function(t,e){var a,r,o,n=i.createElement(t);for(a in e)if(r=e[a],"style"===a)for(o in r)n.style[o]=r[o];else n[a]=r;return n},getElement:function(t){return i.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,a=e.domElement.style,r=t._stateCache||(t._stateCache={}),o=f.browser.jsVendor,n="px",i=!1;if(this.cacheStateIfChanged(t,["visible"],r)&&(a.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],r)&&(a.opacity=t.alpha),t.visible&&!(t.alpha<=0)){if(this.cacheStateIfChanged(t,["width"],r)&&(a.width=t.width+n),this.cacheStateIfChanged(t,["height"],r)&&(a.height=t.height+n),this.cacheStateIfChanged(t,["depth"],r)&&(a.zIndex=t.depth+1),t.transform){var s=t.transform;(i=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(a[o+"TransformOrigin"]="0 0"),a[o+"Transform"]="matrix3d("+s.a+", "+s.b+", 0, 0, "+s.c+", "+s.d+", 0, 0, 0, 0, 1, 0, "+s.tx+", "+s.ty+", 0, 1)"}else(i=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(a[o+"TransformOrigin"]=t.pivotX+n+" "+t.pivotY+n),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],r)||i)&&(a[o+"Transform"]=this.getTransformCSS(t));this.cacheStateIfChanged(t,["background"],r)&&(a.backgroundColor=t.background),a.pointerEvents||(a.pointerEvents="none");var c=e.image;if(c){var h=c.src;h!==r.image&&(r.image=h,a.backgroundImage="url("+h+")");var d=e.rect;if(d){var l=d[0],g=d[1];l!==r.sx&&(r.sx=l,a.backgroundPositionX=-l+n),g!==r.sy&&(r.sy=g,a.backgroundPositionY=-g+n)}}var p=t.mask;if(p){var m=p.drawable.domElement.style.backgroundImage;m!==r.maskImage&&(r.maskImage=m,a[o+"MaskImage"]=m,a[o+"MaskRepeat"]="no-repeat");var T=p.x,u=p.y;T===r.maskX&&u===r.maskY||(r.maskX=T,r.maskY=u,a[o+"MaskPosition"]=T+n+" "+u+n)}}},cacheStateIfChanged:function(t,e,a){var r,o,n,i,s=!1;for(r=0,o=e.length;r=48&&a<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,a=t;a;)e=e?a.id+"."+e:a.id,a=a.parent;return e},copy:function(t,e,a){return o.copy(t,e,a),h.copy||(h.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),t},browser:r,event:{POINTER_START:r.POINTER_START,POINTER_MOVE:r.POINTER_MOVE,POINTER_END:r.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(t){var e;try{e=t.getBoundingClientRect()}catch(a){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var r=(n.pageXOffset||s.scrollLeft)-(s.clientLeft||0)||0,o=(n.pageYOffset||s.scrollTop)-(s.clientTop||0)||0,i=n.getComputedStyle?getComputedStyle(t):t.currentStyle,c=parseInt,h=c(i.paddingLeft)+c(i.borderLeftWidth)||0,f=c(i.paddingTop)+c(i.borderTopWidth)||0,d=c(i.paddingRight)+c(i.borderRightWidth)||0,l=c(i.paddingBottom)+c(i.borderBottomWidth)||0,g=e.top||0,p=e.left||0,m=e.right||0,T=e.bottom||0;return{left:p+r+h,top:g+o+f,width:m-d-p-h,height:T-l-g-f}},createElement:function(t,e){var a,r,o,n=i.createElement(t);for(a in e)if(r=e[a],"style"===a)for(o in r)n.style[o]=r[o];else n[a]=r;return n},getElement:function(t){return i.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,a=e.domElement.style,r=t._stateCache||(t._stateCache={}),o=f.browser.jsVendor,n="px",i=!1;if(this.cacheStateIfChanged(t,["visible"],r)&&(a.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],r)&&(a.opacity=t.alpha),t.visible&&!(t.alpha<=0)){if(this.cacheStateIfChanged(t,["width"],r)&&(a.width=t.width+n),this.cacheStateIfChanged(t,["height"],r)&&(a.height=t.height+n),this.cacheStateIfChanged(t,["depth"],r)&&(a.zIndex=t.depth+1),t.transform){var s=t.transform;(i=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(a[o+"TransformOrigin"]="0 0"),a[o+"Transform"]="matrix3d("+s.a+", "+s.b+", 0, 0, "+s.c+", "+s.d+", 0, 0, 0, 0, 1, 0, "+s.tx+", "+s.ty+", 0, 1)"}else(i=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(a[o+"TransformOrigin"]=t.pivotX+n+" "+t.pivotY+n),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],r)||i)&&(a[o+"Transform"]=this.getTransformCSS(t));this.cacheStateIfChanged(t,["background"],r)&&(a.backgroundColor=t.background),a.pointerEvents||(a.pointerEvents="none");var c=e.image;if(c){var h=c.src;h!==r.image&&(r.image=h,a.backgroundImage="url("+h+")");var d=e.rect;if(d){var l=d[0],g=d[1];l!==r.sx&&(r.sx=l,a.backgroundPositionX=-l+n),g!==r.sy&&(r.sy=g,a.backgroundPositionY=-g+n)}}var p=t.mask;if(p){var m=p.drawable.domElement.style.backgroundImage;m!==r.maskImage&&(r.maskImage=m,a[o+"MaskImage"]=m,a[o+"MaskRepeat"]="no-repeat");var T=p.x,u=p.y;T===r.maskX&&u===r.maskY||(r.maskX=T,r.maskY=u,a[o+"MaskPosition"]=T+n+" "+u+n)}}},cacheStateIfChanged:function(t,e,a){var r,o,n,i,s=!1;for(r=0,o=e.length;r0)&&(t===this.stage&&this.clear(),!0)},draw:function(t){var e=t.width,r=t.height,i=(t.background,t.drawable),a=i&&i.image;if(a){var n=i.rect,s=n[2],o=n[3];e||r||(e=t.width=s,r=t.height=o),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(a,n[0],n[1],s,o,0,0,e,r),c=this.batchIndex*this.positionStride,_=this.float32Array,l=this.uint32Array,d=(t.tint>>16)+(65280&t.tint)+((255&t.tint)<<16)+(255*t.__webglRenderAlpha<<24);_[c+0]=h[0],_[c+1]=h[1],_[c+2]=h[2],_[c+3]=h[3],l[c+4]=d,_[c+5]=h[4],_[c+6]=h[5],_[c+7]=h[6],_[c+8]=h[7],l[c+9]=d,_[c+10]=h[8],_[c+11]=h[9],_[c+12]=h[10],_[c+13]=h[11],l[c+14]=d,_[c+15]=h[12],_[c+16]=h[13],_[c+17]=h[14],_[c+18]=h[15],l[c+19]=d;for(var u=t.__webglWorldMatrix,f=0;f<4;f++){var g=_[c+5*f],T=_[c+5*f+1];_[c+5*f]=u.a*g+u.c*T+u.tx,_[c+5*f+1]=u.b*g+u.d*T+u.ty}t.__textureImage=a,this.sprites[this.batchIndex++]=t}},endDraw:function(t){t===this.stage&&this._renderBatches()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void a.setElementStyleByView(t);var r=t.scaleX,i=t.scaleY;if(t===this.stage){var n=this.canvas.style,o=t._scaleX,h=t._scaleY,c=!1;(!o&&1!=r||o&&o!=r)&&(t._scaleX=r,n.width=r*t.width+"px",c=!0),(!h&&1!=i||h&&h!=i)&&(t._scaleY=i,n.height=i*t.height+"px",c=!0),c&&t.updateViewport(),t.__webglWorldMatrix=t.__webglWorldMatrix||new s(1,0,0,1,0,0)}else t.parent&&(t.__webglWorldMatrix=t.__webglWorldMatrix||new s(1,0,0,1,0,0),this._setConcatenatedMatrix(t,t.parent));t.alpha>0&&(t.parent&&t.parent.__webglRenderAlpha?t.__webglRenderAlpha=t.alpha*t.parent.__webglRenderAlpha:t.__webglRenderAlpha=t.alpha)},remove:function(t){var e=t.drawable,r=e&&e.domElement;if(r){var i=r.parentNode;i&&i.removeChild(r)}},clear:function(t,e,r,i){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(t,e){if(this.width!==t||this.height!==e){var r=this.canvas,i=this.stage,a=r.style;this.width=r.width=t,this.height=r.height=e,a.width=i.width*i.scaleX+"px",a.height=i.height*i.scaleY+"px",this.gl.viewport(0,0,t,e),this.canvasHalfWidth=.5*t,this.canvasHalfHeight=.5*e,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var t=this.gl;t.bufferSubData(t.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var e=0,r=0,i=null,a=0;a0&&(r.bindTexture(r.TEXTURE_2D,this._getTexture(this.sprites[t])),r.drawElements(r.TRIANGLES,6*i,r.UNSIGNED_SHORT,6*t*2))},_uploadProjectionTransform:function(t){this._projectionTransformElements&&!t||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var t=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",e="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new c(this,{v:t,f:e},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(t,e,r,i,a,n,s,o,h){var c=this.__tempVertexs||[],_=t.width,l=t.height;i/=_,a/=l,e/=_,r/=l,o=o,h=h,n=n,s=s,i+e>1&&(i=1-e),a+r>1&&(a=1-r);var d=0;return c[d++]=n,c[d++]=s,c[d++]=e,c[d++]=r,c[d++]=n+o,c[d++]=s,c[d++]=e+i,c[d++]=r,c[d++]=n,c[d++]=s+h,c[d++]=e,c[d++]=r+a,c[d++]=n+o,c[d++]=s+h,c[d++]=e+i,c[d++]=r+a,c},_setConcatenatedMatrix:function(t,e){var r=t.__webglWorldMatrix,i=1,a=0,n=t.rotation%360,s=t.pivotX,h=t.pivotY,c=t.scaleX,_=t.scaleY,l=t.transform;if(l)r.copy(l);else{if(n){var d=n*o;i=Math.cos(d),a=Math.sin(d)}var u=t.getAlignPosition();r.a=i*c,r.b=a*c,r.c=-a*_,r.d=i*_,r.tx=u.x-r.a*s-r.c*h,r.ty=u.y-r.b*s-r.d*h}r.concat(e.__webglWorldMatrix)},_getTexture:function(t){var e=t.__textureImage,r=this._cacheTexture[e.src];return r||(r=this.activeShader.uploadTexture(e)),r}}),c=function(t,e,r){this.renderer=t,this.gl=t.gl,this.program=this._createProgram(this.gl,e.v,e.f),r=r||{},this.attributes=r.attributes||[],this.uniforms=r.uniforms||[]};return c.prototype={active:function(){var t=this,e=t.renderer,r=t.gl,i=t.program;i&&r&&(e.activeShader=t,r.useProgram(i),t.attributes.forEach(function(t){e[t]=r.getAttribLocation(i,t),r.enableVertexAttribArray(e[t])}),t.uniforms.forEach(function(t){e[t]=r.getUniformLocation(i,t)}),t.width===e.width&&t.height===e.height||(t.width=e.width,t.height=e.height,e._uploadProjectionTransform()))},uploadTexture:function(t){var e=this.gl,r=this.renderer,i=e.createTexture(),a=r.u_Sampler;return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,i),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(a,0),e.bindTexture(e.TEXTURE_2D,null),this.renderer._cacheTexture[t.src]=i,i},_createProgram:function(t,e,r){var i=this._createShader(t,t.VERTEX_SHADER,e),a=this._createShader(t,t.FRAGMENT_SHADER,r);if(!i||!a)return null;var n=t.createProgram();if(n){t.attachShader(n,i),t.attachShader(n,a),t.linkProgram(n),t.deleteShader(a),t.deleteShader(i);var s=t.getProgramParameter(n,t.LINK_STATUS);if(!s){var o=t.getProgramInfoLog(n);return console.log("Failed to link program: "+o),t.deleteProgram(n),null}}return n},_createShader:function(t,e,r){var i=t.createShader(e);if(i){t.shaderSource(i,r),t.compileShader(i);var a=t.getShaderParameter(i,t.COMPILE_STATUS);if(!a){var n=t.getShaderInfoLog(i);return console.log("Failed to compile shader: "+n),t.deleteShader(i),null}}return i}},h}); \ No newline at end of file +define(function(t,e,r){var i=t("hilo/core/Class"),a=t("hilo/core/Hilo"),n=t("hilo/renderer/Renderer"),s=t("hilo/geom/Matrix"),o=Math.PI/180,h=i.create({Extends:n,Statics:{MAX_BATCH_NUM:2e3,ATTRIBUTE_NUM:5,isSupport:function(){if(void 0==this._isSupported){var t=document.createElement("canvas");t.getContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))?this._isSupported=!0:this._isSupported=!1}return this._isSupported},contextOptions:null},renderType:"webgl",gl:null,_isContextLost:!1,_cacheTexture:{},constructor:function(t){h.superclass.constructor.call(this,t);var e=this,r=h.contextOptions||{};this.gl=this.canvas.getContext("webgl",r)||this.canvas.getContext("experimental-webgl",r),this.maxBatchNum=h.MAX_BATCH_NUM,this.positionStride=4*h.ATTRIBUTE_NUM;var i=this.maxBatchNum*h.ATTRIBUTE_NUM*4,a=6*this.maxBatchNum;this.arrayBuffer=new ArrayBuffer(4*i),this.float32Array=new Float32Array(this.arrayBuffer),this.uint32Array=new Uint32Array(this.arrayBuffer),this.indexs=new Uint16Array(a);for(var n=0,s=0;n0)&&(t===this.stage&&this.clear(),!0)},draw:function(t){var e=t.width,r=t.height,i=(t.background,t.drawable),a=i&&i.image;if(a){var n=i.rect,s=n[2],o=n[3];e||r||(e=t.width=s,r=t.height=o),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(a,n[0],n[1],s,o,0,0,e,r),c=this.batchIndex*this.positionStride,_=this.float32Array,l=this.uint32Array,d=(t.tint>>16)+(65280&t.tint)+((255&t.tint)<<16)+(255*t.__webglRenderAlpha<<24);_[c+0]=h[0],_[c+1]=h[1],_[c+2]=h[2],_[c+3]=h[3],l[c+4]=d,_[c+5]=h[4],_[c+6]=h[5],_[c+7]=h[6],_[c+8]=h[7],l[c+9]=d,_[c+10]=h[8],_[c+11]=h[9],_[c+12]=h[10],_[c+13]=h[11],l[c+14]=d,_[c+15]=h[12],_[c+16]=h[13],_[c+17]=h[14],_[c+18]=h[15],l[c+19]=d;for(var u=t.__webglWorldMatrix,f=0;f<4;f++){var g=_[c+5*f],x=_[c+5*f+1];_[c+5*f]=u.a*g+u.c*x+u.tx,_[c+5*f+1]=u.b*g+u.d*x+u.ty}t.__textureImage=a,this.sprites[this.batchIndex++]=t}},endDraw:function(t){t===this.stage&&this._renderBatches()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void a.setElementStyleByView(t);var r=t.scaleX,i=t.scaleY;if(t===this.stage){var n=this.canvas.style,o=t._scaleX,h=t._scaleY,c=!1;(!o&&1!=r||o&&o!=r)&&(t._scaleX=r,n.width=r*t.width+"px",c=!0),(!h&&1!=i||h&&h!=i)&&(t._scaleY=i,n.height=i*t.height+"px",c=!0),c&&t.updateViewport(),t.__webglWorldMatrix=t.__webglWorldMatrix||new s(1,0,0,1,0,0)}else t.parent&&(t.__webglWorldMatrix=t.__webglWorldMatrix||new s(1,0,0,1,0,0),this._setConcatenatedMatrix(t,t.parent));t.alpha>0&&(t.parent&&t.parent.__webglRenderAlpha?t.__webglRenderAlpha=t.alpha*t.parent.__webglRenderAlpha:t.__webglRenderAlpha=t.alpha)},remove:function(t){var e=t.drawable,r=e&&e.domElement;if(r){var i=r.parentNode;i&&i.removeChild(r)}},clear:function(t,e,r,i){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(t,e){if(this.width!==t||this.height!==e){var r=this.canvas,i=this.stage,a=r.style;this.width=r.width=t,this.height=r.height=e,a.width=i.width*i.scaleX+"px",a.height=i.height*i.scaleY+"px",this.gl.viewport(0,0,t,e),this.canvasHalfWidth=.5*t,this.canvasHalfHeight=.5*e,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var t=this.gl;t.bufferSubData(t.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var e=0,r=0,i=null,a=0;a0&&(r.bindTexture(r.TEXTURE_2D,this._getTexture(this.sprites[t])),r.drawElements(r.TRIANGLES,6*i,r.UNSIGNED_SHORT,6*t*2))},_uploadProjectionTransform:function(t){this._projectionTransformElements&&!t||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var t=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",e="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new c(this,{v:t,f:e},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(t,e,r,i,a,n,s,o,h){var c=this.__tempVertexs||[],_=t.width,l=t.height;i/=_,a/=l,e/=_,r/=l,o=o,h=h,n=n,s=s,i+e>1&&(i=1-e),a+r>1&&(a=1-r);var d=0;return c[d++]=n,c[d++]=s,c[d++]=e,c[d++]=r,c[d++]=n+o,c[d++]=s,c[d++]=e+i,c[d++]=r,c[d++]=n,c[d++]=s+h,c[d++]=e,c[d++]=r+a,c[d++]=n+o,c[d++]=s+h,c[d++]=e+i,c[d++]=r+a,c},_setConcatenatedMatrix:function(t,e){var r=t.__webglWorldMatrix,i=1,a=0,n=t.rotation%360,s=t.pivotX,h=t.pivotY,c=t.scaleX,_=t.scaleY,l=t.transform;if(l)r.copy(l);else{if(n){var d=n*o;i=Math.cos(d),a=Math.sin(d)}var u=t.getAlignPosition();r.a=i*c,r.b=a*c,r.c=-a*_,r.d=i*_,r.tx=u.x-r.a*s-r.c*h,r.ty=u.y-r.b*s-r.d*h}r.concat(e.__webglWorldMatrix)},_getTexture:function(t){var e=t.__textureImage,r=this._cacheTexture[e.src];return r||(r=this.activeShader.uploadTexture(e)),r}}),c=function(t,e,r){this.renderer=t,this.gl=t.gl,this.program=this._createProgram(this.gl,e.v,e.f),r=r||{},this.attributes=r.attributes||[],this.uniforms=r.uniforms||[]};return c.prototype={active:function(){var t=this,e=t.renderer,r=t.gl,i=t.program;i&&r&&(e.activeShader=t,r.useProgram(i),t.attributes.forEach(function(t){e[t]=r.getAttribLocation(i,t),r.enableVertexAttribArray(e[t])}),t.uniforms.forEach(function(t){e[t]=r.getUniformLocation(i,t)}),t.width===e.width&&t.height===e.height||(t.width=e.width,t.height=e.height,e._uploadProjectionTransform()))},uploadTexture:function(t){var e=this.gl,r=this.renderer,i=e.createTexture(),a=r.u_Sampler;return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,i),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(a,0),e.bindTexture(e.TEXTURE_2D,null),this.renderer._cacheTexture[t.src]=i,i},_createProgram:function(t,e,r){var i=this._createShader(t,t.VERTEX_SHADER,e),a=this._createShader(t,t.FRAGMENT_SHADER,r);if(!i||!a)return null;var n=t.createProgram();if(n){t.attachShader(n,i),t.attachShader(n,a),t.linkProgram(n),t.deleteShader(a),t.deleteShader(i);var s=t.getProgramParameter(n,t.LINK_STATUS);if(!s){var o=t.getProgramInfoLog(n);return console.log("Failed to link program: "+o),t.deleteProgram(n),null}}return n},_createShader:function(t,e,r){var i=t.createShader(e);if(i){t.shaderSource(i,r),t.compileShader(i);var a=t.getShaderParameter(i,t.COMPILE_STATUS);if(!a){var n=t.getShaderInfoLog(i);return console.log("Failed to compile shader: "+n),t.deleteShader(i),null}}return i}},h}); \ No newline at end of file diff --git a/build/cmd/hilo/tween/Ease.js b/build/cmd/hilo/tween/Ease.js index 81c927d5..f3374090 100644 --- a/build/cmd/hilo/tween/Ease.js +++ b/build/cmd/hilo/tween/Ease.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/tween/Ease.min.js b/build/cmd/hilo/tween/Ease.min.js index 0fb258ac..e0bfb5c9 100644 --- a/build/cmd/hilo/tween/Ease.min.js +++ b/build/cmd/hilo/tween/Ease.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/tween/Tween.js b/build/cmd/hilo/tween/Tween.js index 1936d9f0..fe201295 100644 --- a/build/cmd/hilo/tween/Tween.js +++ b/build/cmd/hilo/tween/Tween.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/tween/Tween.min.js b/build/cmd/hilo/tween/Tween.min.js index ab50d8cc..a2cecbe9 100644 --- a/build/cmd/hilo/tween/Tween.min.js +++ b/build/cmd/hilo/tween/Tween.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/util/TextureAtlas.js b/build/cmd/hilo/util/TextureAtlas.js index e07d4680..7d69d27b 100644 --- a/build/cmd/hilo/util/TextureAtlas.js +++ b/build/cmd/hilo/util/TextureAtlas.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/util/TextureAtlas.min.js b/build/cmd/hilo/util/TextureAtlas.min.js index 6de54279..ee25abb9 100644 --- a/build/cmd/hilo/util/TextureAtlas.min.js +++ b/build/cmd/hilo/util/TextureAtlas.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/util/Ticker.js b/build/cmd/hilo/util/Ticker.js index 717bd0e4..9c7ee7c8 100644 --- a/build/cmd/hilo/util/Ticker.js +++ b/build/cmd/hilo/util/Ticker.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/util/Ticker.min.js b/build/cmd/hilo/util/Ticker.min.js index d1d4f051..b79eba1a 100644 --- a/build/cmd/hilo/util/Ticker.min.js +++ b/build/cmd/hilo/util/Ticker.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/util/browser.js b/build/cmd/hilo/util/browser.js index 735124ec..75c4f538 100644 --- a/build/cmd/hilo/util/browser.js +++ b/build/cmd/hilo/util/browser.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/util/browser.min.js b/build/cmd/hilo/util/browser.min.js index 8b8fc3d8..8a41c70a 100644 --- a/build/cmd/hilo/util/browser.min.js +++ b/build/cmd/hilo/util/browser.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/util/drag.js b/build/cmd/hilo/util/drag.js index 3e439a5c..43653a36 100644 --- a/build/cmd/hilo/util/drag.js +++ b/build/cmd/hilo/util/drag.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/util/drag.min.js b/build/cmd/hilo/util/drag.min.js index 23a284b2..0183231c 100644 --- a/build/cmd/hilo/util/drag.min.js +++ b/build/cmd/hilo/util/drag.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/util/polyfill.js b/build/cmd/hilo/util/polyfill.js index cc6529a6..f70f2495 100644 --- a/build/cmd/hilo/util/polyfill.js +++ b/build/cmd/hilo/util/polyfill.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/util/polyfill.min.js b/build/cmd/hilo/util/polyfill.min.js index b8623dad..8df7e197 100644 --- a/build/cmd/hilo/util/polyfill.min.js +++ b/build/cmd/hilo/util/polyfill.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/util/util.js b/build/cmd/hilo/util/util.js index ba922061..c9061937 100644 --- a/build/cmd/hilo/util/util.js +++ b/build/cmd/hilo/util/util.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/util/util.min.js b/build/cmd/hilo/util/util.min.js index bc7fad4f..bf12b704 100644 --- a/build/cmd/hilo/util/util.min.js +++ b/build/cmd/hilo/util/util.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/Bitmap.js b/build/cmd/hilo/view/Bitmap.js index 162efe1b..c267f716 100644 --- a/build/cmd/hilo/view/Bitmap.js +++ b/build/cmd/hilo/view/Bitmap.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/Bitmap.min.js b/build/cmd/hilo/view/Bitmap.min.js index 655b1896..de753753 100644 --- a/build/cmd/hilo/view/Bitmap.min.js +++ b/build/cmd/hilo/view/Bitmap.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/BitmapText.js b/build/cmd/hilo/view/BitmapText.js index ce41a6b6..9e5495c7 100644 --- a/build/cmd/hilo/view/BitmapText.js +++ b/build/cmd/hilo/view/BitmapText.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/BitmapText.min.js b/build/cmd/hilo/view/BitmapText.min.js index 4c5d9604..d6e207c3 100644 --- a/build/cmd/hilo/view/BitmapText.min.js +++ b/build/cmd/hilo/view/BitmapText.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/Button.js b/build/cmd/hilo/view/Button.js index 26d050c0..4c595d9d 100644 --- a/build/cmd/hilo/view/Button.js +++ b/build/cmd/hilo/view/Button.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/Button.min.js b/build/cmd/hilo/view/Button.min.js index e21a1386..ec80877a 100644 --- a/build/cmd/hilo/view/Button.min.js +++ b/build/cmd/hilo/view/Button.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/CacheMixin.js b/build/cmd/hilo/view/CacheMixin.js index b4c92415..7302adee 100644 --- a/build/cmd/hilo/view/CacheMixin.js +++ b/build/cmd/hilo/view/CacheMixin.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/CacheMixin.min.js b/build/cmd/hilo/view/CacheMixin.min.js index 233db2f8..7fc1ee96 100644 --- a/build/cmd/hilo/view/CacheMixin.min.js +++ b/build/cmd/hilo/view/CacheMixin.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/Container.js b/build/cmd/hilo/view/Container.js index ae80ab3e..4cd6cc46 100644 --- a/build/cmd/hilo/view/Container.js +++ b/build/cmd/hilo/view/Container.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/Container.min.js b/build/cmd/hilo/view/Container.min.js index 08ff10e0..610becb5 100644 --- a/build/cmd/hilo/view/Container.min.js +++ b/build/cmd/hilo/view/Container.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/DOMElement.js b/build/cmd/hilo/view/DOMElement.js index 445bed72..90d8c9dc 100644 --- a/build/cmd/hilo/view/DOMElement.js +++ b/build/cmd/hilo/view/DOMElement.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/DOMElement.min.js b/build/cmd/hilo/view/DOMElement.min.js index a0a4942d..f521fc0a 100644 --- a/build/cmd/hilo/view/DOMElement.min.js +++ b/build/cmd/hilo/view/DOMElement.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/Drawable.js b/build/cmd/hilo/view/Drawable.js index 70ae86c3..9af7c647 100644 --- a/build/cmd/hilo/view/Drawable.js +++ b/build/cmd/hilo/view/Drawable.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/Drawable.min.js b/build/cmd/hilo/view/Drawable.min.js index 6c867477..0bd403c7 100644 --- a/build/cmd/hilo/view/Drawable.min.js +++ b/build/cmd/hilo/view/Drawable.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/Graphics.js b/build/cmd/hilo/view/Graphics.js index 9c6eabfd..bc021800 100644 --- a/build/cmd/hilo/view/Graphics.js +++ b/build/cmd/hilo/view/Graphics.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -14,7 +14,7 @@ var CacheMixin = require('hilo/view/CacheMixin'); /** * @language=en - * + * *
* @class Graphics class contains a group of functions for creating vector graphics. * @augments View diff --git a/build/cmd/hilo/view/Graphics.min.js b/build/cmd/hilo/view/Graphics.min.js index 531fa2a3..2655ad0d 100644 --- a/build/cmd/hilo/view/Graphics.min.js +++ b/build/cmd/hilo/view/Graphics.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/Sprite.js b/build/cmd/hilo/view/Sprite.js index 5619676d..ca311cc8 100644 --- a/build/cmd/hilo/view/Sprite.js +++ b/build/cmd/hilo/view/Sprite.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/Sprite.min.js b/build/cmd/hilo/view/Sprite.min.js index b598c4ee..c88413af 100644 --- a/build/cmd/hilo/view/Sprite.min.js +++ b/build/cmd/hilo/view/Sprite.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/Stage.js b/build/cmd/hilo/view/Stage.js index 07174186..ad78f869 100644 --- a/build/cmd/hilo/view/Stage.js +++ b/build/cmd/hilo/view/Stage.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/Stage.min.js b/build/cmd/hilo/view/Stage.min.js index 6c88e525..aec631e7 100644 --- a/build/cmd/hilo/view/Stage.min.js +++ b/build/cmd/hilo/view/Stage.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/Text.js b/build/cmd/hilo/view/Text.js index 6e42de5d..4697da49 100644 --- a/build/cmd/hilo/view/Text.js +++ b/build/cmd/hilo/view/Text.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -52,7 +52,7 @@ var Text = Class.create(/** @lends Text.prototype */{ this._fontHeight = Text.measureFontHeight(this.font); }, - text: null, + text: '', color: '#000', textAlign: null, textVAlign: null, diff --git a/build/cmd/hilo/view/Text.min.js b/build/cmd/hilo/view/Text.min.js index 09b182ea..a8484681 100644 --- a/build/cmd/hilo/view/Text.min.js +++ b/build/cmd/hilo/view/Text.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ -define(function(t,e,i){var n=t("hilo/core/Class"),o=t("hilo/core/Hilo"),h=t("hilo/view/View"),r=t("hilo/view/CacheMixin"),l=n.create({Extends:h,Mixes:r,constructor:function(t){t=t||{},this.id=this.id||t.id||o.getUid("Text"),l.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=l.measureFontHeight(this.font)},text:null,color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=l.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var n=i.drawable,o=n.domElement,h=o.style;h.font=i.font,h.textAlign=i.textAlign,h.color=i.color,h.width=i.width+"px",h.height=i.height+"px",h.lineHeight=i._fontHeight+i.lineSpacing+"px",o.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var n,o,h,r,l,a=i.split(/\r\n|\r|\n|/),s=0,c=0,d=e._fontHeight+e.lineSpacing,x=[];for(n=0,r=a.length;ne.maxWidth?(x.push({text:w,y:c}),s>1;break;case"bottom":p=e.height-e.textHeight}var v=e.background;for(v&&(t.fillStyle=v,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,n=0;n>1;break;case"right":case"end":o=h}n.outline?t.strokeText(e,o,i):t.fillText(e,o,i)},Statics:{measureFontHeight:function(t){var e,i=document.documentElement,n=o.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return i.appendChild(n),e=n.offsetHeight,i.removeChild(n),e}}});return l}); \ No newline at end of file +define(function(t,e,i){var n=t("hilo/core/Class"),o=t("hilo/core/Hilo"),h=t("hilo/view/View"),r=t("hilo/view/CacheMixin"),l=n.create({Extends:h,Mixes:r,constructor:function(t){t=t||{},this.id=this.id||t.id||o.getUid("Text"),l.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=l.measureFontHeight(this.font)},text:"",color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=l.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var n=i.drawable,o=n.domElement,h=o.style;h.font=i.font,h.textAlign=i.textAlign,h.color=i.color,h.width=i.width+"px",h.height=i.height+"px",h.lineHeight=i._fontHeight+i.lineSpacing+"px",o.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var n,o,h,r,l,a=i.split(/\r\n|\r|\n|/),s=0,c=0,d=e._fontHeight+e.lineSpacing,x=[];for(n=0,r=a.length;ne.maxWidth?(x.push({text:w,y:c}),s>1;break;case"bottom":p=e.height-e.textHeight}var v=e.background;for(v&&(t.fillStyle=v,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,n=0;n>1;break;case"right":case"end":o=h}n.outline?t.strokeText(e,o,i):t.fillText(e,o,i)},Statics:{measureFontHeight:function(t){var e,i=document.documentElement,n=o.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return i.appendChild(n),e=n.offsetHeight,i.removeChild(n),e}}});return l}); \ No newline at end of file diff --git a/build/cmd/hilo/view/View.js b/build/cmd/hilo/view/View.js index 48a427f6..6ab55f25 100644 --- a/build/cmd/hilo/view/View.js +++ b/build/cmd/hilo/view/View.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/View.min.js b/build/cmd/hilo/view/View.min.js index 15902e0a..42bcc8c9 100644 --- a/build/cmd/hilo/view/View.min.js +++ b/build/cmd/hilo/view/View.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for cmd + * Hilo 1.4.0 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/core/Class.js b/build/commonjs/core/Class.js index e13bc8f3..715292c0 100644 --- a/build/commonjs/core/Class.js +++ b/build/commonjs/core/Class.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/core/Class.min.js b/build/commonjs/core/Class.min.js index 5581b16c..22626bb5 100644 --- a/build/commonjs/core/Class.min.js +++ b/build/commonjs/core/Class.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/core/Hilo.js b/build/commonjs/core/Hilo.js index 1c93e397..ae8759c1 100644 --- a/build/commonjs/core/Hilo.js +++ b/build/commonjs/core/Hilo.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -28,7 +28,7 @@ var Hilo = { * Hilo version * @type String */ - version: '1.3.0', + version: '1.4.0', /** * @language=en * Gets a globally unique id. Such as Stage1, Bitmap2 etc. diff --git a/build/commonjs/core/Hilo.min.js b/build/commonjs/core/Hilo.min.js index ed44b7f3..c5e08613 100644 --- a/build/commonjs/core/Hilo.min.js +++ b/build/commonjs/core/Hilo.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ -var browser=require("../util/browser"),util=require("../util/util"),win=window,doc=document,docElem=doc.documentElement,uid=0,hasWarnedDict={},Hilo={version:"1.3.0",getUid:function(e){var t=++uid;if(e){var a=e.charCodeAt(e.length-1);return a>=48&&a<=57&&(e+="_"),e+t}return t},viewToString:function(e){for(var t,a=e;a;)t=t?a.id+"."+t:a.id,a=a.parent;return t},copy:function(e,t,a){return util.copy(e,t,a),hasWarnedDict.copy||(hasWarnedDict.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),e},browser:browser,event:{POINTER_START:browser.POINTER_START,POINTER_MOVE:browser.POINTER_MOVE,POINTER_END:browser.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(e){var t;try{t=e.getBoundingClientRect()}catch(a){t={top:e.offsetTop,left:e.offsetLeft,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}}var r=(win.pageXOffset||docElem.scrollLeft)-(docElem.clientLeft||0)||0,o=(win.pageYOffset||docElem.scrollTop)-(docElem.clientTop||0)||0,i=win.getComputedStyle?getComputedStyle(e):e.currentStyle,n=parseInt,s=n(i.paddingLeft)+n(i.borderLeftWidth)||0,c=n(i.paddingTop)+n(i.borderTopWidth)||0,d=n(i.paddingRight)+n(i.borderRightWidth)||0,h=n(i.paddingBottom)+n(i.borderBottomWidth)||0,l=t.top||0,f=t.left||0,g=t.right||0,p=t.bottom||0;return{left:f+r+s,top:l+o+c,width:g-d-f-s,height:p-h-l-c}},createElement:function(e,t){var a,r,o,i=doc.createElement(e);for(a in t)if(r=t[a],"style"===a)for(o in r)i.style[o]=r[o];else i[a]=r;return i},getElement:function(e){return doc.getElementById(e)},setElementStyleByView:function(e){var t=e.drawable,a=t.domElement.style,r=e._stateCache||(e._stateCache={}),o=Hilo.browser.jsVendor,i="px",n=!1;if(this.cacheStateIfChanged(e,["visible"],r)&&(a.display=e.visible?"":"none"),this.cacheStateIfChanged(e,["alpha"],r)&&(a.opacity=e.alpha),e.visible&&!(e.alpha<=0)){if(this.cacheStateIfChanged(e,["width"],r)&&(a.width=e.width+i),this.cacheStateIfChanged(e,["height"],r)&&(a.height=e.height+i),this.cacheStateIfChanged(e,["depth"],r)&&(a.zIndex=e.depth+1),e.transform){var s=e.transform;(n=this.cacheStateIfChanged(e,["pivotX","pivotY"],r))&&(a[o+"TransformOrigin"]="0 0"),a[o+"Transform"]="matrix3d("+s.a+", "+s.b+", 0, 0, "+s.c+", "+s.d+", 0, 0, 0, 0, 1, 0, "+s.tx+", "+s.ty+", 0, 1)"}else(n=this.cacheStateIfChanged(e,["pivotX","pivotY"],r))&&(a[o+"TransformOrigin"]=e.pivotX+i+" "+e.pivotY+i),(this.cacheStateIfChanged(e,["x","y","rotation","scaleX","scaleY"],r)||n)&&(a[o+"Transform"]=this.getTransformCSS(e));this.cacheStateIfChanged(e,["background"],r)&&(a.backgroundColor=e.background),a.pointerEvents||(a.pointerEvents="none");var c=t.image;if(c){var d=c.src;d!==r.image&&(r.image=d,a.backgroundImage="url("+d+")");var h=t.rect;if(h){var l=h[0],f=h[1];l!==r.sx&&(r.sx=l,a.backgroundPositionX=-l+i),f!==r.sy&&(r.sy=f,a.backgroundPositionY=-f+i)}}var g=e.mask;if(g){var p=g.drawable.domElement.style.backgroundImage;p!==r.maskImage&&(r.maskImage=p,a[o+"MaskImage"]=p,a[o+"MaskRepeat"]="no-repeat");var m=g.x,u=g.y;m===r.maskX&&u===r.maskY||(r.maskX=m,r.maskY=u,a[o+"MaskPosition"]=m+i+" "+u+i)}}},cacheStateIfChanged:function(e,t,a){var r,o,i,n,s=!1;for(r=0,o=t.length;r=48&&a<=57&&(e+="_"),e+t}return t},viewToString:function(e){for(var t,a=e;a;)t=t?a.id+"."+t:a.id,a=a.parent;return t},copy:function(e,t,a){return util.copy(e,t,a),hasWarnedDict.copy||(hasWarnedDict.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),e},browser:browser,event:{POINTER_START:browser.POINTER_START,POINTER_MOVE:browser.POINTER_MOVE,POINTER_END:browser.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(e){var t;try{t=e.getBoundingClientRect()}catch(a){t={top:e.offsetTop,left:e.offsetLeft,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}}var r=(win.pageXOffset||docElem.scrollLeft)-(docElem.clientLeft||0)||0,o=(win.pageYOffset||docElem.scrollTop)-(docElem.clientTop||0)||0,i=win.getComputedStyle?getComputedStyle(e):e.currentStyle,n=parseInt,s=n(i.paddingLeft)+n(i.borderLeftWidth)||0,c=n(i.paddingTop)+n(i.borderTopWidth)||0,d=n(i.paddingRight)+n(i.borderRightWidth)||0,h=n(i.paddingBottom)+n(i.borderBottomWidth)||0,l=t.top||0,f=t.left||0,g=t.right||0,p=t.bottom||0;return{left:f+r+s,top:l+o+c,width:g-d-f-s,height:p-h-l-c}},createElement:function(e,t){var a,r,o,i=doc.createElement(e);for(a in t)if(r=t[a],"style"===a)for(o in r)i.style[o]=r[o];else i[a]=r;return i},getElement:function(e){return doc.getElementById(e)},setElementStyleByView:function(e){var t=e.drawable,a=t.domElement.style,r=e._stateCache||(e._stateCache={}),o=Hilo.browser.jsVendor,i="px",n=!1;if(this.cacheStateIfChanged(e,["visible"],r)&&(a.display=e.visible?"":"none"),this.cacheStateIfChanged(e,["alpha"],r)&&(a.opacity=e.alpha),e.visible&&!(e.alpha<=0)){if(this.cacheStateIfChanged(e,["width"],r)&&(a.width=e.width+i),this.cacheStateIfChanged(e,["height"],r)&&(a.height=e.height+i),this.cacheStateIfChanged(e,["depth"],r)&&(a.zIndex=e.depth+1),e.transform){var s=e.transform;(n=this.cacheStateIfChanged(e,["pivotX","pivotY"],r))&&(a[o+"TransformOrigin"]="0 0"),a[o+"Transform"]="matrix3d("+s.a+", "+s.b+", 0, 0, "+s.c+", "+s.d+", 0, 0, 0, 0, 1, 0, "+s.tx+", "+s.ty+", 0, 1)"}else(n=this.cacheStateIfChanged(e,["pivotX","pivotY"],r))&&(a[o+"TransformOrigin"]=e.pivotX+i+" "+e.pivotY+i),(this.cacheStateIfChanged(e,["x","y","rotation","scaleX","scaleY"],r)||n)&&(a[o+"Transform"]=this.getTransformCSS(e));this.cacheStateIfChanged(e,["background"],r)&&(a.backgroundColor=e.background),a.pointerEvents||(a.pointerEvents="none");var c=t.image;if(c){var d=c.src;d!==r.image&&(r.image=d,a.backgroundImage="url("+d+")");var h=t.rect;if(h){var l=h[0],f=h[1];l!==r.sx&&(r.sx=l,a.backgroundPositionX=-l+i),f!==r.sy&&(r.sy=f,a.backgroundPositionY=-f+i)}}var g=e.mask;if(g){var p=g.drawable.domElement.style.backgroundImage;p!==r.maskImage&&(r.maskImage=p,a[o+"MaskImage"]=p,a[o+"MaskRepeat"]="no-repeat");var m=g.x,u=g.y;m===r.maskX&&u===r.maskY||(r.maskX=m,r.maskY=u,a[o+"MaskPosition"]=m+i+" "+u+i)}}},cacheStateIfChanged:function(e,t,a){var r,o,i,n,s=!1;for(r=0,o=t.length;r0)&&(e===this.stage&&this.clear(),!0)},draw:function(e){var t=e.width,r=e.height,i=(e.background,e.drawable),a=i&&i.image;if(a){var n=i.rect,s=n[2],o=n[3];t||r||(t=e.width=s,r=e.height=o),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(a,n[0],n[1],s,o,0,0,t,r),d=this.batchIndex*this.positionStride,_=this.float32Array,c=this.uint32Array,l=(e.tint>>16)+(65280&e.tint)+((255&e.tint)<<16)+(255*e.__webglRenderAlpha<<24);_[d+0]=h[0],_[d+1]=h[1],_[d+2]=h[2],_[d+3]=h[3],c[d+4]=l,_[d+5]=h[4],_[d+6]=h[5],_[d+7]=h[6],_[d+8]=h[7],c[d+9]=l,_[d+10]=h[8],_[d+11]=h[9],_[d+12]=h[10],_[d+13]=h[11],c[d+14]=l,_[d+15]=h[12],_[d+16]=h[13],_[d+17]=h[14],_[d+18]=h[15],c[d+19]=l;for(var u=e.__webglWorldMatrix,f=0;f<4;f++){var g=_[d+5*f],x=_[d+5*f+1];_[d+5*f]=u.a*g+u.c*x+u.tx,_[d+5*f+1]=u.b*g+u.d*x+u.ty}e.__textureImage=a,this.sprites[this.batchIndex++]=e}},endDraw:function(e){e===this.stage&&this._renderBatches()},transform:function(e){var t=e.drawable;if(t&&t.domElement)return void Hilo.setElementStyleByView(e);var r=e.scaleX,i=e.scaleY;if(e===this.stage){var a=this.canvas.style,n=e._scaleX,s=e._scaleY,o=!1;(!n&&1!=r||n&&n!=r)&&(e._scaleX=r,a.width=r*e.width+"px",o=!0),(!s&&1!=i||s&&s!=i)&&(e._scaleY=i,a.height=i*e.height+"px",o=!0),o&&e.updateViewport(),e.__webglWorldMatrix=e.__webglWorldMatrix||new Matrix(1,0,0,1,0,0)}else e.parent&&(e.__webglWorldMatrix=e.__webglWorldMatrix||new Matrix(1,0,0,1,0,0),this._setConcatenatedMatrix(e,e.parent));e.alpha>0&&(e.parent&&e.parent.__webglRenderAlpha?e.__webglRenderAlpha=e.alpha*e.parent.__webglRenderAlpha:e.__webglRenderAlpha=e.alpha)},remove:function(e){var t=e.drawable,r=t&&t.domElement;if(r){var i=r.parentNode;i&&i.removeChild(r)}},clear:function(e,t,r,i){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(e,t){if(this.width!==e||this.height!==t){var r=this.canvas,i=this.stage,a=r.style;this.width=r.width=e,this.height=r.height=t,a.width=i.width*i.scaleX+"px",a.height=i.height*i.scaleY+"px",this.gl.viewport(0,0,e,t),this.canvasHalfWidth=.5*e,this.canvasHalfHeight=.5*t,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var e=this.gl;e.bufferSubData(e.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var t=0,r=0,i=null,a=0;a0&&(r.bindTexture(r.TEXTURE_2D,this._getTexture(this.sprites[e])),r.drawElements(r.TRIANGLES,6*i,r.UNSIGNED_SHORT,6*e*2))},_uploadProjectionTransform:function(e){this._projectionTransformElements&&!e||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var e=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",t="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new Shader(this,{v:e,f:t},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(e,t,r,i,a,n,s,o,h){var d=this.__tempVertexs||[],_=e.width,c=e.height;i/=_,a/=c,t/=_,r/=c,o=o,h=h,n=n,s=s,i+t>1&&(i=1-t),a+r>1&&(a=1-r);var l=0;return d[l++]=n,d[l++]=s,d[l++]=t,d[l++]=r,d[l++]=n+o,d[l++]=s,d[l++]=t+i,d[l++]=r,d[l++]=n,d[l++]=s+h,d[l++]=t,d[l++]=r+a,d[l++]=n+o,d[l++]=s+h,d[l++]=t+i,d[l++]=r+a,d},_setConcatenatedMatrix:function(e,t){var r=e.__webglWorldMatrix,i=1,a=0,n=e.rotation%360,s=e.pivotX,o=e.pivotY,h=e.scaleX,d=e.scaleY,_=e.transform;if(_)r.copy(_);else{if(n){var c=n*DEG2RAD;i=Math.cos(c),a=Math.sin(c)}var l=e.getAlignPosition();r.a=i*h,r.b=a*h,r.c=-a*d,r.d=i*d,r.tx=l.x-r.a*s-r.c*o,r.ty=l.y-r.b*s-r.d*o}r.concat(t.__webglWorldMatrix)},_getTexture:function(e){var t=e.__textureImage,r=this._cacheTexture[t.src];return r||(r=this.activeShader.uploadTexture(t)),r}}),Shader=function(e,t,r){this.renderer=e,this.gl=e.gl,this.program=this._createProgram(this.gl,t.v,t.f),r=r||{},this.attributes=r.attributes||[],this.uniforms=r.uniforms||[]};Shader.prototype={active:function(){var e=this,t=e.renderer,r=e.gl,i=e.program;i&&r&&(t.activeShader=e,r.useProgram(i),e.attributes.forEach(function(e){t[e]=r.getAttribLocation(i,e),r.enableVertexAttribArray(t[e])}),e.uniforms.forEach(function(e){t[e]=r.getUniformLocation(i,e)}),e.width===t.width&&e.height===t.height||(e.width=t.width,e.height=t.height,t._uploadProjectionTransform()))},uploadTexture:function(e){var t=this.gl,r=this.renderer,i=t.createTexture(),a=r.u_Sampler;return t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,i),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.uniform1i(a,0),t.bindTexture(t.TEXTURE_2D,null),this.renderer._cacheTexture[e.src]=i,i},_createProgram:function(e,t,r){var i=this._createShader(e,e.VERTEX_SHADER,t),a=this._createShader(e,e.FRAGMENT_SHADER,r);if(!i||!a)return null;var n=e.createProgram();if(n){e.attachShader(n,i),e.attachShader(n,a),e.linkProgram(n),e.deleteShader(a),e.deleteShader(i);var s=e.getProgramParameter(n,e.LINK_STATUS);if(!s){var o=e.getProgramInfoLog(n);return console.log("Failed to link program: "+o),e.deleteProgram(n),null}}return n},_createShader:function(e,t,r){var i=e.createShader(t);if(i){e.shaderSource(i,r),e.compileShader(i);var a=e.getShaderParameter(i,e.COMPILE_STATUS);if(!a){var n=e.getShaderInfoLog(i);return console.log("Failed to compile shader: "+n),e.deleteShader(i),null}}return i}},module.exports=WebGLRenderer; \ No newline at end of file +var Class=require("../core/Class"),Hilo=require("../core/Hilo"),Renderer=require("./Renderer"),Matrix=require("../geom/Matrix"),DEG2RAD=Math.PI/180,WebGLRenderer=Class.create({Extends:Renderer,Statics:{MAX_BATCH_NUM:2e3,ATTRIBUTE_NUM:5,isSupport:function(){if(void 0==this._isSupported){var e=document.createElement("canvas");e.getContext&&(e.getContext("webgl")||e.getContext("experimental-webgl"))?this._isSupported=!0:this._isSupported=!1}return this._isSupported},contextOptions:null},renderType:"webgl",gl:null,_isContextLost:!1,_cacheTexture:{},constructor:function(e){WebGLRenderer.superclass.constructor.call(this,e);var t=this,r=WebGLRenderer.contextOptions||{};this.gl=this.canvas.getContext("webgl",r)||this.canvas.getContext("experimental-webgl",r),this.maxBatchNum=WebGLRenderer.MAX_BATCH_NUM,this.positionStride=4*WebGLRenderer.ATTRIBUTE_NUM;var i=this.maxBatchNum*WebGLRenderer.ATTRIBUTE_NUM*4,a=6*this.maxBatchNum;this.arrayBuffer=new ArrayBuffer(4*i),this.float32Array=new Float32Array(this.arrayBuffer),this.uint32Array=new Uint32Array(this.arrayBuffer),this.indexs=new Uint16Array(a);for(var n=0,s=0;n0)&&(e===this.stage&&this.clear(),!0)},draw:function(e){var t=e.width,r=e.height,i=(e.background,e.drawable),a=i&&i.image;if(a){var n=i.rect,s=n[2],o=n[3];t||r||(t=e.width=s,r=e.height=o),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(a,n[0],n[1],s,o,0,0,t,r),d=this.batchIndex*this.positionStride,c=this.float32Array,_=this.uint32Array,l=(e.tint>>16)+(65280&e.tint)+((255&e.tint)<<16)+(255*e.__webglRenderAlpha<<24);c[d+0]=h[0],c[d+1]=h[1],c[d+2]=h[2],c[d+3]=h[3],_[d+4]=l,c[d+5]=h[4],c[d+6]=h[5],c[d+7]=h[6],c[d+8]=h[7],_[d+9]=l,c[d+10]=h[8],c[d+11]=h[9],c[d+12]=h[10],c[d+13]=h[11],_[d+14]=l,c[d+15]=h[12],c[d+16]=h[13],c[d+17]=h[14],c[d+18]=h[15],_[d+19]=l;for(var u=e.__webglWorldMatrix,f=0;f<4;f++){var x=c[d+5*f],g=c[d+5*f+1];c[d+5*f]=u.a*x+u.c*g+u.tx,c[d+5*f+1]=u.b*x+u.d*g+u.ty}e.__textureImage=a,this.sprites[this.batchIndex++]=e}},endDraw:function(e){e===this.stage&&this._renderBatches()},transform:function(e){var t=e.drawable;if(t&&t.domElement)return void Hilo.setElementStyleByView(e);var r=e.scaleX,i=e.scaleY;if(e===this.stage){var a=this.canvas.style,n=e._scaleX,s=e._scaleY,o=!1;(!n&&1!=r||n&&n!=r)&&(e._scaleX=r,a.width=r*e.width+"px",o=!0),(!s&&1!=i||s&&s!=i)&&(e._scaleY=i,a.height=i*e.height+"px",o=!0),o&&e.updateViewport(),e.__webglWorldMatrix=e.__webglWorldMatrix||new Matrix(1,0,0,1,0,0)}else e.parent&&(e.__webglWorldMatrix=e.__webglWorldMatrix||new Matrix(1,0,0,1,0,0),this._setConcatenatedMatrix(e,e.parent));e.alpha>0&&(e.parent&&e.parent.__webglRenderAlpha?e.__webglRenderAlpha=e.alpha*e.parent.__webglRenderAlpha:e.__webglRenderAlpha=e.alpha)},remove:function(e){var t=e.drawable,r=t&&t.domElement;if(r){var i=r.parentNode;i&&i.removeChild(r)}},clear:function(e,t,r,i){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(e,t){if(this.width!==e||this.height!==t){var r=this.canvas,i=this.stage,a=r.style;this.width=r.width=e,this.height=r.height=t,a.width=i.width*i.scaleX+"px",a.height=i.height*i.scaleY+"px",this.gl.viewport(0,0,e,t),this.canvasHalfWidth=.5*e,this.canvasHalfHeight=.5*t,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var e=this.gl;e.bufferSubData(e.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var t=0,r=0,i=null,a=0;a0&&(r.bindTexture(r.TEXTURE_2D,this._getTexture(this.sprites[e])),r.drawElements(r.TRIANGLES,6*i,r.UNSIGNED_SHORT,6*e*2))},_uploadProjectionTransform:function(e){this._projectionTransformElements&&!e||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var e=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",t="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new Shader(this,{v:e,f:t},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(e,t,r,i,a,n,s,o,h){var d=this.__tempVertexs||[],c=e.width,_=e.height;i/=c,a/=_,t/=c,r/=_,o=o,h=h,n=n,s=s,i+t>1&&(i=1-t),a+r>1&&(a=1-r);var l=0;return d[l++]=n,d[l++]=s,d[l++]=t,d[l++]=r,d[l++]=n+o,d[l++]=s,d[l++]=t+i,d[l++]=r,d[l++]=n,d[l++]=s+h,d[l++]=t,d[l++]=r+a,d[l++]=n+o,d[l++]=s+h,d[l++]=t+i,d[l++]=r+a,d},_setConcatenatedMatrix:function(e,t){var r=e.__webglWorldMatrix,i=1,a=0,n=e.rotation%360,s=e.pivotX,o=e.pivotY,h=e.scaleX,d=e.scaleY,c=e.transform;if(c)r.copy(c);else{if(n){var _=n*DEG2RAD;i=Math.cos(_),a=Math.sin(_)}var l=e.getAlignPosition();r.a=i*h,r.b=a*h,r.c=-a*d,r.d=i*d,r.tx=l.x-r.a*s-r.c*o,r.ty=l.y-r.b*s-r.d*o}r.concat(t.__webglWorldMatrix)},_getTexture:function(e){var t=e.__textureImage,r=this._cacheTexture[t.src];return r||(r=this.activeShader.uploadTexture(t)),r}}),Shader=function(e,t,r){this.renderer=e,this.gl=e.gl,this.program=this._createProgram(this.gl,t.v,t.f),r=r||{},this.attributes=r.attributes||[],this.uniforms=r.uniforms||[]};Shader.prototype={active:function(){var e=this,t=e.renderer,r=e.gl,i=e.program;i&&r&&(t.activeShader=e,r.useProgram(i),e.attributes.forEach(function(e){t[e]=r.getAttribLocation(i,e),r.enableVertexAttribArray(t[e])}),e.uniforms.forEach(function(e){t[e]=r.getUniformLocation(i,e)}),e.width===t.width&&e.height===t.height||(e.width=t.width,e.height=t.height,t._uploadProjectionTransform()))},uploadTexture:function(e){var t=this.gl,r=this.renderer,i=t.createTexture(),a=r.u_Sampler;return t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,i),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.uniform1i(a,0),t.bindTexture(t.TEXTURE_2D,null),this.renderer._cacheTexture[e.src]=i,i},_createProgram:function(e,t,r){var i=this._createShader(e,e.VERTEX_SHADER,t),a=this._createShader(e,e.FRAGMENT_SHADER,r);if(!i||!a)return null;var n=e.createProgram();if(n){e.attachShader(n,i),e.attachShader(n,a),e.linkProgram(n),e.deleteShader(a),e.deleteShader(i);var s=e.getProgramParameter(n,e.LINK_STATUS);if(!s){var o=e.getProgramInfoLog(n);return console.log("Failed to link program: "+o),e.deleteProgram(n),null}}return n},_createShader:function(e,t,r){var i=e.createShader(t);if(i){e.shaderSource(i,r),e.compileShader(i);var a=e.getShaderParameter(i,e.COMPILE_STATUS);if(!a){var n=e.getShaderInfoLog(i);return console.log("Failed to compile shader: "+n),e.deleteShader(i),null}}return i}},module.exports=WebGLRenderer; \ No newline at end of file diff --git a/build/commonjs/tween/Ease.js b/build/commonjs/tween/Ease.js index bc0aeb30..1efe1a6c 100644 --- a/build/commonjs/tween/Ease.js +++ b/build/commonjs/tween/Ease.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/tween/Ease.min.js b/build/commonjs/tween/Ease.min.js index 597d8a2e..30cac976 100644 --- a/build/commonjs/tween/Ease.min.js +++ b/build/commonjs/tween/Ease.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/tween/Tween.js b/build/commonjs/tween/Tween.js index 189869de..bffea20d 100644 --- a/build/commonjs/tween/Tween.js +++ b/build/commonjs/tween/Tween.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/tween/Tween.min.js b/build/commonjs/tween/Tween.min.js index 12ea7f84..294721d5 100644 --- a/build/commonjs/tween/Tween.min.js +++ b/build/commonjs/tween/Tween.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/util/TextureAtlas.js b/build/commonjs/util/TextureAtlas.js index 51e99197..c91b288f 100644 --- a/build/commonjs/util/TextureAtlas.js +++ b/build/commonjs/util/TextureAtlas.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/util/TextureAtlas.min.js b/build/commonjs/util/TextureAtlas.min.js index 8ccdb3fa..433e1352 100644 --- a/build/commonjs/util/TextureAtlas.min.js +++ b/build/commonjs/util/TextureAtlas.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/util/Ticker.js b/build/commonjs/util/Ticker.js index fb3fca6a..d102e8bf 100644 --- a/build/commonjs/util/Ticker.js +++ b/build/commonjs/util/Ticker.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/util/Ticker.min.js b/build/commonjs/util/Ticker.min.js index 8ff6f7f3..f8452252 100644 --- a/build/commonjs/util/Ticker.min.js +++ b/build/commonjs/util/Ticker.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/util/browser.js b/build/commonjs/util/browser.js index 3141d7d3..d27c1a83 100644 --- a/build/commonjs/util/browser.js +++ b/build/commonjs/util/browser.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/util/browser.min.js b/build/commonjs/util/browser.min.js index 11c42d29..3e92feb1 100644 --- a/build/commonjs/util/browser.min.js +++ b/build/commonjs/util/browser.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/util/drag.js b/build/commonjs/util/drag.js index ad453a40..12b1a9d9 100644 --- a/build/commonjs/util/drag.js +++ b/build/commonjs/util/drag.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/util/drag.min.js b/build/commonjs/util/drag.min.js index 020d0fd5..962b5f30 100644 --- a/build/commonjs/util/drag.min.js +++ b/build/commonjs/util/drag.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/util/polyfill.js b/build/commonjs/util/polyfill.js index bcc4dbec..37222b4e 100644 --- a/build/commonjs/util/polyfill.js +++ b/build/commonjs/util/polyfill.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/util/polyfill.min.js b/build/commonjs/util/polyfill.min.js index ddc13af6..f1845955 100644 --- a/build/commonjs/util/polyfill.min.js +++ b/build/commonjs/util/polyfill.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/util/util.js b/build/commonjs/util/util.js index f15522e4..80b42cd1 100644 --- a/build/commonjs/util/util.js +++ b/build/commonjs/util/util.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/util/util.min.js b/build/commonjs/util/util.min.js index b724ffd0..e404c5bd 100644 --- a/build/commonjs/util/util.min.js +++ b/build/commonjs/util/util.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/Bitmap.js b/build/commonjs/view/Bitmap.js index b23c92be..efd4f598 100644 --- a/build/commonjs/view/Bitmap.js +++ b/build/commonjs/view/Bitmap.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/Bitmap.min.js b/build/commonjs/view/Bitmap.min.js index 3cb08a0f..54fb808d 100644 --- a/build/commonjs/view/Bitmap.min.js +++ b/build/commonjs/view/Bitmap.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/BitmapText.js b/build/commonjs/view/BitmapText.js index 093a9cf8..138ae7ad 100644 --- a/build/commonjs/view/BitmapText.js +++ b/build/commonjs/view/BitmapText.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/BitmapText.min.js b/build/commonjs/view/BitmapText.min.js index c0ebdd75..045b3eb3 100644 --- a/build/commonjs/view/BitmapText.min.js +++ b/build/commonjs/view/BitmapText.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/Button.js b/build/commonjs/view/Button.js index f6d9eb90..06b5a7e6 100644 --- a/build/commonjs/view/Button.js +++ b/build/commonjs/view/Button.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/Button.min.js b/build/commonjs/view/Button.min.js index 445aeb48..240f603e 100644 --- a/build/commonjs/view/Button.min.js +++ b/build/commonjs/view/Button.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/CacheMixin.js b/build/commonjs/view/CacheMixin.js index 4272d09c..0feb1be3 100644 --- a/build/commonjs/view/CacheMixin.js +++ b/build/commonjs/view/CacheMixin.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/CacheMixin.min.js b/build/commonjs/view/CacheMixin.min.js index 30860217..1351393d 100644 --- a/build/commonjs/view/CacheMixin.min.js +++ b/build/commonjs/view/CacheMixin.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/Container.js b/build/commonjs/view/Container.js index c83d3ef4..ba94e7ab 100644 --- a/build/commonjs/view/Container.js +++ b/build/commonjs/view/Container.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/Container.min.js b/build/commonjs/view/Container.min.js index e182afb6..9c8477ec 100644 --- a/build/commonjs/view/Container.min.js +++ b/build/commonjs/view/Container.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/DOMElement.js b/build/commonjs/view/DOMElement.js index fa07229a..06d76762 100644 --- a/build/commonjs/view/DOMElement.js +++ b/build/commonjs/view/DOMElement.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/DOMElement.min.js b/build/commonjs/view/DOMElement.min.js index 9f6d6c16..206e28bc 100644 --- a/build/commonjs/view/DOMElement.min.js +++ b/build/commonjs/view/DOMElement.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/Drawable.js b/build/commonjs/view/Drawable.js index cba36c8b..63777aa4 100644 --- a/build/commonjs/view/Drawable.js +++ b/build/commonjs/view/Drawable.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/Drawable.min.js b/build/commonjs/view/Drawable.min.js index 4b03d66d..0cb815f2 100644 --- a/build/commonjs/view/Drawable.min.js +++ b/build/commonjs/view/Drawable.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/Graphics.js b/build/commonjs/view/Graphics.js index d25e441f..903d30a5 100644 --- a/build/commonjs/view/Graphics.js +++ b/build/commonjs/view/Graphics.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -12,7 +12,7 @@ var CacheMixin = require('./CacheMixin'); /** * @language=en - * + * *
* @class Graphics class contains a group of functions for creating vector graphics. * @augments View diff --git a/build/commonjs/view/Graphics.min.js b/build/commonjs/view/Graphics.min.js index c184d9d7..0be513eb 100644 --- a/build/commonjs/view/Graphics.min.js +++ b/build/commonjs/view/Graphics.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/Sprite.js b/build/commonjs/view/Sprite.js index d4ec9892..ecbee03d 100644 --- a/build/commonjs/view/Sprite.js +++ b/build/commonjs/view/Sprite.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/Sprite.min.js b/build/commonjs/view/Sprite.min.js index 59eb2d64..553b4826 100644 --- a/build/commonjs/view/Sprite.min.js +++ b/build/commonjs/view/Sprite.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/Stage.js b/build/commonjs/view/Stage.js index afcfa12b..b81b488c 100644 --- a/build/commonjs/view/Stage.js +++ b/build/commonjs/view/Stage.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/Stage.min.js b/build/commonjs/view/Stage.min.js index 1f2d5d89..11eba98d 100644 --- a/build/commonjs/view/Stage.min.js +++ b/build/commonjs/view/Stage.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/Text.js b/build/commonjs/view/Text.js index aad19441..78f10aa3 100644 --- a/build/commonjs/view/Text.js +++ b/build/commonjs/view/Text.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -50,7 +50,7 @@ var Text = Class.create(/** @lends Text.prototype */{ this._fontHeight = Text.measureFontHeight(this.font); }, - text: null, + text: '', color: '#000', textAlign: null, textVAlign: null, diff --git a/build/commonjs/view/Text.min.js b/build/commonjs/view/Text.min.js index 5ecd8c3e..a84e17f2 100644 --- a/build/commonjs/view/Text.min.js +++ b/build/commonjs/view/Text.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ -var Class=require("../core/Class"),Hilo=require("../core/Hilo"),View=require("./View"),CacheMixin=require("./CacheMixin"),Text=Class.create({Extends:View,Mixes:CacheMixin,constructor:function(t){t=t||{},this.id=this.id||t.id||Hilo.getUid("Text"),Text.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=Text.measureFontHeight(this.font)},text:null,color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=Text.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var n=i.drawable,r=n.domElement,l=r.style;l.font=i.font,l.textAlign=i.textAlign,l.color=i.color,l.width=i.width+"px",l.height=i.height+"px",l.lineHeight=i._fontHeight+i.lineSpacing+"px",r.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var n,r,l,o,h,a=i.split(/\r\n|\r|\n|/),s=0,x=0,c=e._fontHeight+e.lineSpacing,d=[];for(n=0,o=a.length;ne.maxWidth?(d.push({text:w,y:x}),s>1;break;case"bottom":p=e.height-e.textHeight}var H=e.background;for(H&&(t.fillStyle=H,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,n=0;n>1;break;case"right":case"end":r=l}n.outline?t.strokeText(e,r,i):t.fillText(e,r,i)},Statics:{measureFontHeight:function(t){var e,i=document.documentElement,n=Hilo.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return i.appendChild(n),e=n.offsetHeight,i.removeChild(n),e}}});module.exports=Text; \ No newline at end of file +var Class=require("../core/Class"),Hilo=require("../core/Hilo"),View=require("./View"),CacheMixin=require("./CacheMixin"),Text=Class.create({Extends:View,Mixes:CacheMixin,constructor:function(t){t=t||{},this.id=this.id||t.id||Hilo.getUid("Text"),Text.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=Text.measureFontHeight(this.font)},text:"",color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=Text.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var n=i.drawable,r=n.domElement,o=r.style;o.font=i.font,o.textAlign=i.textAlign,o.color=i.color,o.width=i.width+"px",o.height=i.height+"px",o.lineHeight=i._fontHeight+i.lineSpacing+"px",r.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var n,r,o,l,h,a=i.split(/\r\n|\r|\n|/),s=0,x=0,c=e._fontHeight+e.lineSpacing,d=[];for(n=0,l=a.length;ne.maxWidth?(d.push({text:w,y:x}),s>1;break;case"bottom":p=e.height-e.textHeight}var H=e.background;for(H&&(t.fillStyle=H,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,n=0;n>1;break;case"right":case"end":r=o}n.outline?t.strokeText(e,r,i):t.fillText(e,r,i)},Statics:{measureFontHeight:function(t){var e,i=document.documentElement,n=Hilo.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return i.appendChild(n),e=n.offsetHeight,i.removeChild(n),e}}});module.exports=Text; \ No newline at end of file diff --git a/build/commonjs/view/View.js b/build/commonjs/view/View.js index 8427096d..2e789c4e 100644 --- a/build/commonjs/view/View.js +++ b/build/commonjs/view/View.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/View.min.js b/build/commonjs/view/View.min.js index 47759a46..3ff4ca4e 100644 --- a/build/commonjs/view/View.min.js +++ b/build/commonjs/view/View.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for commonjs + * Hilo 1.4.0 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/dragonbones/dragonbones.js b/build/dragonbones/dragonbones.js index c0027fad..d0857d23 100644 --- a/build/dragonbones/dragonbones.js +++ b/build/dragonbones/dragonbones.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for dragonbones + * Hilo 1.4.0 for dragonbones * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/dragonbones/dragonbones.min.js b/build/dragonbones/dragonbones.min.js index 0de49ab4..b6e1f010 100644 --- a/build/dragonbones/dragonbones.min.js +++ b/build/dragonbones/dragonbones.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for dragonbones + * Hilo 1.4.0 for dragonbones * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/flash/hilo-flash.js b/build/flash/hilo-flash.js index c082d754..612d08fe 100644 --- a/build/flash/hilo-flash.js +++ b/build/flash/hilo-flash.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for flashAdaptor + * Hilo 1.4.0 for flashAdaptor * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/flash/hilo-flash.min.js b/build/flash/hilo-flash.min.js index 7909b81e..b32cc13c 100644 --- a/build/flash/hilo-flash.min.js +++ b/build/flash/hilo-flash.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for flashAdaptor + * Hilo 1.4.0 for flashAdaptor * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo-kissy.js b/build/kissy/hilo-kissy.js index 519834f4..71d95632 100644 --- a/build/kissy/hilo-kissy.js +++ b/build/kissy/hilo-kissy.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -192,7 +192,7 @@ return browser; }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -229,7 +229,7 @@ return util; }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -257,7 +257,7 @@ var Hilo = { * Hilo version * @type String */ - version: '1.3.0', + version: '1.4.0', /** * @language=en * Gets a globally unique id. Such as Stage1, Bitmap2 etc. @@ -567,7 +567,7 @@ return Hilo; requires: ['hilo/util/browser', 'hilo/util/util'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -750,7 +750,7 @@ return Class; }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -976,7 +976,7 @@ return Matrix; requires: ['hilo/core/Class'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1131,7 +1131,7 @@ return EventMixin; requires: ['hilo/core/Class'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1214,7 +1214,7 @@ return Drawable; requires: ['hilo/core/Class', 'hilo/util/util'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1310,7 +1310,7 @@ return Renderer; requires: ['hilo/core/Class', 'hilo/util/util'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1523,7 +1523,7 @@ return CanvasRenderer; requires: ['hilo/core/Class', 'hilo/core/Hilo', 'hilo/renderer/Renderer'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1707,7 +1707,7 @@ return DOMRenderer; requires: ['hilo/core/Class', 'hilo/core/Hilo', 'hilo/renderer/Renderer', 'hilo/view/Drawable'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1764,7 +1764,13 @@ var WebGLRenderer = Class.create(/** @lends WebGLRenderer.prototype */{ } } return this._isSupported; - } + }, + /** + * WebGL context Options + * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getContextAttributes + * @type {Object} + */ + contextOptions: null }, renderType:'webgl', gl:null, @@ -1773,7 +1779,8 @@ var WebGLRenderer = Class.create(/** @lends WebGLRenderer.prototype */{ constructor: function(properties){ WebGLRenderer.superclass.constructor.call(this, properties); var that = this; - this.gl = this.canvas.getContext("webgl")||this.canvas.getContext('experimental-webgl'); + var contextOptions = WebGLRenderer.contextOptions || {}; + this.gl = this.canvas.getContext("webgl", contextOptions)||this.canvas.getContext('experimental-webgl', contextOptions); this.maxBatchNum = WebGLRenderer.MAX_BATCH_NUM; this.positionStride = WebGLRenderer.ATTRIBUTE_NUM * 4; @@ -2286,7 +2293,7 @@ return WebGLRenderer; requires: ['hilo/core/Class', 'hilo/core/Hilo', 'hilo/renderer/Renderer', 'hilo/geom/Matrix'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2785,7 +2792,7 @@ return View; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/event/EventMixin', 'hilo/geom/Matrix', 'hilo/util/util'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2853,7 +2860,7 @@ return CacheMixin; requires: ['hilo/view/Drawable', 'hilo/util/browser'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3229,7 +3236,7 @@ return Container; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/view/View'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3498,7 +3505,7 @@ return Stage; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/view/Container', 'hilo/renderer/CanvasRenderer', 'hilo/renderer/DOMRenderer', 'hilo/renderer/WebGLRenderer', 'hilo/util/browser', 'hilo/util/util'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3578,7 +3585,7 @@ return Bitmap; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/view/View', 'hilo/view/Drawable'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3851,7 +3858,7 @@ return Sprite; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/view/View', 'hilo/view/Drawable'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3968,7 +3975,7 @@ return DOMElement; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/view/View', 'hilo/view/Drawable'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3978,7 +3985,7 @@ KISSY.add('hilo/view/Graphics', function(S, Hilo, Class, View, CacheMixin){ /** * @language=en - * + * *
* @class Graphics class contains a group of functions for creating vector graphics. * @augments View @@ -4532,7 +4539,7 @@ return Graphics; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/view/View', 'hilo/view/CacheMixin'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4580,7 +4587,7 @@ var Text = Class.create(/** @lends Text.prototype */{ this._fontHeight = Text.measureFontHeight(this.font); }, - text: null, + text: '', color: '#000', textAlign: null, textVAlign: null, @@ -4787,7 +4794,7 @@ return Text; requires: ['hilo/core/Class', 'hilo/core/Hilo', 'hilo/view/View', 'hilo/view/CacheMixin'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4973,7 +4980,7 @@ return BitmapText; requires: ['hilo/core/Class', 'hilo/core/Hilo', 'hilo/view/Container', 'hilo/view/Bitmap'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5154,7 +5161,7 @@ return Button; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/view/View', 'hilo/view/Drawable', 'hilo/util/util'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5393,7 +5400,7 @@ return TextureAtlas; requires: ['hilo/core/Class'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5624,7 +5631,7 @@ return Ticker; requires: ['hilo/core/Class', 'hilo/util/browser'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5672,7 +5679,7 @@ if (!fnProto.bind) { }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5813,7 +5820,7 @@ return drag; requires: ['hilo/core/Hilo'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6265,7 +6272,7 @@ return Tween; requires: ['hilo/core/Class'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6537,7 +6544,7 @@ return Ease; }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6587,7 +6594,7 @@ return ImageLoader; requires: ['hilo/core/Class'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6656,7 +6663,7 @@ return ScriptLoader; requires: ['hilo/core/Class'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6908,7 +6915,7 @@ return LoadQueue; requires: ['hilo/core/Class', 'hilo/event/EventMixin', 'hilo/loader/ImageLoader', 'hilo/loader/ScriptLoader'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7113,7 +7120,7 @@ return HTMLAudio; requires: ['hilo/core/Class', 'hilo/util/util', 'hilo/event/EventMixin'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7432,7 +7439,7 @@ return WebAudio; requires: ['hilo/core/Class', 'hilo/util/util', 'hilo/event/EventMixin'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7537,7 +7544,7 @@ return WebSound; requires: ['hilo/media/HTMLAudio', 'hilo/media/WebAudio', 'hilo/util/util'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7632,7 +7639,7 @@ return Camera; requires: ['hilo/core/Class', 'hilo/util/util'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7821,7 +7828,7 @@ return Camera3d; requires: ['hilo/core/Class', 'hilo/util/util'] }); /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo-kissy.min.js b/build/kissy/hilo-kissy.min.js index 412c2bd5..84d1c21b 100644 --- a/build/kissy/hilo-kissy.min.js +++ b/build/kissy/hilo-kissy.min.js @@ -1,8 +1,8 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ -KISSY.add("hilo/util/browser",function(t){var e=function(){var t=navigator.userAgent,e=document,i=window,r=e.documentElement,n={iphone:/iphone/i.test(t),ipad:/ipad/i.test(t),ipod:/ipod/i.test(t),ios:/iphone|ipad|ipod/i.test(t),android:/android/i.test(t),webkit:/webkit/i.test(t),chrome:/chrome/i.test(t),safari:/safari/i.test(t),firefox:/firefox/i.test(t),ie:/msie/i.test(t),opera:/opera/i.test(t),supportTouch:"ontouchstart"in i,supportCanvas:null!=e.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in i||"orientation"in i.screen,supportDeviceMotion:"ondevicemotion"in i};try{var a="hilo";localStorage.setItem(a,a),localStorage.removeItem(a),n.supportStorage=!0}catch(o){}var s=n.jsVendor=n.webkit?"webkit":n.firefox?"webkit":n.opera?"o":n.ie?"ms":"",h=n.cssVendor="-"+s+"-",l=e.createElement("div"),c=l.style,u=void 0!=c[s+"Transform"],d=void 0!=c[s+"Perspective"];d&&(l.id="test3d",c=e.createElement("style"),c.textContent="@media ("+h+"transform-3d){#test3d{height:3px}}",e.head.appendChild(c),r.appendChild(l),d=3==l.offsetHeight,e.head.removeChild(c),r.removeChild(l)),n.supportTransform=u,n.supportTransform3D=d;var f=n.supportTouch,p=f?"touchstart":"mousedown",v=f?"touchmove":"mousemove",m=f?"touchend":"mouseup";return n.POINTER_START=p,n.POINTER_MOVE=v,n.POINTER_END=m,n}();return e}),KISSY.add("hilo/util/util",function(t){var e={copy:function(t,e,i){for(var r in e)i&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t}};return e}),KISSY.add("hilo/core/Hilo",function(t,e,i){var r=window,n=document,a=n.documentElement,o=0,s={},h={version:"1.3.0",getUid:function(t){var e=++o;if(t){var i=t.charCodeAt(t.length-1);return i>=48&&i<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,i=t;i;)e=e?i.id+"."+e:i.id,i=i.parent;return e},copy:function(t,e,r){return i.copy(t,e,r),s.copy||(s.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),t},browser:e,event:{POINTER_START:e.POINTER_START,POINTER_MOVE:e.POINTER_MOVE,POINTER_END:e.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(t){var e;try{e=t.getBoundingClientRect()}catch(i){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var n=(r.pageXOffset||a.scrollLeft)-(a.clientLeft||0)||0,o=(r.pageYOffset||a.scrollTop)-(a.clientTop||0)||0,s=r.getComputedStyle?getComputedStyle(t):t.currentStyle,h=parseInt,l=h(s.paddingLeft)+h(s.borderLeftWidth)||0,c=h(s.paddingTop)+h(s.borderTopWidth)||0,u=h(s.paddingRight)+h(s.borderRightWidth)||0,d=h(s.paddingBottom)+h(s.borderBottomWidth)||0,f=e.top||0,p=e.left||0,v=e.right||0,m=e.bottom||0;return{left:p+n+l,top:f+o+c,width:v-u-p-l,height:m-d-f-c}},createElement:function(t,e){var i,r,a,o=n.createElement(t);for(i in e)if(r=e[i],"style"===i)for(a in r)o.style[a]=r[a];else o[i]=r;return o},getElement:function(t){return n.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,i=e.domElement.style,r=t._stateCache||(t._stateCache={}),n=h.browser.jsVendor,a="px",o=!1;if(this.cacheStateIfChanged(t,["visible"],r)&&(i.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],r)&&(i.opacity=t.alpha),t.visible&&!(t.alpha<=0)){if(this.cacheStateIfChanged(t,["width"],r)&&(i.width=t.width+a),this.cacheStateIfChanged(t,["height"],r)&&(i.height=t.height+a),this.cacheStateIfChanged(t,["depth"],r)&&(i.zIndex=t.depth+1),t.transform){var s=t.transform;(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(i[n+"TransformOrigin"]="0 0"),i[n+"Transform"]="matrix3d("+s.a+", "+s.b+", 0, 0, "+s.c+", "+s.d+", 0, 0, 0, 0, 1, 0, "+s.tx+", "+s.ty+", 0, 1)"}else(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(i[n+"TransformOrigin"]=t.pivotX+a+" "+t.pivotY+a),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],r)||o)&&(i[n+"Transform"]=this.getTransformCSS(t));this.cacheStateIfChanged(t,["background"],r)&&(i.backgroundColor=t.background),i.pointerEvents||(i.pointerEvents="none");var l=e.image;if(l){var c=l.src;c!==r.image&&(r.image=c,i.backgroundImage="url("+c+")");var u=e.rect;if(u){var d=u[0],f=u[1];d!==r.sx&&(r.sx=d,i.backgroundPositionX=-d+a),f!==r.sy&&(r.sy=f,i.backgroundPositionY=-f+a)}}var p=t.mask;if(p){var v=p.drawable.domElement.style.backgroundImage;v!==r.maskImage&&(r.maskImage=v,i[n+"MaskImage"]=v,i[n+"MaskRepeat"]="no-repeat");var m=p.x,g=p.y;m===r.maskX&&g===r.maskY||(r.maskX=m,r.maskY=g,i[n+"MaskPosition"]=m+a+" "+g+a)}}},cacheStateIfChanged:function(t,e,i){var r,n,a,o,s=!1;for(r=0,n=e.length;r=6?(e=s[0],i=s[1],r=s[2],n=s[3],a=s[4],o=s[5]):(e=t.a,i=t.b,r=t.c,n=t.d,a=t.tx,o=t.ty),this.a=h*e+l*r,this.b=h*i+l*n,this.c=c*e+u*r,this.d=c*i+u*n,this.tx=d*e+f*r+a,this.ty=d*i+f*n+o,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),r=this.a,n=this.b,a=this.c,o=this.d,s=this.tx,h=this.ty;return this.a=r*i-n*e,this.b=r*e+n*i,this.c=a*i-o*e,this.d=a*e+o*i,this.tx=s*i-h*e,this.ty=s*e+h*i,this},scale:function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},translate:function(t,e){return this.tx+=t,this.ty+=e,this},identity:function(){return this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this},invert:function(){var t=this.a,e=this.b,i=this.c,r=this.d,n=this.tx,a=t*r-e*i;return this.a=r/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-r*n)/a,this.ty=-(t*this.ty-e*n)/a,this},transformPoint:function(t,e,i){var r=t.x*this.a+t.y*this.c+this.tx,n=t.x*this.b+t.y*this.d+this.ty;return e&&(r=r+.5>>0,n=n+.5>>0),i?{x:r,y:n}:(t.x=r,t.y=n,t)}});return i},{requires:["hilo/core/Class"]}),KISSY.add("hilo/event/EventMixin",function(t,e){var i={_listeners:null,on:function(t,e,i){for(var r=this._listeners=this._listeners||{},n=r[t]=r[t]||[],a=0,o=n.length;a-1&&o.splice(c,1)}}return 0==o.length&&delete a[n],!0}return!1}},r=e.create({constructor:function(t,e,i){this.type=t,this.target=e,this.detail=i,this.timeStamp=+new Date},type:null,target:null,detail:null,timeStamp:0,stopImmediatePropagation:function(){this._stopped=!0}}),n=window.Event;if(n){var a=n.prototype,o=a.stopImmediatePropagation;a.stopImmediatePropagation=function(){o&&o.call(this),this._stopped=!0}}return i},{requires:["hilo/core/Class"]}),KISSY.add("hilo/view/Drawable",function(t,e,i){var r=e.create({constructor:function(t){this.init(t)},image:null,rect:null,init:function(t){var e=this,n=e.image;r.isDrawable(t)?e.image=t:i.copy(e,t,!0);var a=e.image;if("string"==typeof a){if(!n||a!==n.getAttribute("src")){e.image=null;var o=new Image;return t.crossOrigin&&(o.crossOrigin=t.crossOrigin),o.onload=function(){o.onload=null,e.init(o)},void(o.src=a)}a=e.image=n}a&&!e.rect&&(e.rect=[0,0,a.width,a.height])},Statics:{isDrawable:function(t){if(!t||!t.tagName)return!1;var e=t.tagName.toLowerCase();return"img"===e||"canvas"===e||"video"===e}}});return r},{requires:["hilo/core/Class","hilo/util/util"]}),KISSY.add("hilo/renderer/Renderer",function(t,e,i){var r=e.create({constructor:function(t){t=t||{},i.copy(this,t,!0)},renderType:null,canvas:null,stage:null,blendMode:"source-over",startDraw:function(t){},draw:function(t){},endDraw:function(t){},transform:function(){},hide:function(){},remove:function(t){},clear:function(t,e,i,r){},resize:function(t,e){}});return r},{requires:["hilo/core/Class","hilo/util/util"]}),KISSY.add("hilo/renderer/CanvasRenderer",function(t,e,i,r){var n=e.create({Extends:r,constructor:function(t){n.superclass.constructor.call(this,t),this.context=this.canvas.getContext("2d")},renderType:"canvas",context:null,startDraw:function(t){return!!(t.visible&&t.alpha>0)&&(t===this.stage&&this.context.clearRect(0,0,t.width,t.height),t.blendMode!==this.blendMode&&(this.context.globalCompositeOperation=this.blendMode=t.blendMode),this.context.save(),!0)},draw:function(t){var e=this.context,i=t.width,r=t.height,n=t.background;n&&(e.fillStyle=n,e.fillRect(0,0,i,r));var a=t.drawable,o=a&&a.image;if(o){var s=a.rect,h=s[2],l=s[3],c=s[4],u=s[5];if(!h||!l)return;i||r||(i=t.width=h,r=t.height=l),(c||u)&&e.translate(c-.5*h,u-.5*l),e.drawImage(o,s[0],s[1],h,l,0,0,i,r)}},endDraw:function(t){this.context.restore()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void i.setElementStyleByView(t);var r=this.context,n=t.scaleX,a=t.scaleY;if(t===this.stage){var o=this.canvas.style,s=t._scaleX,h=t._scaleY,l=!1;(!s&&1!=n||s&&s!=n)&&(t._scaleX=n,o.width=n*t.width+"px",l=!0),(!h&&1!=a||h&&h!=a)&&(t._scaleY=a,o.height=a*t.height+"px",l=!0),l&&t.updateViewport()}else{var c=t.x,u=t.y,d=t.pivotX,f=t.pivotY,p=t.rotation%360,v=t.transform,m=t.mask;m&&(m._render(this),r.clip());var g=t.align;if(g){var _=t.getAlignPosition();c=_.x,u=_.y}v?r.transform(v.a,v.b,v.c,v.d,v.tx,v.ty):(0==c&&0==u||r.translate(c,u),0!=p&&r.rotate(p*Math.PI/180),1==n&&1==a||r.scale(n,a),0==d&&0==f||r.translate(-d,-f))}t.alpha>0&&(r.globalAlpha*=t.alpha)},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},clear:function(t,e,i,r){this.context.clearRect(t,e,i,r)},resize:function(t,e){var i=this.canvas,r=this.stage,n=i.style;i.width=t,i.height=e,n.width=r.width*r.scaleX+"px",n.height=r.height*r.scaleY+"px"}});return n},{requires:["hilo/core/Class","hilo/core/Hilo","hilo/renderer/Renderer"]}),KISSY.add("hilo/renderer/DOMRenderer",function(t,e,i,r,n){var a=function(){function t(t,e){var r=t.tagName||"div",n=e.image,a=t.width||n&&n.width,o=t.height||n&&n.height,s=i.createElement(r),h=s.style;if(t.id&&(s.id=t.id),h.position="absolute",h.left=(t.left||0)+"px",h.top=(t.top||0)+"px",h.width=a+"px",h.height=o+"px","canvas"==r){if(s.width=a,s.height=o,n){var l=s.getContext("2d"),c=e.rect||[0,0,a,o];l.drawImage(n,c[0],c[1],c[2],c[3],t.x||0,t.y||0,t.width||c[2],t.height||c[3])}}else if(h.opacity=void 0!=t.alpha?t.alpha:1,(t===this.stage||t.clipChildren)&&(h.overflow="hidden"),n&&n.src){h.backgroundImage="url("+n.src+")";var u=t.rectX||0,d=t.rectY||0;h.backgroundPosition=-u+"px "+-d+"px"}return s}return e.create({Extends:r,constructor:function(t){a.superclass.constructor.call(this,t)},renderType:"dom",startDraw:function(e){var i=e.drawable=e.drawable||new n;return i.domElement=i.domElement||t(e,i),!0},draw:function(t){var e=t.parent,i=t.drawable.domElement,r=i.parentNode;if(e){var n=e.drawable.domElement;if(n!=r&&n.appendChild(i),!t.width&&!t.height){var a=t.drawable.rect;a&&(a[2]||a[3])&&(t.width=a[2],t.height=a[3])}}else t!==this.stage||r||(i.style.overflow="hidden",this.canvas.appendChild(i))},transform:function(t){if(i.setElementStyleByView(t),t===this.stage){var e=this.canvas.style,r=t._scaleX,n=t._scaleY,a=t.scaleX,o=t.scaleY;(!r&&1!=a||r&&r!=a)&&(t._scaleX=a,e.width=a*t.width+"px"),(!n&&1!=o||n&&n!=o)&&(t._scaleY=o,e.height=o*t.height+"px")}},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},hide:function(t){var e=t.drawable&&t.drawable.domElement;e&&(e.style.display="none")},resize:function(t,e){var i=this.canvas.style;i.width=t+"px",i.height=e+"px","absolute"!=i.position&&(i.position="relative")}})}();return a},{requires:["hilo/core/Class","hilo/core/Hilo","hilo/renderer/Renderer","hilo/view/Drawable"]}),KISSY.add("hilo/renderer/WebGLRenderer",function(t,e,i,r,n){var a=Math.PI/180,o=e.create({Extends:r,Statics:{MAX_BATCH_NUM:2e3,ATTRIBUTE_NUM:5,isSupport:function(){if(void 0==this._isSupported){var t=document.createElement("canvas");t.getContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))?this._isSupported=!0:this._isSupported=!1}return this._isSupported}},renderType:"webgl",gl:null,_isContextLost:!1,_cacheTexture:{},constructor:function(t){o.superclass.constructor.call(this,t);var e=this;this.gl=this.canvas.getContext("webgl")||this.canvas.getContext("experimental-webgl"),this.maxBatchNum=o.MAX_BATCH_NUM,this.positionStride=4*o.ATTRIBUTE_NUM;var i=this.maxBatchNum*o.ATTRIBUTE_NUM*4,r=6*this.maxBatchNum;this.arrayBuffer=new ArrayBuffer(4*i),this.float32Array=new Float32Array(this.arrayBuffer),this.uint32Array=new Uint32Array(this.arrayBuffer),this.indexs=new Uint16Array(r);for(var n=0,a=0;n0)&&(t===this.stage&&this.clear(),!0)},draw:function(t){var e=t.width,i=t.height,r=(t.background,t.drawable),n=r&&r.image;if(n){var a=r.rect,o=a[2],s=a[3];e||i||(e=t.width=o,i=t.height=s),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(n,a[0],a[1],o,s,0,0,e,i),l=this.batchIndex*this.positionStride,c=this.float32Array,u=this.uint32Array,d=(t.tint>>16)+(65280&t.tint)+((255&t.tint)<<16)+(255*t.__webglRenderAlpha<<24);c[l+0]=h[0],c[l+1]=h[1],c[l+2]=h[2],c[l+3]=h[3],u[l+4]=d,c[l+5]=h[4],c[l+6]=h[5],c[l+7]=h[6],c[l+8]=h[7],u[l+9]=d,c[l+10]=h[8],c[l+11]=h[9],c[l+12]=h[10],c[l+13]=h[11],u[l+14]=d,c[l+15]=h[12],c[l+16]=h[13],c[l+17]=h[14],c[l+18]=h[15],u[l+19]=d;for(var f=t.__webglWorldMatrix,p=0;p<4;p++){var v=c[l+5*p],m=c[l+5*p+1];c[l+5*p]=f.a*v+f.c*m+f.tx,c[l+5*p+1]=f.b*v+f.d*m+f.ty}t.__textureImage=n,this.sprites[this.batchIndex++]=t}},endDraw:function(t){t===this.stage&&this._renderBatches()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void i.setElementStyleByView(t);var r=t.scaleX,a=t.scaleY;if(t===this.stage){var o=this.canvas.style,s=t._scaleX,h=t._scaleY,l=!1;(!s&&1!=r||s&&s!=r)&&(t._scaleX=r,o.width=r*t.width+"px",l=!0),(!h&&1!=a||h&&h!=a)&&(t._scaleY=a,o.height=a*t.height+"px",l=!0),l&&t.updateViewport(),t.__webglWorldMatrix=t.__webglWorldMatrix||new n(1,0,0,1,0,0)}else t.parent&&(t.__webglWorldMatrix=t.__webglWorldMatrix||new n(1,0,0,1,0,0),this._setConcatenatedMatrix(t,t.parent));t.alpha>0&&(t.parent&&t.parent.__webglRenderAlpha?t.__webglRenderAlpha=t.alpha*t.parent.__webglRenderAlpha:t.__webglRenderAlpha=t.alpha)},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},clear:function(t,e,i,r){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(t,e){if(this.width!==t||this.height!==e){var i=this.canvas,r=this.stage,n=i.style;this.width=i.width=t,this.height=i.height=e,n.width=r.width*r.scaleX+"px",n.height=r.height*r.scaleY+"px",this.gl.viewport(0,0,t,e),this.canvasHalfWidth=.5*t,this.canvasHalfHeight=.5*e,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var t=this.gl;t.bufferSubData(t.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var e=0,i=0,r=null,n=0;n0&&(i.bindTexture(i.TEXTURE_2D,this._getTexture(this.sprites[t])),i.drawElements(i.TRIANGLES,6*r,i.UNSIGNED_SHORT,6*t*2))},_uploadProjectionTransform:function(t){this._projectionTransformElements&&!t||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var t=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",e="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new s(this,{v:t,f:e},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(t,e,i,r,n,a,o,s,h){var l=this.__tempVertexs||[],c=t.width,u=t.height;r/=c,n/=u,e/=c,i/=u,s=s,h=h,a=a,o=o,r+e>1&&(r=1-e),n+i>1&&(n=1-i);var d=0;return l[d++]=a,l[d++]=o,l[d++]=e,l[d++]=i,l[d++]=a+s,l[d++]=o,l[d++]=e+r,l[d++]=i,l[d++]=a,l[d++]=o+h,l[d++]=e,l[d++]=i+n,l[d++]=a+s,l[d++]=o+h,l[d++]=e+r,l[d++]=i+n,l},_setConcatenatedMatrix:function(t,e){var i=t.__webglWorldMatrix,r=1,n=0,o=t.rotation%360,s=t.pivotX,h=t.pivotY,l=t.scaleX,c=t.scaleY,u=t.transform;if(u)i.copy(u);else{if(o){var d=o*a;r=Math.cos(d),n=Math.sin(d)}var f=t.getAlignPosition();i.a=r*l,i.b=n*l,i.c=-n*c,i.d=r*c,i.tx=f.x-i.a*s-i.c*h,i.ty=f.y-i.b*s-i.d*h}i.concat(e.__webglWorldMatrix)},_getTexture:function(t){var e=t.__textureImage,i=this._cacheTexture[e.src];return i||(i=this.activeShader.uploadTexture(e)),i}}),s=function(t,e,i){this.renderer=t,this.gl=t.gl,this.program=this._createProgram(this.gl,e.v,e.f),i=i||{},this.attributes=i.attributes||[],this.uniforms=i.uniforms||[]};return s.prototype={active:function(){var t=this,e=t.renderer,i=t.gl,r=t.program;r&&i&&(e.activeShader=t,i.useProgram(r),t.attributes.forEach(function(t){e[t]=i.getAttribLocation(r,t),i.enableVertexAttribArray(e[t])}),t.uniforms.forEach(function(t){e[t]=i.getUniformLocation(r,t)}),t.width===e.width&&t.height===e.height||(t.width=e.width,t.height=e.height,e._uploadProjectionTransform()))},uploadTexture:function(t){var e=this.gl,i=this.renderer,r=e.createTexture(),n=i.u_Sampler;return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,r),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(n,0),e.bindTexture(e.TEXTURE_2D,null),this.renderer._cacheTexture[t.src]=r,r},_createProgram:function(t,e,i){var r=this._createShader(t,t.VERTEX_SHADER,e),n=this._createShader(t,t.FRAGMENT_SHADER,i);if(!r||!n)return null;var a=t.createProgram();if(a){t.attachShader(a,r),t.attachShader(a,n),t.linkProgram(a),t.deleteShader(n),t.deleteShader(r);var o=t.getProgramParameter(a,t.LINK_STATUS);if(!o){var s=t.getProgramInfoLog(a);return console.log("Failed to link program: "+s),t.deleteProgram(a),null}}return a},_createShader:function(t,e,i){var r=t.createShader(e);if(r){t.shaderSource(r,i),t.compileShader(r);var n=t.getShaderParameter(r,t.COMPILE_STATUS);if(!n){var a=t.getShaderInfoLog(r);return console.log("Failed to compile shader: "+a),t.deleteShader(r),null}}return r}},o},{requires:["hilo/core/Class","hilo/core/Hilo","hilo/renderer/Renderer","hilo/geom/Matrix"]}),KISSY.add("hilo/view/View",function(t,e,i,r,n,a){var o=function(){function t(t,e,i){for(var r,n,a,o,s=0,h=!1,l=0,c=i.length;ld.x?(r=d.x,n=u.x):(r=u.x,n=d.x),t>=r&&t<=n))h=!0;else if(u.y>d.y?(a=d.y,o=u.y):(a=u.y,o=d.y),!(eo)){var f=(e-u.y)*(d.x-u.x)/(d.y-u.y)+u.x;if(f>t?s++:f==t&&(h=!0),u.x>t&&u.y==e){var p=i[(c+l-1)%c];(p.ye||p.y>e&&d.ys?s=c:cl?l=c:c=0)return!1;u>i.overlap&&(i.overlap=u,i.normal.x=p.x,i.normal.y=p.y)}return i}return i.create({Mixes:r,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("View"),a.copy(this,t,!0)},tint:16777215,id:null,x:0,y:0,width:0,height:0,alpha:1,rotation:0,visible:!0,pivotX:0,pivotY:0,scaleX:1,scaleY:1,pointerEnabled:!0,background:null,mask:null,align:null,drawable:null,boundsArea:null,parent:null,depth:-1,transform:null,blendMode:"source-over",getStage:function(){for(var t,e=this;t=e.parent;)e=t;return e.canvas?e:null},getScaledWidth:function(){return this.width*this.scaleX},getScaledHeight:function(){return this.height*this.scaleY},addTo:function(t,e){return"number"==typeof e?t.addChildAt(this,e):t.addChild(this),this},removeFromParent:function(){var t=this.parent;return t&&t.removeChild(this),this},getBounds:function(){for(var t,e,i,r,n,a,o,s=this.width,h=this.height,l=this.getConcatenatedMatrix(),c=this.boundsArea||[{x:0,y:0},{x:s,y:0},{x:s,y:h},{x:0,y:h}],u=[],d=0,f=c.length;de?r=e:ni?a=i:o>1,r=0;break;case"TR":i=o-n,r=0;break;case"L":i=0,r=s-a>>1;break;case"C":i=o-n>>1,r=s-a>>1;break;case"R":i=o-n,r=s-a>>1;break;case"BL":i=0,r=s-a;break;case"B":i=o-n>>1,r=s-a;break;case"BR":i=o-n,r=s-a}}return{x:i,y:r}},hitTestPoint:function(e,i,r){var n=this.getBounds(),a=e>=n.x&&e<=n.x+n.width&&i>=n.y&&i<=n.y+n.height;return a&&r&&(a=t(e,i,n)),a},hitTestObject:function(t,e){var i=this.getBounds(),r=t.getBounds(),n=i.x<=r.x+r.width&&r.x<=i.x+i.width&&i.y<=r.y+r.height&&r.y<=i.y+i.height;return n&&e&&(n=o(i,r)),!!n},_render:function(t,e){this.onUpdate&&this.onUpdate(e)===!1||!t.startDraw(this)||(t.transform(this),this.render(t,e),t.endDraw(this))},_fireMouseEvent:function(t){if(t.eventCurrentTarget=this,this.fire(t),"mousemove"==t.type){if(!this.__mouseOver){this.__mouseOver=!0;var e=a.copy({},t);e.type="mouseover",this.fire(e)}}else"mouseout"==t.type&&(this.__mouseOver=!1);var i=this.parent;t._stopped||t._stopPropagationed||!i||("mouseout"==t.type||"touchout"==t.type?i.hitTestPoint(t.stageX,t.stageY,!0)||i._fireMouseEvent(t):i._fireMouseEvent(t))},onUpdate:null,render:function(t,e){t.draw(this)},toString:function(){return e.viewToString(this)}})}();return o},{requires:["hilo/core/Hilo","hilo/core/Class","hilo/event/EventMixin","hilo/geom/Matrix","hilo/util/util"]}),KISSY.add("hilo/view/CacheMixin",function(t,e,i){var r,n,a={_cacheDirty:!0,cache:function(t){(t||this._cacheDirty||!this.drawable)&&this.updateCache()},updateCache:function(){i.supportCanvas&&(r||(r=document.createElement("canvas"),n=r.getContext("2d")),r.width=this.width,r.height=this.height,this._draw(n),this.drawable=this.drawable||new e,this.drawable.init({image:r.toDataURL()}),this._cacheDirty=!1)},setCacheDirty:function(t){this._cacheDirty=t}};return a},{requires:["hilo/view/Drawable","hilo/util/browser"]}),KISSY.add("hilo/view/Container",function(t,e,i,r){var n=i.create({Extends:r,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("Container"),n.superclass.constructor.call(this,t),this.children?this._updateChildren():this.children=[]},children:null,pointerChildren:!0,clipChildren:!1,getNumChildren:function(){return this.children.length},addChildAt:function(t,e){var i=this.children,r=i.length,n=t.parent;e=e<0?0:e>r?r:e;var a=this.getChildIndex(t);if(a==e)return this;if(a>=0?(i.splice(a,1),e=e==r?r-1:e):n&&n.removeChild(t),i.splice(e,0,t),a<0)this._updateChildren(e);else{var o=a=e.length)return null;var i=e[t];if(i){if(!i.__renderer)for(var r=i;r=r.parent;){if(r.renderer){i.__renderer=r.renderer;break}if(r.__renderer){i.__renderer=r.__renderer;break}}i.__renderer&&i.__renderer.remove(i),i.parent=null,i.depth=-1}return e.splice(t,1),this._updateChildren(t),i},removeChild:function(t){return this.removeChildAt(this.getChildIndex(t))},removeChildById:function(t){for(var e,i=this.children,r=0,n=i.length;r=e.length?null:e[t]},getChildById:function(t){for(var e,i=this.children,r=0,n=i.length;r=0&&r!=e){var n=i.length;e=e<0?0:e>=n?n-1:e,i.splice(r,1),i.splice(e,0,t),this._updateChildren()}return this},swapChildren:function(t,e){var i=this.children,r=this.getChildIndex(t),n=this.getChildIndex(e);t.depth=n,i[n]=t,e.depth=r,i[r]=e},swapChildrenAt:function(t,e){var i=this.children,r=this.getChildAt(t),n=this.getChildAt(e);r.depth=e,i[e]=r,n.depth=t,i[t]=n},sortChildren:function(t){var e=t,i=this.children;if("string"==typeof e){var r=e;e=function(t,e){return e[r]-t[r]}}i.sort(e),this._updateChildren()},_updateChildren:function(t,e){var i,r=this.children;t=t||0,e=e||r.length;for(var n=t;n=0;l--)if(a=h[l],!(!a||!a.visible||a.alpha<=0||n&&!a.pointerEnabled))if(a.children&&a.children.length&&(!n||a.pointerChildren)&&(o=a.getViewAtPoint(t,e,i,r,n)),o){if(!r)return o;o.length&&(s=s.concat(o))}else if(a.hitTestPoint(t,e,i)){if(!r)return a;s.push(a)}return r&&s.length?s:null},render:function(t,e){n.superclass.render.call(this,t,e);var i,r,a,o=this.children.slice(0);for(i=0,r=o.length;ir?r:e,i[e]=t,t.name&&(this._frameNames[t.name]=t),(0!=e||this.width)&&this.height||(this.width=t.rect[2],this.height=t.rect[3]),this},getFrame:function(t){if("number"==typeof t){var e=this._frames;return t<0||t>=e.length?null:e[t]}return this._frameNames[t]},getFrameIndex:function(t){var e=this._frames,i=e.length,r=-1;if("number"==typeof t)r=t;else{var n="string"==typeof t?this._frameNames[t]:t;if(n)for(var a=0;a=i?i-1:r,this.paused=e,this._firstRender=!0,this},_render:function(t,e){var i,r=this.currentFrame;if(this._firstRender?(i=r,this._firstRender=!1):i=this._nextFrame(e),i!=r){this.currentFrame=i;var n=this._frames[i].callback;n&&n.call(this)}this.onEnterFrame&&this.onEnterFrame(i),this.drawable.init(this._frames[i]),a.superclass._render.call(this,t,e)},_nextFrame:function(t){var e=this._frames,i=e.length,r=this.currentFrame,n=e[r],a=n.duration||this.interval,o=this._frameElapsed,s=0!=r||this.drawable?o+(this.timeBased?t:1):0;return o=this._frameElapsed=s=i-1)&&this.stop(),this.paused||0!=o||(null!=n.next?r=this.getFrameIndex(n.next):r>=i-1?r=0:this.drawable&&r++),r},setFrameCallback:function(t,e){return t=this.getFrame(t),t&&(t.callback=e),this},onEnterFrame:null});return a},{requires:["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/Drawable"]}),KISSY.add("hilo/view/DOMElement",function(t,e,i,r,n){var a=i.create({Extends:r,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("DOMElement"),a.superclass.constructor.call(this,t),this.drawable=new n;var i=this.drawable.domElement=t.element||e.createElement("div");i.id=this.id,this.pointerEnabled&&!i.style.pointerEvents&&(i.style.pointerEvents="visible")},_render:function(t,e){this.onUpdate&&this.onUpdate(e)===!1||(t.transform(this),this.visible&&this.alpha>0&&this.render(t,e))},render:function(t,i){if("dom"!==t.renderType){var r=t.canvas,n=this.parent,a=t._domElementContainer;t._domElementContainer||(a=t._domElementContainer=e.createElement("div",{style:{position:"absolute",transform:"scale3d("+n.scaleX+","+n.scaleY+", 1)",transformOrigin:"0 0",zIndex:"1"}}),r.parentNode.insertBefore(t._domElementContainer,r.nextSibling));var o,s=this.drawable.domElement,h=this.depth,l=a.childNodes[0];if(s.parentNode)return;for(;l&&3!=l.nodeType&&(o=parseInt(l.style.zIndex)||0,!(o<=0||o>h));)l=l.nextSibling;a.insertBefore(this.drawable.domElement,l)}else t.draw(this)}});return a},{requires:["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/Drawable"]}),KISSY.add("hilo/view/Graphics",function(t,e,i,r,n){var a=function(){var t=document.createElement("canvas"),o=t.getContext&&t.getContext("2d");return i.create({Extends:r,Mixes:n,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("Graphics"),a.superclass.constructor.call(this,t),this._actions=[]},lineWidth:1,lineAlpha:1,lineCap:null,lineJoin:null,miterLimit:10,hasStroke:!1,strokeStyle:"0",hasFill:!1,fillStyle:"0",fillAlpha:0,lineStyle:function(t,e,i,r,n,a){var o=this,s=o._addAction;return s.call(o,["lineWidth",o.lineWidth=t||1]),s.call(o,["strokeStyle",o.strokeStyle=e||"0"]),s.call(o,["lineAlpha",o.lineAlpha=i||1]),void 0!=r&&s.call(o,["lineCap",o.lineCap=r]),void 0!=n&&s.call(o,["lineJoin",o.lineJoin=n]),void 0!=a&&s.call(o,["miterLimit",o.miterLimit=a]),o.hasStroke=!0,o},setLineDash:function(t){return this._addAction(["setLineDash",t])},beginFill:function(t,e){var i=this,r=i._addAction;return r.call(i,["fillStyle",i.fillStyle=t]),r.call(i,["fillAlpha",i.fillAlpha=e||1]),i.hasFill=!0,i},endFill:function(){var t=this,e=t._addAction;return t.hasStroke&&e.call(t,["stroke"]),t.hasFill&&e.call(t,["fill"]),t.setCacheDirty(!0),t},beginLinearGradientFill:function(t,e,i,r,n,a){for(var s=this,h=o.createLinearGradient(t,e,i,r),l=0,c=n.length;l1?a.slice(1):null;"function"==typeof t[o]?t[o].apply(t,s):t[o]=a[1]}},render:function(t,e){var i=this;"canvas"===t.renderType?i._draw(t.context):(i.cache(),t.draw(i))},clear:function(){var t=this;return t._actions.length=0,t.lineWidth=1,t.lineAlpha=1,t.lineCap=null,t.lineJoin=null,t.miterLimit=10,t.hasStroke=!1,t.strokeStyle="0",t.hasFill=!1,t.fillStyle="0",t.fillAlpha=1,t.setCacheDirty(!0),t},_addAction:function(t){var e=this;return e._actions.push(t),e}})}();return a},{requires:["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/CacheMixin"]}),KISSY.add("hilo/view/Text",function(t,e,i,r,n){var a=e.create({Extends:r,Mixes:n,constructor:function(t){t=t||{},this.id=this.id||t.id||i.getUid("Text"),a.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=a.measureFontHeight(this.font)},text:null,color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=a.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var r=i.drawable,n=r.domElement,a=n.style;a.font=i.font,a.textAlign=i.textAlign,a.color=i.color,a.width=i.width+"px",a.height=i.height+"px",a.lineHeight=i._fontHeight+i.lineSpacing+"px",n.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var r,n,a,o,s,h=i.split(/\r\n|\r|\n|/),l=0,c=0,u=e._fontHeight+e.lineSpacing,d=[];for(r=0,o=h.length;re.maxWidth?(d.push({text:m,y:c}),l>1;break;case"bottom":_=e.height-e.textHeight}var x=e.background;for(x&&(t.fillStyle=x,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,r=0;r>1;break;case"right":case"end":n=a}r.outline?t.strokeText(e,n,i):t.fillText(e,n,i)},Statics:{measureFontHeight:function(t){var e,r=document.documentElement,n=i.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return r.appendChild(n),e=n.offsetHeight,r.removeChild(n),e}}});return a},{requires:["hilo/core/Class","hilo/core/Hilo","hilo/view/View","hilo/view/CacheMixin"]}),KISSY.add("hilo/view/BitmapText",function(t,e,i,r,n){var a=e.create({Extends:r,constructor:function(t){t=t||{},this.id=this.id||t.id||i.getUid("BitmapText"),a.superclass.constructor.call(this,t);var e=t.text+"";e&&(this.text="",this.setText(e)),this.pointerChildren=!1},glyphs:null,letterSpacing:0,text:"",textAlign:"left",setText:function(t){var e=this,i=t.toString(),r=i.length;if(e.text!=i){e.text=i;var n,a,o,s,h=0,l=0,c=0;for(n=0;n0?e.letterSpacing:0),e.children[n]?(s=e.children[n],s.setImage(o.image,o.rect)):(s=e._createBitmap(o),e.addChild(s)),s.x=c,h=c+o.rect[2],l=Math.max(l,o.rect[3]));for(n=e.children.length-1;n>=r;n--)e._releaseBitmap(e.children[n]),e.children[n].removeFromParent();return e.width=h,e.height=l,this.setTextAlign(),e}},_createBitmap:function(t){var e;return a._pool.length?(e=a._pool.pop(),e.setImage(t.image,t.rect)):e=new n({image:t.image,rect:t.rect}),e},_releaseBitmap:function(t){a._pool.push(t)},setTextAlign:function(t){switch(this.textAlign=t||this.textAlign,this.textAlign){case"center":this.pivotX=.5*this.width;break;case"right":this.pivotX=this.width;break;case"left":default:this.pivotX=0}return this},hasGlyphs:function(t){var e=this.glyphs;if(!e)return!1;t=t.toString();var i,r=t.length;for(i=0;i=this._targetFPS?(this._measuredFPS=1e3/(this._tickTime/this._tickCount)+.5>>0,this._tickCount=0,this._tickTime=0):this._tickTime+=t-this._lastTime,this._lastTime=t;for(var r=i.slice(0),n=0,a=r.length;n=0&&e.splice(i,1)},nextTick:function(t){var e=this,i={tick:function(r){e.removeTick(i),t()}};return e.addTick(i),i},timeout:function(t,e){var i=this,r=(new Date).getTime()+e,n={tick:function(){var e=(new Date).getTime(),a=e-r;a>=0&&(i.removeTick(n),t())}};return i.addTick(n),n},interval:function(t,e){var i=this,r=(new Date).getTime()+e,n={tick:function(){var i=(new Date).getTime(),n=i-r;n>=0&&(n=r)return-1;for(e<0&&(e=r+e),i=e;i=1?1:s;var l=n.ease?n.ease(s):s;n.reverse&&(n._reverseFlag<0&&(s=1-s,l=1-l),s<1e-7&&(n.repeat>0&&n._repeatCount++>=n.repeat||0==n.repeat&&!n.loop?h=!0:(n._startTime=t(),n._pausedTime=0,n._reverseFlag*=-1))),n.isStart||(n.setProps(n._fromProps,n._toProps),n.isStart=!0,n.onStart&&n.onStart.call(n,n)),n.time=a,n._render(l),(o=n.onUpdate)&&o.call(n,s,n),s>=1&&(n.reverse?(n._startTime=t(),n._pausedTime=0,n._reverseFlag*=-1):n.loop||n.repeat>0&&n._repeatCount++0&&u<=e?(c._render(s),c.time=a,i.add(c)):h&&(u<0||u>e)&&c.start()}return h?((o=n.onComplete)&&o.call(n,n),!0):void 0}}},Statics:{_tweens:[],tick:function(){var e,r,n=i._tweens,a=n.length;for(r=0;r-1&&n.splice(e,1);else for(e=0;e=i)return void t.fire("complete");if(t._currentIndex=48&&i<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,i=t;i;)e=e?i.id+"."+e:i.id,i=i.parent;return e},copy:function(t,e,r){return i.copy(t,e,r),s.copy||(s.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),t},browser:e,event:{POINTER_START:e.POINTER_START,POINTER_MOVE:e.POINTER_MOVE,POINTER_END:e.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(t){var e;try{e=t.getBoundingClientRect()}catch(i){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var n=(r.pageXOffset||a.scrollLeft)-(a.clientLeft||0)||0,o=(r.pageYOffset||a.scrollTop)-(a.clientTop||0)||0,s=r.getComputedStyle?getComputedStyle(t):t.currentStyle,h=parseInt,l=h(s.paddingLeft)+h(s.borderLeftWidth)||0,c=h(s.paddingTop)+h(s.borderTopWidth)||0,u=h(s.paddingRight)+h(s.borderRightWidth)||0,d=h(s.paddingBottom)+h(s.borderBottomWidth)||0,f=e.top||0,p=e.left||0,v=e.right||0,m=e.bottom||0;return{left:p+n+l,top:f+o+c,width:v-u-p-l,height:m-d-f-c}},createElement:function(t,e){var i,r,a,o=n.createElement(t);for(i in e)if(r=e[i],"style"===i)for(a in r)o.style[a]=r[a];else o[i]=r;return o},getElement:function(t){return n.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,i=e.domElement.style,r=t._stateCache||(t._stateCache={}),n=h.browser.jsVendor,a="px",o=!1;if(this.cacheStateIfChanged(t,["visible"],r)&&(i.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],r)&&(i.opacity=t.alpha),t.visible&&!(t.alpha<=0)){if(this.cacheStateIfChanged(t,["width"],r)&&(i.width=t.width+a),this.cacheStateIfChanged(t,["height"],r)&&(i.height=t.height+a),this.cacheStateIfChanged(t,["depth"],r)&&(i.zIndex=t.depth+1),t.transform){var s=t.transform;(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(i[n+"TransformOrigin"]="0 0"),i[n+"Transform"]="matrix3d("+s.a+", "+s.b+", 0, 0, "+s.c+", "+s.d+", 0, 0, 0, 0, 1, 0, "+s.tx+", "+s.ty+", 0, 1)"}else(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(i[n+"TransformOrigin"]=t.pivotX+a+" "+t.pivotY+a),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],r)||o)&&(i[n+"Transform"]=this.getTransformCSS(t));this.cacheStateIfChanged(t,["background"],r)&&(i.backgroundColor=t.background),i.pointerEvents||(i.pointerEvents="none");var l=e.image;if(l){var c=l.src;c!==r.image&&(r.image=c,i.backgroundImage="url("+c+")");var u=e.rect;if(u){var d=u[0],f=u[1];d!==r.sx&&(r.sx=d,i.backgroundPositionX=-d+a),f!==r.sy&&(r.sy=f,i.backgroundPositionY=-f+a)}}var p=t.mask;if(p){var v=p.drawable.domElement.style.backgroundImage;v!==r.maskImage&&(r.maskImage=v,i[n+"MaskImage"]=v,i[n+"MaskRepeat"]="no-repeat");var m=p.x,g=p.y;m===r.maskX&&g===r.maskY||(r.maskX=m,r.maskY=g,i[n+"MaskPosition"]=m+a+" "+g+a)}}},cacheStateIfChanged:function(t,e,i){var r,n,a,o,s=!1;for(r=0,n=e.length;r=6?(e=s[0],i=s[1],r=s[2],n=s[3],a=s[4],o=s[5]):(e=t.a,i=t.b,r=t.c,n=t.d,a=t.tx,o=t.ty),this.a=h*e+l*r,this.b=h*i+l*n,this.c=c*e+u*r,this.d=c*i+u*n,this.tx=d*e+f*r+a,this.ty=d*i+f*n+o,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),r=this.a,n=this.b,a=this.c,o=this.d,s=this.tx,h=this.ty;return this.a=r*i-n*e,this.b=r*e+n*i,this.c=a*i-o*e,this.d=a*e+o*i,this.tx=s*i-h*e,this.ty=s*e+h*i,this},scale:function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},translate:function(t,e){return this.tx+=t,this.ty+=e,this},identity:function(){return this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this},invert:function(){var t=this.a,e=this.b,i=this.c,r=this.d,n=this.tx,a=t*r-e*i;return this.a=r/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-r*n)/a,this.ty=-(t*this.ty-e*n)/a,this},transformPoint:function(t,e,i){var r=t.x*this.a+t.y*this.c+this.tx,n=t.x*this.b+t.y*this.d+this.ty;return e&&(r=r+.5>>0,n=n+.5>>0),i?{x:r,y:n}:(t.x=r,t.y=n,t)}});return i},{requires:["hilo/core/Class"]}),KISSY.add("hilo/event/EventMixin",function(t,e){var i={_listeners:null,on:function(t,e,i){for(var r=this._listeners=this._listeners||{},n=r[t]=r[t]||[],a=0,o=n.length;a-1&&o.splice(c,1)}}return 0==o.length&&delete a[n],!0}return!1}},r=e.create({constructor:function(t,e,i){this.type=t,this.target=e,this.detail=i,this.timeStamp=+new Date},type:null,target:null,detail:null,timeStamp:0,stopImmediatePropagation:function(){this._stopped=!0}}),n=window.Event;if(n){var a=n.prototype,o=a.stopImmediatePropagation;a.stopImmediatePropagation=function(){o&&o.call(this),this._stopped=!0}}return i},{requires:["hilo/core/Class"]}),KISSY.add("hilo/view/Drawable",function(t,e,i){var r=e.create({constructor:function(t){this.init(t)},image:null,rect:null,init:function(t){var e=this,n=e.image;r.isDrawable(t)?e.image=t:i.copy(e,t,!0);var a=e.image;if("string"==typeof a){if(!n||a!==n.getAttribute("src")){e.image=null;var o=new Image;return t.crossOrigin&&(o.crossOrigin=t.crossOrigin),o.onload=function(){o.onload=null,e.init(o)},void(o.src=a)}a=e.image=n}a&&!e.rect&&(e.rect=[0,0,a.width,a.height])},Statics:{isDrawable:function(t){if(!t||!t.tagName)return!1;var e=t.tagName.toLowerCase();return"img"===e||"canvas"===e||"video"===e}}});return r},{requires:["hilo/core/Class","hilo/util/util"]}),KISSY.add("hilo/renderer/Renderer",function(t,e,i){var r=e.create({constructor:function(t){t=t||{},i.copy(this,t,!0)},renderType:null,canvas:null,stage:null,blendMode:"source-over",startDraw:function(t){},draw:function(t){},endDraw:function(t){},transform:function(){},hide:function(){},remove:function(t){},clear:function(t,e,i,r){},resize:function(t,e){}});return r},{requires:["hilo/core/Class","hilo/util/util"]}),KISSY.add("hilo/renderer/CanvasRenderer",function(t,e,i,r){var n=e.create({Extends:r,constructor:function(t){n.superclass.constructor.call(this,t),this.context=this.canvas.getContext("2d")},renderType:"canvas",context:null,startDraw:function(t){return!!(t.visible&&t.alpha>0)&&(t===this.stage&&this.context.clearRect(0,0,t.width,t.height),t.blendMode!==this.blendMode&&(this.context.globalCompositeOperation=this.blendMode=t.blendMode),this.context.save(),!0)},draw:function(t){var e=this.context,i=t.width,r=t.height,n=t.background;n&&(e.fillStyle=n,e.fillRect(0,0,i,r));var a=t.drawable,o=a&&a.image;if(o){var s=a.rect,h=s[2],l=s[3],c=s[4],u=s[5];if(!h||!l)return;i||r||(i=t.width=h,r=t.height=l),(c||u)&&e.translate(c-.5*h,u-.5*l),e.drawImage(o,s[0],s[1],h,l,0,0,i,r)}},endDraw:function(t){this.context.restore()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void i.setElementStyleByView(t);var r=this.context,n=t.scaleX,a=t.scaleY;if(t===this.stage){var o=this.canvas.style,s=t._scaleX,h=t._scaleY,l=!1;(!s&&1!=n||s&&s!=n)&&(t._scaleX=n,o.width=n*t.width+"px",l=!0),(!h&&1!=a||h&&h!=a)&&(t._scaleY=a,o.height=a*t.height+"px",l=!0),l&&t.updateViewport()}else{var c=t.x,u=t.y,d=t.pivotX,f=t.pivotY,p=t.rotation%360,v=t.transform,m=t.mask;m&&(m._render(this),r.clip());var g=t.align;if(g){var _=t.getAlignPosition();c=_.x,u=_.y}v?r.transform(v.a,v.b,v.c,v.d,v.tx,v.ty):(0==c&&0==u||r.translate(c,u),0!=p&&r.rotate(p*Math.PI/180),1==n&&1==a||r.scale(n,a),0==d&&0==f||r.translate(-d,-f))}t.alpha>0&&(r.globalAlpha*=t.alpha)},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},clear:function(t,e,i,r){this.context.clearRect(t,e,i,r)},resize:function(t,e){var i=this.canvas,r=this.stage,n=i.style;i.width=t,i.height=e,n.width=r.width*r.scaleX+"px",n.height=r.height*r.scaleY+"px"}});return n},{requires:["hilo/core/Class","hilo/core/Hilo","hilo/renderer/Renderer"]}),KISSY.add("hilo/renderer/DOMRenderer",function(t,e,i,r,n){var a=function(){function t(t,e){var r=t.tagName||"div",n=e.image,a=t.width||n&&n.width,o=t.height||n&&n.height,s=i.createElement(r),h=s.style;if(t.id&&(s.id=t.id),h.position="absolute",h.left=(t.left||0)+"px",h.top=(t.top||0)+"px",h.width=a+"px",h.height=o+"px","canvas"==r){if(s.width=a,s.height=o,n){var l=s.getContext("2d"),c=e.rect||[0,0,a,o];l.drawImage(n,c[0],c[1],c[2],c[3],t.x||0,t.y||0,t.width||c[2],t.height||c[3])}}else if(h.opacity=void 0!=t.alpha?t.alpha:1,(t===this.stage||t.clipChildren)&&(h.overflow="hidden"),n&&n.src){h.backgroundImage="url("+n.src+")";var u=t.rectX||0,d=t.rectY||0;h.backgroundPosition=-u+"px "+-d+"px"}return s}return e.create({Extends:r,constructor:function(t){a.superclass.constructor.call(this,t)},renderType:"dom",startDraw:function(e){var i=e.drawable=e.drawable||new n;return i.domElement=i.domElement||t(e,i),!0},draw:function(t){var e=t.parent,i=t.drawable.domElement,r=i.parentNode;if(e){var n=e.drawable.domElement;if(n!=r&&n.appendChild(i),!t.width&&!t.height){var a=t.drawable.rect;a&&(a[2]||a[3])&&(t.width=a[2],t.height=a[3])}}else t!==this.stage||r||(i.style.overflow="hidden",this.canvas.appendChild(i))},transform:function(t){if(i.setElementStyleByView(t),t===this.stage){var e=this.canvas.style,r=t._scaleX,n=t._scaleY,a=t.scaleX,o=t.scaleY;(!r&&1!=a||r&&r!=a)&&(t._scaleX=a,e.width=a*t.width+"px"),(!n&&1!=o||n&&n!=o)&&(t._scaleY=o,e.height=o*t.height+"px")}},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},hide:function(t){var e=t.drawable&&t.drawable.domElement;e&&(e.style.display="none")},resize:function(t,e){var i=this.canvas.style;i.width=t+"px",i.height=e+"px","absolute"!=i.position&&(i.position="relative")}})}();return a},{requires:["hilo/core/Class","hilo/core/Hilo","hilo/renderer/Renderer","hilo/view/Drawable"]}),KISSY.add("hilo/renderer/WebGLRenderer",function(t,e,i,r,n){var a=Math.PI/180,o=e.create({Extends:r,Statics:{MAX_BATCH_NUM:2e3,ATTRIBUTE_NUM:5,isSupport:function(){if(void 0==this._isSupported){var t=document.createElement("canvas");t.getContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))?this._isSupported=!0:this._isSupported=!1}return this._isSupported},contextOptions:null},renderType:"webgl",gl:null,_isContextLost:!1,_cacheTexture:{},constructor:function(t){o.superclass.constructor.call(this,t);var e=this,i=o.contextOptions||{};this.gl=this.canvas.getContext("webgl",i)||this.canvas.getContext("experimental-webgl",i),this.maxBatchNum=o.MAX_BATCH_NUM,this.positionStride=4*o.ATTRIBUTE_NUM;var r=this.maxBatchNum*o.ATTRIBUTE_NUM*4,n=6*this.maxBatchNum;this.arrayBuffer=new ArrayBuffer(4*r),this.float32Array=new Float32Array(this.arrayBuffer),this.uint32Array=new Uint32Array(this.arrayBuffer),this.indexs=new Uint16Array(n);for(var a=0,s=0;a0)&&(t===this.stage&&this.clear(),!0)},draw:function(t){var e=t.width,i=t.height,r=(t.background,t.drawable),n=r&&r.image;if(n){var a=r.rect,o=a[2],s=a[3];e||i||(e=t.width=o,i=t.height=s),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(n,a[0],a[1],o,s,0,0,e,i),l=this.batchIndex*this.positionStride,c=this.float32Array,u=this.uint32Array,d=(t.tint>>16)+(65280&t.tint)+((255&t.tint)<<16)+(255*t.__webglRenderAlpha<<24);c[l+0]=h[0],c[l+1]=h[1],c[l+2]=h[2],c[l+3]=h[3],u[l+4]=d,c[l+5]=h[4],c[l+6]=h[5],c[l+7]=h[6],c[l+8]=h[7],u[l+9]=d,c[l+10]=h[8],c[l+11]=h[9],c[l+12]=h[10],c[l+13]=h[11],u[l+14]=d,c[l+15]=h[12],c[l+16]=h[13],c[l+17]=h[14],c[l+18]=h[15],u[l+19]=d;for(var f=t.__webglWorldMatrix,p=0;p<4;p++){var v=c[l+5*p],m=c[l+5*p+1];c[l+5*p]=f.a*v+f.c*m+f.tx,c[l+5*p+1]=f.b*v+f.d*m+f.ty}t.__textureImage=n,this.sprites[this.batchIndex++]=t}},endDraw:function(t){t===this.stage&&this._renderBatches()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void i.setElementStyleByView(t);var r=t.scaleX,a=t.scaleY;if(t===this.stage){var o=this.canvas.style,s=t._scaleX,h=t._scaleY,l=!1;(!s&&1!=r||s&&s!=r)&&(t._scaleX=r,o.width=r*t.width+"px",l=!0),(!h&&1!=a||h&&h!=a)&&(t._scaleY=a,o.height=a*t.height+"px",l=!0),l&&t.updateViewport(),t.__webglWorldMatrix=t.__webglWorldMatrix||new n(1,0,0,1,0,0)}else t.parent&&(t.__webglWorldMatrix=t.__webglWorldMatrix||new n(1,0,0,1,0,0),this._setConcatenatedMatrix(t,t.parent));t.alpha>0&&(t.parent&&t.parent.__webglRenderAlpha?t.__webglRenderAlpha=t.alpha*t.parent.__webglRenderAlpha:t.__webglRenderAlpha=t.alpha)},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var r=i.parentNode;r&&r.removeChild(i)}},clear:function(t,e,i,r){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(t,e){if(this.width!==t||this.height!==e){var i=this.canvas,r=this.stage,n=i.style;this.width=i.width=t,this.height=i.height=e,n.width=r.width*r.scaleX+"px",n.height=r.height*r.scaleY+"px",this.gl.viewport(0,0,t,e),this.canvasHalfWidth=.5*t,this.canvasHalfHeight=.5*e,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var t=this.gl;t.bufferSubData(t.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var e=0,i=0,r=null,n=0;n0&&(i.bindTexture(i.TEXTURE_2D,this._getTexture(this.sprites[t])),i.drawElements(i.TRIANGLES,6*r,i.UNSIGNED_SHORT,6*t*2))},_uploadProjectionTransform:function(t){this._projectionTransformElements&&!t||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var t=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",e="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new s(this,{v:t,f:e},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(t,e,i,r,n,a,o,s,h){var l=this.__tempVertexs||[],c=t.width,u=t.height;r/=c,n/=u,e/=c,i/=u,s=s,h=h,a=a,o=o,r+e>1&&(r=1-e),n+i>1&&(n=1-i);var d=0;return l[d++]=a,l[d++]=o,l[d++]=e,l[d++]=i,l[d++]=a+s,l[d++]=o,l[d++]=e+r,l[d++]=i,l[d++]=a,l[d++]=o+h,l[d++]=e,l[d++]=i+n,l[d++]=a+s,l[d++]=o+h,l[d++]=e+r,l[d++]=i+n,l},_setConcatenatedMatrix:function(t,e){var i=t.__webglWorldMatrix,r=1,n=0,o=t.rotation%360,s=t.pivotX,h=t.pivotY,l=t.scaleX,c=t.scaleY,u=t.transform;if(u)i.copy(u);else{if(o){var d=o*a;r=Math.cos(d),n=Math.sin(d)}var f=t.getAlignPosition();i.a=r*l,i.b=n*l,i.c=-n*c,i.d=r*c,i.tx=f.x-i.a*s-i.c*h,i.ty=f.y-i.b*s-i.d*h}i.concat(e.__webglWorldMatrix)},_getTexture:function(t){var e=t.__textureImage,i=this._cacheTexture[e.src];return i||(i=this.activeShader.uploadTexture(e)),i}}),s=function(t,e,i){this.renderer=t,this.gl=t.gl,this.program=this._createProgram(this.gl,e.v,e.f),i=i||{},this.attributes=i.attributes||[],this.uniforms=i.uniforms||[]};return s.prototype={active:function(){var t=this,e=t.renderer,i=t.gl,r=t.program;r&&i&&(e.activeShader=t,i.useProgram(r),t.attributes.forEach(function(t){e[t]=i.getAttribLocation(r,t),i.enableVertexAttribArray(e[t])}),t.uniforms.forEach(function(t){e[t]=i.getUniformLocation(r,t)}),t.width===e.width&&t.height===e.height||(t.width=e.width,t.height=e.height,e._uploadProjectionTransform()))},uploadTexture:function(t){var e=this.gl,i=this.renderer,r=e.createTexture(),n=i.u_Sampler;return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,r),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(n,0),e.bindTexture(e.TEXTURE_2D,null),this.renderer._cacheTexture[t.src]=r,r},_createProgram:function(t,e,i){var r=this._createShader(t,t.VERTEX_SHADER,e),n=this._createShader(t,t.FRAGMENT_SHADER,i);if(!r||!n)return null;var a=t.createProgram();if(a){t.attachShader(a,r),t.attachShader(a,n),t.linkProgram(a),t.deleteShader(n),t.deleteShader(r);var o=t.getProgramParameter(a,t.LINK_STATUS);if(!o){var s=t.getProgramInfoLog(a);return console.log("Failed to link program: "+s),t.deleteProgram(a),null}}return a},_createShader:function(t,e,i){var r=t.createShader(e);if(r){t.shaderSource(r,i),t.compileShader(r);var n=t.getShaderParameter(r,t.COMPILE_STATUS);if(!n){var a=t.getShaderInfoLog(r);return console.log("Failed to compile shader: "+a),t.deleteShader(r),null}}return r}},o},{requires:["hilo/core/Class","hilo/core/Hilo","hilo/renderer/Renderer","hilo/geom/Matrix"]}),KISSY.add("hilo/view/View",function(t,e,i,r,n,a){var o=function(){function t(t,e,i){for(var r,n,a,o,s=0,h=!1,l=0,c=i.length;ld.x?(r=d.x,n=u.x):(r=u.x,n=d.x),t>=r&&t<=n))h=!0;else if(u.y>d.y?(a=d.y,o=u.y):(a=u.y,o=d.y),!(eo)){var f=(e-u.y)*(d.x-u.x)/(d.y-u.y)+u.x;if(f>t?s++:f==t&&(h=!0),u.x>t&&u.y==e){var p=i[(c+l-1)%c];(p.ye||p.y>e&&d.ys?s=c:cl?l=c:c=0)return!1;u>i.overlap&&(i.overlap=u,i.normal.x=p.x,i.normal.y=p.y)}return i}return i.create({Mixes:r,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("View"),a.copy(this,t,!0)},tint:16777215,id:null,x:0,y:0,width:0,height:0,alpha:1,rotation:0,visible:!0,pivotX:0,pivotY:0,scaleX:1,scaleY:1,pointerEnabled:!0,background:null,mask:null,align:null,drawable:null,boundsArea:null,parent:null,depth:-1,transform:null,blendMode:"source-over",getStage:function(){for(var t,e=this;t=e.parent;)e=t;return e.canvas?e:null},getScaledWidth:function(){return this.width*this.scaleX},getScaledHeight:function(){return this.height*this.scaleY},addTo:function(t,e){return"number"==typeof e?t.addChildAt(this,e):t.addChild(this),this},removeFromParent:function(){var t=this.parent;return t&&t.removeChild(this),this},getBounds:function(){for(var t,e,i,r,n,a,o,s=this.width,h=this.height,l=this.getConcatenatedMatrix(),c=this.boundsArea||[{x:0,y:0},{x:s,y:0},{x:s,y:h},{x:0,y:h}],u=[],d=0,f=c.length;de?r=e:ni?a=i:o>1,r=0;break;case"TR":i=o-n,r=0;break;case"L":i=0,r=s-a>>1;break;case"C":i=o-n>>1,r=s-a>>1;break;case"R":i=o-n,r=s-a>>1;break;case"BL":i=0,r=s-a;break;case"B":i=o-n>>1,r=s-a;break;case"BR":i=o-n,r=s-a}}return{x:i,y:r}},hitTestPoint:function(e,i,r){var n=this.getBounds(),a=e>=n.x&&e<=n.x+n.width&&i>=n.y&&i<=n.y+n.height;return a&&r&&(a=t(e,i,n)),a},hitTestObject:function(t,e){var i=this.getBounds(),r=t.getBounds(),n=i.x<=r.x+r.width&&r.x<=i.x+i.width&&i.y<=r.y+r.height&&r.y<=i.y+i.height;return n&&e&&(n=o(i,r)),!!n},_render:function(t,e){this.onUpdate&&this.onUpdate(e)===!1||!t.startDraw(this)||(t.transform(this),this.render(t,e),t.endDraw(this))},_fireMouseEvent:function(t){if(t.eventCurrentTarget=this,this.fire(t),"mousemove"==t.type){if(!this.__mouseOver){this.__mouseOver=!0;var e=a.copy({},t);e.type="mouseover",this.fire(e)}}else"mouseout"==t.type&&(this.__mouseOver=!1);var i=this.parent;t._stopped||t._stopPropagationed||!i||("mouseout"==t.type||"touchout"==t.type?i.hitTestPoint(t.stageX,t.stageY,!0)||i._fireMouseEvent(t):i._fireMouseEvent(t))},onUpdate:null,render:function(t,e){t.draw(this)},toString:function(){return e.viewToString(this)}})}();return o},{requires:["hilo/core/Hilo","hilo/core/Class","hilo/event/EventMixin","hilo/geom/Matrix","hilo/util/util"]}),KISSY.add("hilo/view/CacheMixin",function(t,e,i){var r,n,a={_cacheDirty:!0,cache:function(t){(t||this._cacheDirty||!this.drawable)&&this.updateCache()},updateCache:function(){i.supportCanvas&&(r||(r=document.createElement("canvas"),n=r.getContext("2d")),r.width=this.width,r.height=this.height,this._draw(n),this.drawable=this.drawable||new e,this.drawable.init({image:r.toDataURL()}),this._cacheDirty=!1)},setCacheDirty:function(t){this._cacheDirty=t}};return a},{requires:["hilo/view/Drawable","hilo/util/browser"]}),KISSY.add("hilo/view/Container",function(t,e,i,r){var n=i.create({Extends:r,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("Container"),n.superclass.constructor.call(this,t),this.children?this._updateChildren():this.children=[]},children:null,pointerChildren:!0,clipChildren:!1,getNumChildren:function(){return this.children.length},addChildAt:function(t,e){var i=this.children,r=i.length,n=t.parent;e=e<0?0:e>r?r:e;var a=this.getChildIndex(t);if(a==e)return this;if(a>=0?(i.splice(a,1),e=e==r?r-1:e):n&&n.removeChild(t),i.splice(e,0,t),a<0)this._updateChildren(e);else{var o=a=e.length)return null;var i=e[t];if(i){if(!i.__renderer)for(var r=i;r=r.parent;){if(r.renderer){i.__renderer=r.renderer;break}if(r.__renderer){i.__renderer=r.__renderer;break}}i.__renderer&&i.__renderer.remove(i),i.parent=null,i.depth=-1}return e.splice(t,1),this._updateChildren(t),i},removeChild:function(t){return this.removeChildAt(this.getChildIndex(t))},removeChildById:function(t){for(var e,i=this.children,r=0,n=i.length;r=e.length?null:e[t]},getChildById:function(t){for(var e,i=this.children,r=0,n=i.length;r=0&&r!=e){var n=i.length;e=e<0?0:e>=n?n-1:e,i.splice(r,1),i.splice(e,0,t),this._updateChildren()}return this},swapChildren:function(t,e){var i=this.children,r=this.getChildIndex(t),n=this.getChildIndex(e);t.depth=n,i[n]=t,e.depth=r,i[r]=e},swapChildrenAt:function(t,e){var i=this.children,r=this.getChildAt(t),n=this.getChildAt(e);r.depth=e,i[e]=r,n.depth=t,i[t]=n},sortChildren:function(t){var e=t,i=this.children;if("string"==typeof e){var r=e;e=function(t,e){return e[r]-t[r]}}i.sort(e),this._updateChildren()},_updateChildren:function(t,e){var i,r=this.children;t=t||0,e=e||r.length;for(var n=t;n=0;l--)if(a=h[l],!(!a||!a.visible||a.alpha<=0||n&&!a.pointerEnabled))if(a.children&&a.children.length&&(!n||a.pointerChildren)&&(o=a.getViewAtPoint(t,e,i,r,n)),o){if(!r)return o;o.length&&(s=s.concat(o))}else if(a.hitTestPoint(t,e,i)){if(!r)return a;s.push(a)}return r&&s.length?s:null},render:function(t,e){n.superclass.render.call(this,t,e);var i,r,a,o=this.children.slice(0);for(i=0,r=o.length;ir?r:e,i[e]=t,t.name&&(this._frameNames[t.name]=t),(0!=e||this.width)&&this.height||(this.width=t.rect[2],this.height=t.rect[3]),this},getFrame:function(t){if("number"==typeof t){var e=this._frames;return t<0||t>=e.length?null:e[t]}return this._frameNames[t]},getFrameIndex:function(t){var e=this._frames,i=e.length,r=-1;if("number"==typeof t)r=t;else{var n="string"==typeof t?this._frameNames[t]:t;if(n)for(var a=0;a=i?i-1:r,this.paused=e,this._firstRender=!0,this},_render:function(t,e){var i,r=this.currentFrame;if(this._firstRender?(i=r,this._firstRender=!1):i=this._nextFrame(e),i!=r){this.currentFrame=i;var n=this._frames[i].callback;n&&n.call(this)}this.onEnterFrame&&this.onEnterFrame(i),this.drawable.init(this._frames[i]),a.superclass._render.call(this,t,e)},_nextFrame:function(t){var e=this._frames,i=e.length,r=this.currentFrame,n=e[r],a=n.duration||this.interval,o=this._frameElapsed,s=0!=r||this.drawable?o+(this.timeBased?t:1):0;return o=this._frameElapsed=s=i-1)&&this.stop(),this.paused||0!=o||(null!=n.next?r=this.getFrameIndex(n.next):r>=i-1?r=0:this.drawable&&r++),r},setFrameCallback:function(t,e){return t=this.getFrame(t),t&&(t.callback=e),this},onEnterFrame:null});return a},{requires:["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/Drawable"]}),KISSY.add("hilo/view/DOMElement",function(t,e,i,r,n){var a=i.create({Extends:r,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("DOMElement"),a.superclass.constructor.call(this,t),this.drawable=new n;var i=this.drawable.domElement=t.element||e.createElement("div");i.id=this.id,this.pointerEnabled&&!i.style.pointerEvents&&(i.style.pointerEvents="visible")},_render:function(t,e){this.onUpdate&&this.onUpdate(e)===!1||(t.transform(this),this.visible&&this.alpha>0&&this.render(t,e))},render:function(t,i){if("dom"!==t.renderType){var r=t.canvas,n=this.parent,a=t._domElementContainer;t._domElementContainer||(a=t._domElementContainer=e.createElement("div",{style:{position:"absolute",transform:"scale3d("+n.scaleX+","+n.scaleY+", 1)",transformOrigin:"0 0",zIndex:"1"}}),r.parentNode.insertBefore(t._domElementContainer,r.nextSibling));var o,s=this.drawable.domElement,h=this.depth,l=a.childNodes[0];if(s.parentNode)return;for(;l&&3!=l.nodeType&&(o=parseInt(l.style.zIndex)||0,!(o<=0||o>h));)l=l.nextSibling;a.insertBefore(this.drawable.domElement,l)}else t.draw(this)}});return a},{requires:["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/Drawable"]}),KISSY.add("hilo/view/Graphics",function(t,e,i,r,n){var a=function(){var t=document.createElement("canvas"),o=t.getContext&&t.getContext("2d");return i.create({Extends:r,Mixes:n,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("Graphics"),a.superclass.constructor.call(this,t),this._actions=[]},lineWidth:1,lineAlpha:1,lineCap:null,lineJoin:null,miterLimit:10,hasStroke:!1,strokeStyle:"0",hasFill:!1,fillStyle:"0",fillAlpha:0,lineStyle:function(t,e,i,r,n,a){var o=this,s=o._addAction;return s.call(o,["lineWidth",o.lineWidth=t||1]),s.call(o,["strokeStyle",o.strokeStyle=e||"0"]),s.call(o,["lineAlpha",o.lineAlpha=i||1]),void 0!=r&&s.call(o,["lineCap",o.lineCap=r]),void 0!=n&&s.call(o,["lineJoin",o.lineJoin=n]),void 0!=a&&s.call(o,["miterLimit",o.miterLimit=a]),o.hasStroke=!0,o},setLineDash:function(t){return this._addAction(["setLineDash",t])},beginFill:function(t,e){var i=this,r=i._addAction;return r.call(i,["fillStyle",i.fillStyle=t]),r.call(i,["fillAlpha",i.fillAlpha=e||1]),i.hasFill=!0,i},endFill:function(){var t=this,e=t._addAction;return t.hasStroke&&e.call(t,["stroke"]),t.hasFill&&e.call(t,["fill"]),t.setCacheDirty(!0),t},beginLinearGradientFill:function(t,e,i,r,n,a){for(var s=this,h=o.createLinearGradient(t,e,i,r),l=0,c=n.length;l1?a.slice(1):null;"function"==typeof t[o]?t[o].apply(t,s):t[o]=a[1]}},render:function(t,e){var i=this;"canvas"===t.renderType?i._draw(t.context):(i.cache(),t.draw(i))},clear:function(){var t=this;return t._actions.length=0,t.lineWidth=1,t.lineAlpha=1,t.lineCap=null,t.lineJoin=null,t.miterLimit=10,t.hasStroke=!1,t.strokeStyle="0",t.hasFill=!1,t.fillStyle="0",t.fillAlpha=1,t.setCacheDirty(!0),t},_addAction:function(t){var e=this;return e._actions.push(t),e}})}();return a},{requires:["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/CacheMixin"]}),KISSY.add("hilo/view/Text",function(t,e,i,r,n){var a=e.create({Extends:r,Mixes:n,constructor:function(t){t=t||{},this.id=this.id||t.id||i.getUid("Text"),a.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=a.measureFontHeight(this.font)},text:"",color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=a.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var r=i.drawable,n=r.domElement,a=n.style;a.font=i.font,a.textAlign=i.textAlign,a.color=i.color,a.width=i.width+"px",a.height=i.height+"px",a.lineHeight=i._fontHeight+i.lineSpacing+"px",n.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var r,n,a,o,s,h=i.split(/\r\n|\r|\n|/),l=0,c=0,u=e._fontHeight+e.lineSpacing,d=[];for(r=0,o=h.length;re.maxWidth?(d.push({text:m,y:c}),l>1;break;case"bottom":_=e.height-e.textHeight}var x=e.background;for(x&&(t.fillStyle=x,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,r=0;r>1;break;case"right":case"end":n=a}r.outline?t.strokeText(e,n,i):t.fillText(e,n,i)},Statics:{measureFontHeight:function(t){var e,r=document.documentElement,n=i.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return r.appendChild(n),e=n.offsetHeight,r.removeChild(n),e}}});return a},{requires:["hilo/core/Class","hilo/core/Hilo","hilo/view/View","hilo/view/CacheMixin"]}),KISSY.add("hilo/view/BitmapText",function(t,e,i,r,n){var a=e.create({Extends:r,constructor:function(t){t=t||{},this.id=this.id||t.id||i.getUid("BitmapText"),a.superclass.constructor.call(this,t);var e=t.text+"";e&&(this.text="",this.setText(e)),this.pointerChildren=!1},glyphs:null,letterSpacing:0,text:"",textAlign:"left",setText:function(t){var e=this,i=t.toString(),r=i.length;if(e.text!=i){e.text=i;var n,a,o,s,h=0,l=0,c=0;for(n=0;n0?e.letterSpacing:0),e.children[n]?(s=e.children[n],s.setImage(o.image,o.rect)):(s=e._createBitmap(o),e.addChild(s)),s.x=c,h=c+o.rect[2],l=Math.max(l,o.rect[3]));for(n=e.children.length-1;n>=r;n--)e._releaseBitmap(e.children[n]),e.children[n].removeFromParent();return e.width=h,e.height=l,this.setTextAlign(),e}},_createBitmap:function(t){var e;return a._pool.length?(e=a._pool.pop(),e.setImage(t.image,t.rect)):e=new n({image:t.image,rect:t.rect}),e},_releaseBitmap:function(t){a._pool.push(t)},setTextAlign:function(t){switch(this.textAlign=t||this.textAlign,this.textAlign){case"center":this.pivotX=.5*this.width;break;case"right":this.pivotX=this.width;break;case"left":default:this.pivotX=0}return this},hasGlyphs:function(t){var e=this.glyphs;if(!e)return!1;t=t.toString();var i,r=t.length;for(i=0;i=this._targetFPS?(this._measuredFPS=1e3/(this._tickTime/this._tickCount)+.5>>0,this._tickCount=0,this._tickTime=0):this._tickTime+=t-this._lastTime,this._lastTime=t;for(var r=i.slice(0),n=0,a=r.length;n=0&&e.splice(i,1)},nextTick:function(t){var e=this,i={tick:function(r){e.removeTick(i),t()}};return e.addTick(i),i},timeout:function(t,e){var i=this,r=(new Date).getTime()+e,n={tick:function(){var e=(new Date).getTime(),a=e-r;a>=0&&(i.removeTick(n),t())}};return i.addTick(n),n},interval:function(t,e){var i=this,r=(new Date).getTime()+e,n={tick:function(){var i=(new Date).getTime(),n=i-r;n>=0&&(n=r)return-1;for(e<0&&(e=r+e),i=e;i=1?1:s;var l=n.ease?n.ease(s):s;n.reverse&&(n._reverseFlag<0&&(s=1-s,l=1-l),s<1e-7&&(n.repeat>0&&n._repeatCount++>=n.repeat||0==n.repeat&&!n.loop?h=!0:(n._startTime=t(),n._pausedTime=0,n._reverseFlag*=-1))),n.isStart||(n.setProps(n._fromProps,n._toProps),n.isStart=!0,n.onStart&&n.onStart.call(n,n)),n.time=a,n._render(l),(o=n.onUpdate)&&o.call(n,s,n),s>=1&&(n.reverse?(n._startTime=t(),n._pausedTime=0,n._reverseFlag*=-1):n.loop||n.repeat>0&&n._repeatCount++0&&u<=e?(c._render(s),c.time=a,i.add(c)):h&&(u<0||u>e)&&c.start()}return h?((o=n.onComplete)&&o.call(n,n),!0):void 0}}},Statics:{_tweens:[],tick:function(){var e,r,n=i._tweens,a=n.length;for(r=0;r-1&&n.splice(e,1);else for(e=0;e=i)return void t.fire("complete");if(t._currentIndexe.z})},tick:function(){this.sortZ()}});return o}();return r},{requires:["hilo/core/Class","hilo/util/util"]}),KISSY.add("hilo/game/ParticleSystem",function(t,e,i,r,n,a,o){var s=function(){function t(t,e){return e?t+2*(Math.random()-.5)*e:t}for(var s=["x","y","vx","vy","ax","ay","rotation","rotationV","scale","scaleV","alpha","alphaV","life"],h=[],l=0,c=s.length;l=this._emitTime&&(this._currentRunTime=0,this._emitTime=t(this.emitTime,this.emitTimeVar),this._emit()),this._totalRunTime>=this.totalTime&&this.stop())},_emit:function(){for(var e=t(this.emitNum,this.emitNumVar)>>0,i=0;i=0;e--)this.children[e].destroy()}}),v=i.create({Extends:r,constructor:function(t){this.id=this.id||t.id||e.getUid("Particle"),v.superclass.constructor.call(this,t),this.init(t)},onUpdate:function(t){if(t*=.001,this._died)return!1;var e=this.ax+this.system.gx,i=this.ay+this.system.gy;return this.vx+=e*t,this.vy+=i*t,this.x+=this.vx*t,this.y+=this.vy*t,this.rotation+=this.rotationV,this._time>.1&&(this.alpha+=this.alphaV),this.scale+=this.scaleV,this.scaleX=this.scaleY=this.scale,this._time+=t,this._time>=this.life||this.alpha<=0?(this.destroy(),!1):void 0},setImage:function(t,e){this.drawable=this.drawable||new a,e=e||[0,0,t.width,t.height],this.width=e[2],this.height=e[3],this.drawable.rect=e,this.drawable.image=t},destroy:function(){this._died=!0,this.alpha=0,this.removeFromParent(),f.push(this)},init:function(e){this.system=e.system,this._died=!1,this._time=0,this.alpha=1;for(var i=0,r=h.length;i>0]),this.setImage(e.image,o),void 0!==e.pivotX&&(this.pivotX=e.pivotX*o[2]),void 0!==e.pivotY&&(this.pivotY=e.pivotY*o[3])}},Statics:{create:function(t){if(f.length>0){var e=f.pop();return e.init(t),e}return new v(t)}}});return p}();return s},{requires:["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/Container","hilo/view/Drawable","hilo/util/util"]}); \ No newline at end of file diff --git a/build/kissy/hilo-kissy.zip b/build/kissy/hilo-kissy.zip index 0e5585d2..c3c75519 100644 Binary files a/build/kissy/hilo-kissy.zip and b/build/kissy/hilo-kissy.zip differ diff --git a/build/kissy/hilo/core/Class.js b/build/kissy/hilo/core/Class.js index 50b11b43..25d6fb20 100644 --- a/build/kissy/hilo/core/Class.js +++ b/build/kissy/hilo/core/Class.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/core/Class.min.js b/build/kissy/hilo/core/Class.min.js index 883e7b9c..37a38914 100644 --- a/build/kissy/hilo/core/Class.min.js +++ b/build/kissy/hilo/core/Class.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/core/Hilo.js b/build/kissy/hilo/core/Hilo.js index e53d3a95..43dbf4ed 100644 --- a/build/kissy/hilo/core/Hilo.js +++ b/build/kissy/hilo/core/Hilo.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -27,7 +27,7 @@ var Hilo = { * Hilo version * @type String */ - version: '1.3.0', + version: '1.4.0', /** * @language=en * Gets a globally unique id. Such as Stage1, Bitmap2 etc. diff --git a/build/kissy/hilo/core/Hilo.min.js b/build/kissy/hilo/core/Hilo.min.js index 37c5206f..5fdf10f9 100644 --- a/build/kissy/hilo/core/Hilo.min.js +++ b/build/kissy/hilo/core/Hilo.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ -KISSY.add("hilo/core/Hilo",function(t,e,a){var r=window,o=document,i=o.documentElement,n=0,s={},c={version:"1.3.0",getUid:function(t){var e=++n;if(t){var a=t.charCodeAt(t.length-1);return a>=48&&a<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,a=t;a;)e=e?a.id+"."+e:a.id,a=a.parent;return e},copy:function(t,e,r){return a.copy(t,e,r),s.copy||(s.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),t},browser:e,event:{POINTER_START:e.POINTER_START,POINTER_MOVE:e.POINTER_MOVE,POINTER_END:e.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(t){var e;try{e=t.getBoundingClientRect()}catch(a){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var o=(r.pageXOffset||i.scrollLeft)-(i.clientLeft||0)||0,n=(r.pageYOffset||i.scrollTop)-(i.clientTop||0)||0,s=r.getComputedStyle?getComputedStyle(t):t.currentStyle,c=parseInt,h=c(s.paddingLeft)+c(s.borderLeftWidth)||0,d=c(s.paddingTop)+c(s.borderTopWidth)||0,f=c(s.paddingRight)+c(s.borderRightWidth)||0,l=c(s.paddingBottom)+c(s.borderBottomWidth)||0,g=e.top||0,p=e.left||0,m=e.right||0,T=e.bottom||0;return{left:p+o+h,top:g+n+d,width:m-f-p-h,height:T-l-g-d}},createElement:function(t,e){var a,r,i,n=o.createElement(t);for(a in e)if(r=e[a],"style"===a)for(i in r)n.style[i]=r[i];else n[a]=r;return n},getElement:function(t){return o.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,a=e.domElement.style,r=t._stateCache||(t._stateCache={}),o=c.browser.jsVendor,i="px",n=!1;if(this.cacheStateIfChanged(t,["visible"],r)&&(a.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],r)&&(a.opacity=t.alpha),t.visible&&!(t.alpha<=0)){if(this.cacheStateIfChanged(t,["width"],r)&&(a.width=t.width+i),this.cacheStateIfChanged(t,["height"],r)&&(a.height=t.height+i),this.cacheStateIfChanged(t,["depth"],r)&&(a.zIndex=t.depth+1),t.transform){var s=t.transform;(n=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(a[o+"TransformOrigin"]="0 0"),a[o+"Transform"]="matrix3d("+s.a+", "+s.b+", 0, 0, "+s.c+", "+s.d+", 0, 0, 0, 0, 1, 0, "+s.tx+", "+s.ty+", 0, 1)"}else(n=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(a[o+"TransformOrigin"]=t.pivotX+i+" "+t.pivotY+i),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],r)||n)&&(a[o+"Transform"]=this.getTransformCSS(t));this.cacheStateIfChanged(t,["background"],r)&&(a.backgroundColor=t.background),a.pointerEvents||(a.pointerEvents="none");var h=e.image;if(h){var d=h.src;d!==r.image&&(r.image=d,a.backgroundImage="url("+d+")");var f=e.rect;if(f){var l=f[0],g=f[1];l!==r.sx&&(r.sx=l,a.backgroundPositionX=-l+i),g!==r.sy&&(r.sy=g,a.backgroundPositionY=-g+i)}}var p=t.mask;if(p){var m=p.drawable.domElement.style.backgroundImage;m!==r.maskImage&&(r.maskImage=m,a[o+"MaskImage"]=m,a[o+"MaskRepeat"]="no-repeat");var T=p.x,u=p.y;T===r.maskX&&u===r.maskY||(r.maskX=T,r.maskY=u,a[o+"MaskPosition"]=T+i+" "+u+i)}}},cacheStateIfChanged:function(t,e,a){var r,o,i,n,s=!1;for(r=0,o=e.length;r=48&&a<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,a=t;a;)e=e?a.id+"."+e:a.id,a=a.parent;return e},copy:function(t,e,r){return a.copy(t,e,r),s.copy||(s.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),t},browser:e,event:{POINTER_START:e.POINTER_START,POINTER_MOVE:e.POINTER_MOVE,POINTER_END:e.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(t){var e;try{e=t.getBoundingClientRect()}catch(a){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var o=(r.pageXOffset||i.scrollLeft)-(i.clientLeft||0)||0,n=(r.pageYOffset||i.scrollTop)-(i.clientTop||0)||0,s=r.getComputedStyle?getComputedStyle(t):t.currentStyle,c=parseInt,h=c(s.paddingLeft)+c(s.borderLeftWidth)||0,d=c(s.paddingTop)+c(s.borderTopWidth)||0,f=c(s.paddingRight)+c(s.borderRightWidth)||0,l=c(s.paddingBottom)+c(s.borderBottomWidth)||0,g=e.top||0,p=e.left||0,m=e.right||0,T=e.bottom||0;return{left:p+o+h,top:g+n+d,width:m-f-p-h,height:T-l-g-d}},createElement:function(t,e){var a,r,i,n=o.createElement(t);for(a in e)if(r=e[a],"style"===a)for(i in r)n.style[i]=r[i];else n[a]=r;return n},getElement:function(t){return o.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,a=e.domElement.style,r=t._stateCache||(t._stateCache={}),o=c.browser.jsVendor,i="px",n=!1;if(this.cacheStateIfChanged(t,["visible"],r)&&(a.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],r)&&(a.opacity=t.alpha),t.visible&&!(t.alpha<=0)){if(this.cacheStateIfChanged(t,["width"],r)&&(a.width=t.width+i),this.cacheStateIfChanged(t,["height"],r)&&(a.height=t.height+i),this.cacheStateIfChanged(t,["depth"],r)&&(a.zIndex=t.depth+1),t.transform){var s=t.transform;(n=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(a[o+"TransformOrigin"]="0 0"),a[o+"Transform"]="matrix3d("+s.a+", "+s.b+", 0, 0, "+s.c+", "+s.d+", 0, 0, 0, 0, 1, 0, "+s.tx+", "+s.ty+", 0, 1)"}else(n=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(a[o+"TransformOrigin"]=t.pivotX+i+" "+t.pivotY+i),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],r)||n)&&(a[o+"Transform"]=this.getTransformCSS(t));this.cacheStateIfChanged(t,["background"],r)&&(a.backgroundColor=t.background),a.pointerEvents||(a.pointerEvents="none");var h=e.image;if(h){var d=h.src;d!==r.image&&(r.image=d,a.backgroundImage="url("+d+")");var f=e.rect;if(f){var l=f[0],g=f[1];l!==r.sx&&(r.sx=l,a.backgroundPositionX=-l+i),g!==r.sy&&(r.sy=g,a.backgroundPositionY=-g+i)}}var p=t.mask;if(p){var m=p.drawable.domElement.style.backgroundImage;m!==r.maskImage&&(r.maskImage=m,a[o+"MaskImage"]=m,a[o+"MaskRepeat"]="no-repeat");var T=p.x,u=p.y;T===r.maskX&&u===r.maskY||(r.maskX=T,r.maskY=u,a[o+"MaskPosition"]=T+i+" "+u+i)}}},cacheStateIfChanged:function(t,e,a){var r,o,i,n,s=!1;for(r=0,o=e.length;r0)&&(t===this.stage&&this.clear(),!0)},draw:function(t){var e=t.width,r=t.height,i=(t.background,t.drawable),a=i&&i.image;if(a){var n=i.rect,s=n[2],o=n[3];e||r||(e=t.width=s,r=t.height=o),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(a,n[0],n[1],s,o,0,0,e,r),c=this.batchIndex*this.positionStride,_=this.float32Array,l=this.uint32Array,d=(t.tint>>16)+(65280&t.tint)+((255&t.tint)<<16)+(255*t.__webglRenderAlpha<<24);_[c+0]=h[0],_[c+1]=h[1],_[c+2]=h[2],_[c+3]=h[3],l[c+4]=d,_[c+5]=h[4],_[c+6]=h[5],_[c+7]=h[6],_[c+8]=h[7],l[c+9]=d,_[c+10]=h[8],_[c+11]=h[9],_[c+12]=h[10],_[c+13]=h[11],l[c+14]=d,_[c+15]=h[12],_[c+16]=h[13],_[c+17]=h[14],_[c+18]=h[15],l[c+19]=d;for(var u=t.__webglWorldMatrix,f=0;f<4;f++){var g=_[c+5*f],T=_[c+5*f+1];_[c+5*f]=u.a*g+u.c*T+u.tx,_[c+5*f+1]=u.b*g+u.d*T+u.ty}t.__textureImage=a,this.sprites[this.batchIndex++]=t}},endDraw:function(t){t===this.stage&&this._renderBatches()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void r.setElementStyleByView(t);var i=t.scaleX,n=t.scaleY;if(t===this.stage){var s=this.canvas.style,o=t._scaleX,h=t._scaleY,c=!1;(!o&&1!=i||o&&o!=i)&&(t._scaleX=i,s.width=i*t.width+"px",c=!0),(!h&&1!=n||h&&h!=n)&&(t._scaleY=n,s.height=n*t.height+"px",c=!0),c&&t.updateViewport(),t.__webglWorldMatrix=t.__webglWorldMatrix||new a(1,0,0,1,0,0)}else t.parent&&(t.__webglWorldMatrix=t.__webglWorldMatrix||new a(1,0,0,1,0,0),this._setConcatenatedMatrix(t,t.parent));t.alpha>0&&(t.parent&&t.parent.__webglRenderAlpha?t.__webglRenderAlpha=t.alpha*t.parent.__webglRenderAlpha:t.__webglRenderAlpha=t.alpha)},remove:function(t){var e=t.drawable,r=e&&e.domElement;if(r){var i=r.parentNode;i&&i.removeChild(r)}},clear:function(t,e,r,i){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(t,e){if(this.width!==t||this.height!==e){var r=this.canvas,i=this.stage,a=r.style;this.width=r.width=t,this.height=r.height=e,a.width=i.width*i.scaleX+"px",a.height=i.height*i.scaleY+"px",this.gl.viewport(0,0,t,e),this.canvasHalfWidth=.5*t,this.canvasHalfHeight=.5*e,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var t=this.gl;t.bufferSubData(t.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var e=0,r=0,i=null,a=0;a0&&(r.bindTexture(r.TEXTURE_2D,this._getTexture(this.sprites[t])),r.drawElements(r.TRIANGLES,6*i,r.UNSIGNED_SHORT,6*t*2))},_uploadProjectionTransform:function(t){this._projectionTransformElements&&!t||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var t=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",e="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new o(this,{v:t,f:e},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(t,e,r,i,a,n,s,o,h){var c=this.__tempVertexs||[],_=t.width,l=t.height;i/=_,a/=l,e/=_,r/=l,o=o,h=h,n=n,s=s,i+e>1&&(i=1-e),a+r>1&&(a=1-r);var d=0;return c[d++]=n,c[d++]=s,c[d++]=e,c[d++]=r,c[d++]=n+o,c[d++]=s,c[d++]=e+i,c[d++]=r,c[d++]=n,c[d++]=s+h,c[d++]=e,c[d++]=r+a,c[d++]=n+o,c[d++]=s+h,c[d++]=e+i,c[d++]=r+a,c},_setConcatenatedMatrix:function(t,e){var r=t.__webglWorldMatrix,i=1,a=0,s=t.rotation%360,o=t.pivotX,h=t.pivotY,c=t.scaleX,_=t.scaleY,l=t.transform;if(l)r.copy(l);else{if(s){var d=s*n;i=Math.cos(d),a=Math.sin(d)}var u=t.getAlignPosition();r.a=i*c,r.b=a*c,r.c=-a*_,r.d=i*_,r.tx=u.x-r.a*o-r.c*h,r.ty=u.y-r.b*o-r.d*h}r.concat(e.__webglWorldMatrix)},_getTexture:function(t){var e=t.__textureImage,r=this._cacheTexture[e.src];return r||(r=this.activeShader.uploadTexture(e)),r}}),o=function(t,e,r){this.renderer=t,this.gl=t.gl,this.program=this._createProgram(this.gl,e.v,e.f),r=r||{},this.attributes=r.attributes||[],this.uniforms=r.uniforms||[]};return o.prototype={active:function(){var t=this,e=t.renderer,r=t.gl,i=t.program;i&&r&&(e.activeShader=t,r.useProgram(i),t.attributes.forEach(function(t){e[t]=r.getAttribLocation(i,t),r.enableVertexAttribArray(e[t])}),t.uniforms.forEach(function(t){e[t]=r.getUniformLocation(i,t)}),t.width===e.width&&t.height===e.height||(t.width=e.width,t.height=e.height,e._uploadProjectionTransform()))},uploadTexture:function(t){var e=this.gl,r=this.renderer,i=e.createTexture(),a=r.u_Sampler;return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,i),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(a,0),e.bindTexture(e.TEXTURE_2D,null),this.renderer._cacheTexture[t.src]=i,i},_createProgram:function(t,e,r){var i=this._createShader(t,t.VERTEX_SHADER,e),a=this._createShader(t,t.FRAGMENT_SHADER,r);if(!i||!a)return null;var n=t.createProgram();if(n){t.attachShader(n,i),t.attachShader(n,a),t.linkProgram(n),t.deleteShader(a),t.deleteShader(i);var s=t.getProgramParameter(n,t.LINK_STATUS);if(!s){var o=t.getProgramInfoLog(n);return console.log("Failed to link program: "+o),t.deleteProgram(n),null}}return n},_createShader:function(t,e,r){var i=t.createShader(e);if(i){t.shaderSource(i,r),t.compileShader(i);var a=t.getShaderParameter(i,t.COMPILE_STATUS);if(!a){var n=t.getShaderInfoLog(i);return console.log("Failed to compile shader: "+n),t.deleteShader(i),null}}return i}},s},{requires:["hilo/core/Class","hilo/core/Hilo","hilo/renderer/Renderer","hilo/geom/Matrix"]}); \ No newline at end of file +KISSY.add("hilo/renderer/WebGLRenderer",function(t,e,r,i,a){var n=Math.PI/180,s=e.create({Extends:i,Statics:{MAX_BATCH_NUM:2e3,ATTRIBUTE_NUM:5,isSupport:function(){if(void 0==this._isSupported){var t=document.createElement("canvas");t.getContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))?this._isSupported=!0:this._isSupported=!1}return this._isSupported},contextOptions:null},renderType:"webgl",gl:null,_isContextLost:!1,_cacheTexture:{},constructor:function(t){s.superclass.constructor.call(this,t);var e=this,r=s.contextOptions||{};this.gl=this.canvas.getContext("webgl",r)||this.canvas.getContext("experimental-webgl",r),this.maxBatchNum=s.MAX_BATCH_NUM,this.positionStride=4*s.ATTRIBUTE_NUM;var i=this.maxBatchNum*s.ATTRIBUTE_NUM*4,a=6*this.maxBatchNum;this.arrayBuffer=new ArrayBuffer(4*i),this.float32Array=new Float32Array(this.arrayBuffer),this.uint32Array=new Uint32Array(this.arrayBuffer),this.indexs=new Uint16Array(a);for(var n=0,o=0;n0)&&(t===this.stage&&this.clear(),!0)},draw:function(t){var e=t.width,r=t.height,i=(t.background,t.drawable),a=i&&i.image;if(a){var n=i.rect,s=n[2],o=n[3];e||r||(e=t.width=s,r=t.height=o),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(a,n[0],n[1],s,o,0,0,e,r),c=this.batchIndex*this.positionStride,_=this.float32Array,l=this.uint32Array,d=(t.tint>>16)+(65280&t.tint)+((255&t.tint)<<16)+(255*t.__webglRenderAlpha<<24);_[c+0]=h[0],_[c+1]=h[1],_[c+2]=h[2],_[c+3]=h[3],l[c+4]=d,_[c+5]=h[4],_[c+6]=h[5],_[c+7]=h[6],_[c+8]=h[7],l[c+9]=d,_[c+10]=h[8],_[c+11]=h[9],_[c+12]=h[10],_[c+13]=h[11],l[c+14]=d,_[c+15]=h[12],_[c+16]=h[13],_[c+17]=h[14],_[c+18]=h[15],l[c+19]=d;for(var u=t.__webglWorldMatrix,f=0;f<4;f++){var g=_[c+5*f],x=_[c+5*f+1];_[c+5*f]=u.a*g+u.c*x+u.tx,_[c+5*f+1]=u.b*g+u.d*x+u.ty}t.__textureImage=a,this.sprites[this.batchIndex++]=t}},endDraw:function(t){t===this.stage&&this._renderBatches()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void r.setElementStyleByView(t);var i=t.scaleX,n=t.scaleY;if(t===this.stage){var s=this.canvas.style,o=t._scaleX,h=t._scaleY,c=!1;(!o&&1!=i||o&&o!=i)&&(t._scaleX=i,s.width=i*t.width+"px",c=!0),(!h&&1!=n||h&&h!=n)&&(t._scaleY=n,s.height=n*t.height+"px",c=!0),c&&t.updateViewport(),t.__webglWorldMatrix=t.__webglWorldMatrix||new a(1,0,0,1,0,0)}else t.parent&&(t.__webglWorldMatrix=t.__webglWorldMatrix||new a(1,0,0,1,0,0),this._setConcatenatedMatrix(t,t.parent));t.alpha>0&&(t.parent&&t.parent.__webglRenderAlpha?t.__webglRenderAlpha=t.alpha*t.parent.__webglRenderAlpha:t.__webglRenderAlpha=t.alpha)},remove:function(t){var e=t.drawable,r=e&&e.domElement;if(r){var i=r.parentNode;i&&i.removeChild(r)}},clear:function(t,e,r,i){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(t,e){if(this.width!==t||this.height!==e){var r=this.canvas,i=this.stage,a=r.style;this.width=r.width=t,this.height=r.height=e,a.width=i.width*i.scaleX+"px",a.height=i.height*i.scaleY+"px",this.gl.viewport(0,0,t,e),this.canvasHalfWidth=.5*t,this.canvasHalfHeight=.5*e,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var t=this.gl;t.bufferSubData(t.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var e=0,r=0,i=null,a=0;a0&&(r.bindTexture(r.TEXTURE_2D,this._getTexture(this.sprites[t])),r.drawElements(r.TRIANGLES,6*i,r.UNSIGNED_SHORT,6*t*2))},_uploadProjectionTransform:function(t){this._projectionTransformElements&&!t||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var t=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",e="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new o(this,{v:t,f:e},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(t,e,r,i,a,n,s,o,h){var c=this.__tempVertexs||[],_=t.width,l=t.height;i/=_,a/=l,e/=_,r/=l,o=o,h=h,n=n,s=s,i+e>1&&(i=1-e),a+r>1&&(a=1-r);var d=0;return c[d++]=n,c[d++]=s,c[d++]=e,c[d++]=r,c[d++]=n+o,c[d++]=s,c[d++]=e+i,c[d++]=r,c[d++]=n,c[d++]=s+h,c[d++]=e,c[d++]=r+a,c[d++]=n+o,c[d++]=s+h,c[d++]=e+i,c[d++]=r+a,c},_setConcatenatedMatrix:function(t,e){var r=t.__webglWorldMatrix,i=1,a=0,s=t.rotation%360,o=t.pivotX,h=t.pivotY,c=t.scaleX,_=t.scaleY,l=t.transform;if(l)r.copy(l);else{if(s){var d=s*n;i=Math.cos(d),a=Math.sin(d)}var u=t.getAlignPosition();r.a=i*c,r.b=a*c,r.c=-a*_,r.d=i*_,r.tx=u.x-r.a*o-r.c*h,r.ty=u.y-r.b*o-r.d*h}r.concat(e.__webglWorldMatrix)},_getTexture:function(t){var e=t.__textureImage,r=this._cacheTexture[e.src];return r||(r=this.activeShader.uploadTexture(e)),r}}),o=function(t,e,r){this.renderer=t,this.gl=t.gl,this.program=this._createProgram(this.gl,e.v,e.f),r=r||{},this.attributes=r.attributes||[],this.uniforms=r.uniforms||[]};return o.prototype={active:function(){var t=this,e=t.renderer,r=t.gl,i=t.program;i&&r&&(e.activeShader=t,r.useProgram(i),t.attributes.forEach(function(t){e[t]=r.getAttribLocation(i,t),r.enableVertexAttribArray(e[t])}),t.uniforms.forEach(function(t){e[t]=r.getUniformLocation(i,t)}),t.width===e.width&&t.height===e.height||(t.width=e.width,t.height=e.height,e._uploadProjectionTransform()))},uploadTexture:function(t){var e=this.gl,r=this.renderer,i=e.createTexture(),a=r.u_Sampler;return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,i),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(a,0),e.bindTexture(e.TEXTURE_2D,null),this.renderer._cacheTexture[t.src]=i,i},_createProgram:function(t,e,r){var i=this._createShader(t,t.VERTEX_SHADER,e),a=this._createShader(t,t.FRAGMENT_SHADER,r);if(!i||!a)return null;var n=t.createProgram();if(n){t.attachShader(n,i),t.attachShader(n,a),t.linkProgram(n),t.deleteShader(a),t.deleteShader(i);var s=t.getProgramParameter(n,t.LINK_STATUS);if(!s){var o=t.getProgramInfoLog(n);return console.log("Failed to link program: "+o),t.deleteProgram(n),null}}return n},_createShader:function(t,e,r){var i=t.createShader(e);if(i){t.shaderSource(i,r),t.compileShader(i);var a=t.getShaderParameter(i,t.COMPILE_STATUS);if(!a){var n=t.getShaderInfoLog(i);return console.log("Failed to compile shader: "+n),t.deleteShader(i),null}}return i}},s},{requires:["hilo/core/Class","hilo/core/Hilo","hilo/renderer/Renderer","hilo/geom/Matrix"]}); \ No newline at end of file diff --git a/build/kissy/hilo/tween/Ease.js b/build/kissy/hilo/tween/Ease.js index 44c6550f..0b53ff2c 100644 --- a/build/kissy/hilo/tween/Ease.js +++ b/build/kissy/hilo/tween/Ease.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/tween/Ease.min.js b/build/kissy/hilo/tween/Ease.min.js index a3d521e5..aae6e90c 100644 --- a/build/kissy/hilo/tween/Ease.min.js +++ b/build/kissy/hilo/tween/Ease.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/tween/Tween.js b/build/kissy/hilo/tween/Tween.js index 86b507db..4fd80696 100644 --- a/build/kissy/hilo/tween/Tween.js +++ b/build/kissy/hilo/tween/Tween.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/tween/Tween.min.js b/build/kissy/hilo/tween/Tween.min.js index 3b7f7a75..e4f674e5 100644 --- a/build/kissy/hilo/tween/Tween.min.js +++ b/build/kissy/hilo/tween/Tween.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/util/TextureAtlas.js b/build/kissy/hilo/util/TextureAtlas.js index 868b80c0..a7589d6e 100644 --- a/build/kissy/hilo/util/TextureAtlas.js +++ b/build/kissy/hilo/util/TextureAtlas.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/util/TextureAtlas.min.js b/build/kissy/hilo/util/TextureAtlas.min.js index bb84ce5d..b0850aba 100644 --- a/build/kissy/hilo/util/TextureAtlas.min.js +++ b/build/kissy/hilo/util/TextureAtlas.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/util/Ticker.js b/build/kissy/hilo/util/Ticker.js index b49b36a2..7b792266 100644 --- a/build/kissy/hilo/util/Ticker.js +++ b/build/kissy/hilo/util/Ticker.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/util/Ticker.min.js b/build/kissy/hilo/util/Ticker.min.js index 46fc1cbf..7099dca1 100644 --- a/build/kissy/hilo/util/Ticker.min.js +++ b/build/kissy/hilo/util/Ticker.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/util/browser.js b/build/kissy/hilo/util/browser.js index e672cdb5..a6e333af 100644 --- a/build/kissy/hilo/util/browser.js +++ b/build/kissy/hilo/util/browser.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/util/browser.min.js b/build/kissy/hilo/util/browser.min.js index 73d1ce41..95a93335 100644 --- a/build/kissy/hilo/util/browser.min.js +++ b/build/kissy/hilo/util/browser.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/util/drag.js b/build/kissy/hilo/util/drag.js index 80af7e20..399b0fd2 100644 --- a/build/kissy/hilo/util/drag.js +++ b/build/kissy/hilo/util/drag.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/util/drag.min.js b/build/kissy/hilo/util/drag.min.js index 1b1aa1ad..7f5c4cd6 100644 --- a/build/kissy/hilo/util/drag.min.js +++ b/build/kissy/hilo/util/drag.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/util/polyfill.js b/build/kissy/hilo/util/polyfill.js index da592488..fab724e4 100644 --- a/build/kissy/hilo/util/polyfill.js +++ b/build/kissy/hilo/util/polyfill.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/util/polyfill.min.js b/build/kissy/hilo/util/polyfill.min.js index d30070d7..f3cb8339 100644 --- a/build/kissy/hilo/util/polyfill.min.js +++ b/build/kissy/hilo/util/polyfill.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/util/util.js b/build/kissy/hilo/util/util.js index c1b62241..ed6159e8 100644 --- a/build/kissy/hilo/util/util.js +++ b/build/kissy/hilo/util/util.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/util/util.min.js b/build/kissy/hilo/util/util.min.js index c9aec06f..3a7a1bb1 100644 --- a/build/kissy/hilo/util/util.min.js +++ b/build/kissy/hilo/util/util.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/Bitmap.js b/build/kissy/hilo/view/Bitmap.js index c090e715..7ed6285b 100644 --- a/build/kissy/hilo/view/Bitmap.js +++ b/build/kissy/hilo/view/Bitmap.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/Bitmap.min.js b/build/kissy/hilo/view/Bitmap.min.js index 5db9fdeb..9d0f223d 100644 --- a/build/kissy/hilo/view/Bitmap.min.js +++ b/build/kissy/hilo/view/Bitmap.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/BitmapText.js b/build/kissy/hilo/view/BitmapText.js index deb03359..7bec0adc 100644 --- a/build/kissy/hilo/view/BitmapText.js +++ b/build/kissy/hilo/view/BitmapText.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/BitmapText.min.js b/build/kissy/hilo/view/BitmapText.min.js index 12251bc9..687e8f2b 100644 --- a/build/kissy/hilo/view/BitmapText.min.js +++ b/build/kissy/hilo/view/BitmapText.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/Button.js b/build/kissy/hilo/view/Button.js index e062561f..384e2680 100644 --- a/build/kissy/hilo/view/Button.js +++ b/build/kissy/hilo/view/Button.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/Button.min.js b/build/kissy/hilo/view/Button.min.js index 3a5fb7d2..a810b157 100644 --- a/build/kissy/hilo/view/Button.min.js +++ b/build/kissy/hilo/view/Button.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/CacheMixin.js b/build/kissy/hilo/view/CacheMixin.js index 240847b8..f5fb07c3 100644 --- a/build/kissy/hilo/view/CacheMixin.js +++ b/build/kissy/hilo/view/CacheMixin.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/CacheMixin.min.js b/build/kissy/hilo/view/CacheMixin.min.js index 531f43d4..4bc52958 100644 --- a/build/kissy/hilo/view/CacheMixin.min.js +++ b/build/kissy/hilo/view/CacheMixin.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/Container.js b/build/kissy/hilo/view/Container.js index 2afc447a..396fbd19 100644 --- a/build/kissy/hilo/view/Container.js +++ b/build/kissy/hilo/view/Container.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/Container.min.js b/build/kissy/hilo/view/Container.min.js index 79e3ae2d..8517feca 100644 --- a/build/kissy/hilo/view/Container.min.js +++ b/build/kissy/hilo/view/Container.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/DOMElement.js b/build/kissy/hilo/view/DOMElement.js index fbb779a5..5d1b1d5a 100644 --- a/build/kissy/hilo/view/DOMElement.js +++ b/build/kissy/hilo/view/DOMElement.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/DOMElement.min.js b/build/kissy/hilo/view/DOMElement.min.js index 4e9e2c5d..5ddca5ec 100644 --- a/build/kissy/hilo/view/DOMElement.min.js +++ b/build/kissy/hilo/view/DOMElement.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/Drawable.js b/build/kissy/hilo/view/Drawable.js index cd1f5f74..faaeb3d1 100644 --- a/build/kissy/hilo/view/Drawable.js +++ b/build/kissy/hilo/view/Drawable.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/Drawable.min.js b/build/kissy/hilo/view/Drawable.min.js index e1268bd5..c107bbeb 100644 --- a/build/kissy/hilo/view/Drawable.min.js +++ b/build/kissy/hilo/view/Drawable.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/Graphics.js b/build/kissy/hilo/view/Graphics.js index 1bcf698f..d50c4604 100644 --- a/build/kissy/hilo/view/Graphics.js +++ b/build/kissy/hilo/view/Graphics.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -9,7 +9,7 @@ KISSY.add('hilo/view/Graphics', function(S, Hilo, Class, View, CacheMixin){ /** * @language=en - * + * *
* @class Graphics class contains a group of functions for creating vector graphics. * @augments View diff --git a/build/kissy/hilo/view/Graphics.min.js b/build/kissy/hilo/view/Graphics.min.js index 35c1ba0b..74347766 100644 --- a/build/kissy/hilo/view/Graphics.min.js +++ b/build/kissy/hilo/view/Graphics.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/Sprite.js b/build/kissy/hilo/view/Sprite.js index 8e1893b7..3ac846f8 100644 --- a/build/kissy/hilo/view/Sprite.js +++ b/build/kissy/hilo/view/Sprite.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/Sprite.min.js b/build/kissy/hilo/view/Sprite.min.js index 7b57bff5..ce979e17 100644 --- a/build/kissy/hilo/view/Sprite.min.js +++ b/build/kissy/hilo/view/Sprite.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/Stage.js b/build/kissy/hilo/view/Stage.js index cbd029d6..81d88a65 100644 --- a/build/kissy/hilo/view/Stage.js +++ b/build/kissy/hilo/view/Stage.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/Stage.min.js b/build/kissy/hilo/view/Stage.min.js index 49d229ac..b8e89909 100644 --- a/build/kissy/hilo/view/Stage.min.js +++ b/build/kissy/hilo/view/Stage.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/Text.js b/build/kissy/hilo/view/Text.js index 1cd999fd..57032cb5 100644 --- a/build/kissy/hilo/view/Text.js +++ b/build/kissy/hilo/view/Text.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -47,7 +47,7 @@ var Text = Class.create(/** @lends Text.prototype */{ this._fontHeight = Text.measureFontHeight(this.font); }, - text: null, + text: '', color: '#000', textAlign: null, textVAlign: null, diff --git a/build/kissy/hilo/view/Text.min.js b/build/kissy/hilo/view/Text.min.js index 59df6d64..2e5cb5de 100644 --- a/build/kissy/hilo/view/Text.min.js +++ b/build/kissy/hilo/view/Text.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ -KISSY.add("hilo/view/Text",function(t,e,i,n,o){var r=e.create({Extends:n,Mixes:o,constructor:function(t){t=t||{},this.id=this.id||t.id||i.getUid("Text"),r.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=r.measureFontHeight(this.font)},text:null,color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=r.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var n=i.drawable,o=n.domElement,r=o.style;r.font=i.font,r.textAlign=i.textAlign,r.color=i.color,r.width=i.width+"px",r.height=i.height+"px",r.lineHeight=i._fontHeight+i.lineSpacing+"px",o.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var n,o,r,h,l,a=i.split(/\r\n|\r|\n|/),s=0,d=0,c=e._fontHeight+e.lineSpacing,x=[];for(n=0,h=a.length;ne.maxWidth?(x.push({text:w,y:d}),s>1;break;case"bottom":p=e.height-e.textHeight}var v=e.background;for(v&&(t.fillStyle=v,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,n=0;n>1;break;case"right":case"end":o=r}n.outline?t.strokeText(e,o,i):t.fillText(e,o,i)},Statics:{measureFontHeight:function(t){var e,n=document.documentElement,o=i.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return n.appendChild(o),e=o.offsetHeight,n.removeChild(o),e}}});return r},{requires:["hilo/core/Class","hilo/core/Hilo","hilo/view/View","hilo/view/CacheMixin"]}); \ No newline at end of file +KISSY.add("hilo/view/Text",function(t,e,i,n,o){var r=e.create({Extends:n,Mixes:o,constructor:function(t){t=t||{},this.id=this.id||t.id||i.getUid("Text"),r.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=r.measureFontHeight(this.font)},text:"",color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=r.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var n=i.drawable,o=n.domElement,r=o.style;r.font=i.font,r.textAlign=i.textAlign,r.color=i.color,r.width=i.width+"px",r.height=i.height+"px",r.lineHeight=i._fontHeight+i.lineSpacing+"px",o.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var n,o,r,h,l,a=i.split(/\r\n|\r|\n|/),s=0,d=0,c=e._fontHeight+e.lineSpacing,x=[];for(n=0,h=a.length;ne.maxWidth?(x.push({text:w,y:d}),s>1;break;case"bottom":p=e.height-e.textHeight}var v=e.background;for(v&&(t.fillStyle=v,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,n=0;n>1;break;case"right":case"end":o=r}n.outline?t.strokeText(e,o,i):t.fillText(e,o,i)},Statics:{measureFontHeight:function(t){var e,n=document.documentElement,o=i.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return n.appendChild(o),e=o.offsetHeight,n.removeChild(o),e}}});return r},{requires:["hilo/core/Class","hilo/core/Hilo","hilo/view/View","hilo/view/CacheMixin"]}); \ No newline at end of file diff --git a/build/kissy/hilo/view/View.js b/build/kissy/hilo/view/View.js index 55372748..0b1ea1bb 100644 --- a/build/kissy/hilo/view/View.js +++ b/build/kissy/hilo/view/View.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/View.min.js b/build/kissy/hilo/view/View.min.js index d04b6eb7..11b90395 100644 --- a/build/kissy/hilo/view/View.min.js +++ b/build/kissy/hilo/view/View.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for kissy + * Hilo 1.4.0 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/physics/physics.js b/build/physics/physics.js index ce1f876a..219532da 100644 --- a/build/physics/physics.js +++ b/build/physics/physics.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for physics + * Hilo 1.4.0 for physics * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/physics/physics.min.js b/build/physics/physics.min.js index a629cd68..09bf71d2 100644 --- a/build/physics/physics.min.js +++ b/build/physics/physics.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for physics + * Hilo 1.4.0 for physics * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo-standalone.js b/build/standalone/hilo-standalone.js index 74dd7c5c..1159c8b3 100644 --- a/build/standalone/hilo-standalone.js +++ b/build/standalone/hilo-standalone.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -190,7 +190,7 @@ var browser = (function(){ window.Hilo.browser = browser; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -225,7 +225,7 @@ var util = { window.Hilo.util = util; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -255,7 +255,7 @@ var Hilo = { * Hilo version * @type String */ - version: '1.3.0', + version: '1.4.0', /** * @language=en * Gets a globally unique id. Such as Stage1, Bitmap2 etc. @@ -561,7 +561,7 @@ var Hilo = { for(var i in Hilo){window.Hilo[i] = Hilo[i];} })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -742,7 +742,7 @@ return {create:create, mix:mix}; window.Hilo.Class = Class; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -965,7 +965,7 @@ var Matrix = Class.create(/** @lends Matrix.prototype */{ window.Hilo.Matrix = Matrix; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1117,7 +1117,7 @@ if(RawEvent){ window.Hilo.EventMixin = EventMixin; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1198,7 +1198,7 @@ var Drawable = Class.create(/** @lends Drawable.prototype */{ window.Hilo.Drawable = Drawable; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1292,7 +1292,7 @@ var Renderer = Class.create(/** @lends Renderer.prototype */{ window.Hilo.Renderer = Renderer; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1503,7 +1503,7 @@ var CanvasRenderer = Class.create( /** @lends CanvasRenderer.prototype */ { window.Hilo.CanvasRenderer = CanvasRenderer; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1686,7 +1686,7 @@ function createDOMDrawable(view, imageObj){ window.Hilo.DOMRenderer = DOMRenderer; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1746,7 +1746,13 @@ var WebGLRenderer = Class.create(/** @lends WebGLRenderer.prototype */{ } } return this._isSupported; - } + }, + /** + * WebGL context Options + * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getContextAttributes + * @type {Object} + */ + contextOptions: null }, renderType:'webgl', gl:null, @@ -1755,7 +1761,8 @@ var WebGLRenderer = Class.create(/** @lends WebGLRenderer.prototype */{ constructor: function(properties){ WebGLRenderer.superclass.constructor.call(this, properties); var that = this; - this.gl = this.canvas.getContext("webgl")||this.canvas.getContext('experimental-webgl'); + var contextOptions = WebGLRenderer.contextOptions || {}; + this.gl = this.canvas.getContext("webgl", contextOptions)||this.canvas.getContext('experimental-webgl', contextOptions); this.maxBatchNum = WebGLRenderer.MAX_BATCH_NUM; this.positionStride = WebGLRenderer.ATTRIBUTE_NUM * 4; @@ -2264,7 +2271,7 @@ Shader.prototype = { window.Hilo.WebGLRenderer = WebGLRenderer; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2763,7 +2770,7 @@ function doSATCheck(poly1, poly2, result){ window.Hilo.View = View; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2829,7 +2836,7 @@ var CacheMixin = /** @lends CacheMixin# */ { window.Hilo.CacheMixin = CacheMixin; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3203,7 +3210,7 @@ var Container = Class.create(/** @lends Container.prototype */{ window.Hilo.Container = Container; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3475,7 +3482,7 @@ var Stage = Class.create(/** @lends Stage.prototype */{ window.Hilo.Stage = Stage; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3554,7 +3561,7 @@ var Drawable = window.Hilo.Drawable; window.Hilo.Bitmap = Bitmap; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3826,7 +3833,7 @@ var Sprite = Class.create(/** @lends Sprite.prototype */{ window.Hilo.Sprite = Sprite; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3942,7 +3949,7 @@ var DOMElement = Class.create(/** @lends DOMElement.prototype */{ window.Hilo.DOMElement = DOMElement; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3955,7 +3962,7 @@ var CacheMixin = window.Hilo.CacheMixin; /** * @language=en - * + * *
* @class Graphics class contains a group of functions for creating vector graphics. * @augments View @@ -4505,7 +4512,7 @@ return Class.create(/** @lends Graphics.prototype */{ window.Hilo.Graphics = Graphics; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4556,7 +4563,7 @@ var Text = Class.create(/** @lends Text.prototype */{ this._fontHeight = Text.measureFontHeight(this.font); }, - text: null, + text: '', color: '#000', textAlign: null, textVAlign: null, @@ -4759,7 +4766,7 @@ var Text = Class.create(/** @lends Text.prototype */{ window.Hilo.Text = Text; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4944,7 +4951,7 @@ var BitmapText = Class.create(/** @lends BitmapText.prototype */{ window.Hilo.BitmapText = BitmapText; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5125,7 +5132,7 @@ var util = window.Hilo.util; window.Hilo.Button = Button; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5361,7 +5368,7 @@ function isNumber(value){ window.Hilo.TextureAtlas = TextureAtlas; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5590,7 +5597,7 @@ var Ticker = Class.create(/** @lends Ticker.prototype */{ window.Hilo.Ticker = Ticker; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5638,7 +5645,7 @@ if (!fnProto.bind) { window.Hilo.undefined = undefined; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5775,7 +5782,7 @@ var drag = { window.Hilo.drag = drag; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6224,7 +6231,7 @@ return Class.create(/** @lends Tween.prototype */{ window.Hilo.Tween = Tween; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6494,7 +6501,7 @@ return { window.Hilo.Ease = Ease; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6541,7 +6548,7 @@ var ImageLoader = Class.create({ window.Hilo.ImageLoader = ImageLoader; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6607,7 +6614,7 @@ var ScriptLoader = Class.create({ window.Hilo.ScriptLoader = ScriptLoader; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6859,7 +6866,7 @@ function getExtension(src){ window.Hilo.LoadQueue = LoadQueue; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7063,7 +7070,7 @@ var HTMLAudio = Class.create(/** @lends HTMLAudio.prototype */{ window.Hilo.HTMLAudio = HTMLAudio; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7381,7 +7388,7 @@ return Class.create(/** @lends WebAudio.prototype */{ window.Hilo.WebAudio = WebAudio; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7485,7 +7492,7 @@ var WebSound = { window.Hilo.WebSound = WebSound; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7578,7 +7585,7 @@ var Camera = Class.create(/** @lends Camera.prototype */{ window.Hilo.Camera = Camera; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7765,7 +7772,7 @@ var Camera3d = (function(){ window.Hilo.Camera3d = Camera3d; })(window); /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo-standalone.min.js b/build/standalone/hilo-standalone.min.js index 177a3755..e8a13a9f 100644 --- a/build/standalone/hilo-standalone.min.js +++ b/build/standalone/hilo-standalone.min.js @@ -1,8 +1,8 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ -!function(t){t.Hilo||(t.Hilo={});var e=function(){var e=navigator.userAgent,i=document,n=t,r=i.documentElement,a={iphone:/iphone/i.test(e),ipad:/ipad/i.test(e),ipod:/ipod/i.test(e),ios:/iphone|ipad|ipod/i.test(e),android:/android/i.test(e),webkit:/webkit/i.test(e),chrome:/chrome/i.test(e),safari:/safari/i.test(e),firefox:/firefox/i.test(e),ie:/msie/i.test(e),opera:/opera/i.test(e),supportTouch:"ontouchstart"in n,supportCanvas:null!=i.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in n||"orientation"in n.screen,supportDeviceMotion:"ondevicemotion"in n};try{var o="hilo";localStorage.setItem(o,o),localStorage.removeItem(o),a.supportStorage=!0}catch(s){}var l=a.jsVendor=a.webkit?"webkit":a.firefox?"webkit":a.opera?"o":a.ie?"ms":"",h=a.cssVendor="-"+l+"-",c=i.createElement("div"),u=c.style,d=void 0!=u[l+"Transform"],f=void 0!=u[l+"Perspective"];f&&(c.id="test3d",u=i.createElement("style"),u.textContent="@media ("+h+"transform-3d){#test3d{height:3px}}",i.head.appendChild(u),r.appendChild(c),f=3==c.offsetHeight,i.head.removeChild(u),r.removeChild(c)),a.supportTransform=d,a.supportTransform3D=f;var p=a.supportTouch,v=p?"touchstart":"mousedown",m=p?"touchmove":"mousemove",g=p?"touchend":"mouseup";return a.POINTER_START=v,a.POINTER_MOVE=m,a.POINTER_END=g,a}();t.Hilo.browser=e}(window),function(t){t.Hilo||(t.Hilo={});var e={copy:function(t,e,i){for(var n in e)i&&!t.hasOwnProperty(n)&&void 0===t[n]||(t[n]=e[n]);return t}};t.Hilo.util=e}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.browser,i=t.Hilo.util,n=t,r=document,a=r.documentElement,o=0,s={},l={version:"1.3.0",getUid:function(t){var e=++o;if(t){var i=t.charCodeAt(t.length-1);return i>=48&&i<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,i=t;i;)e=e?i.id+"."+e:i.id,i=i.parent;return e},copy:function(t,e,n){return i.copy(t,e,n),s.copy||(s.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),t},browser:e,event:{POINTER_START:e.POINTER_START,POINTER_MOVE:e.POINTER_MOVE,POINTER_END:e.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(t){var e;try{e=t.getBoundingClientRect()}catch(i){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var r=(n.pageXOffset||a.scrollLeft)-(a.clientLeft||0)||0,o=(n.pageYOffset||a.scrollTop)-(a.clientTop||0)||0,s=n.getComputedStyle?getComputedStyle(t):t.currentStyle,l=parseInt,h=l(s.paddingLeft)+l(s.borderLeftWidth)||0,c=l(s.paddingTop)+l(s.borderTopWidth)||0,u=l(s.paddingRight)+l(s.borderRightWidth)||0,d=l(s.paddingBottom)+l(s.borderBottomWidth)||0,f=e.top||0,p=e.left||0,v=e.right||0,m=e.bottom||0;return{left:p+r+h,top:f+o+c,width:v-u-p-h,height:m-d-f-c}},createElement:function(t,e){var i,n,a,o=r.createElement(t);for(i in e)if(n=e[i],"style"===i)for(a in n)o.style[a]=n[a];else o[i]=n;return o},getElement:function(t){return r.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,i=e.domElement.style,n=t._stateCache||(t._stateCache={}),r=l.browser.jsVendor,a="px",o=!1;if(this.cacheStateIfChanged(t,["visible"],n)&&(i.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],n)&&(i.opacity=t.alpha),t.visible&&!(t.alpha<=0)){if(this.cacheStateIfChanged(t,["width"],n)&&(i.width=t.width+a),this.cacheStateIfChanged(t,["height"],n)&&(i.height=t.height+a),this.cacheStateIfChanged(t,["depth"],n)&&(i.zIndex=t.depth+1),t.transform){var s=t.transform;(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],n))&&(i[r+"TransformOrigin"]="0 0"),i[r+"Transform"]="matrix3d("+s.a+", "+s.b+", 0, 0, "+s.c+", "+s.d+", 0, 0, 0, 0, 1, 0, "+s.tx+", "+s.ty+", 0, 1)"}else(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],n))&&(i[r+"TransformOrigin"]=t.pivotX+a+" "+t.pivotY+a),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],n)||o)&&(i[r+"Transform"]=this.getTransformCSS(t));this.cacheStateIfChanged(t,["background"],n)&&(i.backgroundColor=t.background),i.pointerEvents||(i.pointerEvents="none");var h=e.image;if(h){var c=h.src;c!==n.image&&(n.image=c,i.backgroundImage="url("+c+")");var u=e.rect;if(u){var d=u[0],f=u[1];d!==n.sx&&(n.sx=d,i.backgroundPositionX=-d+a),f!==n.sy&&(n.sy=f,i.backgroundPositionY=-f+a)}}var p=t.mask;if(p){var v=p.drawable.domElement.style.backgroundImage;v!==n.maskImage&&(n.maskImage=v,i[r+"MaskImage"]=v,i[r+"MaskRepeat"]="no-repeat");var m=p.x,g=p.y;m===n.maskX&&g===n.maskY||(n.maskX=m,n.maskY=g,i[r+"MaskPosition"]=m+a+" "+g+a)}}},cacheStateIfChanged:function(t,e,i){var n,r,a,o,s=!1;for(n=0,r=e.length;n=6?(e=s[0],i=s[1],n=s[2],r=s[3],a=s[4],o=s[5]):(e=t.a,i=t.b,n=t.c,r=t.d,a=t.tx,o=t.ty),this.a=l*e+h*n,this.b=l*i+h*r,this.c=c*e+u*n,this.d=c*i+u*r,this.tx=d*e+f*n+a,this.ty=d*i+f*r+o,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),n=this.a,r=this.b,a=this.c,o=this.d,s=this.tx,l=this.ty;return this.a=n*i-r*e,this.b=n*e+r*i,this.c=a*i-o*e,this.d=a*e+o*i,this.tx=s*i-l*e,this.ty=s*e+l*i,this},scale:function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},translate:function(t,e){return this.tx+=t,this.ty+=e,this},identity:function(){return this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this},invert:function(){var t=this.a,e=this.b,i=this.c,n=this.d,r=this.tx,a=t*n-e*i;return this.a=n/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-n*r)/a,this.ty=-(t*this.ty-e*r)/a,this},transformPoint:function(t,e,i){var n=t.x*this.a+t.y*this.c+this.tx,r=t.x*this.b+t.y*this.d+this.ty;return e&&(n=n+.5>>0,r=r+.5>>0),i?{x:n,y:r}:(t.x=n,t.y=r,t)}});t.Hilo.Matrix=i}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i={_listeners:null,on:function(t,e,i){for(var n=this._listeners=this._listeners||{},r=n[t]=n[t]||[],a=0,o=r.length;a-1&&o.splice(c,1)}}return 0==o.length&&delete a[r],!0}return!1}},n=e.create({constructor:function(t,e,i){this.type=t,this.target=e,this.detail=i,this.timeStamp=+new Date},type:null,target:null,detail:null,timeStamp:0,stopImmediatePropagation:function(){this._stopped=!0}}),r=t.Event;if(r){var a=r.prototype,o=a.stopImmediatePropagation;a.stopImmediatePropagation=function(){o&&o.call(this),this._stopped=!0}}t.Hilo.EventMixin=i}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i=t.Hilo.util,n=e.create({constructor:function(t){this.init(t)},image:null,rect:null,init:function(t){var e=this,r=e.image;n.isDrawable(t)?e.image=t:i.copy(e,t,!0);var a=e.image;if("string"==typeof a){if(!r||a!==r.getAttribute("src")){e.image=null;var o=new Image;return t.crossOrigin&&(o.crossOrigin=t.crossOrigin),o.onload=function(){o.onload=null,e.init(o)},void(o.src=a)}a=e.image=r}a&&!e.rect&&(e.rect=[0,0,a.width,a.height])},Statics:{isDrawable:function(t){if(!t||!t.tagName)return!1;var e=t.tagName.toLowerCase();return"img"===e||"canvas"===e||"video"===e}}});t.Hilo.Drawable=n}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i=t.Hilo.util,n=e.create({constructor:function(t){t=t||{},i.copy(this,t,!0)},renderType:null,canvas:null,stage:null,blendMode:"source-over",startDraw:function(t){},draw:function(t){},endDraw:function(t){},transform:function(){},hide:function(){},remove:function(t){},clear:function(t,e,i,n){},resize:function(t,e){}});t.Hilo.Renderer=n}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i=t.Hilo,n=t.Hilo.Renderer,r=e.create({Extends:n,constructor:function(t){r.superclass.constructor.call(this,t),this.context=this.canvas.getContext("2d")},renderType:"canvas",context:null,startDraw:function(t){return!!(t.visible&&t.alpha>0)&&(t===this.stage&&this.context.clearRect(0,0,t.width,t.height),t.blendMode!==this.blendMode&&(this.context.globalCompositeOperation=this.blendMode=t.blendMode),this.context.save(),!0)},draw:function(t){var e=this.context,i=t.width,n=t.height,r=t.background;r&&(e.fillStyle=r,e.fillRect(0,0,i,n));var a=t.drawable,o=a&&a.image;if(o){var s=a.rect,l=s[2],h=s[3],c=s[4],u=s[5];if(!l||!h)return;i||n||(i=t.width=l,n=t.height=h),(c||u)&&e.translate(c-.5*l,u-.5*h),e.drawImage(o,s[0],s[1],l,h,0,0,i,n)}},endDraw:function(t){this.context.restore()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void i.setElementStyleByView(t);var n=this.context,r=t.scaleX,a=t.scaleY;if(t===this.stage){var o=this.canvas.style,s=t._scaleX,l=t._scaleY,h=!1;(!s&&1!=r||s&&s!=r)&&(t._scaleX=r,o.width=r*t.width+"px",h=!0),(!l&&1!=a||l&&l!=a)&&(t._scaleY=a,o.height=a*t.height+"px",h=!0),h&&t.updateViewport()}else{var c=t.x,u=t.y,d=t.pivotX,f=t.pivotY,p=t.rotation%360,v=t.transform,m=t.mask;m&&(m._render(this),n.clip());var g=t.align;if(g){var _=t.getAlignPosition();c=_.x,u=_.y}v?n.transform(v.a,v.b,v.c,v.d,v.tx,v.ty):(0==c&&0==u||n.translate(c,u),0!=p&&n.rotate(p*Math.PI/180),1==r&&1==a||n.scale(r,a),0==d&&0==f||n.translate(-d,-f))}t.alpha>0&&(n.globalAlpha*=t.alpha)},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var n=i.parentNode;n&&n.removeChild(i)}},clear:function(t,e,i,n){this.context.clearRect(t,e,i,n)},resize:function(t,e){var i=this.canvas,n=this.stage,r=i.style;i.width=t,i.height=e,r.width=n.width*n.scaleX+"px",r.height=n.height*n.scaleY+"px"}});t.Hilo.CanvasRenderer=r}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i=t.Hilo,n=t.Hilo.Renderer,r=t.Hilo.Drawable,a=function(){function t(t,e){var n=t.tagName||"div",r=e.image,a=t.width||r&&r.width,o=t.height||r&&r.height,s=i.createElement(n),l=s.style;if(t.id&&(s.id=t.id),l.position="absolute",l.left=(t.left||0)+"px",l.top=(t.top||0)+"px",l.width=a+"px",l.height=o+"px","canvas"==n){if(s.width=a,s.height=o,r){var h=s.getContext("2d"),c=e.rect||[0,0,a,o];h.drawImage(r,c[0],c[1],c[2],c[3],t.x||0,t.y||0,t.width||c[2],t.height||c[3])}}else if(l.opacity=void 0!=t.alpha?t.alpha:1,(t===this.stage||t.clipChildren)&&(l.overflow="hidden"),r&&r.src){l.backgroundImage="url("+r.src+")";var u=t.rectX||0,d=t.rectY||0;l.backgroundPosition=-u+"px "+-d+"px"}return s}return e.create({Extends:n,constructor:function(t){a.superclass.constructor.call(this,t)},renderType:"dom",startDraw:function(e){var i=e.drawable=e.drawable||new r;return i.domElement=i.domElement||t(e,i),!0},draw:function(t){var e=t.parent,i=t.drawable.domElement,n=i.parentNode;if(e){var r=e.drawable.domElement;if(r!=n&&r.appendChild(i),!t.width&&!t.height){var a=t.drawable.rect;a&&(a[2]||a[3])&&(t.width=a[2],t.height=a[3])}}else t!==this.stage||n||(i.style.overflow="hidden",this.canvas.appendChild(i))},transform:function(t){if(i.setElementStyleByView(t),t===this.stage){var e=this.canvas.style,n=t._scaleX,r=t._scaleY,a=t.scaleX,o=t.scaleY;(!n&&1!=a||n&&n!=a)&&(t._scaleX=a,e.width=a*t.width+"px"),(!r&&1!=o||r&&r!=o)&&(t._scaleY=o,e.height=o*t.height+"px")}},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var n=i.parentNode;n&&n.removeChild(i)}},hide:function(t){var e=t.drawable&&t.drawable.domElement;e&&(e.style.display="none")},resize:function(t,e){var i=this.canvas.style;i.width=t+"px",i.height=e+"px","absolute"!=i.position&&(i.position="relative")}})}();t.Hilo.DOMRenderer=a}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i=t.Hilo,n=t.Hilo.Renderer,r=t.Hilo.Matrix,a=Math.PI/180,o=e.create({Extends:n,Statics:{MAX_BATCH_NUM:2e3,ATTRIBUTE_NUM:5,isSupport:function(){if(void 0==this._isSupported){var t=document.createElement("canvas");t.getContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))?this._isSupported=!0:this._isSupported=!1}return this._isSupported}},renderType:"webgl",gl:null,_isContextLost:!1,_cacheTexture:{},constructor:function(t){o.superclass.constructor.call(this,t);var e=this;this.gl=this.canvas.getContext("webgl")||this.canvas.getContext("experimental-webgl"),this.maxBatchNum=o.MAX_BATCH_NUM,this.positionStride=4*o.ATTRIBUTE_NUM;var i=this.maxBatchNum*o.ATTRIBUTE_NUM*4,n=6*this.maxBatchNum;this.arrayBuffer=new ArrayBuffer(4*i),this.float32Array=new Float32Array(this.arrayBuffer),this.uint32Array=new Uint32Array(this.arrayBuffer),this.indexs=new Uint16Array(n);for(var r=0,a=0;r0)&&(t===this.stage&&this.clear(),!0)},draw:function(t){var e=t.width,i=t.height,n=(t.background,t.drawable),r=n&&n.image;if(r){var a=n.rect,o=a[2],s=a[3];e||i||(e=t.width=o,i=t.height=s),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var l=this._createVertexs(r,a[0],a[1],o,s,0,0,e,i),h=this.batchIndex*this.positionStride,c=this.float32Array,u=this.uint32Array,d=(t.tint>>16)+(65280&t.tint)+((255&t.tint)<<16)+(255*t.__webglRenderAlpha<<24);c[h+0]=l[0],c[h+1]=l[1],c[h+2]=l[2],c[h+3]=l[3],u[h+4]=d,c[h+5]=l[4],c[h+6]=l[5],c[h+7]=l[6],c[h+8]=l[7],u[h+9]=d,c[h+10]=l[8],c[h+11]=l[9],c[h+12]=l[10],c[h+13]=l[11],u[h+14]=d,c[h+15]=l[12],c[h+16]=l[13],c[h+17]=l[14],c[h+18]=l[15],u[h+19]=d;for(var f=t.__webglWorldMatrix,p=0;p<4;p++){var v=c[h+5*p],m=c[h+5*p+1];c[h+5*p]=f.a*v+f.c*m+f.tx,c[h+5*p+1]=f.b*v+f.d*m+f.ty}t.__textureImage=r,this.sprites[this.batchIndex++]=t}},endDraw:function(t){t===this.stage&&this._renderBatches()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void i.setElementStyleByView(t);var n=t.scaleX,a=t.scaleY;if(t===this.stage){var o=this.canvas.style,s=t._scaleX,l=t._scaleY,h=!1;(!s&&1!=n||s&&s!=n)&&(t._scaleX=n,o.width=n*t.width+"px",h=!0),(!l&&1!=a||l&&l!=a)&&(t._scaleY=a,o.height=a*t.height+"px",h=!0),h&&t.updateViewport(),t.__webglWorldMatrix=t.__webglWorldMatrix||new r(1,0,0,1,0,0)}else t.parent&&(t.__webglWorldMatrix=t.__webglWorldMatrix||new r(1,0,0,1,0,0),this._setConcatenatedMatrix(t,t.parent));t.alpha>0&&(t.parent&&t.parent.__webglRenderAlpha?t.__webglRenderAlpha=t.alpha*t.parent.__webglRenderAlpha:t.__webglRenderAlpha=t.alpha)},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var n=i.parentNode;n&&n.removeChild(i)}},clear:function(t,e,i,n){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(t,e){if(this.width!==t||this.height!==e){var i=this.canvas,n=this.stage,r=i.style;this.width=i.width=t,this.height=i.height=e,r.width=n.width*n.scaleX+"px",r.height=n.height*n.scaleY+"px",this.gl.viewport(0,0,t,e),this.canvasHalfWidth=.5*t,this.canvasHalfHeight=.5*e,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var t=this.gl;t.bufferSubData(t.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var e=0,i=0,n=null,r=0;r0&&(i.bindTexture(i.TEXTURE_2D,this._getTexture(this.sprites[t])),i.drawElements(i.TRIANGLES,6*n,i.UNSIGNED_SHORT,6*t*2))},_uploadProjectionTransform:function(t){this._projectionTransformElements&&!t||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var t=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",e="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new s(this,{v:t,f:e},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(t,e,i,n,r,a,o,s,l){var h=this.__tempVertexs||[],c=t.width,u=t.height;n/=c,r/=u,e/=c,i/=u,s=s,l=l,a=a,o=o,n+e>1&&(n=1-e),r+i>1&&(r=1-i);var d=0;return h[d++]=a,h[d++]=o,h[d++]=e,h[d++]=i,h[d++]=a+s,h[d++]=o,h[d++]=e+n,h[d++]=i,h[d++]=a,h[d++]=o+l,h[d++]=e,h[d++]=i+r,h[d++]=a+s,h[d++]=o+l,h[d++]=e+n,h[d++]=i+r,h},_setConcatenatedMatrix:function(t,e){var i=t.__webglWorldMatrix,n=1,r=0,o=t.rotation%360,s=t.pivotX,l=t.pivotY,h=t.scaleX,c=t.scaleY,u=t.transform;if(u)i.copy(u);else{if(o){var d=o*a;n=Math.cos(d),r=Math.sin(d)}var f=t.getAlignPosition();i.a=n*h,i.b=r*h,i.c=-r*c,i.d=n*c,i.tx=f.x-i.a*s-i.c*l,i.ty=f.y-i.b*s-i.d*l}i.concat(e.__webglWorldMatrix)},_getTexture:function(t){var e=t.__textureImage,i=this._cacheTexture[e.src];return i||(i=this.activeShader.uploadTexture(e)),i}}),s=function(t,e,i){this.renderer=t,this.gl=t.gl,this.program=this._createProgram(this.gl,e.v,e.f),i=i||{},this.attributes=i.attributes||[],this.uniforms=i.uniforms||[]};s.prototype={active:function(){var t=this,e=t.renderer,i=t.gl,n=t.program;n&&i&&(e.activeShader=t,i.useProgram(n),t.attributes.forEach(function(t){e[t]=i.getAttribLocation(n,t),i.enableVertexAttribArray(e[t])}),t.uniforms.forEach(function(t){e[t]=i.getUniformLocation(n,t)}),t.width===e.width&&t.height===e.height||(t.width=e.width,t.height=e.height,e._uploadProjectionTransform()))},uploadTexture:function(t){var e=this.gl,i=this.renderer,n=e.createTexture(),r=i.u_Sampler;return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,n),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(r,0),e.bindTexture(e.TEXTURE_2D,null),this.renderer._cacheTexture[t.src]=n,n},_createProgram:function(t,e,i){var n=this._createShader(t,t.VERTEX_SHADER,e),r=this._createShader(t,t.FRAGMENT_SHADER,i);if(!n||!r)return null;var a=t.createProgram();if(a){t.attachShader(a,n),t.attachShader(a,r),t.linkProgram(a),t.deleteShader(r),t.deleteShader(n);var o=t.getProgramParameter(a,t.LINK_STATUS);if(!o){var s=t.getProgramInfoLog(a);return console.log("Failed to link program: "+s),t.deleteProgram(a),null}}return a},_createShader:function(t,e,i){var n=t.createShader(e);if(n){t.shaderSource(n,i),t.compileShader(n);var r=t.getShaderParameter(n,t.COMPILE_STATUS);if(!r){var a=t.getShaderInfoLog(n);return console.log("Failed to compile shader: "+a),t.deleteShader(n),null}}return n}},t.Hilo.WebGLRenderer=o}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo,i=t.Hilo.Class,n=t.Hilo.EventMixin,r=t.Hilo.Matrix,a=t.Hilo.util,o=function(){function t(t,e,i){for(var n,r,a,o,s=0,l=!1,h=0,c=i.length;hd.x?(n=d.x,r=u.x):(n=u.x,r=d.x),t>=n&&t<=r))l=!0;else if(u.y>d.y?(a=d.y,o=u.y):(a=u.y,o=d.y),!(eo)){var f=(e-u.y)*(d.x-u.x)/(d.y-u.y)+u.x;if(f>t?s++:f==t&&(l=!0),u.x>t&&u.y==e){var p=i[(c+h-1)%c];(p.ye||p.y>e&&d.ys?s=c:ch?h=c:c=0)return!1;u>i.overlap&&(i.overlap=u,i.normal.x=p.x,i.normal.y=p.y)}return i}return i.create({Mixes:n,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("View"),a.copy(this,t,!0)},tint:16777215,id:null,x:0,y:0,width:0,height:0,alpha:1,rotation:0,visible:!0,pivotX:0,pivotY:0,scaleX:1,scaleY:1,pointerEnabled:!0,background:null,mask:null,align:null,drawable:null,boundsArea:null,parent:null,depth:-1,transform:null,blendMode:"source-over",getStage:function(){for(var t,e=this;t=e.parent;)e=t;return e.canvas?e:null},getScaledWidth:function(){return this.width*this.scaleX},getScaledHeight:function(){return this.height*this.scaleY},addTo:function(t,e){return"number"==typeof e?t.addChildAt(this,e):t.addChild(this),this},removeFromParent:function(){var t=this.parent;return t&&t.removeChild(this),this},getBounds:function(){for(var t,e,i,n,r,a,o,s=this.width,l=this.height,h=this.getConcatenatedMatrix(),c=this.boundsArea||[{x:0,y:0},{x:s,y:0},{x:s,y:l},{x:0,y:l}],u=[],d=0,f=c.length;de?n=e:ri?a=i:o>1,n=0;break;case"TR":i=o-r,n=0;break;case"L":i=0,n=s-a>>1;break;case"C":i=o-r>>1,n=s-a>>1;break;case"R":i=o-r,n=s-a>>1;break;case"BL":i=0,n=s-a;break;case"B":i=o-r>>1,n=s-a;break;case"BR":i=o-r,n=s-a}}return{x:i,y:n}},hitTestPoint:function(e,i,n){var r=this.getBounds(),a=e>=r.x&&e<=r.x+r.width&&i>=r.y&&i<=r.y+r.height;return a&&n&&(a=t(e,i,r)),a},hitTestObject:function(t,e){var i=this.getBounds(),n=t.getBounds(),r=i.x<=n.x+n.width&&n.x<=i.x+i.width&&i.y<=n.y+n.height&&n.y<=i.y+i.height;return r&&e&&(r=o(i,n)),!!r},_render:function(t,e){this.onUpdate&&this.onUpdate(e)===!1||!t.startDraw(this)||(t.transform(this),this.render(t,e),t.endDraw(this))},_fireMouseEvent:function(t){if(t.eventCurrentTarget=this,this.fire(t),"mousemove"==t.type){if(!this.__mouseOver){this.__mouseOver=!0;var e=a.copy({},t);e.type="mouseover",this.fire(e)}}else"mouseout"==t.type&&(this.__mouseOver=!1);var i=this.parent;t._stopped||t._stopPropagationed||!i||("mouseout"==t.type||"touchout"==t.type?i.hitTestPoint(t.stageX,t.stageY,!0)||i._fireMouseEvent(t):i._fireMouseEvent(t))},onUpdate:null,render:function(t,e){t.draw(this)},toString:function(){return e.viewToString(this)}})}();t.Hilo.View=o}(window),function(t){t.Hilo||(t.Hilo={});var e,i,n=t.Hilo.Drawable,r=t.Hilo.browser,a={_cacheDirty:!0,cache:function(t){(t||this._cacheDirty||!this.drawable)&&this.updateCache()},updateCache:function(){r.supportCanvas&&(e||(e=document.createElement("canvas"),i=e.getContext("2d")),e.width=this.width,e.height=this.height,this._draw(i),this.drawable=this.drawable||new n,this.drawable.init({image:e.toDataURL()}),this._cacheDirty=!1)},setCacheDirty:function(t){this._cacheDirty=t}};t.Hilo.CacheMixin=a}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo,i=t.Hilo.Class,n=t.Hilo.View,r=i.create({Extends:n,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("Container"),r.superclass.constructor.call(this,t),this.children?this._updateChildren():this.children=[]},children:null,pointerChildren:!0,clipChildren:!1,getNumChildren:function(){return this.children.length},addChildAt:function(t,e){var i=this.children,n=i.length,r=t.parent;e=e<0?0:e>n?n:e;var a=this.getChildIndex(t);if(a==e)return this;if(a>=0?(i.splice(a,1),e=e==n?n-1:e):r&&r.removeChild(t),i.splice(e,0,t),a<0)this._updateChildren(e);else{var o=a=e.length)return null;var i=e[t];if(i){if(!i.__renderer)for(var n=i;n=n.parent;){if(n.renderer){i.__renderer=n.renderer;break}if(n.__renderer){i.__renderer=n.__renderer;break}}i.__renderer&&i.__renderer.remove(i),i.parent=null,i.depth=-1}return e.splice(t,1),this._updateChildren(t),i},removeChild:function(t){return this.removeChildAt(this.getChildIndex(t))},removeChildById:function(t){for(var e,i=this.children,n=0,r=i.length;n=e.length?null:e[t]},getChildById:function(t){for(var e,i=this.children,n=0,r=i.length;n=0&&n!=e){var r=i.length;e=e<0?0:e>=r?r-1:e,i.splice(n,1),i.splice(e,0,t),this._updateChildren()}return this},swapChildren:function(t,e){var i=this.children,n=this.getChildIndex(t),r=this.getChildIndex(e);t.depth=r,i[r]=t,e.depth=n,i[n]=e},swapChildrenAt:function(t,e){var i=this.children,n=this.getChildAt(t),r=this.getChildAt(e);n.depth=e,i[e]=n,r.depth=t,i[t]=r},sortChildren:function(t){var e=t,i=this.children;if("string"==typeof e){var n=e;e=function(t,e){return e[n]-t[n]}}i.sort(e),this._updateChildren()},_updateChildren:function(t,e){var i,n=this.children;t=t||0,e=e||n.length;for(var r=t;r=0;h--)if(a=l[h],!(!a||!a.visible||a.alpha<=0||r&&!a.pointerEnabled))if(a.children&&a.children.length&&(!r||a.pointerChildren)&&(o=a.getViewAtPoint(t,e,i,n,r)),o){if(!n)return o;o.length&&(s=s.concat(o))}else if(a.hitTestPoint(t,e,i)){if(!n)return a;s.push(a)}return n&&s.length?s:null},render:function(t,e){r.superclass.render.call(this,t,e);var i,n,a,o=this.children.slice(0);for(i=0,n=o.length;in?n:e,i[e]=t,t.name&&(this._frameNames[t.name]=t),(0!=e||this.width)&&this.height||(this.width=t.rect[2],this.height=t.rect[3]),this},getFrame:function(t){if("number"==typeof t){var e=this._frames;return t<0||t>=e.length?null:e[t]}return this._frameNames[t]},getFrameIndex:function(t){var e=this._frames,i=e.length,n=-1;if("number"==typeof t)n=t;else{var r="string"==typeof t?this._frameNames[t]:t;if(r)for(var a=0;a=i?i-1:n,this.paused=e,this._firstRender=!0,this},_render:function(t,e){var i,n=this.currentFrame;if(this._firstRender?(i=n,this._firstRender=!1):i=this._nextFrame(e),i!=n){this.currentFrame=i;var r=this._frames[i].callback;r&&r.call(this)}this.onEnterFrame&&this.onEnterFrame(i),this.drawable.init(this._frames[i]),a.superclass._render.call(this,t,e)},_nextFrame:function(t){var e=this._frames,i=e.length,n=this.currentFrame,r=e[n],a=r.duration||this.interval,o=this._frameElapsed,s=0!=n||this.drawable?o+(this.timeBased?t:1):0;return o=this._frameElapsed=s=i-1)&&this.stop(),this.paused||0!=o||(null!=r.next?n=this.getFrameIndex(r.next):n>=i-1?n=0:this.drawable&&n++),n},setFrameCallback:function(t,e){return t=this.getFrame(t),t&&(t.callback=e),this},onEnterFrame:null});t.Hilo.Sprite=a}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo,i=t.Hilo.Class,n=t.Hilo.View,r=t.Hilo.Drawable,a=i.create({Extends:n,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("DOMElement"),a.superclass.constructor.call(this,t),this.drawable=new r;var i=this.drawable.domElement=t.element||e.createElement("div");i.id=this.id,this.pointerEnabled&&!i.style.pointerEvents&&(i.style.pointerEvents="visible")},_render:function(t,e){this.onUpdate&&this.onUpdate(e)===!1||(t.transform(this),this.visible&&this.alpha>0&&this.render(t,e))},render:function(t,i){if("dom"!==t.renderType){var n=t.canvas,r=this.parent,a=t._domElementContainer;t._domElementContainer||(a=t._domElementContainer=e.createElement("div",{style:{position:"absolute",transform:"scale3d("+r.scaleX+","+r.scaleY+", 1)",transformOrigin:"0 0",zIndex:"1"}}),n.parentNode.insertBefore(t._domElementContainer,n.nextSibling));var o,s=this.drawable.domElement,l=this.depth,h=a.childNodes[0];if(s.parentNode)return;for(;h&&3!=h.nodeType&&(o=parseInt(h.style.zIndex)||0,!(o<=0||o>l));)h=h.nextSibling;a.insertBefore(this.drawable.domElement,h)}else t.draw(this)}});t.Hilo.DOMElement=a}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo,i=t.Hilo.Class,n=t.Hilo.View,r=t.Hilo.CacheMixin,a=function(){var t=document.createElement("canvas"),o=t.getContext&&t.getContext("2d");return i.create({Extends:n,Mixes:r,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("Graphics"),a.superclass.constructor.call(this,t),this._actions=[]},lineWidth:1,lineAlpha:1,lineCap:null,lineJoin:null,miterLimit:10,hasStroke:!1,strokeStyle:"0",hasFill:!1,fillStyle:"0",fillAlpha:0,lineStyle:function(t,e,i,n,r,a){var o=this,s=o._addAction;return s.call(o,["lineWidth",o.lineWidth=t||1]),s.call(o,["strokeStyle",o.strokeStyle=e||"0"]),s.call(o,["lineAlpha",o.lineAlpha=i||1]),void 0!=n&&s.call(o,["lineCap",o.lineCap=n]),void 0!=r&&s.call(o,["lineJoin",o.lineJoin=r]),void 0!=a&&s.call(o,["miterLimit",o.miterLimit=a]),o.hasStroke=!0,o},setLineDash:function(t){return this._addAction(["setLineDash",t])},beginFill:function(t,e){var i=this,n=i._addAction;return n.call(i,["fillStyle",i.fillStyle=t]),n.call(i,["fillAlpha",i.fillAlpha=e||1]),i.hasFill=!0,i},endFill:function(){var t=this,e=t._addAction;return t.hasStroke&&e.call(t,["stroke"]),t.hasFill&&e.call(t,["fill"]),t.setCacheDirty(!0),t},beginLinearGradientFill:function(t,e,i,n,r,a){for(var s=this,l=o.createLinearGradient(t,e,i,n),h=0,c=r.length;h1?a.slice(1):null;"function"==typeof t[o]?t[o].apply(t,s):t[o]=a[1]}},render:function(t,e){var i=this;"canvas"===t.renderType?i._draw(t.context):(i.cache(),t.draw(i))},clear:function(){var t=this;return t._actions.length=0,t.lineWidth=1,t.lineAlpha=1,t.lineCap=null,t.lineJoin=null,t.miterLimit=10,t.hasStroke=!1,t.strokeStyle="0",t.hasFill=!1,t.fillStyle="0",t.fillAlpha=1,t.setCacheDirty(!0),t},_addAction:function(t){var e=this;return e._actions.push(t),e}})}();t.Hilo.Graphics=a}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i=t.Hilo,n=t.Hilo.View,r=t.Hilo.CacheMixin,a=e.create({Extends:n,Mixes:r,constructor:function(t){t=t||{},this.id=this.id||t.id||i.getUid("Text"),a.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=a.measureFontHeight(this.font)},text:null,color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=a.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var n=i.drawable,r=n.domElement,a=r.style;a.font=i.font,a.textAlign=i.textAlign,a.color=i.color,a.width=i.width+"px",a.height=i.height+"px",a.lineHeight=i._fontHeight+i.lineSpacing+"px",r.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var n,r,a,o,s,l=i.split(/\r\n|\r|\n|/),h=0,c=0,u=e._fontHeight+e.lineSpacing,d=[];for(n=0,o=l.length;ne.maxWidth?(d.push({text:m,y:c}),h>1;break;case"bottom":_=e.height-e.textHeight}var x=e.background;for(x&&(t.fillStyle=x,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,n=0;n>1;break;case"right":case"end":r=a}n.outline?t.strokeText(e,r,i):t.fillText(e,r,i)},Statics:{measureFontHeight:function(t){var e,n=document.documentElement,r=i.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return n.appendChild(r),e=r.offsetHeight,n.removeChild(r),e}}});t.Hilo.Text=a}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i=t.Hilo,n=t.Hilo.Container,r=t.Hilo.Bitmap,a=e.create({Extends:n,constructor:function(t){t=t||{},this.id=this.id||t.id||i.getUid("BitmapText"),a.superclass.constructor.call(this,t);var e=t.text+"";e&&(this.text="",this.setText(e)),this.pointerChildren=!1},glyphs:null,letterSpacing:0,text:"",textAlign:"left",setText:function(t){var e=this,i=t.toString(),n=i.length;if(e.text!=i){e.text=i;var r,a,o,s,l=0,h=0,c=0;for(r=0;r0?e.letterSpacing:0),e.children[r]?(s=e.children[r],s.setImage(o.image,o.rect)):(s=e._createBitmap(o),e.addChild(s)),s.x=c,l=c+o.rect[2],h=Math.max(h,o.rect[3]));for(r=e.children.length-1;r>=n;r--)e._releaseBitmap(e.children[r]),e.children[r].removeFromParent();return e.width=l,e.height=h,this.setTextAlign(),e}},_createBitmap:function(t){var e;return a._pool.length?(e=a._pool.pop(),e.setImage(t.image,t.rect)):e=new r({image:t.image,rect:t.rect}),e},_releaseBitmap:function(t){a._pool.push(t)},setTextAlign:function(t){switch(this.textAlign=t||this.textAlign,this.textAlign){case"center":this.pivotX=.5*this.width;break;case"right":this.pivotX=this.width;break;case"left":default:this.pivotX=0}return this},hasGlyphs:function(t){var e=this.glyphs;if(!e)return!1;t=t.toString();var i,n=t.length;for(i=0;i=this._targetFPS?(this._measuredFPS=1e3/(this._tickTime/this._tickCount)+.5>>0,this._tickCount=0,this._tickTime=0):this._tickTime+=t-this._lastTime,this._lastTime=t;for(var n=i.slice(0),r=0,a=n.length;r=0&&e.splice(i,1)},nextTick:function(t){var e=this,i={tick:function(n){e.removeTick(i),t()}};return e.addTick(i),i},timeout:function(t,e){var i=this,n=(new Date).getTime()+e,r={tick:function(){var e=(new Date).getTime(),a=e-n;a>=0&&(i.removeTick(r),t())}};return i.addTick(r),r},interval:function(t,e){var i=this,n=(new Date).getTime()+e,r={tick:function(){var i=(new Date).getTime(),r=i-n;r>=0&&(r=n)return-1;for(e<0&&(e=n+e),i=e;i=1?1:s;var h=r.ease?r.ease(s):s;r.reverse&&(r._reverseFlag<0&&(s=1-s,h=1-h),s<1e-7&&(r.repeat>0&&r._repeatCount++>=r.repeat||0==r.repeat&&!r.loop?l=!0:(r._startTime=t(),r._pausedTime=0,r._reverseFlag*=-1))),r.isStart||(r.setProps(r._fromProps,r._toProps),r.isStart=!0,r.onStart&&r.onStart.call(r,r)),r.time=a,r._render(h),(o=r.onUpdate)&&o.call(r,s,r),s>=1&&(r.reverse?(r._startTime=t(),r._pausedTime=0,r._reverseFlag*=-1):r.loop||r.repeat>0&&r._repeatCount++0&&u<=e?(c._render(s),c.time=a,i.add(c)):l&&(u<0||u>e)&&c.start()}return l?((o=r.onComplete)&&o.call(r,r),!0):void 0}}},Statics:{_tweens:[],tick:function(){var e,n,r=i._tweens,a=r.length;for(n=0;n-1&&r.splice(e,1);else for(e=0;e=i)return void t.fire("complete");if(t._currentIndex=48&&i<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,i=t;i;)e=e?i.id+"."+e:i.id,i=i.parent;return e},copy:function(t,e,n){return i.copy(t,e,n),s.copy||(s.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),t},browser:e,event:{POINTER_START:e.POINTER_START,POINTER_MOVE:e.POINTER_MOVE,POINTER_END:e.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(t){var e;try{e=t.getBoundingClientRect()}catch(i){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var r=(n.pageXOffset||a.scrollLeft)-(a.clientLeft||0)||0,o=(n.pageYOffset||a.scrollTop)-(a.clientTop||0)||0,s=n.getComputedStyle?getComputedStyle(t):t.currentStyle,l=parseInt,h=l(s.paddingLeft)+l(s.borderLeftWidth)||0,c=l(s.paddingTop)+l(s.borderTopWidth)||0,u=l(s.paddingRight)+l(s.borderRightWidth)||0,d=l(s.paddingBottom)+l(s.borderBottomWidth)||0,f=e.top||0,p=e.left||0,v=e.right||0,m=e.bottom||0;return{left:p+r+h,top:f+o+c,width:v-u-p-h,height:m-d-f-c}},createElement:function(t,e){var i,n,a,o=r.createElement(t);for(i in e)if(n=e[i],"style"===i)for(a in n)o.style[a]=n[a];else o[i]=n;return o},getElement:function(t){return r.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,i=e.domElement.style,n=t._stateCache||(t._stateCache={}),r=l.browser.jsVendor,a="px",o=!1;if(this.cacheStateIfChanged(t,["visible"],n)&&(i.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],n)&&(i.opacity=t.alpha),t.visible&&!(t.alpha<=0)){if(this.cacheStateIfChanged(t,["width"],n)&&(i.width=t.width+a),this.cacheStateIfChanged(t,["height"],n)&&(i.height=t.height+a),this.cacheStateIfChanged(t,["depth"],n)&&(i.zIndex=t.depth+1),t.transform){var s=t.transform;(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],n))&&(i[r+"TransformOrigin"]="0 0"),i[r+"Transform"]="matrix3d("+s.a+", "+s.b+", 0, 0, "+s.c+", "+s.d+", 0, 0, 0, 0, 1, 0, "+s.tx+", "+s.ty+", 0, 1)"}else(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],n))&&(i[r+"TransformOrigin"]=t.pivotX+a+" "+t.pivotY+a),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],n)||o)&&(i[r+"Transform"]=this.getTransformCSS(t));this.cacheStateIfChanged(t,["background"],n)&&(i.backgroundColor=t.background),i.pointerEvents||(i.pointerEvents="none");var h=e.image;if(h){var c=h.src;c!==n.image&&(n.image=c,i.backgroundImage="url("+c+")");var u=e.rect;if(u){var d=u[0],f=u[1];d!==n.sx&&(n.sx=d,i.backgroundPositionX=-d+a),f!==n.sy&&(n.sy=f,i.backgroundPositionY=-f+a)}}var p=t.mask;if(p){var v=p.drawable.domElement.style.backgroundImage;v!==n.maskImage&&(n.maskImage=v,i[r+"MaskImage"]=v,i[r+"MaskRepeat"]="no-repeat");var m=p.x,g=p.y;m===n.maskX&&g===n.maskY||(n.maskX=m,n.maskY=g,i[r+"MaskPosition"]=m+a+" "+g+a)}}},cacheStateIfChanged:function(t,e,i){var n,r,a,o,s=!1;for(n=0,r=e.length;n=6?(e=s[0],i=s[1],n=s[2],r=s[3],a=s[4],o=s[5]):(e=t.a,i=t.b,n=t.c,r=t.d,a=t.tx,o=t.ty),this.a=l*e+h*n,this.b=l*i+h*r,this.c=c*e+u*n,this.d=c*i+u*r,this.tx=d*e+f*n+a,this.ty=d*i+f*r+o,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),n=this.a,r=this.b,a=this.c,o=this.d,s=this.tx,l=this.ty;return this.a=n*i-r*e,this.b=n*e+r*i,this.c=a*i-o*e,this.d=a*e+o*i,this.tx=s*i-l*e,this.ty=s*e+l*i,this},scale:function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},translate:function(t,e){return this.tx+=t,this.ty+=e,this},identity:function(){return this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this},invert:function(){var t=this.a,e=this.b,i=this.c,n=this.d,r=this.tx,a=t*n-e*i;return this.a=n/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-n*r)/a,this.ty=-(t*this.ty-e*r)/a,this},transformPoint:function(t,e,i){var n=t.x*this.a+t.y*this.c+this.tx,r=t.x*this.b+t.y*this.d+this.ty;return e&&(n=n+.5>>0,r=r+.5>>0),i?{x:n,y:r}:(t.x=n,t.y=r,t)}});t.Hilo.Matrix=i}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i={_listeners:null,on:function(t,e,i){for(var n=this._listeners=this._listeners||{},r=n[t]=n[t]||[],a=0,o=r.length;a-1&&o.splice(c,1)}}return 0==o.length&&delete a[r],!0}return!1}},n=e.create({constructor:function(t,e,i){this.type=t,this.target=e,this.detail=i,this.timeStamp=+new Date},type:null,target:null,detail:null,timeStamp:0,stopImmediatePropagation:function(){this._stopped=!0}}),r=t.Event;if(r){var a=r.prototype,o=a.stopImmediatePropagation;a.stopImmediatePropagation=function(){o&&o.call(this),this._stopped=!0}}t.Hilo.EventMixin=i}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i=t.Hilo.util,n=e.create({constructor:function(t){this.init(t)},image:null,rect:null,init:function(t){var e=this,r=e.image;n.isDrawable(t)?e.image=t:i.copy(e,t,!0);var a=e.image;if("string"==typeof a){if(!r||a!==r.getAttribute("src")){e.image=null;var o=new Image;return t.crossOrigin&&(o.crossOrigin=t.crossOrigin),o.onload=function(){o.onload=null,e.init(o)},void(o.src=a)}a=e.image=r}a&&!e.rect&&(e.rect=[0,0,a.width,a.height])},Statics:{isDrawable:function(t){if(!t||!t.tagName)return!1;var e=t.tagName.toLowerCase();return"img"===e||"canvas"===e||"video"===e}}});t.Hilo.Drawable=n}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i=t.Hilo.util,n=e.create({constructor:function(t){t=t||{},i.copy(this,t,!0)},renderType:null,canvas:null,stage:null,blendMode:"source-over",startDraw:function(t){},draw:function(t){},endDraw:function(t){},transform:function(){},hide:function(){},remove:function(t){},clear:function(t,e,i,n){},resize:function(t,e){}});t.Hilo.Renderer=n}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i=t.Hilo,n=t.Hilo.Renderer,r=e.create({Extends:n,constructor:function(t){r.superclass.constructor.call(this,t),this.context=this.canvas.getContext("2d")},renderType:"canvas",context:null,startDraw:function(t){return!!(t.visible&&t.alpha>0)&&(t===this.stage&&this.context.clearRect(0,0,t.width,t.height),t.blendMode!==this.blendMode&&(this.context.globalCompositeOperation=this.blendMode=t.blendMode),this.context.save(),!0)},draw:function(t){var e=this.context,i=t.width,n=t.height,r=t.background;r&&(e.fillStyle=r,e.fillRect(0,0,i,n));var a=t.drawable,o=a&&a.image;if(o){var s=a.rect,l=s[2],h=s[3],c=s[4],u=s[5];if(!l||!h)return;i||n||(i=t.width=l,n=t.height=h),(c||u)&&e.translate(c-.5*l,u-.5*h),e.drawImage(o,s[0],s[1],l,h,0,0,i,n)}},endDraw:function(t){this.context.restore()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void i.setElementStyleByView(t);var n=this.context,r=t.scaleX,a=t.scaleY;if(t===this.stage){var o=this.canvas.style,s=t._scaleX,l=t._scaleY,h=!1;(!s&&1!=r||s&&s!=r)&&(t._scaleX=r,o.width=r*t.width+"px",h=!0),(!l&&1!=a||l&&l!=a)&&(t._scaleY=a,o.height=a*t.height+"px",h=!0),h&&t.updateViewport()}else{var c=t.x,u=t.y,d=t.pivotX,f=t.pivotY,p=t.rotation%360,v=t.transform,m=t.mask;m&&(m._render(this),n.clip());var g=t.align;if(g){var _=t.getAlignPosition();c=_.x,u=_.y}v?n.transform(v.a,v.b,v.c,v.d,v.tx,v.ty):(0==c&&0==u||n.translate(c,u),0!=p&&n.rotate(p*Math.PI/180),1==r&&1==a||n.scale(r,a),0==d&&0==f||n.translate(-d,-f))}t.alpha>0&&(n.globalAlpha*=t.alpha)},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var n=i.parentNode;n&&n.removeChild(i)}},clear:function(t,e,i,n){this.context.clearRect(t,e,i,n)},resize:function(t,e){var i=this.canvas,n=this.stage,r=i.style;i.width=t,i.height=e,r.width=n.width*n.scaleX+"px",r.height=n.height*n.scaleY+"px"}});t.Hilo.CanvasRenderer=r}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i=t.Hilo,n=t.Hilo.Renderer,r=t.Hilo.Drawable,a=function(){function t(t,e){var n=t.tagName||"div",r=e.image,a=t.width||r&&r.width,o=t.height||r&&r.height,s=i.createElement(n),l=s.style;if(t.id&&(s.id=t.id),l.position="absolute",l.left=(t.left||0)+"px",l.top=(t.top||0)+"px",l.width=a+"px",l.height=o+"px","canvas"==n){if(s.width=a,s.height=o,r){var h=s.getContext("2d"),c=e.rect||[0,0,a,o];h.drawImage(r,c[0],c[1],c[2],c[3],t.x||0,t.y||0,t.width||c[2],t.height||c[3])}}else if(l.opacity=void 0!=t.alpha?t.alpha:1,(t===this.stage||t.clipChildren)&&(l.overflow="hidden"),r&&r.src){l.backgroundImage="url("+r.src+")";var u=t.rectX||0,d=t.rectY||0;l.backgroundPosition=-u+"px "+-d+"px"}return s}return e.create({Extends:n,constructor:function(t){a.superclass.constructor.call(this,t)},renderType:"dom",startDraw:function(e){var i=e.drawable=e.drawable||new r;return i.domElement=i.domElement||t(e,i),!0},draw:function(t){var e=t.parent,i=t.drawable.domElement,n=i.parentNode;if(e){var r=e.drawable.domElement;if(r!=n&&r.appendChild(i),!t.width&&!t.height){var a=t.drawable.rect;a&&(a[2]||a[3])&&(t.width=a[2],t.height=a[3])}}else t!==this.stage||n||(i.style.overflow="hidden",this.canvas.appendChild(i))},transform:function(t){if(i.setElementStyleByView(t),t===this.stage){var e=this.canvas.style,n=t._scaleX,r=t._scaleY,a=t.scaleX,o=t.scaleY;(!n&&1!=a||n&&n!=a)&&(t._scaleX=a,e.width=a*t.width+"px"),(!r&&1!=o||r&&r!=o)&&(t._scaleY=o,e.height=o*t.height+"px")}},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var n=i.parentNode;n&&n.removeChild(i)}},hide:function(t){var e=t.drawable&&t.drawable.domElement;e&&(e.style.display="none")},resize:function(t,e){var i=this.canvas.style;i.width=t+"px",i.height=e+"px","absolute"!=i.position&&(i.position="relative")}})}();t.Hilo.DOMRenderer=a}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i=t.Hilo,n=t.Hilo.Renderer,r=t.Hilo.Matrix,a=Math.PI/180,o=e.create({Extends:n,Statics:{MAX_BATCH_NUM:2e3,ATTRIBUTE_NUM:5,isSupport:function(){if(void 0==this._isSupported){var t=document.createElement("canvas");t.getContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))?this._isSupported=!0:this._isSupported=!1}return this._isSupported},contextOptions:null},renderType:"webgl",gl:null,_isContextLost:!1,_cacheTexture:{},constructor:function(t){o.superclass.constructor.call(this,t);var e=this,i=o.contextOptions||{};this.gl=this.canvas.getContext("webgl",i)||this.canvas.getContext("experimental-webgl",i),this.maxBatchNum=o.MAX_BATCH_NUM,this.positionStride=4*o.ATTRIBUTE_NUM;var n=this.maxBatchNum*o.ATTRIBUTE_NUM*4,r=6*this.maxBatchNum;this.arrayBuffer=new ArrayBuffer(4*n),this.float32Array=new Float32Array(this.arrayBuffer),this.uint32Array=new Uint32Array(this.arrayBuffer),this.indexs=new Uint16Array(r);for(var a=0,s=0;a0)&&(t===this.stage&&this.clear(),!0)},draw:function(t){var e=t.width,i=t.height,n=(t.background,t.drawable),r=n&&n.image;if(r){var a=n.rect,o=a[2],s=a[3];e||i||(e=t.width=o,i=t.height=s),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var l=this._createVertexs(r,a[0],a[1],o,s,0,0,e,i),h=this.batchIndex*this.positionStride,c=this.float32Array,u=this.uint32Array,d=(t.tint>>16)+(65280&t.tint)+((255&t.tint)<<16)+(255*t.__webglRenderAlpha<<24);c[h+0]=l[0],c[h+1]=l[1],c[h+2]=l[2],c[h+3]=l[3],u[h+4]=d,c[h+5]=l[4],c[h+6]=l[5],c[h+7]=l[6],c[h+8]=l[7],u[h+9]=d,c[h+10]=l[8],c[h+11]=l[9],c[h+12]=l[10],c[h+13]=l[11],u[h+14]=d,c[h+15]=l[12],c[h+16]=l[13],c[h+17]=l[14],c[h+18]=l[15],u[h+19]=d;for(var f=t.__webglWorldMatrix,p=0;p<4;p++){var v=c[h+5*p],m=c[h+5*p+1];c[h+5*p]=f.a*v+f.c*m+f.tx,c[h+5*p+1]=f.b*v+f.d*m+f.ty}t.__textureImage=r,this.sprites[this.batchIndex++]=t}},endDraw:function(t){t===this.stage&&this._renderBatches()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void i.setElementStyleByView(t);var n=t.scaleX,a=t.scaleY;if(t===this.stage){var o=this.canvas.style,s=t._scaleX,l=t._scaleY,h=!1;(!s&&1!=n||s&&s!=n)&&(t._scaleX=n,o.width=n*t.width+"px",h=!0),(!l&&1!=a||l&&l!=a)&&(t._scaleY=a,o.height=a*t.height+"px",h=!0),h&&t.updateViewport(),t.__webglWorldMatrix=t.__webglWorldMatrix||new r(1,0,0,1,0,0)}else t.parent&&(t.__webglWorldMatrix=t.__webglWorldMatrix||new r(1,0,0,1,0,0),this._setConcatenatedMatrix(t,t.parent));t.alpha>0&&(t.parent&&t.parent.__webglRenderAlpha?t.__webglRenderAlpha=t.alpha*t.parent.__webglRenderAlpha:t.__webglRenderAlpha=t.alpha)},remove:function(t){var e=t.drawable,i=e&&e.domElement;if(i){var n=i.parentNode;n&&n.removeChild(i)}},clear:function(t,e,i,n){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(t,e){if(this.width!==t||this.height!==e){var i=this.canvas,n=this.stage,r=i.style;this.width=i.width=t,this.height=i.height=e,r.width=n.width*n.scaleX+"px",r.height=n.height*n.scaleY+"px",this.gl.viewport(0,0,t,e),this.canvasHalfWidth=.5*t,this.canvasHalfHeight=.5*e,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var t=this.gl;t.bufferSubData(t.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var e=0,i=0,n=null,r=0;r0&&(i.bindTexture(i.TEXTURE_2D,this._getTexture(this.sprites[t])),i.drawElements(i.TRIANGLES,6*n,i.UNSIGNED_SHORT,6*t*2))},_uploadProjectionTransform:function(t){this._projectionTransformElements&&!t||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var t=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",e="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new s(this,{v:t,f:e},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(t,e,i,n,r,a,o,s,l){var h=this.__tempVertexs||[],c=t.width,u=t.height;n/=c,r/=u,e/=c,i/=u,s=s,l=l,a=a,o=o,n+e>1&&(n=1-e),r+i>1&&(r=1-i);var d=0;return h[d++]=a,h[d++]=o,h[d++]=e,h[d++]=i,h[d++]=a+s,h[d++]=o,h[d++]=e+n,h[d++]=i,h[d++]=a,h[d++]=o+l,h[d++]=e,h[d++]=i+r,h[d++]=a+s,h[d++]=o+l,h[d++]=e+n,h[d++]=i+r,h},_setConcatenatedMatrix:function(t,e){var i=t.__webglWorldMatrix,n=1,r=0,o=t.rotation%360,s=t.pivotX,l=t.pivotY,h=t.scaleX,c=t.scaleY,u=t.transform;if(u)i.copy(u);else{if(o){var d=o*a;n=Math.cos(d),r=Math.sin(d)}var f=t.getAlignPosition();i.a=n*h,i.b=r*h,i.c=-r*c,i.d=n*c,i.tx=f.x-i.a*s-i.c*l,i.ty=f.y-i.b*s-i.d*l}i.concat(e.__webglWorldMatrix)},_getTexture:function(t){var e=t.__textureImage,i=this._cacheTexture[e.src];return i||(i=this.activeShader.uploadTexture(e)),i}}),s=function(t,e,i){this.renderer=t,this.gl=t.gl,this.program=this._createProgram(this.gl,e.v,e.f),i=i||{},this.attributes=i.attributes||[],this.uniforms=i.uniforms||[]};s.prototype={active:function(){var t=this,e=t.renderer,i=t.gl,n=t.program;n&&i&&(e.activeShader=t,i.useProgram(n),t.attributes.forEach(function(t){e[t]=i.getAttribLocation(n,t),i.enableVertexAttribArray(e[t])}),t.uniforms.forEach(function(t){e[t]=i.getUniformLocation(n,t)}),t.width===e.width&&t.height===e.height||(t.width=e.width,t.height=e.height,e._uploadProjectionTransform()))},uploadTexture:function(t){var e=this.gl,i=this.renderer,n=e.createTexture(),r=i.u_Sampler;return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,n),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(r,0),e.bindTexture(e.TEXTURE_2D,null),this.renderer._cacheTexture[t.src]=n,n},_createProgram:function(t,e,i){var n=this._createShader(t,t.VERTEX_SHADER,e),r=this._createShader(t,t.FRAGMENT_SHADER,i);if(!n||!r)return null;var a=t.createProgram();if(a){t.attachShader(a,n),t.attachShader(a,r),t.linkProgram(a),t.deleteShader(r),t.deleteShader(n);var o=t.getProgramParameter(a,t.LINK_STATUS);if(!o){var s=t.getProgramInfoLog(a);return console.log("Failed to link program: "+s),t.deleteProgram(a),null}}return a},_createShader:function(t,e,i){var n=t.createShader(e);if(n){t.shaderSource(n,i),t.compileShader(n);var r=t.getShaderParameter(n,t.COMPILE_STATUS);if(!r){var a=t.getShaderInfoLog(n);return console.log("Failed to compile shader: "+a),t.deleteShader(n),null}}return n}},t.Hilo.WebGLRenderer=o}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo,i=t.Hilo.Class,n=t.Hilo.EventMixin,r=t.Hilo.Matrix,a=t.Hilo.util,o=function(){function t(t,e,i){for(var n,r,a,o,s=0,l=!1,h=0,c=i.length;hd.x?(n=d.x,r=u.x):(n=u.x,r=d.x),t>=n&&t<=r))l=!0;else if(u.y>d.y?(a=d.y,o=u.y):(a=u.y,o=d.y),!(eo)){var f=(e-u.y)*(d.x-u.x)/(d.y-u.y)+u.x;if(f>t?s++:f==t&&(l=!0),u.x>t&&u.y==e){var p=i[(c+h-1)%c];(p.ye||p.y>e&&d.ys?s=c:ch?h=c:c=0)return!1;u>i.overlap&&(i.overlap=u,i.normal.x=p.x,i.normal.y=p.y)}return i}return i.create({Mixes:n,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("View"),a.copy(this,t,!0)},tint:16777215,id:null,x:0,y:0,width:0,height:0,alpha:1,rotation:0,visible:!0,pivotX:0,pivotY:0,scaleX:1,scaleY:1,pointerEnabled:!0,background:null,mask:null,align:null,drawable:null,boundsArea:null,parent:null,depth:-1,transform:null,blendMode:"source-over",getStage:function(){for(var t,e=this;t=e.parent;)e=t;return e.canvas?e:null},getScaledWidth:function(){return this.width*this.scaleX},getScaledHeight:function(){return this.height*this.scaleY},addTo:function(t,e){return"number"==typeof e?t.addChildAt(this,e):t.addChild(this),this},removeFromParent:function(){var t=this.parent;return t&&t.removeChild(this),this},getBounds:function(){for(var t,e,i,n,r,a,o,s=this.width,l=this.height,h=this.getConcatenatedMatrix(),c=this.boundsArea||[{x:0,y:0},{x:s,y:0},{x:s,y:l},{x:0,y:l}],u=[],d=0,f=c.length;de?n=e:ri?a=i:o>1,n=0;break;case"TR":i=o-r,n=0;break;case"L":i=0,n=s-a>>1;break;case"C":i=o-r>>1,n=s-a>>1;break;case"R":i=o-r,n=s-a>>1;break;case"BL":i=0,n=s-a;break;case"B":i=o-r>>1,n=s-a;break;case"BR":i=o-r,n=s-a}}return{x:i,y:n}},hitTestPoint:function(e,i,n){var r=this.getBounds(),a=e>=r.x&&e<=r.x+r.width&&i>=r.y&&i<=r.y+r.height;return a&&n&&(a=t(e,i,r)),a},hitTestObject:function(t,e){var i=this.getBounds(),n=t.getBounds(),r=i.x<=n.x+n.width&&n.x<=i.x+i.width&&i.y<=n.y+n.height&&n.y<=i.y+i.height;return r&&e&&(r=o(i,n)),!!r},_render:function(t,e){this.onUpdate&&this.onUpdate(e)===!1||!t.startDraw(this)||(t.transform(this),this.render(t,e),t.endDraw(this))},_fireMouseEvent:function(t){if(t.eventCurrentTarget=this,this.fire(t),"mousemove"==t.type){if(!this.__mouseOver){this.__mouseOver=!0;var e=a.copy({},t);e.type="mouseover",this.fire(e)}}else"mouseout"==t.type&&(this.__mouseOver=!1);var i=this.parent;t._stopped||t._stopPropagationed||!i||("mouseout"==t.type||"touchout"==t.type?i.hitTestPoint(t.stageX,t.stageY,!0)||i._fireMouseEvent(t):i._fireMouseEvent(t))},onUpdate:null,render:function(t,e){t.draw(this)},toString:function(){return e.viewToString(this)}})}();t.Hilo.View=o}(window),function(t){t.Hilo||(t.Hilo={});var e,i,n=t.Hilo.Drawable,r=t.Hilo.browser,a={_cacheDirty:!0,cache:function(t){(t||this._cacheDirty||!this.drawable)&&this.updateCache()},updateCache:function(){r.supportCanvas&&(e||(e=document.createElement("canvas"),i=e.getContext("2d")),e.width=this.width,e.height=this.height,this._draw(i),this.drawable=this.drawable||new n,this.drawable.init({image:e.toDataURL()}),this._cacheDirty=!1)},setCacheDirty:function(t){this._cacheDirty=t}};t.Hilo.CacheMixin=a}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo,i=t.Hilo.Class,n=t.Hilo.View,r=i.create({Extends:n,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("Container"),r.superclass.constructor.call(this,t),this.children?this._updateChildren():this.children=[]},children:null,pointerChildren:!0,clipChildren:!1,getNumChildren:function(){return this.children.length},addChildAt:function(t,e){var i=this.children,n=i.length,r=t.parent;e=e<0?0:e>n?n:e;var a=this.getChildIndex(t);if(a==e)return this;if(a>=0?(i.splice(a,1),e=e==n?n-1:e):r&&r.removeChild(t),i.splice(e,0,t),a<0)this._updateChildren(e);else{var o=a=e.length)return null;var i=e[t];if(i){if(!i.__renderer)for(var n=i;n=n.parent;){if(n.renderer){i.__renderer=n.renderer;break}if(n.__renderer){i.__renderer=n.__renderer;break}}i.__renderer&&i.__renderer.remove(i),i.parent=null,i.depth=-1}return e.splice(t,1),this._updateChildren(t),i},removeChild:function(t){return this.removeChildAt(this.getChildIndex(t))},removeChildById:function(t){for(var e,i=this.children,n=0,r=i.length;n=e.length?null:e[t]},getChildById:function(t){for(var e,i=this.children,n=0,r=i.length;n=0&&n!=e){var r=i.length;e=e<0?0:e>=r?r-1:e,i.splice(n,1),i.splice(e,0,t),this._updateChildren()}return this},swapChildren:function(t,e){var i=this.children,n=this.getChildIndex(t),r=this.getChildIndex(e);t.depth=r,i[r]=t,e.depth=n,i[n]=e},swapChildrenAt:function(t,e){var i=this.children,n=this.getChildAt(t),r=this.getChildAt(e);n.depth=e,i[e]=n,r.depth=t,i[t]=r},sortChildren:function(t){var e=t,i=this.children;if("string"==typeof e){var n=e;e=function(t,e){return e[n]-t[n]}}i.sort(e),this._updateChildren()},_updateChildren:function(t,e){var i,n=this.children;t=t||0,e=e||n.length;for(var r=t;r=0;h--)if(a=l[h],!(!a||!a.visible||a.alpha<=0||r&&!a.pointerEnabled))if(a.children&&a.children.length&&(!r||a.pointerChildren)&&(o=a.getViewAtPoint(t,e,i,n,r)),o){if(!n)return o;o.length&&(s=s.concat(o))}else if(a.hitTestPoint(t,e,i)){if(!n)return a;s.push(a)}return n&&s.length?s:null},render:function(t,e){r.superclass.render.call(this,t,e);var i,n,a,o=this.children.slice(0);for(i=0,n=o.length;in?n:e,i[e]=t,t.name&&(this._frameNames[t.name]=t),(0!=e||this.width)&&this.height||(this.width=t.rect[2],this.height=t.rect[3]),this},getFrame:function(t){if("number"==typeof t){var e=this._frames;return t<0||t>=e.length?null:e[t]}return this._frameNames[t]},getFrameIndex:function(t){var e=this._frames,i=e.length,n=-1;if("number"==typeof t)n=t;else{var r="string"==typeof t?this._frameNames[t]:t;if(r)for(var a=0;a=i?i-1:n,this.paused=e,this._firstRender=!0,this},_render:function(t,e){var i,n=this.currentFrame;if(this._firstRender?(i=n,this._firstRender=!1):i=this._nextFrame(e),i!=n){this.currentFrame=i;var r=this._frames[i].callback;r&&r.call(this)}this.onEnterFrame&&this.onEnterFrame(i),this.drawable.init(this._frames[i]),a.superclass._render.call(this,t,e)},_nextFrame:function(t){var e=this._frames,i=e.length,n=this.currentFrame,r=e[n],a=r.duration||this.interval,o=this._frameElapsed,s=0!=n||this.drawable?o+(this.timeBased?t:1):0;return o=this._frameElapsed=s=i-1)&&this.stop(),this.paused||0!=o||(null!=r.next?n=this.getFrameIndex(r.next):n>=i-1?n=0:this.drawable&&n++),n},setFrameCallback:function(t,e){return t=this.getFrame(t),t&&(t.callback=e),this},onEnterFrame:null});t.Hilo.Sprite=a}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo,i=t.Hilo.Class,n=t.Hilo.View,r=t.Hilo.Drawable,a=i.create({Extends:n,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("DOMElement"),a.superclass.constructor.call(this,t),this.drawable=new r;var i=this.drawable.domElement=t.element||e.createElement("div");i.id=this.id,this.pointerEnabled&&!i.style.pointerEvents&&(i.style.pointerEvents="visible")},_render:function(t,e){this.onUpdate&&this.onUpdate(e)===!1||(t.transform(this),this.visible&&this.alpha>0&&this.render(t,e))},render:function(t,i){if("dom"!==t.renderType){var n=t.canvas,r=this.parent,a=t._domElementContainer;t._domElementContainer||(a=t._domElementContainer=e.createElement("div",{style:{position:"absolute",transform:"scale3d("+r.scaleX+","+r.scaleY+", 1)",transformOrigin:"0 0",zIndex:"1"}}),n.parentNode.insertBefore(t._domElementContainer,n.nextSibling));var o,s=this.drawable.domElement,l=this.depth,h=a.childNodes[0];if(s.parentNode)return;for(;h&&3!=h.nodeType&&(o=parseInt(h.style.zIndex)||0,!(o<=0||o>l));)h=h.nextSibling;a.insertBefore(this.drawable.domElement,h)}else t.draw(this)}});t.Hilo.DOMElement=a}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo,i=t.Hilo.Class,n=t.Hilo.View,r=t.Hilo.CacheMixin,a=function(){var t=document.createElement("canvas"),o=t.getContext&&t.getContext("2d");return i.create({Extends:n,Mixes:r,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("Graphics"),a.superclass.constructor.call(this,t),this._actions=[]},lineWidth:1,lineAlpha:1,lineCap:null,lineJoin:null,miterLimit:10,hasStroke:!1,strokeStyle:"0",hasFill:!1,fillStyle:"0",fillAlpha:0,lineStyle:function(t,e,i,n,r,a){var o=this,s=o._addAction;return s.call(o,["lineWidth",o.lineWidth=t||1]),s.call(o,["strokeStyle",o.strokeStyle=e||"0"]),s.call(o,["lineAlpha",o.lineAlpha=i||1]),void 0!=n&&s.call(o,["lineCap",o.lineCap=n]),void 0!=r&&s.call(o,["lineJoin",o.lineJoin=r]),void 0!=a&&s.call(o,["miterLimit",o.miterLimit=a]),o.hasStroke=!0,o},setLineDash:function(t){return this._addAction(["setLineDash",t])},beginFill:function(t,e){var i=this,n=i._addAction;return n.call(i,["fillStyle",i.fillStyle=t]),n.call(i,["fillAlpha",i.fillAlpha=e||1]),i.hasFill=!0,i},endFill:function(){var t=this,e=t._addAction;return t.hasStroke&&e.call(t,["stroke"]),t.hasFill&&e.call(t,["fill"]),t.setCacheDirty(!0),t},beginLinearGradientFill:function(t,e,i,n,r,a){for(var s=this,l=o.createLinearGradient(t,e,i,n),h=0,c=r.length;h1?a.slice(1):null;"function"==typeof t[o]?t[o].apply(t,s):t[o]=a[1]}},render:function(t,e){var i=this;"canvas"===t.renderType?i._draw(t.context):(i.cache(),t.draw(i))},clear:function(){var t=this;return t._actions.length=0,t.lineWidth=1,t.lineAlpha=1,t.lineCap=null,t.lineJoin=null,t.miterLimit=10,t.hasStroke=!1,t.strokeStyle="0",t.hasFill=!1,t.fillStyle="0",t.fillAlpha=1,t.setCacheDirty(!0),t},_addAction:function(t){var e=this;return e._actions.push(t),e}})}();t.Hilo.Graphics=a}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i=t.Hilo,n=t.Hilo.View,r=t.Hilo.CacheMixin,a=e.create({Extends:n,Mixes:r,constructor:function(t){t=t||{},this.id=this.id||t.id||i.getUid("Text"),a.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=a.measureFontHeight(this.font)},text:"",color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=a.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var n=i.drawable,r=n.domElement,a=r.style;a.font=i.font,a.textAlign=i.textAlign,a.color=i.color,a.width=i.width+"px",a.height=i.height+"px",a.lineHeight=i._fontHeight+i.lineSpacing+"px",r.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var n,r,a,o,s,l=i.split(/\r\n|\r|\n|/),h=0,c=0,u=e._fontHeight+e.lineSpacing,d=[];for(n=0,o=l.length;ne.maxWidth?(d.push({text:m,y:c}),h>1;break;case"bottom":_=e.height-e.textHeight}var x=e.background;for(x&&(t.fillStyle=x,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,n=0;n>1;break;case"right":case"end":r=a}n.outline?t.strokeText(e,r,i):t.fillText(e,r,i)},Statics:{measureFontHeight:function(t){var e,n=document.documentElement,r=i.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return n.appendChild(r),e=r.offsetHeight,n.removeChild(r),e}}});t.Hilo.Text=a}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i=t.Hilo,n=t.Hilo.Container,r=t.Hilo.Bitmap,a=e.create({Extends:n,constructor:function(t){t=t||{},this.id=this.id||t.id||i.getUid("BitmapText"),a.superclass.constructor.call(this,t);var e=t.text+"";e&&(this.text="",this.setText(e)),this.pointerChildren=!1},glyphs:null,letterSpacing:0,text:"",textAlign:"left",setText:function(t){var e=this,i=t.toString(),n=i.length;if(e.text!=i){e.text=i;var r,a,o,s,l=0,h=0,c=0;for(r=0;r0?e.letterSpacing:0),e.children[r]?(s=e.children[r],s.setImage(o.image,o.rect)):(s=e._createBitmap(o),e.addChild(s)),s.x=c,l=c+o.rect[2],h=Math.max(h,o.rect[3]));for(r=e.children.length-1;r>=n;r--)e._releaseBitmap(e.children[r]),e.children[r].removeFromParent();return e.width=l,e.height=h,this.setTextAlign(),e}},_createBitmap:function(t){var e;return a._pool.length?(e=a._pool.pop(),e.setImage(t.image,t.rect)):e=new r({image:t.image,rect:t.rect}),e},_releaseBitmap:function(t){a._pool.push(t)},setTextAlign:function(t){switch(this.textAlign=t||this.textAlign,this.textAlign){case"center":this.pivotX=.5*this.width;break;case"right":this.pivotX=this.width;break;case"left":default:this.pivotX=0}return this},hasGlyphs:function(t){var e=this.glyphs;if(!e)return!1;t=t.toString();var i,n=t.length;for(i=0;i=this._targetFPS?(this._measuredFPS=1e3/(this._tickTime/this._tickCount)+.5>>0,this._tickCount=0,this._tickTime=0):this._tickTime+=t-this._lastTime,this._lastTime=t;for(var n=i.slice(0),r=0,a=n.length;r=0&&e.splice(i,1)},nextTick:function(t){var e=this,i={tick:function(n){e.removeTick(i),t()}};return e.addTick(i),i},timeout:function(t,e){var i=this,n=(new Date).getTime()+e,r={tick:function(){var e=(new Date).getTime(),a=e-n;a>=0&&(i.removeTick(r),t())}};return i.addTick(r),r},interval:function(t,e){var i=this,n=(new Date).getTime()+e,r={tick:function(){var i=(new Date).getTime(),r=i-n;r>=0&&(r=n)return-1;for(e<0&&(e=n+e),i=e;i=1?1:s;var h=r.ease?r.ease(s):s;r.reverse&&(r._reverseFlag<0&&(s=1-s,h=1-h),s<1e-7&&(r.repeat>0&&r._repeatCount++>=r.repeat||0==r.repeat&&!r.loop?l=!0:(r._startTime=t(),r._pausedTime=0,r._reverseFlag*=-1))),r.isStart||(r.setProps(r._fromProps,r._toProps),r.isStart=!0,r.onStart&&r.onStart.call(r,r)),r.time=a,r._render(h),(o=r.onUpdate)&&o.call(r,s,r),s>=1&&(r.reverse?(r._startTime=t(),r._pausedTime=0,r._reverseFlag*=-1):r.loop||r.repeat>0&&r._repeatCount++0&&u<=e?(c._render(s),c.time=a,i.add(c)):l&&(u<0||u>e)&&c.start()}return l?((o=r.onComplete)&&o.call(r,r),!0):void 0}}},Statics:{_tweens:[],tick:function(){var e,n,r=i._tweens,a=r.length;for(n=0;n-1&&r.splice(e,1);else for(e=0;e=i)return void t.fire("complete");if(t._currentIndexe.z})},tick:function(){this.sortZ()}});return o}();t.Hilo.Camera3d=n}(window),function(t){t.Hilo||(t.Hilo={});var e=t.Hilo,i=t.Hilo.Class,n=t.Hilo.View,r=t.Hilo.Container,a=t.Hilo.Drawable,o=t.Hilo.util,s=function(){function t(t,e){return e?t+2*(Math.random()-.5)*e:t}for(var s=["x","y","vx","vy","ax","ay","rotation","rotationV","scale","scaleV","alpha","alphaV","life"],l=[],h=0,c=s.length;h=this._emitTime&&(this._currentRunTime=0,this._emitTime=t(this.emitTime,this.emitTimeVar),this._emit()),this._totalRunTime>=this.totalTime&&this.stop())},_emit:function(){for(var e=t(this.emitNum,this.emitNumVar)>>0,i=0;i=0;e--)this.children[e].destroy()}}),v=i.create({Extends:n,constructor:function(t){this.id=this.id||t.id||e.getUid("Particle"),v.superclass.constructor.call(this,t),this.init(t)},onUpdate:function(t){if(t*=.001,this._died)return!1;var e=this.ax+this.system.gx,i=this.ay+this.system.gy;return this.vx+=e*t,this.vy+=i*t,this.x+=this.vx*t,this.y+=this.vy*t,this.rotation+=this.rotationV,this._time>.1&&(this.alpha+=this.alphaV),this.scale+=this.scaleV,this.scaleX=this.scaleY=this.scale,this._time+=t,this._time>=this.life||this.alpha<=0?(this.destroy(),!1):void 0},setImage:function(t,e){this.drawable=this.drawable||new a,e=e||[0,0,t.width,t.height],this.width=e[2],this.height=e[3],this.drawable.rect=e,this.drawable.image=t},destroy:function(){this._died=!0,this.alpha=0,this.removeFromParent(),f.push(this)},init:function(e){this.system=e.system,this._died=!1,this._time=0,this.alpha=1;for(var i=0,n=l.length;i>0]),this.setImage(e.image,o),void 0!==e.pivotX&&(this.pivotX=e.pivotX*o[2]),void 0!==e.pivotY&&(this.pivotY=e.pivotY*o[3])}},Statics:{create:function(t){if(f.length>0){var e=f.pop();return e.init(t),e}return new v(t)}}});return p}();t.Hilo.ParticleSystem=s}(window); \ No newline at end of file diff --git a/build/standalone/hilo-standalone.zip b/build/standalone/hilo-standalone.zip index aace432d..c4feafa1 100644 Binary files a/build/standalone/hilo-standalone.zip and b/build/standalone/hilo-standalone.zip differ diff --git a/build/standalone/hilo/core/Class.js b/build/standalone/hilo/core/Class.js index 47849497..d71a2188 100644 --- a/build/standalone/hilo/core/Class.js +++ b/build/standalone/hilo/core/Class.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/core/Class.min.js b/build/standalone/hilo/core/Class.min.js index 26fc4f15..535f7a81 100644 --- a/build/standalone/hilo/core/Class.min.js +++ b/build/standalone/hilo/core/Class.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/core/Hilo.js b/build/standalone/hilo/core/Hilo.js index 0073f71e..258e62c4 100644 --- a/build/standalone/hilo/core/Hilo.js +++ b/build/standalone/hilo/core/Hilo.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -29,7 +29,7 @@ var Hilo = { * Hilo version * @type String */ - version: '1.3.0', + version: '1.4.0', /** * @language=en * Gets a globally unique id. Such as Stage1, Bitmap2 etc. diff --git a/build/standalone/hilo/core/Hilo.min.js b/build/standalone/hilo/core/Hilo.min.js index 65930db8..75beb077 100644 --- a/build/standalone/hilo/core/Hilo.min.js +++ b/build/standalone/hilo/core/Hilo.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ -!function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.browser,a=t.Hilo.util,o=t,r=document,n=r.documentElement,i=0,s={},c={version:"1.3.0",getUid:function(t){var e=++i;if(t){var a=t.charCodeAt(t.length-1);return a>=48&&a<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,a=t;a;)e=e?a.id+"."+e:a.id,a=a.parent;return e},copy:function(t,e,o){return a.copy(t,e,o),s.copy||(s.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),t},browser:e,event:{POINTER_START:e.POINTER_START,POINTER_MOVE:e.POINTER_MOVE,POINTER_END:e.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(t){var e;try{e=t.getBoundingClientRect()}catch(a){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var r=(o.pageXOffset||n.scrollLeft)-(n.clientLeft||0)||0,i=(o.pageYOffset||n.scrollTop)-(n.clientTop||0)||0,s=o.getComputedStyle?getComputedStyle(t):t.currentStyle,c=parseInt,f=c(s.paddingLeft)+c(s.borderLeftWidth)||0,h=c(s.paddingTop)+c(s.borderTopWidth)||0,d=c(s.paddingRight)+c(s.borderRightWidth)||0,l=c(s.paddingBottom)+c(s.borderBottomWidth)||0,g=e.top||0,p=e.left||0,m=e.right||0,T=e.bottom||0;return{left:p+r+f,top:g+i+h,width:m-d-p-f,height:T-l-g-h}},createElement:function(t,e){var a,o,n,i=r.createElement(t);for(a in e)if(o=e[a],"style"===a)for(n in o)i.style[n]=o[n];else i[a]=o;return i},getElement:function(t){return r.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,a=e.domElement.style,o=t._stateCache||(t._stateCache={}),r=c.browser.jsVendor,n="px",i=!1;if(this.cacheStateIfChanged(t,["visible"],o)&&(a.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],o)&&(a.opacity=t.alpha),t.visible&&!(t.alpha<=0)){if(this.cacheStateIfChanged(t,["width"],o)&&(a.width=t.width+n),this.cacheStateIfChanged(t,["height"],o)&&(a.height=t.height+n),this.cacheStateIfChanged(t,["depth"],o)&&(a.zIndex=t.depth+1),t.transform){var s=t.transform;(i=this.cacheStateIfChanged(t,["pivotX","pivotY"],o))&&(a[r+"TransformOrigin"]="0 0"),a[r+"Transform"]="matrix3d("+s.a+", "+s.b+", 0, 0, "+s.c+", "+s.d+", 0, 0, 0, 0, 1, 0, "+s.tx+", "+s.ty+", 0, 1)"}else(i=this.cacheStateIfChanged(t,["pivotX","pivotY"],o))&&(a[r+"TransformOrigin"]=t.pivotX+n+" "+t.pivotY+n),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],o)||i)&&(a[r+"Transform"]=this.getTransformCSS(t));this.cacheStateIfChanged(t,["background"],o)&&(a.backgroundColor=t.background),a.pointerEvents||(a.pointerEvents="none");var f=e.image;if(f){var h=f.src;h!==o.image&&(o.image=h,a.backgroundImage="url("+h+")");var d=e.rect;if(d){var l=d[0],g=d[1];l!==o.sx&&(o.sx=l,a.backgroundPositionX=-l+n),g!==o.sy&&(o.sy=g,a.backgroundPositionY=-g+n)}}var p=t.mask;if(p){var m=p.drawable.domElement.style.backgroundImage;m!==o.maskImage&&(o.maskImage=m,a[r+"MaskImage"]=m,a[r+"MaskRepeat"]="no-repeat");var T=p.x,u=p.y;T===o.maskX&&u===o.maskY||(o.maskX=T,o.maskY=u,a[r+"MaskPosition"]=T+n+" "+u+n)}}},cacheStateIfChanged:function(t,e,a){var o,r,n,i,s=!1;for(o=0,r=e.length;o=48&&a<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,a=t;a;)e=e?a.id+"."+e:a.id,a=a.parent;return e},copy:function(t,e,o){return a.copy(t,e,o),s.copy||(s.copy=!0,console.warn("Hilo.copy has been Deprecated! Use Hilo.util.copy instead.")),t},browser:e,event:{POINTER_START:e.POINTER_START,POINTER_MOVE:e.POINTER_MOVE,POINTER_END:e.POINTER_END},align:{TOP_LEFT:"TL",TOP:"T",TOP_RIGHT:"TR",LEFT:"L",CENTER:"C",RIGHT:"R",BOTTOM_LEFT:"BL",BOTTOM:"B",BOTTOM_RIGHT:"BR"},getElementRect:function(t){var e;try{e=t.getBoundingClientRect()}catch(a){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var r=(o.pageXOffset||n.scrollLeft)-(n.clientLeft||0)||0,i=(o.pageYOffset||n.scrollTop)-(n.clientTop||0)||0,s=o.getComputedStyle?getComputedStyle(t):t.currentStyle,c=parseInt,f=c(s.paddingLeft)+c(s.borderLeftWidth)||0,h=c(s.paddingTop)+c(s.borderTopWidth)||0,d=c(s.paddingRight)+c(s.borderRightWidth)||0,l=c(s.paddingBottom)+c(s.borderBottomWidth)||0,g=e.top||0,p=e.left||0,m=e.right||0,T=e.bottom||0;return{left:p+r+f,top:g+i+h,width:m-d-p-f,height:T-l-g-h}},createElement:function(t,e){var a,o,n,i=r.createElement(t);for(a in e)if(o=e[a],"style"===a)for(n in o)i.style[n]=o[n];else i[a]=o;return i},getElement:function(t){return r.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,a=e.domElement.style,o=t._stateCache||(t._stateCache={}),r=c.browser.jsVendor,n="px",i=!1;if(this.cacheStateIfChanged(t,["visible"],o)&&(a.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],o)&&(a.opacity=t.alpha),t.visible&&!(t.alpha<=0)){if(this.cacheStateIfChanged(t,["width"],o)&&(a.width=t.width+n),this.cacheStateIfChanged(t,["height"],o)&&(a.height=t.height+n),this.cacheStateIfChanged(t,["depth"],o)&&(a.zIndex=t.depth+1),t.transform){var s=t.transform;(i=this.cacheStateIfChanged(t,["pivotX","pivotY"],o))&&(a[r+"TransformOrigin"]="0 0"),a[r+"Transform"]="matrix3d("+s.a+", "+s.b+", 0, 0, "+s.c+", "+s.d+", 0, 0, 0, 0, 1, 0, "+s.tx+", "+s.ty+", 0, 1)"}else(i=this.cacheStateIfChanged(t,["pivotX","pivotY"],o))&&(a[r+"TransformOrigin"]=t.pivotX+n+" "+t.pivotY+n),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],o)||i)&&(a[r+"Transform"]=this.getTransformCSS(t));this.cacheStateIfChanged(t,["background"],o)&&(a.backgroundColor=t.background),a.pointerEvents||(a.pointerEvents="none");var f=e.image;if(f){var h=f.src;h!==o.image&&(o.image=h,a.backgroundImage="url("+h+")");var d=e.rect;if(d){var l=d[0],g=d[1];l!==o.sx&&(o.sx=l,a.backgroundPositionX=-l+n),g!==o.sy&&(o.sy=g,a.backgroundPositionY=-g+n)}}var p=t.mask;if(p){var m=p.drawable.domElement.style.backgroundImage;m!==o.maskImage&&(o.maskImage=m,a[r+"MaskImage"]=m,a[r+"MaskRepeat"]="no-repeat");var T=p.x,u=p.y;T===o.maskX&&u===o.maskY||(o.maskX=T,o.maskY=u,a[r+"MaskPosition"]=T+n+" "+u+n)}}},cacheStateIfChanged:function(t,e,a){var o,r,n,i,s=!1;for(o=0,r=e.length;o0)&&(t===this.stage&&this.clear(),!0)},draw:function(t){var e=t.width,r=t.height,i=(t.background,t.drawable),a=i&&i.image;if(a){var n=i.rect,s=n[2],o=n[3];e||r||(e=t.width=s,r=t.height=o),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(a,n[0],n[1],s,o,0,0,e,r),_=this.batchIndex*this.positionStride,c=this.float32Array,l=this.uint32Array,d=(t.tint>>16)+(65280&t.tint)+((255&t.tint)<<16)+(255*t.__webglRenderAlpha<<24);c[_+0]=h[0],c[_+1]=h[1],c[_+2]=h[2],c[_+3]=h[3],l[_+4]=d,c[_+5]=h[4],c[_+6]=h[5],c[_+7]=h[6],c[_+8]=h[7],l[_+9]=d,c[_+10]=h[8],c[_+11]=h[9],c[_+12]=h[10],c[_+13]=h[11],l[_+14]=d,c[_+15]=h[12],c[_+16]=h[13],c[_+17]=h[14],c[_+18]=h[15],l[_+19]=d;for(var u=t.__webglWorldMatrix,f=0;f<4;f++){var g=c[_+5*f],T=c[_+5*f+1];c[_+5*f]=u.a*g+u.c*T+u.tx,c[_+5*f+1]=u.b*g+u.d*T+u.ty}t.__textureImage=a,this.sprites[this.batchIndex++]=t}},endDraw:function(t){t===this.stage&&this._renderBatches()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void r.setElementStyleByView(t);var i=t.scaleX,n=t.scaleY;if(t===this.stage){var s=this.canvas.style,o=t._scaleX,h=t._scaleY,_=!1;(!o&&1!=i||o&&o!=i)&&(t._scaleX=i,s.width=i*t.width+"px",_=!0),(!h&&1!=n||h&&h!=n)&&(t._scaleY=n,s.height=n*t.height+"px",_=!0),_&&t.updateViewport(),t.__webglWorldMatrix=t.__webglWorldMatrix||new a(1,0,0,1,0,0)}else t.parent&&(t.__webglWorldMatrix=t.__webglWorldMatrix||new a(1,0,0,1,0,0),this._setConcatenatedMatrix(t,t.parent));t.alpha>0&&(t.parent&&t.parent.__webglRenderAlpha?t.__webglRenderAlpha=t.alpha*t.parent.__webglRenderAlpha:t.__webglRenderAlpha=t.alpha)},remove:function(t){var e=t.drawable,r=e&&e.domElement;if(r){var i=r.parentNode;i&&i.removeChild(r)}},clear:function(t,e,r,i){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(t,e){if(this.width!==t||this.height!==e){var r=this.canvas,i=this.stage,a=r.style;this.width=r.width=t,this.height=r.height=e,a.width=i.width*i.scaleX+"px",a.height=i.height*i.scaleY+"px",this.gl.viewport(0,0,t,e),this.canvasHalfWidth=.5*t,this.canvasHalfHeight=.5*e,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var t=this.gl;t.bufferSubData(t.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var e=0,r=0,i=null,a=0;a0&&(r.bindTexture(r.TEXTURE_2D,this._getTexture(this.sprites[t])),r.drawElements(r.TRIANGLES,6*i,r.UNSIGNED_SHORT,6*t*2))},_uploadProjectionTransform:function(t){this._projectionTransformElements&&!t||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var t=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",e="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new o(this,{v:t,f:e},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(t,e,r,i,a,n,s,o,h){var _=this.__tempVertexs||[],c=t.width,l=t.height;i/=c,a/=l,e/=c,r/=l,o=o,h=h,n=n,s=s,i+e>1&&(i=1-e),a+r>1&&(a=1-r);var d=0;return _[d++]=n,_[d++]=s,_[d++]=e,_[d++]=r,_[d++]=n+o,_[d++]=s,_[d++]=e+i,_[d++]=r,_[d++]=n,_[d++]=s+h,_[d++]=e,_[d++]=r+a,_[d++]=n+o,_[d++]=s+h,_[d++]=e+i,_[d++]=r+a,_},_setConcatenatedMatrix:function(t,e){var r=t.__webglWorldMatrix,i=1,a=0,s=t.rotation%360,o=t.pivotX,h=t.pivotY,_=t.scaleX,c=t.scaleY,l=t.transform;if(l)r.copy(l);else{if(s){var d=s*n;i=Math.cos(d),a=Math.sin(d)}var u=t.getAlignPosition();r.a=i*_,r.b=a*_,r.c=-a*c,r.d=i*c,r.tx=u.x-r.a*o-r.c*h,r.ty=u.y-r.b*o-r.d*h}r.concat(e.__webglWorldMatrix)},_getTexture:function(t){var e=t.__textureImage,r=this._cacheTexture[e.src];return r||(r=this.activeShader.uploadTexture(e)),r}}),o=function(t,e,r){this.renderer=t,this.gl=t.gl,this.program=this._createProgram(this.gl,e.v,e.f),r=r||{},this.attributes=r.attributes||[],this.uniforms=r.uniforms||[]};o.prototype={active:function(){var t=this,e=t.renderer,r=t.gl,i=t.program;i&&r&&(e.activeShader=t,r.useProgram(i),t.attributes.forEach(function(t){e[t]=r.getAttribLocation(i,t),r.enableVertexAttribArray(e[t])}),t.uniforms.forEach(function(t){e[t]=r.getUniformLocation(i,t)}),t.width===e.width&&t.height===e.height||(t.width=e.width,t.height=e.height,e._uploadProjectionTransform()))},uploadTexture:function(t){var e=this.gl,r=this.renderer,i=e.createTexture(),a=r.u_Sampler;return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,i),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(a,0),e.bindTexture(e.TEXTURE_2D,null),this.renderer._cacheTexture[t.src]=i,i},_createProgram:function(t,e,r){var i=this._createShader(t,t.VERTEX_SHADER,e),a=this._createShader(t,t.FRAGMENT_SHADER,r);if(!i||!a)return null;var n=t.createProgram();if(n){t.attachShader(n,i),t.attachShader(n,a),t.linkProgram(n),t.deleteShader(a),t.deleteShader(i);var s=t.getProgramParameter(n,t.LINK_STATUS);if(!s){var o=t.getProgramInfoLog(n);return console.log("Failed to link program: "+o),t.deleteProgram(n),null}}return n},_createShader:function(t,e,r){var i=t.createShader(e);if(i){t.shaderSource(i,r),t.compileShader(i);var a=t.getShaderParameter(i,t.COMPILE_STATUS);if(!a){var n=t.getShaderInfoLog(i);return console.log("Failed to compile shader: "+n),t.deleteShader(i),null}}return i}},t.Hilo.WebGLRenderer=s}(window); \ No newline at end of file +!function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,r=t.Hilo,i=t.Hilo.Renderer,a=t.Hilo.Matrix,n=Math.PI/180,s=e.create({Extends:i,Statics:{MAX_BATCH_NUM:2e3,ATTRIBUTE_NUM:5,isSupport:function(){if(void 0==this._isSupported){var t=document.createElement("canvas");t.getContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))?this._isSupported=!0:this._isSupported=!1}return this._isSupported},contextOptions:null},renderType:"webgl",gl:null,_isContextLost:!1,_cacheTexture:{},constructor:function(t){s.superclass.constructor.call(this,t);var e=this,r=s.contextOptions||{};this.gl=this.canvas.getContext("webgl",r)||this.canvas.getContext("experimental-webgl",r),this.maxBatchNum=s.MAX_BATCH_NUM,this.positionStride=4*s.ATTRIBUTE_NUM;var i=this.maxBatchNum*s.ATTRIBUTE_NUM*4,a=6*this.maxBatchNum;this.arrayBuffer=new ArrayBuffer(4*i),this.float32Array=new Float32Array(this.arrayBuffer),this.uint32Array=new Uint32Array(this.arrayBuffer),this.indexs=new Uint16Array(a);for(var n=0,o=0;n0)&&(t===this.stage&&this.clear(),!0)},draw:function(t){var e=t.width,r=t.height,i=(t.background,t.drawable),a=i&&i.image;if(a){var n=i.rect,s=n[2],o=n[3];e||r||(e=t.width=s,r=t.height=o),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(a,n[0],n[1],s,o,0,0,e,r),c=this.batchIndex*this.positionStride,_=this.float32Array,l=this.uint32Array,d=(t.tint>>16)+(65280&t.tint)+((255&t.tint)<<16)+(255*t.__webglRenderAlpha<<24);_[c+0]=h[0],_[c+1]=h[1],_[c+2]=h[2],_[c+3]=h[3],l[c+4]=d,_[c+5]=h[4],_[c+6]=h[5],_[c+7]=h[6],_[c+8]=h[7],l[c+9]=d,_[c+10]=h[8],_[c+11]=h[9],_[c+12]=h[10],_[c+13]=h[11],l[c+14]=d,_[c+15]=h[12],_[c+16]=h[13],_[c+17]=h[14],_[c+18]=h[15],l[c+19]=d;for(var u=t.__webglWorldMatrix,f=0;f<4;f++){var g=_[c+5*f],x=_[c+5*f+1];_[c+5*f]=u.a*g+u.c*x+u.tx,_[c+5*f+1]=u.b*g+u.d*x+u.ty}t.__textureImage=a,this.sprites[this.batchIndex++]=t}},endDraw:function(t){t===this.stage&&this._renderBatches()},transform:function(t){var e=t.drawable;if(e&&e.domElement)return void r.setElementStyleByView(t);var i=t.scaleX,n=t.scaleY;if(t===this.stage){var s=this.canvas.style,o=t._scaleX,h=t._scaleY,c=!1;(!o&&1!=i||o&&o!=i)&&(t._scaleX=i,s.width=i*t.width+"px",c=!0),(!h&&1!=n||h&&h!=n)&&(t._scaleY=n,s.height=n*t.height+"px",c=!0),c&&t.updateViewport(),t.__webglWorldMatrix=t.__webglWorldMatrix||new a(1,0,0,1,0,0)}else t.parent&&(t.__webglWorldMatrix=t.__webglWorldMatrix||new a(1,0,0,1,0,0),this._setConcatenatedMatrix(t,t.parent));t.alpha>0&&(t.parent&&t.parent.__webglRenderAlpha?t.__webglRenderAlpha=t.alpha*t.parent.__webglRenderAlpha:t.__webglRenderAlpha=t.alpha)},remove:function(t){var e=t.drawable,r=e&&e.domElement;if(r){var i=r.parentNode;i&&i.removeChild(r)}},clear:function(t,e,r,i){this.gl.clear(this.gl.COLOR_BUFFER_BIT)},resize:function(t,e){if(this.width!==t||this.height!==e){var r=this.canvas,i=this.stage,a=r.style;this.width=r.width=t,this.height=r.height=e,a.width=i.width*i.scaleX+"px",a.height=i.height*i.scaleY+"px",this.gl.viewport(0,0,t,e),this.canvasHalfWidth=.5*t,this.canvasHalfHeight=.5*e,this._uploadProjectionTransform(!0)}},_renderBatches:function(){var t=this.gl;t.bufferSubData(t.ARRAY_BUFFER,0,this.uint32Array.subarray(0,this.batchIndex*this.positionStride));for(var e=0,r=0,i=null,a=0;a0&&(r.bindTexture(r.TEXTURE_2D,this._getTexture(this.sprites[t])),r.drawElements(r.TRIANGLES,6*i,r.UNSIGNED_SHORT,6*t*2))},_uploadProjectionTransform:function(t){this._projectionTransformElements&&!t||(this._projectionTransformElements=new Float32Array([1/this.canvasHalfWidth,0,0,0,-1/this.canvasHalfHeight,0,-1,1,1])),this.gl.uniformMatrix3fv(this.u_projectionTransform,!1,this._projectionTransformElements)},_initShaders:function(){var t=" attribute vec2 a_position;\n attribute vec2 a_TexCoord;\n attribute vec4 a_tint;\n uniform mat3 u_projectionTransform;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n v_TexCoord = a_TexCoord;\n v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n }\n ",e="\n precision mediump float;\n uniform sampler2D u_Sampler;\n varying vec2 v_TexCoord;\n varying vec4 v_tint;\n void main(){\n gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n }\n ";this.defaultShader=new o(this,{v:t,f:e},{attributes:["a_position","a_TexCoord","a_tint"],uniforms:["u_projectionTransform","u_Sampler"]})},_createVertexs:function(t,e,r,i,a,n,s,o,h){var c=this.__tempVertexs||[],_=t.width,l=t.height;i/=_,a/=l,e/=_,r/=l,o=o,h=h,n=n,s=s,i+e>1&&(i=1-e),a+r>1&&(a=1-r);var d=0;return c[d++]=n,c[d++]=s,c[d++]=e,c[d++]=r,c[d++]=n+o,c[d++]=s,c[d++]=e+i,c[d++]=r,c[d++]=n,c[d++]=s+h,c[d++]=e,c[d++]=r+a,c[d++]=n+o,c[d++]=s+h,c[d++]=e+i,c[d++]=r+a,c},_setConcatenatedMatrix:function(t,e){var r=t.__webglWorldMatrix,i=1,a=0,s=t.rotation%360,o=t.pivotX,h=t.pivotY,c=t.scaleX,_=t.scaleY,l=t.transform;if(l)r.copy(l);else{if(s){var d=s*n;i=Math.cos(d),a=Math.sin(d)}var u=t.getAlignPosition();r.a=i*c,r.b=a*c,r.c=-a*_,r.d=i*_,r.tx=u.x-r.a*o-r.c*h,r.ty=u.y-r.b*o-r.d*h}r.concat(e.__webglWorldMatrix)},_getTexture:function(t){var e=t.__textureImage,r=this._cacheTexture[e.src];return r||(r=this.activeShader.uploadTexture(e)),r}}),o=function(t,e,r){this.renderer=t,this.gl=t.gl,this.program=this._createProgram(this.gl,e.v,e.f),r=r||{},this.attributes=r.attributes||[],this.uniforms=r.uniforms||[]};o.prototype={active:function(){var t=this,e=t.renderer,r=t.gl,i=t.program;i&&r&&(e.activeShader=t,r.useProgram(i),t.attributes.forEach(function(t){e[t]=r.getAttribLocation(i,t),r.enableVertexAttribArray(e[t])}),t.uniforms.forEach(function(t){e[t]=r.getUniformLocation(i,t)}),t.width===e.width&&t.height===e.height||(t.width=e.width,t.height=e.height,e._uploadProjectionTransform()))},uploadTexture:function(t){var e=this.gl,r=this.renderer,i=e.createTexture(),a=r.u_Sampler;return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,i),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(a,0),e.bindTexture(e.TEXTURE_2D,null),this.renderer._cacheTexture[t.src]=i,i},_createProgram:function(t,e,r){var i=this._createShader(t,t.VERTEX_SHADER,e),a=this._createShader(t,t.FRAGMENT_SHADER,r);if(!i||!a)return null;var n=t.createProgram();if(n){t.attachShader(n,i),t.attachShader(n,a),t.linkProgram(n),t.deleteShader(a),t.deleteShader(i);var s=t.getProgramParameter(n,t.LINK_STATUS);if(!s){var o=t.getProgramInfoLog(n);return console.log("Failed to link program: "+o),t.deleteProgram(n),null}}return n},_createShader:function(t,e,r){var i=t.createShader(e);if(i){t.shaderSource(i,r),t.compileShader(i);var a=t.getShaderParameter(i,t.COMPILE_STATUS);if(!a){var n=t.getShaderInfoLog(i);return console.log("Failed to compile shader: "+n),t.deleteShader(i),null}}return i}},t.Hilo.WebGLRenderer=s}(window); \ No newline at end of file diff --git a/build/standalone/hilo/tween/Ease.js b/build/standalone/hilo/tween/Ease.js index 198d12ca..5afecbbd 100644 --- a/build/standalone/hilo/tween/Ease.js +++ b/build/standalone/hilo/tween/Ease.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/tween/Ease.min.js b/build/standalone/hilo/tween/Ease.min.js index 7493714e..a24435aa 100644 --- a/build/standalone/hilo/tween/Ease.min.js +++ b/build/standalone/hilo/tween/Ease.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/tween/Tween.js b/build/standalone/hilo/tween/Tween.js index a0923c44..3833e6d6 100644 --- a/build/standalone/hilo/tween/Tween.js +++ b/build/standalone/hilo/tween/Tween.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/tween/Tween.min.js b/build/standalone/hilo/tween/Tween.min.js index dd0a801f..58e74824 100644 --- a/build/standalone/hilo/tween/Tween.min.js +++ b/build/standalone/hilo/tween/Tween.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/util/TextureAtlas.js b/build/standalone/hilo/util/TextureAtlas.js index b79bb12d..63b3c633 100644 --- a/build/standalone/hilo/util/TextureAtlas.js +++ b/build/standalone/hilo/util/TextureAtlas.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/util/TextureAtlas.min.js b/build/standalone/hilo/util/TextureAtlas.min.js index 725173d1..8f66c9ef 100644 --- a/build/standalone/hilo/util/TextureAtlas.min.js +++ b/build/standalone/hilo/util/TextureAtlas.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/util/Ticker.js b/build/standalone/hilo/util/Ticker.js index e9c7b594..609972fe 100644 --- a/build/standalone/hilo/util/Ticker.js +++ b/build/standalone/hilo/util/Ticker.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/util/Ticker.min.js b/build/standalone/hilo/util/Ticker.min.js index 8b5faf81..bd995ddd 100644 --- a/build/standalone/hilo/util/Ticker.min.js +++ b/build/standalone/hilo/util/Ticker.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/util/browser.js b/build/standalone/hilo/util/browser.js index 9b4df826..73a7f259 100644 --- a/build/standalone/hilo/util/browser.js +++ b/build/standalone/hilo/util/browser.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/util/browser.min.js b/build/standalone/hilo/util/browser.min.js index 1a674f63..dba149a0 100644 --- a/build/standalone/hilo/util/browser.min.js +++ b/build/standalone/hilo/util/browser.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/util/drag.js b/build/standalone/hilo/util/drag.js index 80157298..a34538e3 100644 --- a/build/standalone/hilo/util/drag.js +++ b/build/standalone/hilo/util/drag.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/util/drag.min.js b/build/standalone/hilo/util/drag.min.js index 81210ce5..ec398a00 100644 --- a/build/standalone/hilo/util/drag.min.js +++ b/build/standalone/hilo/util/drag.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/util/polyfill.js b/build/standalone/hilo/util/polyfill.js index d722b411..a14720e6 100644 --- a/build/standalone/hilo/util/polyfill.js +++ b/build/standalone/hilo/util/polyfill.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/util/polyfill.min.js b/build/standalone/hilo/util/polyfill.min.js index 624147c6..91992836 100644 --- a/build/standalone/hilo/util/polyfill.min.js +++ b/build/standalone/hilo/util/polyfill.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/util/util.js b/build/standalone/hilo/util/util.js index 31cdf3d8..3ea0165e 100644 --- a/build/standalone/hilo/util/util.js +++ b/build/standalone/hilo/util/util.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/util/util.min.js b/build/standalone/hilo/util/util.min.js index ae760db2..ec9e6b99 100644 --- a/build/standalone/hilo/util/util.min.js +++ b/build/standalone/hilo/util/util.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/Bitmap.js b/build/standalone/hilo/view/Bitmap.js index 785b0297..c15f6e0f 100644 --- a/build/standalone/hilo/view/Bitmap.js +++ b/build/standalone/hilo/view/Bitmap.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/Bitmap.min.js b/build/standalone/hilo/view/Bitmap.min.js index 589de7f8..aaa2885d 100644 --- a/build/standalone/hilo/view/Bitmap.min.js +++ b/build/standalone/hilo/view/Bitmap.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/BitmapText.js b/build/standalone/hilo/view/BitmapText.js index a1027e3e..eedf1ea5 100644 --- a/build/standalone/hilo/view/BitmapText.js +++ b/build/standalone/hilo/view/BitmapText.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/BitmapText.min.js b/build/standalone/hilo/view/BitmapText.min.js index 71ee04b6..afcbc5fd 100644 --- a/build/standalone/hilo/view/BitmapText.min.js +++ b/build/standalone/hilo/view/BitmapText.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/Button.js b/build/standalone/hilo/view/Button.js index f3f2d12b..28045249 100644 --- a/build/standalone/hilo/view/Button.js +++ b/build/standalone/hilo/view/Button.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/Button.min.js b/build/standalone/hilo/view/Button.min.js index 6456a8b8..b8d4cac7 100644 --- a/build/standalone/hilo/view/Button.min.js +++ b/build/standalone/hilo/view/Button.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/CacheMixin.js b/build/standalone/hilo/view/CacheMixin.js index 83315461..3c882d9a 100644 --- a/build/standalone/hilo/view/CacheMixin.js +++ b/build/standalone/hilo/view/CacheMixin.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/CacheMixin.min.js b/build/standalone/hilo/view/CacheMixin.min.js index 339997bd..17e24a57 100644 --- a/build/standalone/hilo/view/CacheMixin.min.js +++ b/build/standalone/hilo/view/CacheMixin.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/Container.js b/build/standalone/hilo/view/Container.js index a70ed2ff..a18a3dae 100644 --- a/build/standalone/hilo/view/Container.js +++ b/build/standalone/hilo/view/Container.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/Container.min.js b/build/standalone/hilo/view/Container.min.js index d8080596..407f85b7 100644 --- a/build/standalone/hilo/view/Container.min.js +++ b/build/standalone/hilo/view/Container.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/DOMElement.js b/build/standalone/hilo/view/DOMElement.js index cdeb9c26..21227430 100644 --- a/build/standalone/hilo/view/DOMElement.js +++ b/build/standalone/hilo/view/DOMElement.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/DOMElement.min.js b/build/standalone/hilo/view/DOMElement.min.js index 1f6cc7e3..688d790c 100644 --- a/build/standalone/hilo/view/DOMElement.min.js +++ b/build/standalone/hilo/view/DOMElement.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/Drawable.js b/build/standalone/hilo/view/Drawable.js index 36ed1d2d..59ac0318 100644 --- a/build/standalone/hilo/view/Drawable.js +++ b/build/standalone/hilo/view/Drawable.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/Drawable.min.js b/build/standalone/hilo/view/Drawable.min.js index d13bfa7f..c43dcc18 100644 --- a/build/standalone/hilo/view/Drawable.min.js +++ b/build/standalone/hilo/view/Drawable.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/Graphics.js b/build/standalone/hilo/view/Graphics.js index 5eed2803..7bb1d30d 100644 --- a/build/standalone/hilo/view/Graphics.js +++ b/build/standalone/hilo/view/Graphics.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -12,7 +12,7 @@ var CacheMixin = window.Hilo.CacheMixin; /** * @language=en - * + * *
* @class Graphics class contains a group of functions for creating vector graphics. * @augments View diff --git a/build/standalone/hilo/view/Graphics.min.js b/build/standalone/hilo/view/Graphics.min.js index a0de2ee4..37f634cb 100644 --- a/build/standalone/hilo/view/Graphics.min.js +++ b/build/standalone/hilo/view/Graphics.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/Sprite.js b/build/standalone/hilo/view/Sprite.js index d8471afa..0424da4f 100644 --- a/build/standalone/hilo/view/Sprite.js +++ b/build/standalone/hilo/view/Sprite.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/Sprite.min.js b/build/standalone/hilo/view/Sprite.min.js index a4a03386..b2bf2f86 100644 --- a/build/standalone/hilo/view/Sprite.min.js +++ b/build/standalone/hilo/view/Sprite.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/Stage.js b/build/standalone/hilo/view/Stage.js index 61aa4c9d..7dbdec76 100644 --- a/build/standalone/hilo/view/Stage.js +++ b/build/standalone/hilo/view/Stage.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/Stage.min.js b/build/standalone/hilo/view/Stage.min.js index e9a99556..a5e254f3 100644 --- a/build/standalone/hilo/view/Stage.min.js +++ b/build/standalone/hilo/view/Stage.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/Text.js b/build/standalone/hilo/view/Text.js index 47c546c7..bd035b62 100644 --- a/build/standalone/hilo/view/Text.js +++ b/build/standalone/hilo/view/Text.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -50,7 +50,7 @@ var Text = Class.create(/** @lends Text.prototype */{ this._fontHeight = Text.measureFontHeight(this.font); }, - text: null, + text: '', color: '#000', textAlign: null, textVAlign: null, diff --git a/build/standalone/hilo/view/Text.min.js b/build/standalone/hilo/view/Text.min.js index 68b27ac6..3e560e8e 100644 --- a/build/standalone/hilo/view/Text.min.js +++ b/build/standalone/hilo/view/Text.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ -!function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i=t.Hilo,n=t.Hilo.View,o=t.Hilo.CacheMixin,l=e.create({Extends:n,Mixes:o,constructor:function(t){t=t||{},this.id=this.id||t.id||i.getUid("Text"),l.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=l.measureFontHeight(this.font)},text:null,color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=l.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var n=i.drawable,o=n.domElement,l=o.style;l.font=i.font,l.textAlign=i.textAlign,l.color=i.color,l.width=i.width+"px",l.height=i.height+"px",l.lineHeight=i._fontHeight+i.lineSpacing+"px",o.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var n,o,l,h,r,a=i.split(/\r\n|\r|\n|/),s=0,d=0,c=e._fontHeight+e.lineSpacing,x=[];for(n=0,h=a.length;ne.maxWidth?(x.push({text:w,y:d}),s>1;break;case"bottom":m=e.height-e.textHeight}var p=e.background;for(p&&(t.fillStyle=p,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,n=0;n>1;break;case"right":case"end":o=l}n.outline?t.strokeText(e,o,i):t.fillText(e,o,i)},Statics:{measureFontHeight:function(t){var e,n=document.documentElement,o=i.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return n.appendChild(o),e=o.offsetHeight,n.removeChild(o),e}}});t.Hilo.Text=l}(window); \ No newline at end of file +!function(t){t.Hilo||(t.Hilo={});var e=t.Hilo.Class,i=t.Hilo,n=t.Hilo.View,o=t.Hilo.CacheMixin,l=e.create({Extends:n,Mixes:o,constructor:function(t){t=t||{},this.id=this.id||t.id||i.getUid("Text"),l.superclass.constructor.call(this,t),t.font||(this.font="12px arial"),this._fontHeight=l.measureFontHeight(this.font)},text:"",color:"#000",textAlign:null,textVAlign:null,outline:!1,lineSpacing:0,maxWidth:200,font:null,textWidth:0,textHeight:0,setFont:function(t){var e=this;return e.font!==t&&(e.font=t,e._fontHeight=l.measureFontHeight(t)),e},render:function(t,e){var i=this;if("canvas"===t.renderType)this.drawable?t.draw(i):i._draw(t.context);else if("dom"===t.renderType){var n=i.drawable,o=n.domElement,l=o.style;l.font=i.font,l.textAlign=i.textAlign,l.color=i.color,l.width=i.width+"px",l.height=i.height+"px",l.lineHeight=i._fontHeight+i.lineSpacing+"px",o.innerHTML=i.text,t.draw(this)}else i.cache(),t.draw(i)},_draw:function(t){var e=this,i=e.text.toString();if(i){t.font=e.font,t.textAlign=e.textAlign,t.textBaseline="top";var n,o,l,h,r,a=i.split(/\r\n|\r|\n|/),s=0,d=0,c=e._fontHeight+e.lineSpacing,x=[];for(n=0,h=a.length;ne.maxWidth?(x.push({text:w,y:d}),s>1;break;case"bottom":m=e.height-e.textHeight}var p=e.background;for(p&&(t.fillStyle=p,t.fillRect(0,0,e.width,e.height)),e.outline?t.strokeStyle=e.color:t.fillStyle=e.color,n=0;n>1;break;case"right":case"end":o=l}n.outline?t.strokeText(e,o,i):t.fillText(e,o,i)},Statics:{measureFontHeight:function(t){var e,n=document.documentElement,o=i.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return n.appendChild(o),e=o.offsetHeight,n.removeChild(o),e}}});t.Hilo.Text=l}(window); \ No newline at end of file diff --git a/build/standalone/hilo/view/View.js b/build/standalone/hilo/view/View.js index 72b004d8..7217c4c2 100644 --- a/build/standalone/hilo/view/View.js +++ b/build/standalone/hilo/view/View.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/View.min.js b/build/standalone/hilo/view/View.min.js index d20fd7a9..d693bbfe 100644 --- a/build/standalone/hilo/view/View.min.js +++ b/build/standalone/hilo/view/View.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.3.0 for standalone + * Hilo 1.4.0 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/docs/api-en/code/renderer/WebGLRenderer.js b/docs/api-en/code/renderer/WebGLRenderer.js index 50f58757..79b0aa6e 100644 --- a/docs/api-en/code/renderer/WebGLRenderer.js +++ b/docs/api-en/code/renderer/WebGLRenderer.js @@ -49,7 +49,13 @@ var WebGLRenderer = Class.create(/** @lends WebGLRenderer.prototype */{ } } return this._isSupported; - } + }, + /** + * WebGL context Options + * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getContextAttributes + * @type {Object} + */ + contextOptions: null }, renderType:'webgl', gl:null, @@ -58,7 +64,8 @@ var WebGLRenderer = Class.create(/** @lends WebGLRenderer.prototype */{ constructor: function(properties){ WebGLRenderer.superclass.constructor.call(this, properties); var that = this; - this.gl = this.canvas.getContext("webgl")||this.canvas.getContext('experimental-webgl'); + var contextOptions = WebGLRenderer.contextOptions || {}; + this.gl = this.canvas.getContext("webgl", contextOptions)||this.canvas.getContext('experimental-webgl', contextOptions); this.maxBatchNum = WebGLRenderer.MAX_BATCH_NUM; this.positionStride = WebGLRenderer.ATTRIBUTE_NUM * 4; diff --git a/docs/api-en/code/view/Text.js b/docs/api-en/code/view/Text.js index d25e0d8e..d776711e 100644 --- a/docs/api-en/code/view/Text.js +++ b/docs/api-en/code/view/Text.js @@ -43,7 +43,7 @@ var Text = Class.create(/** @lends Text.prototype */{ this._fontHeight = Text.measureFontHeight(this.font); }, - text: null, + text: '', color: '#000', textAlign: null, textVAlign: null, diff --git a/docs/api-en/index.html b/docs/api-en/index.html index dbce8998..7d408d58 100644 --- a/docs/api-en/index.html +++ b/docs/api-en/index.html @@ -188,7 +188,7 @@
-
All Class Index(v1.3.0)
+
All Class Index(v1.4.0)
diff --git a/docs/api-en/symbols/WebGLRenderer.html b/docs/api-en/symbols/WebGLRenderer.html index 17bc4a53..32a95684 100644 --- a/docs/api-en/symbols/WebGLRenderer.html +++ b/docs/api-en/symbols/WebGLRenderer.html @@ -278,6 +278,28 @@

Properties

+ + + + + + +
+ + + +
+ static + WebGL context Options +
+
+ WebGLRenderer +
@@ -644,6 +666,32 @@

Property Detail

+ + + +
+
[Static] + contextOptions + +
+
+ WebGL context Options +
+ + + + + + +
+
see:
+ +
https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getContextAttributes
+ +
+ + +
diff --git a/docs/api-en/symbols/src/docs_api-en_code_renderer_WebGLRenderer.js.html b/docs/api-en/symbols/src/docs_api-en_code_renderer_WebGLRenderer.js.html index d6ac6c13..181395f8 100644 --- a/docs/api-en/symbols/src/docs_api-en_code_renderer_WebGLRenderer.js.html +++ b/docs/api-en/symbols/src/docs_api-en_code_renderer_WebGLRenderer.js.html @@ -56,517 +56,524 @@ 49 } 50 } 51 return this._isSupported; - 52 } - 53 }, - 54 renderType:'webgl', - 55 gl:null, - 56 _isContextLost:false, - 57 _cacheTexture:{}, - 58 constructor: function(properties){ - 59 WebGLRenderer.superclass.constructor.call(this, properties); - 60 var that = this; - 61 this.gl = this.canvas.getContext("webgl")||this.canvas.getContext('experimental-webgl'); - 62 - 63 this.maxBatchNum = WebGLRenderer.MAX_BATCH_NUM; - 64 this.positionStride = WebGLRenderer.ATTRIBUTE_NUM * 4; - 65 var vertexNum = this.maxBatchNum * WebGLRenderer.ATTRIBUTE_NUM * 4; - 66 var indexNum = this.maxBatchNum * 6; - 67 this.arrayBuffer = new ArrayBuffer(vertexNum * 4); - 68 this.float32Array = new Float32Array(this.arrayBuffer); - 69 this.uint32Array = new Uint32Array(this.arrayBuffer); - 70 this.indexs = new Uint16Array(indexNum); - 71 for (var i=0, j=0; i < indexNum; i += 6, j += 4) - 72 { - 73 this.indexs[i + 0] = j + 0; - 74 this.indexs[i + 1] = j + 1; - 75 this.indexs[i + 2] = j + 2; - 76 this.indexs[i + 3] = j + 1; - 77 this.indexs[i + 4] = j + 2; - 78 this.indexs[i + 5] = j + 3; - 79 } - 80 this.batchIndex = 0; - 81 this.sprites = []; - 82 - 83 this.canvas.addEventListener('webglcontextlost', function(e){ - 84 that._isContextLost = true; - 85 e.preventDefault(); - 86 }, false); - 87 - 88 this.canvas.addEventListener('webglcontextrestored', function(e){ - 89 that._isContextLost = false; - 90 that.setupWebGLStateAndResource(); - 91 }, false); - 92 - 93 this.setupWebGLStateAndResource(); - 94 }, - 95 setupWebGLStateAndResource:function(){ - 96 var gl = this.gl; - 97 gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); - 98 gl.clearColor(0, 0, 0, 0); - 99 gl.disable(gl.DEPTH_TEST); -100 gl.disable(gl.CULL_FACE); -101 gl.enable(gl.BLEND); -102 -103 this._cacheTexture = {}; -104 this._initShaders(); -105 this.defaultShader.active(); -106 -107 this.positionBuffer = gl.createBuffer(); -108 this.indexBuffer = gl.createBuffer(); + 52 }, + 53 /** + 54 * WebGL context Options + 55 * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getContextAttributes + 56 * @type {Object} + 57 */ + 58 contextOptions: null + 59 }, + 60 renderType:'webgl', + 61 gl:null, + 62 _isContextLost:false, + 63 _cacheTexture:{}, + 64 constructor: function(properties){ + 65 WebGLRenderer.superclass.constructor.call(this, properties); + 66 var that = this; + 67 var contextOptions = WebGLRenderer.contextOptions || {}; + 68 this.gl = this.canvas.getContext("webgl", contextOptions)||this.canvas.getContext('experimental-webgl', contextOptions); + 69 + 70 this.maxBatchNum = WebGLRenderer.MAX_BATCH_NUM; + 71 this.positionStride = WebGLRenderer.ATTRIBUTE_NUM * 4; + 72 var vertexNum = this.maxBatchNum * WebGLRenderer.ATTRIBUTE_NUM * 4; + 73 var indexNum = this.maxBatchNum * 6; + 74 this.arrayBuffer = new ArrayBuffer(vertexNum * 4); + 75 this.float32Array = new Float32Array(this.arrayBuffer); + 76 this.uint32Array = new Uint32Array(this.arrayBuffer); + 77 this.indexs = new Uint16Array(indexNum); + 78 for (var i=0, j=0; i < indexNum; i += 6, j += 4) + 79 { + 80 this.indexs[i + 0] = j + 0; + 81 this.indexs[i + 1] = j + 1; + 82 this.indexs[i + 2] = j + 2; + 83 this.indexs[i + 3] = j + 1; + 84 this.indexs[i + 4] = j + 2; + 85 this.indexs[i + 5] = j + 3; + 86 } + 87 this.batchIndex = 0; + 88 this.sprites = []; + 89 + 90 this.canvas.addEventListener('webglcontextlost', function(e){ + 91 that._isContextLost = true; + 92 e.preventDefault(); + 93 }, false); + 94 + 95 this.canvas.addEventListener('webglcontextrestored', function(e){ + 96 that._isContextLost = false; + 97 that.setupWebGLStateAndResource(); + 98 }, false); + 99 +100 this.setupWebGLStateAndResource(); +101 }, +102 setupWebGLStateAndResource:function(){ +103 var gl = this.gl; +104 gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); +105 gl.clearColor(0, 0, 0, 0); +106 gl.disable(gl.DEPTH_TEST); +107 gl.disable(gl.CULL_FACE); +108 gl.enable(gl.BLEND); 109 -110 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); -111 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indexs, gl.STATIC_DRAW); -112 -113 gl.bindBuffer(gl.ARRAY_BUFFER, this.positionBuffer); -114 gl.bufferData(gl.ARRAY_BUFFER, this.arrayBuffer, gl.DYNAMIC_DRAW); -115 -116 gl.vertexAttribPointer(this.a_position, 2, gl.FLOAT, false, this.positionStride, 0);//x, y -117 gl.vertexAttribPointer(this.a_TexCoord, 2, gl.FLOAT, false, this.positionStride, 2 * 4);//x, y -118 gl.vertexAttribPointer(this.a_tint, 4, gl.UNSIGNED_BYTE, true, this.positionStride, 4 * 4);//alpha -119 }, -120 -121 context: null, +110 this._cacheTexture = {}; +111 this._initShaders(); +112 this.defaultShader.active(); +113 +114 this.positionBuffer = gl.createBuffer(); +115 this.indexBuffer = gl.createBuffer(); +116 +117 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); +118 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indexs, gl.STATIC_DRAW); +119 +120 gl.bindBuffer(gl.ARRAY_BUFFER, this.positionBuffer); +121 gl.bufferData(gl.ARRAY_BUFFER, this.arrayBuffer, gl.DYNAMIC_DRAW); 122 -123 /** -124 * @private -125 * @see Renderer#startDraw -126 */ -127 startDraw: function(target){ -128 if(target.visible && target.alpha > 0){ -129 if(target === this.stage){ -130 this.clear(); -131 } -132 return true; -133 } -134 return false; -135 }, -136 /** -137 * @private -138 * @see Renderer#draw -139 */ -140 draw: function(target){ -141 var w = target.width, -142 h = target.height; -143 -144 //TODO:draw background -145 var bg = target.background; // jshint ignore:line -146 -147 //draw image -148 var drawable = target.drawable, image = drawable && drawable.image; -149 if(image){ -150 var rect = drawable.rect, sw = rect[2], sh = rect[3]; -151 if(!w && !h){ -152 //fix width/height TODO: how to get rid of this? -153 w = target.width = sw; -154 h = target.height = sh; -155 } -156 -157 if(this.batchIndex >= this.maxBatchNum){ -158 this._renderBatches(); -159 } -160 -161 var vertexs = this._createVertexs(image, rect[0], rect[1], sw, sh, 0, 0, w, h); -162 var index = this.batchIndex * this.positionStride; -163 var float32Array = this.float32Array; -164 var uint32Array = this.uint32Array; -165 -166 var tint = (target.tint >> 16) + (target.tint & 0xff00) + ((target.tint & 0xff) << 16) + (target.__webglRenderAlpha * 255 << 24); +123 gl.vertexAttribPointer(this.a_position, 2, gl.FLOAT, false, this.positionStride, 0);//x, y +124 gl.vertexAttribPointer(this.a_TexCoord, 2, gl.FLOAT, false, this.positionStride, 2 * 4);//x, y +125 gl.vertexAttribPointer(this.a_tint, 4, gl.UNSIGNED_BYTE, true, this.positionStride, 4 * 4);//alpha +126 }, +127 +128 context: null, +129 +130 /** +131 * @private +132 * @see Renderer#startDraw +133 */ +134 startDraw: function(target){ +135 if(target.visible && target.alpha > 0){ +136 if(target === this.stage){ +137 this.clear(); +138 } +139 return true; +140 } +141 return false; +142 }, +143 /** +144 * @private +145 * @see Renderer#draw +146 */ +147 draw: function(target){ +148 var w = target.width, +149 h = target.height; +150 +151 //TODO:draw background +152 var bg = target.background; // jshint ignore:line +153 +154 //draw image +155 var drawable = target.drawable, image = drawable && drawable.image; +156 if(image){ +157 var rect = drawable.rect, sw = rect[2], sh = rect[3]; +158 if(!w && !h){ +159 //fix width/height TODO: how to get rid of this? +160 w = target.width = sw; +161 h = target.height = sh; +162 } +163 +164 if(this.batchIndex >= this.maxBatchNum){ +165 this._renderBatches(); +166 } 167 -168 float32Array[index + 0] = vertexs[0];//x -169 float32Array[index + 1] = vertexs[1];//y -170 float32Array[index + 2] = vertexs[2];//uvx -171 float32Array[index + 3] = vertexs[3];//uvy -172 uint32Array[index + 4] = tint;//tint -173 -174 float32Array[index + 5] = vertexs[4]; -175 float32Array[index + 6] = vertexs[5]; -176 float32Array[index + 7] = vertexs[6]; -177 float32Array[index + 8] = vertexs[7]; -178 uint32Array[index + 9] = tint; -179 -180 float32Array[index + 10] = vertexs[8]; -181 float32Array[index + 11] = vertexs[9]; -182 float32Array[index + 12] = vertexs[10]; -183 float32Array[index + 13] = vertexs[11]; -184 uint32Array[index + 14] = tint; -185 -186 float32Array[index + 15] = vertexs[12]; -187 float32Array[index + 16] = vertexs[13]; -188 float32Array[index + 17] = vertexs[14]; -189 float32Array[index + 18] = vertexs[15]; -190 uint32Array[index + 19] = tint; -191 -192 var matrix = target.__webglWorldMatrix; -193 for(var i = 0;i < 4;i ++){ -194 var x = float32Array[index + i*5]; -195 var y = float32Array[index + i*5 + 1]; -196 -197 float32Array[index + i*5] = matrix.a*x + matrix.c*y + matrix.tx; -198 float32Array[index + i*5 + 1] = matrix.b*x + matrix.d*y + matrix.ty; -199 } -200 -201 target.__textureImage = image; -202 this.sprites[this.batchIndex++] = target; -203 } -204 }, -205 -206 /** -207 * @private -208 * @see Renderer#endDraw -209 */ -210 endDraw: function(target){ -211 if(target === this.stage){ -212 this._renderBatches(); -213 } -214 }, -215 /** -216 * @private -217 * @see Renderer#transform -218 */ -219 transform: function(target){ -220 var drawable = target.drawable; -221 if(drawable && drawable.domElement){ -222 Hilo.setElementStyleByView(target); -223 return; -224 } -225 -226 var scaleX = target.scaleX, -227 scaleY = target.scaleY; -228 -229 if(target === this.stage){ -230 var style = this.canvas.style, -231 oldScaleX = target._scaleX, -232 oldScaleY = target._scaleY, -233 isStyleChange = false; -234 -235 if((!oldScaleX && scaleX != 1) || (oldScaleX && oldScaleX != scaleX)){ -236 target._scaleX = scaleX; -237 style.width = scaleX * target.width + "px"; -238 isStyleChange = true; -239 } -240 if((!oldScaleY && scaleY != 1) || (oldScaleY && oldScaleY != scaleY)){ -241 target._scaleY = scaleY; -242 style.height = scaleY * target.height + "px"; -243 isStyleChange = true; -244 } -245 if(isStyleChange){ -246 target.updateViewport(); -247 } -248 target.__webglWorldMatrix = target.__webglWorldMatrix||new Matrix(1, 0, 0, 1, 0, 0); -249 } -250 else if(target.parent){ -251 target.__webglWorldMatrix = target.__webglWorldMatrix||new Matrix(1, 0, 0, 1, 0, 0); -252 this._setConcatenatedMatrix(target, target.parent); -253 } -254 -255 if(target.alpha > 0) { -256 if(target.parent && target.parent.__webglRenderAlpha){ -257 target.__webglRenderAlpha = target.alpha * target.parent.__webglRenderAlpha; -258 } -259 else{ -260 target.__webglRenderAlpha = target.alpha; -261 } -262 } -263 }, -264 -265 /** -266 * @private -267 * @see Renderer#remove -268 */ -269 remove: function(target){ -270 var drawable = target.drawable; -271 var elem = drawable && drawable.domElement; -272 -273 if(elem){ -274 var parentElem = elem.parentNode; -275 if(parentElem){ -276 parentElem.removeChild(elem); -277 } -278 } -279 }, -280 -281 /** -282 * @private -283 * @see Renderer#clear -284 */ -285 clear: function(x, y, width, height){ -286 this.gl.clear(this.gl.COLOR_BUFFER_BIT); -287 }, -288 -289 /** -290 * @private -291 * @see Renderer#resize -292 */ -293 resize: function(width, height){ -294 if(this.width !== width || this.height !== height){ -295 var canvas = this.canvas; -296 var stage = this.stage; -297 var style = canvas.style; -298 -299 this.width = canvas.width = width; -300 this.height = canvas.height = height; -301 -302 style.width = stage.width * stage.scaleX + 'px'; -303 style.height = stage.height * stage.scaleY + 'px'; -304 -305 this.gl.viewport(0, 0, width, height); -306 -307 this.canvasHalfWidth = width * .5; -308 this.canvasHalfHeight = height * .5; -309 -310 this._uploadProjectionTransform(true); -311 } -312 }, -313 _renderBatches:function(){ -314 var gl = this.gl; -315 gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.uint32Array.subarray(0, this.batchIndex * this.positionStride)); -316 var startIndex = 0; -317 var batchNum = 0; -318 var preTextureImage = null; -319 for(var i = 0;i < this.batchIndex;i ++){ -320 var sprite = this.sprites[i]; -321 if(preTextureImage && preTextureImage !== sprite.__textureImage){ -322 this._renderBatch(startIndex, i); -323 startIndex = i; -324 batchNum = 1; -325 } -326 preTextureImage = sprite.__textureImage; -327 } -328 this._renderBatch(startIndex, this.batchIndex); -329 this.batchIndex = 0; -330 }, -331 _renderBatch:function(start, end){ -332 var gl = this.gl; -333 var num = end - start; -334 if(num > 0){ -335 gl.bindTexture(gl.TEXTURE_2D, this._getTexture(this.sprites[start])); -336 gl.drawElements(gl.TRIANGLES, num * 6, gl.UNSIGNED_SHORT, start * 6 * 2); -337 } -338 }, -339 _uploadProjectionTransform:function(force){ -340 if(!this._projectionTransformElements||force){ -341 this._projectionTransformElements = new Float32Array([ -342 1/this.canvasHalfWidth, 0, 0, -343 0, -1/this.canvasHalfHeight, 0, -344 -1, 1, 1, -345 ]); -346 } -347 -348 this.gl.uniformMatrix3fv(this.u_projectionTransform, false, this._projectionTransformElements); -349 }, -350 _initShaders:function(){ -351 var VSHADER_SOURCE ='\ -352 attribute vec2 a_position;\n\ -353 attribute vec2 a_TexCoord;\n\ -354 attribute vec4 a_tint;\n\ -355 uniform mat3 u_projectionTransform;\n\ -356 varying vec2 v_TexCoord;\n\ -357 varying vec4 v_tint;\n\ -358 void main(){\n\ -359 gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n\ -360 v_TexCoord = a_TexCoord;\n\ -361 v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n\ -362 }\n\ -363 '; -364 -365 var FSHADER_SOURCE = '\n\ -366 precision mediump float;\n\ -367 uniform sampler2D u_Sampler;\n\ -368 varying vec2 v_TexCoord;\n\ -369 varying vec4 v_tint;\n\ -370 void main(){\n\ -371 gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n\ -372 }\n\ -373 '; -374 -375 this.defaultShader = new Shader(this, { -376 v:VSHADER_SOURCE, -377 f:FSHADER_SOURCE -378 },{ -379 attributes:["a_position", "a_TexCoord", "a_tint"], -380 uniforms:["u_projectionTransform", "u_Sampler"] -381 }); -382 }, -383 _createVertexs:function(img, tx, ty, tw, th, x, y, w, h){ -384 var tempVertexs = this.__tempVertexs||[]; -385 var width = img.width; -386 var height = img.height; -387 -388 tw = tw/width; -389 th = th/height; -390 tx = tx/width; -391 ty = ty/height; -392 -393 w = w; -394 h = h; -395 x = x; -396 y = y; -397 -398 if(tw + tx > 1){ -399 tw = 1 - tx; -400 } -401 -402 if(th + ty > 1){ -403 th = 1 - ty; -404 } -405 -406 var index = 0; -407 tempVertexs[index++] = x; tempVertexs[index++] = y; tempVertexs[index++] = tx; tempVertexs[index++] = ty; -408 tempVertexs[index++] = x+w;tempVertexs[index++] = y; tempVertexs[index++] = tx+tw; tempVertexs[index++] = ty; -409 tempVertexs[index++] = x; tempVertexs[index++] = y+h; tempVertexs[index++] = tx;tempVertexs[index++] = ty+th; -410 tempVertexs[index++] = x+w;tempVertexs[index++] = y+h;tempVertexs[index++] = tx+tw;tempVertexs[index++] = ty+th; -411 -412 return tempVertexs; -413 }, -414 _setConcatenatedMatrix:function(view, ancestor){ -415 var mtx = view.__webglWorldMatrix; -416 var cos = 1, sin = 0, -417 rotation = view.rotation % 360, -418 pivotX = view.pivotX, pivotY = view.pivotY, -419 scaleX = view.scaleX, scaleY = view.scaleY, -420 transform = view.transform; -421 -422 if (transform) { -423 mtx.copy(transform); -424 } -425 else { -426 if(rotation){ -427 var r = rotation * DEG2RAD; -428 cos = Math.cos(r); -429 sin = Math.sin(r); -430 } -431 -432 var pos = view.getAlignPosition(); -433 -434 mtx.a = cos*scaleX; -435 mtx.b = sin*scaleX; -436 mtx.c = -sin*scaleY; -437 mtx.d = cos*scaleY; -438 mtx.tx = pos.x - mtx.a * pivotX - mtx.c * pivotY; -439 mtx.ty = pos.y - mtx.b * pivotX - mtx.d * pivotY; -440 } -441 -442 mtx.concat(ancestor.__webglWorldMatrix); -443 }, -444 _getTexture:function(sprite){ -445 var image = sprite.__textureImage; -446 var texture = this._cacheTexture[image.src]; -447 if(!texture){ -448 texture = this.activeShader.uploadTexture(image); -449 } -450 return texture; -451 } -452 }); -453 -454 /** -455 * shader -456 * @param {WebGLRenderer} renderer [description] -457 * @param {Object} source -458 * @param {String} source.v 顶点shader -459 * @param {String} source.f 片段shader -460 * @param {Object} attr -461 * @param {Array} attr.attributes attribute数组 -462 * @param {Array} attr.uniforms uniform数组 -463 */ -464 var Shader = function(renderer, source, attr){ -465 this.renderer = renderer; -466 this.gl = renderer.gl; -467 this.program = this._createProgram(this.gl, source.v, source.f); -468 -469 attr = attr||{}; -470 this.attributes = attr.attributes||[]; -471 this.uniforms = attr.uniforms||[]; -472 }; -473 -474 Shader.prototype = { -475 active:function(){ -476 var that = this; -477 var renderer = that.renderer; -478 var gl = that.gl; -479 var program = that.program; +168 var vertexs = this._createVertexs(image, rect[0], rect[1], sw, sh, 0, 0, w, h); +169 var index = this.batchIndex * this.positionStride; +170 var float32Array = this.float32Array; +171 var uint32Array = this.uint32Array; +172 +173 var tint = (target.tint >> 16) + (target.tint & 0xff00) + ((target.tint & 0xff) << 16) + (target.__webglRenderAlpha * 255 << 24); +174 +175 float32Array[index + 0] = vertexs[0];//x +176 float32Array[index + 1] = vertexs[1];//y +177 float32Array[index + 2] = vertexs[2];//uvx +178 float32Array[index + 3] = vertexs[3];//uvy +179 uint32Array[index + 4] = tint;//tint +180 +181 float32Array[index + 5] = vertexs[4]; +182 float32Array[index + 6] = vertexs[5]; +183 float32Array[index + 7] = vertexs[6]; +184 float32Array[index + 8] = vertexs[7]; +185 uint32Array[index + 9] = tint; +186 +187 float32Array[index + 10] = vertexs[8]; +188 float32Array[index + 11] = vertexs[9]; +189 float32Array[index + 12] = vertexs[10]; +190 float32Array[index + 13] = vertexs[11]; +191 uint32Array[index + 14] = tint; +192 +193 float32Array[index + 15] = vertexs[12]; +194 float32Array[index + 16] = vertexs[13]; +195 float32Array[index + 17] = vertexs[14]; +196 float32Array[index + 18] = vertexs[15]; +197 uint32Array[index + 19] = tint; +198 +199 var matrix = target.__webglWorldMatrix; +200 for(var i = 0;i < 4;i ++){ +201 var x = float32Array[index + i*5]; +202 var y = float32Array[index + i*5 + 1]; +203 +204 float32Array[index + i*5] = matrix.a*x + matrix.c*y + matrix.tx; +205 float32Array[index + i*5 + 1] = matrix.b*x + matrix.d*y + matrix.ty; +206 } +207 +208 target.__textureImage = image; +209 this.sprites[this.batchIndex++] = target; +210 } +211 }, +212 +213 /** +214 * @private +215 * @see Renderer#endDraw +216 */ +217 endDraw: function(target){ +218 if(target === this.stage){ +219 this._renderBatches(); +220 } +221 }, +222 /** +223 * @private +224 * @see Renderer#transform +225 */ +226 transform: function(target){ +227 var drawable = target.drawable; +228 if(drawable && drawable.domElement){ +229 Hilo.setElementStyleByView(target); +230 return; +231 } +232 +233 var scaleX = target.scaleX, +234 scaleY = target.scaleY; +235 +236 if(target === this.stage){ +237 var style = this.canvas.style, +238 oldScaleX = target._scaleX, +239 oldScaleY = target._scaleY, +240 isStyleChange = false; +241 +242 if((!oldScaleX && scaleX != 1) || (oldScaleX && oldScaleX != scaleX)){ +243 target._scaleX = scaleX; +244 style.width = scaleX * target.width + "px"; +245 isStyleChange = true; +246 } +247 if((!oldScaleY && scaleY != 1) || (oldScaleY && oldScaleY != scaleY)){ +248 target._scaleY = scaleY; +249 style.height = scaleY * target.height + "px"; +250 isStyleChange = true; +251 } +252 if(isStyleChange){ +253 target.updateViewport(); +254 } +255 target.__webglWorldMatrix = target.__webglWorldMatrix||new Matrix(1, 0, 0, 1, 0, 0); +256 } +257 else if(target.parent){ +258 target.__webglWorldMatrix = target.__webglWorldMatrix||new Matrix(1, 0, 0, 1, 0, 0); +259 this._setConcatenatedMatrix(target, target.parent); +260 } +261 +262 if(target.alpha > 0) { +263 if(target.parent && target.parent.__webglRenderAlpha){ +264 target.__webglRenderAlpha = target.alpha * target.parent.__webglRenderAlpha; +265 } +266 else{ +267 target.__webglRenderAlpha = target.alpha; +268 } +269 } +270 }, +271 +272 /** +273 * @private +274 * @see Renderer#remove +275 */ +276 remove: function(target){ +277 var drawable = target.drawable; +278 var elem = drawable && drawable.domElement; +279 +280 if(elem){ +281 var parentElem = elem.parentNode; +282 if(parentElem){ +283 parentElem.removeChild(elem); +284 } +285 } +286 }, +287 +288 /** +289 * @private +290 * @see Renderer#clear +291 */ +292 clear: function(x, y, width, height){ +293 this.gl.clear(this.gl.COLOR_BUFFER_BIT); +294 }, +295 +296 /** +297 * @private +298 * @see Renderer#resize +299 */ +300 resize: function(width, height){ +301 if(this.width !== width || this.height !== height){ +302 var canvas = this.canvas; +303 var stage = this.stage; +304 var style = canvas.style; +305 +306 this.width = canvas.width = width; +307 this.height = canvas.height = height; +308 +309 style.width = stage.width * stage.scaleX + 'px'; +310 style.height = stage.height * stage.scaleY + 'px'; +311 +312 this.gl.viewport(0, 0, width, height); +313 +314 this.canvasHalfWidth = width * .5; +315 this.canvasHalfHeight = height * .5; +316 +317 this._uploadProjectionTransform(true); +318 } +319 }, +320 _renderBatches:function(){ +321 var gl = this.gl; +322 gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.uint32Array.subarray(0, this.batchIndex * this.positionStride)); +323 var startIndex = 0; +324 var batchNum = 0; +325 var preTextureImage = null; +326 for(var i = 0;i < this.batchIndex;i ++){ +327 var sprite = this.sprites[i]; +328 if(preTextureImage && preTextureImage !== sprite.__textureImage){ +329 this._renderBatch(startIndex, i); +330 startIndex = i; +331 batchNum = 1; +332 } +333 preTextureImage = sprite.__textureImage; +334 } +335 this._renderBatch(startIndex, this.batchIndex); +336 this.batchIndex = 0; +337 }, +338 _renderBatch:function(start, end){ +339 var gl = this.gl; +340 var num = end - start; +341 if(num > 0){ +342 gl.bindTexture(gl.TEXTURE_2D, this._getTexture(this.sprites[start])); +343 gl.drawElements(gl.TRIANGLES, num * 6, gl.UNSIGNED_SHORT, start * 6 * 2); +344 } +345 }, +346 _uploadProjectionTransform:function(force){ +347 if(!this._projectionTransformElements||force){ +348 this._projectionTransformElements = new Float32Array([ +349 1/this.canvasHalfWidth, 0, 0, +350 0, -1/this.canvasHalfHeight, 0, +351 -1, 1, 1, +352 ]); +353 } +354 +355 this.gl.uniformMatrix3fv(this.u_projectionTransform, false, this._projectionTransformElements); +356 }, +357 _initShaders:function(){ +358 var VSHADER_SOURCE ='\ +359 attribute vec2 a_position;\n\ +360 attribute vec2 a_TexCoord;\n\ +361 attribute vec4 a_tint;\n\ +362 uniform mat3 u_projectionTransform;\n\ +363 varying vec2 v_TexCoord;\n\ +364 varying vec4 v_tint;\n\ +365 void main(){\n\ +366 gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n\ +367 v_TexCoord = a_TexCoord;\n\ +368 v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n\ +369 }\n\ +370 '; +371 +372 var FSHADER_SOURCE = '\n\ +373 precision mediump float;\n\ +374 uniform sampler2D u_Sampler;\n\ +375 varying vec2 v_TexCoord;\n\ +376 varying vec4 v_tint;\n\ +377 void main(){\n\ +378 gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n\ +379 }\n\ +380 '; +381 +382 this.defaultShader = new Shader(this, { +383 v:VSHADER_SOURCE, +384 f:FSHADER_SOURCE +385 },{ +386 attributes:["a_position", "a_TexCoord", "a_tint"], +387 uniforms:["u_projectionTransform", "u_Sampler"] +388 }); +389 }, +390 _createVertexs:function(img, tx, ty, tw, th, x, y, w, h){ +391 var tempVertexs = this.__tempVertexs||[]; +392 var width = img.width; +393 var height = img.height; +394 +395 tw = tw/width; +396 th = th/height; +397 tx = tx/width; +398 ty = ty/height; +399 +400 w = w; +401 h = h; +402 x = x; +403 y = y; +404 +405 if(tw + tx > 1){ +406 tw = 1 - tx; +407 } +408 +409 if(th + ty > 1){ +410 th = 1 - ty; +411 } +412 +413 var index = 0; +414 tempVertexs[index++] = x; tempVertexs[index++] = y; tempVertexs[index++] = tx; tempVertexs[index++] = ty; +415 tempVertexs[index++] = x+w;tempVertexs[index++] = y; tempVertexs[index++] = tx+tw; tempVertexs[index++] = ty; +416 tempVertexs[index++] = x; tempVertexs[index++] = y+h; tempVertexs[index++] = tx;tempVertexs[index++] = ty+th; +417 tempVertexs[index++] = x+w;tempVertexs[index++] = y+h;tempVertexs[index++] = tx+tw;tempVertexs[index++] = ty+th; +418 +419 return tempVertexs; +420 }, +421 _setConcatenatedMatrix:function(view, ancestor){ +422 var mtx = view.__webglWorldMatrix; +423 var cos = 1, sin = 0, +424 rotation = view.rotation % 360, +425 pivotX = view.pivotX, pivotY = view.pivotY, +426 scaleX = view.scaleX, scaleY = view.scaleY, +427 transform = view.transform; +428 +429 if (transform) { +430 mtx.copy(transform); +431 } +432 else { +433 if(rotation){ +434 var r = rotation * DEG2RAD; +435 cos = Math.cos(r); +436 sin = Math.sin(r); +437 } +438 +439 var pos = view.getAlignPosition(); +440 +441 mtx.a = cos*scaleX; +442 mtx.b = sin*scaleX; +443 mtx.c = -sin*scaleY; +444 mtx.d = cos*scaleY; +445 mtx.tx = pos.x - mtx.a * pivotX - mtx.c * pivotY; +446 mtx.ty = pos.y - mtx.b * pivotX - mtx.d * pivotY; +447 } +448 +449 mtx.concat(ancestor.__webglWorldMatrix); +450 }, +451 _getTexture:function(sprite){ +452 var image = sprite.__textureImage; +453 var texture = this._cacheTexture[image.src]; +454 if(!texture){ +455 texture = this.activeShader.uploadTexture(image); +456 } +457 return texture; +458 } +459 }); +460 +461 /** +462 * shader +463 * @param {WebGLRenderer} renderer [description] +464 * @param {Object} source +465 * @param {String} source.v 顶点shader +466 * @param {String} source.f 片段shader +467 * @param {Object} attr +468 * @param {Array} attr.attributes attribute数组 +469 * @param {Array} attr.uniforms uniform数组 +470 */ +471 var Shader = function(renderer, source, attr){ +472 this.renderer = renderer; +473 this.gl = renderer.gl; +474 this.program = this._createProgram(this.gl, source.v, source.f); +475 +476 attr = attr||{}; +477 this.attributes = attr.attributes||[]; +478 this.uniforms = attr.uniforms||[]; +479 }; 480 -481 if(program && gl){ -482 renderer.activeShader = that; -483 gl.useProgram(program); -484 that.attributes.forEach(function(attribute){ -485 renderer[attribute] = gl.getAttribLocation(program, attribute); -486 gl.enableVertexAttribArray(renderer[attribute]); -487 }); -488 -489 that.uniforms.forEach(function(uniform){ -490 renderer[uniform] = gl.getUniformLocation(program, uniform); -491 }); -492 -493 if(that.width !== renderer.width || that.height !== renderer.height){ -494 that.width = renderer.width; -495 that.height = renderer.height; -496 renderer._uploadProjectionTransform(); -497 } -498 } -499 }, -500 uploadTexture:function(image){ -501 var gl = this.gl; -502 var renderer = this.renderer; -503 var texture = gl.createTexture(); -504 var u_Sampler = renderer.u_Sampler; -505 -506 gl.activeTexture(gl.TEXTURE0); -507 gl.bindTexture(gl.TEXTURE_2D, texture); -508 -509 // gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1); -510 gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1); -511 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); +481 Shader.prototype = { +482 active:function(){ +483 var that = this; +484 var renderer = that.renderer; +485 var gl = that.gl; +486 var program = that.program; +487 +488 if(program && gl){ +489 renderer.activeShader = that; +490 gl.useProgram(program); +491 that.attributes.forEach(function(attribute){ +492 renderer[attribute] = gl.getAttribLocation(program, attribute); +493 gl.enableVertexAttribArray(renderer[attribute]); +494 }); +495 +496 that.uniforms.forEach(function(uniform){ +497 renderer[uniform] = gl.getUniformLocation(program, uniform); +498 }); +499 +500 if(that.width !== renderer.width || that.height !== renderer.height){ +501 that.width = renderer.width; +502 that.height = renderer.height; +503 renderer._uploadProjectionTransform(); +504 } +505 } +506 }, +507 uploadTexture:function(image){ +508 var gl = this.gl; +509 var renderer = this.renderer; +510 var texture = gl.createTexture(); +511 var u_Sampler = renderer.u_Sampler; 512 -513 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); -514 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); -515 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); -516 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); -517 gl.uniform1i(u_Sampler, 0); -518 gl.bindTexture(gl.TEXTURE_2D, null); +513 gl.activeTexture(gl.TEXTURE0); +514 gl.bindTexture(gl.TEXTURE_2D, texture); +515 +516 // gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1); +517 gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1); +518 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); 519 -520 this.renderer._cacheTexture[image.src] = texture; -521 return texture; -522 }, -523 _createProgram:function(gl, vshader, fshader){ -524 var vertexShader = this._createShader(gl, gl.VERTEX_SHADER, vshader); -525 var fragmentShader = this._createShader(gl, gl.FRAGMENT_SHADER, fshader); -526 if (!vertexShader || !fragmentShader) { -527 return null; -528 } -529 -530 var program = gl.createProgram(); -531 if (program) { -532 gl.attachShader(program, vertexShader); -533 gl.attachShader(program, fragmentShader); -534 -535 gl.linkProgram(program); +520 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); +521 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); +522 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); +523 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); +524 gl.uniform1i(u_Sampler, 0); +525 gl.bindTexture(gl.TEXTURE_2D, null); +526 +527 this.renderer._cacheTexture[image.src] = texture; +528 return texture; +529 }, +530 _createProgram:function(gl, vshader, fshader){ +531 var vertexShader = this._createShader(gl, gl.VERTEX_SHADER, vshader); +532 var fragmentShader = this._createShader(gl, gl.FRAGMENT_SHADER, fshader); +533 if (!vertexShader || !fragmentShader) { +534 return null; +535 } 536 -537 gl.deleteShader(fragmentShader); -538 gl.deleteShader(vertexShader); -539 var linked = gl.getProgramParameter(program, gl.LINK_STATUS); -540 if (!linked) { -541 var error = gl.getProgramInfoLog(program); -542 console.log('Failed to link program: ' + error); -543 gl.deleteProgram(program); -544 return null; -545 } -546 } -547 return program; -548 }, -549 _createShader:function(gl, type, source){ -550 var shader = gl.createShader(type); -551 if(shader){ -552 gl.shaderSource(shader, source); -553 gl.compileShader(shader); -554 -555 var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS); -556 if (!compiled) { -557 var error = gl.getShaderInfoLog(shader); -558 console.log('Failed to compile shader: ' + error); -559 gl.deleteShader(shader); -560 return null; -561 } -562 } -563 return shader; -564 } -565 }; \ No newline at end of file +537 var program = gl.createProgram(); +538 if (program) { +539 gl.attachShader(program, vertexShader); +540 gl.attachShader(program, fragmentShader); +541 +542 gl.linkProgram(program); +543 +544 gl.deleteShader(fragmentShader); +545 gl.deleteShader(vertexShader); +546 var linked = gl.getProgramParameter(program, gl.LINK_STATUS); +547 if (!linked) { +548 var error = gl.getProgramInfoLog(program); +549 console.log('Failed to link program: ' + error); +550 gl.deleteProgram(program); +551 return null; +552 } +553 } +554 return program; +555 }, +556 _createShader:function(gl, type, source){ +557 var shader = gl.createShader(type); +558 if(shader){ +559 gl.shaderSource(shader, source); +560 gl.compileShader(shader); +561 +562 var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS); +563 if (!compiled) { +564 var error = gl.getShaderInfoLog(shader); +565 console.log('Failed to compile shader: ' + error); +566 gl.deleteShader(shader); +567 return null; +568 } +569 } +570 return shader; +571 } +572 }; \ No newline at end of file diff --git a/docs/api-en/symbols/src/docs_api-en_code_view_Text.js.html b/docs/api-en/symbols/src/docs_api-en_code_view_Text.js.html index e0ebf88c..6135e00c 100644 --- a/docs/api-en/symbols/src/docs_api-en_code_view_Text.js.html +++ b/docs/api-en/symbols/src/docs_api-en_code_view_Text.js.html @@ -50,7 +50,7 @@ 43 this._fontHeight = Text.measureFontHeight(this.font); 44 }, 45 - 46 text: null, + 46 text: '', 47 color: '#000', 48 textAlign: null, 49 textVAlign: null, diff --git a/docs/api-zh/code/renderer/WebGLRenderer.js b/docs/api-zh/code/renderer/WebGLRenderer.js index a52ac0d7..16c08d73 100644 --- a/docs/api-zh/code/renderer/WebGLRenderer.js +++ b/docs/api-zh/code/renderer/WebGLRenderer.js @@ -49,7 +49,13 @@ var WebGLRenderer = Class.create(/** @lends WebGLRenderer.prototype */{ } } return this._isSupported; - } + }, + /** + * WebGL context Options + * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getContextAttributes + * @type {Object} + */ + contextOptions: null }, renderType:'webgl', gl:null, @@ -58,7 +64,8 @@ var WebGLRenderer = Class.create(/** @lends WebGLRenderer.prototype */{ constructor: function(properties){ WebGLRenderer.superclass.constructor.call(this, properties); var that = this; - this.gl = this.canvas.getContext("webgl")||this.canvas.getContext('experimental-webgl'); + var contextOptions = WebGLRenderer.contextOptions || {}; + this.gl = this.canvas.getContext("webgl", contextOptions)||this.canvas.getContext('experimental-webgl', contextOptions); this.maxBatchNum = WebGLRenderer.MAX_BATCH_NUM; this.positionStride = WebGLRenderer.ATTRIBUTE_NUM * 4; diff --git a/docs/api-zh/code/view/Text.js b/docs/api-zh/code/view/Text.js index bde0c769..d39b0c43 100644 --- a/docs/api-zh/code/view/Text.js +++ b/docs/api-zh/code/view/Text.js @@ -43,7 +43,7 @@ var Text = Class.create(/** @lends Text.prototype */{ this._fontHeight = Text.measureFontHeight(this.font); }, - text: null, + text: '', color: '#000', textAlign: null, textVAlign: null, diff --git a/docs/api-zh/index.html b/docs/api-zh/index.html index 6f1cc476..858116b1 100644 --- a/docs/api-zh/index.html +++ b/docs/api-zh/index.html @@ -188,7 +188,7 @@
-
全部类概览(v1.3.0)
+
全部类概览(v1.4.0)
diff --git a/docs/api-zh/symbols/WebGLRenderer.html b/docs/api-zh/symbols/WebGLRenderer.html index 9ebe653a..fb5d6d1f 100644 --- a/docs/api-zh/symbols/WebGLRenderer.html +++ b/docs/api-zh/symbols/WebGLRenderer.html @@ -278,6 +278,28 @@

属性概览

+ + + + + + +
+ + + +
+ static + WebGL context Options +
+
+ WebGLRenderer +
@@ -644,6 +666,32 @@

属性详情

+ + + +
+
[Static] + contextOptions + +
+
+ WebGL context Options +
+ + + + + + +
+
查看相关:
+ +
https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getContextAttributes
+ +
+ + +
diff --git a/docs/api-zh/symbols/src/docs_api-zh_code_renderer_WebGLRenderer.js.html b/docs/api-zh/symbols/src/docs_api-zh_code_renderer_WebGLRenderer.js.html index 6b030c23..ff059392 100644 --- a/docs/api-zh/symbols/src/docs_api-zh_code_renderer_WebGLRenderer.js.html +++ b/docs/api-zh/symbols/src/docs_api-zh_code_renderer_WebGLRenderer.js.html @@ -56,517 +56,524 @@ 49 } 50 } 51 return this._isSupported; - 52 } - 53 }, - 54 renderType:'webgl', - 55 gl:null, - 56 _isContextLost:false, - 57 _cacheTexture:{}, - 58 constructor: function(properties){ - 59 WebGLRenderer.superclass.constructor.call(this, properties); - 60 var that = this; - 61 this.gl = this.canvas.getContext("webgl")||this.canvas.getContext('experimental-webgl'); - 62 - 63 this.maxBatchNum = WebGLRenderer.MAX_BATCH_NUM; - 64 this.positionStride = WebGLRenderer.ATTRIBUTE_NUM * 4; - 65 var vertexNum = this.maxBatchNum * WebGLRenderer.ATTRIBUTE_NUM * 4; - 66 var indexNum = this.maxBatchNum * 6; - 67 this.arrayBuffer = new ArrayBuffer(vertexNum * 4); - 68 this.float32Array = new Float32Array(this.arrayBuffer); - 69 this.uint32Array = new Uint32Array(this.arrayBuffer); - 70 this.indexs = new Uint16Array(indexNum); - 71 for (var i=0, j=0; i < indexNum; i += 6, j += 4) - 72 { - 73 this.indexs[i + 0] = j + 0; - 74 this.indexs[i + 1] = j + 1; - 75 this.indexs[i + 2] = j + 2; - 76 this.indexs[i + 3] = j + 1; - 77 this.indexs[i + 4] = j + 2; - 78 this.indexs[i + 5] = j + 3; - 79 } - 80 this.batchIndex = 0; - 81 this.sprites = []; - 82 - 83 this.canvas.addEventListener('webglcontextlost', function(e){ - 84 that._isContextLost = true; - 85 e.preventDefault(); - 86 }, false); - 87 - 88 this.canvas.addEventListener('webglcontextrestored', function(e){ - 89 that._isContextLost = false; - 90 that.setupWebGLStateAndResource(); - 91 }, false); - 92 - 93 this.setupWebGLStateAndResource(); - 94 }, - 95 setupWebGLStateAndResource:function(){ - 96 var gl = this.gl; - 97 gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); - 98 gl.clearColor(0, 0, 0, 0); - 99 gl.disable(gl.DEPTH_TEST); -100 gl.disable(gl.CULL_FACE); -101 gl.enable(gl.BLEND); -102 -103 this._cacheTexture = {}; -104 this._initShaders(); -105 this.defaultShader.active(); -106 -107 this.positionBuffer = gl.createBuffer(); -108 this.indexBuffer = gl.createBuffer(); + 52 }, + 53 /** + 54 * WebGL context Options + 55 * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getContextAttributes + 56 * @type {Object} + 57 */ + 58 contextOptions: null + 59 }, + 60 renderType:'webgl', + 61 gl:null, + 62 _isContextLost:false, + 63 _cacheTexture:{}, + 64 constructor: function(properties){ + 65 WebGLRenderer.superclass.constructor.call(this, properties); + 66 var that = this; + 67 var contextOptions = WebGLRenderer.contextOptions || {}; + 68 this.gl = this.canvas.getContext("webgl", contextOptions)||this.canvas.getContext('experimental-webgl', contextOptions); + 69 + 70 this.maxBatchNum = WebGLRenderer.MAX_BATCH_NUM; + 71 this.positionStride = WebGLRenderer.ATTRIBUTE_NUM * 4; + 72 var vertexNum = this.maxBatchNum * WebGLRenderer.ATTRIBUTE_NUM * 4; + 73 var indexNum = this.maxBatchNum * 6; + 74 this.arrayBuffer = new ArrayBuffer(vertexNum * 4); + 75 this.float32Array = new Float32Array(this.arrayBuffer); + 76 this.uint32Array = new Uint32Array(this.arrayBuffer); + 77 this.indexs = new Uint16Array(indexNum); + 78 for (var i=0, j=0; i < indexNum; i += 6, j += 4) + 79 { + 80 this.indexs[i + 0] = j + 0; + 81 this.indexs[i + 1] = j + 1; + 82 this.indexs[i + 2] = j + 2; + 83 this.indexs[i + 3] = j + 1; + 84 this.indexs[i + 4] = j + 2; + 85 this.indexs[i + 5] = j + 3; + 86 } + 87 this.batchIndex = 0; + 88 this.sprites = []; + 89 + 90 this.canvas.addEventListener('webglcontextlost', function(e){ + 91 that._isContextLost = true; + 92 e.preventDefault(); + 93 }, false); + 94 + 95 this.canvas.addEventListener('webglcontextrestored', function(e){ + 96 that._isContextLost = false; + 97 that.setupWebGLStateAndResource(); + 98 }, false); + 99 +100 this.setupWebGLStateAndResource(); +101 }, +102 setupWebGLStateAndResource:function(){ +103 var gl = this.gl; +104 gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); +105 gl.clearColor(0, 0, 0, 0); +106 gl.disable(gl.DEPTH_TEST); +107 gl.disable(gl.CULL_FACE); +108 gl.enable(gl.BLEND); 109 -110 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); -111 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indexs, gl.STATIC_DRAW); -112 -113 gl.bindBuffer(gl.ARRAY_BUFFER, this.positionBuffer); -114 gl.bufferData(gl.ARRAY_BUFFER, this.arrayBuffer, gl.DYNAMIC_DRAW); -115 -116 gl.vertexAttribPointer(this.a_position, 2, gl.FLOAT, false, this.positionStride, 0);//x, y -117 gl.vertexAttribPointer(this.a_TexCoord, 2, gl.FLOAT, false, this.positionStride, 2 * 4);//x, y -118 gl.vertexAttribPointer(this.a_tint, 4, gl.UNSIGNED_BYTE, true, this.positionStride, 4 * 4);//alpha -119 }, -120 -121 context: null, +110 this._cacheTexture = {}; +111 this._initShaders(); +112 this.defaultShader.active(); +113 +114 this.positionBuffer = gl.createBuffer(); +115 this.indexBuffer = gl.createBuffer(); +116 +117 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); +118 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indexs, gl.STATIC_DRAW); +119 +120 gl.bindBuffer(gl.ARRAY_BUFFER, this.positionBuffer); +121 gl.bufferData(gl.ARRAY_BUFFER, this.arrayBuffer, gl.DYNAMIC_DRAW); 122 -123 /** -124 * @private -125 * @see Renderer#startDraw -126 */ -127 startDraw: function(target){ -128 if(target.visible && target.alpha > 0){ -129 if(target === this.stage){ -130 this.clear(); -131 } -132 return true; -133 } -134 return false; -135 }, -136 /** -137 * @private -138 * @see Renderer#draw -139 */ -140 draw: function(target){ -141 var w = target.width, -142 h = target.height; -143 -144 //TODO:draw background -145 var bg = target.background; // jshint ignore:line -146 -147 //draw image -148 var drawable = target.drawable, image = drawable && drawable.image; -149 if(image){ -150 var rect = drawable.rect, sw = rect[2], sh = rect[3]; -151 if(!w && !h){ -152 //fix width/height TODO: how to get rid of this? -153 w = target.width = sw; -154 h = target.height = sh; -155 } -156 -157 if(this.batchIndex >= this.maxBatchNum){ -158 this._renderBatches(); -159 } -160 -161 var vertexs = this._createVertexs(image, rect[0], rect[1], sw, sh, 0, 0, w, h); -162 var index = this.batchIndex * this.positionStride; -163 var float32Array = this.float32Array; -164 var uint32Array = this.uint32Array; -165 -166 var tint = (target.tint >> 16) + (target.tint & 0xff00) + ((target.tint & 0xff) << 16) + (target.__webglRenderAlpha * 255 << 24); +123 gl.vertexAttribPointer(this.a_position, 2, gl.FLOAT, false, this.positionStride, 0);//x, y +124 gl.vertexAttribPointer(this.a_TexCoord, 2, gl.FLOAT, false, this.positionStride, 2 * 4);//x, y +125 gl.vertexAttribPointer(this.a_tint, 4, gl.UNSIGNED_BYTE, true, this.positionStride, 4 * 4);//alpha +126 }, +127 +128 context: null, +129 +130 /** +131 * @private +132 * @see Renderer#startDraw +133 */ +134 startDraw: function(target){ +135 if(target.visible && target.alpha > 0){ +136 if(target === this.stage){ +137 this.clear(); +138 } +139 return true; +140 } +141 return false; +142 }, +143 /** +144 * @private +145 * @see Renderer#draw +146 */ +147 draw: function(target){ +148 var w = target.width, +149 h = target.height; +150 +151 //TODO:draw background +152 var bg = target.background; // jshint ignore:line +153 +154 //draw image +155 var drawable = target.drawable, image = drawable && drawable.image; +156 if(image){ +157 var rect = drawable.rect, sw = rect[2], sh = rect[3]; +158 if(!w && !h){ +159 //fix width/height TODO: how to get rid of this? +160 w = target.width = sw; +161 h = target.height = sh; +162 } +163 +164 if(this.batchIndex >= this.maxBatchNum){ +165 this._renderBatches(); +166 } 167 -168 float32Array[index + 0] = vertexs[0];//x -169 float32Array[index + 1] = vertexs[1];//y -170 float32Array[index + 2] = vertexs[2];//uvx -171 float32Array[index + 3] = vertexs[3];//uvy -172 uint32Array[index + 4] = tint;//tint -173 -174 float32Array[index + 5] = vertexs[4]; -175 float32Array[index + 6] = vertexs[5]; -176 float32Array[index + 7] = vertexs[6]; -177 float32Array[index + 8] = vertexs[7]; -178 uint32Array[index + 9] = tint; -179 -180 float32Array[index + 10] = vertexs[8]; -181 float32Array[index + 11] = vertexs[9]; -182 float32Array[index + 12] = vertexs[10]; -183 float32Array[index + 13] = vertexs[11]; -184 uint32Array[index + 14] = tint; -185 -186 float32Array[index + 15] = vertexs[12]; -187 float32Array[index + 16] = vertexs[13]; -188 float32Array[index + 17] = vertexs[14]; -189 float32Array[index + 18] = vertexs[15]; -190 uint32Array[index + 19] = tint; -191 -192 var matrix = target.__webglWorldMatrix; -193 for(var i = 0;i < 4;i ++){ -194 var x = float32Array[index + i*5]; -195 var y = float32Array[index + i*5 + 1]; -196 -197 float32Array[index + i*5] = matrix.a*x + matrix.c*y + matrix.tx; -198 float32Array[index + i*5 + 1] = matrix.b*x + matrix.d*y + matrix.ty; -199 } -200 -201 target.__textureImage = image; -202 this.sprites[this.batchIndex++] = target; -203 } -204 }, -205 -206 /** -207 * @private -208 * @see Renderer#endDraw -209 */ -210 endDraw: function(target){ -211 if(target === this.stage){ -212 this._renderBatches(); -213 } -214 }, -215 /** -216 * @private -217 * @see Renderer#transform -218 */ -219 transform: function(target){ -220 var drawable = target.drawable; -221 if(drawable && drawable.domElement){ -222 Hilo.setElementStyleByView(target); -223 return; -224 } -225 -226 var scaleX = target.scaleX, -227 scaleY = target.scaleY; -228 -229 if(target === this.stage){ -230 var style = this.canvas.style, -231 oldScaleX = target._scaleX, -232 oldScaleY = target._scaleY, -233 isStyleChange = false; -234 -235 if((!oldScaleX && scaleX != 1) || (oldScaleX && oldScaleX != scaleX)){ -236 target._scaleX = scaleX; -237 style.width = scaleX * target.width + "px"; -238 isStyleChange = true; -239 } -240 if((!oldScaleY && scaleY != 1) || (oldScaleY && oldScaleY != scaleY)){ -241 target._scaleY = scaleY; -242 style.height = scaleY * target.height + "px"; -243 isStyleChange = true; -244 } -245 if(isStyleChange){ -246 target.updateViewport(); -247 } -248 target.__webglWorldMatrix = target.__webglWorldMatrix||new Matrix(1, 0, 0, 1, 0, 0); -249 } -250 else if(target.parent){ -251 target.__webglWorldMatrix = target.__webglWorldMatrix||new Matrix(1, 0, 0, 1, 0, 0); -252 this._setConcatenatedMatrix(target, target.parent); -253 } -254 -255 if(target.alpha > 0) { -256 if(target.parent && target.parent.__webglRenderAlpha){ -257 target.__webglRenderAlpha = target.alpha * target.parent.__webglRenderAlpha; -258 } -259 else{ -260 target.__webglRenderAlpha = target.alpha; -261 } -262 } -263 }, -264 -265 /** -266 * @private -267 * @see Renderer#remove -268 */ -269 remove: function(target){ -270 var drawable = target.drawable; -271 var elem = drawable && drawable.domElement; -272 -273 if(elem){ -274 var parentElem = elem.parentNode; -275 if(parentElem){ -276 parentElem.removeChild(elem); -277 } -278 } -279 }, -280 -281 /** -282 * @private -283 * @see Renderer#clear -284 */ -285 clear: function(x, y, width, height){ -286 this.gl.clear(this.gl.COLOR_BUFFER_BIT); -287 }, -288 -289 /** -290 * @private -291 * @see Renderer#resize -292 */ -293 resize: function(width, height){ -294 if(this.width !== width || this.height !== height){ -295 var canvas = this.canvas; -296 var stage = this.stage; -297 var style = canvas.style; -298 -299 this.width = canvas.width = width; -300 this.height = canvas.height = height; -301 -302 style.width = stage.width * stage.scaleX + 'px'; -303 style.height = stage.height * stage.scaleY + 'px'; -304 -305 this.gl.viewport(0, 0, width, height); -306 -307 this.canvasHalfWidth = width * .5; -308 this.canvasHalfHeight = height * .5; -309 -310 this._uploadProjectionTransform(true); -311 } -312 }, -313 _renderBatches:function(){ -314 var gl = this.gl; -315 gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.uint32Array.subarray(0, this.batchIndex * this.positionStride)); -316 var startIndex = 0; -317 var batchNum = 0; -318 var preTextureImage = null; -319 for(var i = 0;i < this.batchIndex;i ++){ -320 var sprite = this.sprites[i]; -321 if(preTextureImage && preTextureImage !== sprite.__textureImage){ -322 this._renderBatch(startIndex, i); -323 startIndex = i; -324 batchNum = 1; -325 } -326 preTextureImage = sprite.__textureImage; -327 } -328 this._renderBatch(startIndex, this.batchIndex); -329 this.batchIndex = 0; -330 }, -331 _renderBatch:function(start, end){ -332 var gl = this.gl; -333 var num = end - start; -334 if(num > 0){ -335 gl.bindTexture(gl.TEXTURE_2D, this._getTexture(this.sprites[start])); -336 gl.drawElements(gl.TRIANGLES, num * 6, gl.UNSIGNED_SHORT, start * 6 * 2); -337 } -338 }, -339 _uploadProjectionTransform:function(force){ -340 if(!this._projectionTransformElements||force){ -341 this._projectionTransformElements = new Float32Array([ -342 1/this.canvasHalfWidth, 0, 0, -343 0, -1/this.canvasHalfHeight, 0, -344 -1, 1, 1, -345 ]); -346 } -347 -348 this.gl.uniformMatrix3fv(this.u_projectionTransform, false, this._projectionTransformElements); -349 }, -350 _initShaders:function(){ -351 var VSHADER_SOURCE ='\ -352 attribute vec2 a_position;\n\ -353 attribute vec2 a_TexCoord;\n\ -354 attribute vec4 a_tint;\n\ -355 uniform mat3 u_projectionTransform;\n\ -356 varying vec2 v_TexCoord;\n\ -357 varying vec4 v_tint;\n\ -358 void main(){\n\ -359 gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n\ -360 v_TexCoord = a_TexCoord;\n\ -361 v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n\ -362 }\n\ -363 '; -364 -365 var FSHADER_SOURCE = '\n\ -366 precision mediump float;\n\ -367 uniform sampler2D u_Sampler;\n\ -368 varying vec2 v_TexCoord;\n\ -369 varying vec4 v_tint;\n\ -370 void main(){\n\ -371 gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n\ -372 }\n\ -373 '; -374 -375 this.defaultShader = new Shader(this, { -376 v:VSHADER_SOURCE, -377 f:FSHADER_SOURCE -378 },{ -379 attributes:["a_position", "a_TexCoord", "a_tint"], -380 uniforms:["u_projectionTransform", "u_Sampler"] -381 }); -382 }, -383 _createVertexs:function(img, tx, ty, tw, th, x, y, w, h){ -384 var tempVertexs = this.__tempVertexs||[]; -385 var width = img.width; -386 var height = img.height; -387 -388 tw = tw/width; -389 th = th/height; -390 tx = tx/width; -391 ty = ty/height; -392 -393 w = w; -394 h = h; -395 x = x; -396 y = y; -397 -398 if(tw + tx > 1){ -399 tw = 1 - tx; -400 } -401 -402 if(th + ty > 1){ -403 th = 1 - ty; -404 } -405 -406 var index = 0; -407 tempVertexs[index++] = x; tempVertexs[index++] = y; tempVertexs[index++] = tx; tempVertexs[index++] = ty; -408 tempVertexs[index++] = x+w;tempVertexs[index++] = y; tempVertexs[index++] = tx+tw; tempVertexs[index++] = ty; -409 tempVertexs[index++] = x; tempVertexs[index++] = y+h; tempVertexs[index++] = tx;tempVertexs[index++] = ty+th; -410 tempVertexs[index++] = x+w;tempVertexs[index++] = y+h;tempVertexs[index++] = tx+tw;tempVertexs[index++] = ty+th; -411 -412 return tempVertexs; -413 }, -414 _setConcatenatedMatrix:function(view, ancestor){ -415 var mtx = view.__webglWorldMatrix; -416 var cos = 1, sin = 0, -417 rotation = view.rotation % 360, -418 pivotX = view.pivotX, pivotY = view.pivotY, -419 scaleX = view.scaleX, scaleY = view.scaleY, -420 transform = view.transform; -421 -422 if (transform) { -423 mtx.copy(transform); -424 } -425 else { -426 if(rotation){ -427 var r = rotation * DEG2RAD; -428 cos = Math.cos(r); -429 sin = Math.sin(r); -430 } -431 -432 var pos = view.getAlignPosition(); -433 -434 mtx.a = cos*scaleX; -435 mtx.b = sin*scaleX; -436 mtx.c = -sin*scaleY; -437 mtx.d = cos*scaleY; -438 mtx.tx = pos.x - mtx.a * pivotX - mtx.c * pivotY; -439 mtx.ty = pos.y - mtx.b * pivotX - mtx.d * pivotY; -440 } -441 -442 mtx.concat(ancestor.__webglWorldMatrix); -443 }, -444 _getTexture:function(sprite){ -445 var image = sprite.__textureImage; -446 var texture = this._cacheTexture[image.src]; -447 if(!texture){ -448 texture = this.activeShader.uploadTexture(image); -449 } -450 return texture; -451 } -452 }); -453 -454 /** -455 * shader -456 * @param {WebGLRenderer} renderer [description] -457 * @param {Object} source -458 * @param {String} source.v 顶点shader -459 * @param {String} source.f 片段shader -460 * @param {Object} attr -461 * @param {Array} attr.attributes attribute数组 -462 * @param {Array} attr.uniforms uniform数组 -463 */ -464 var Shader = function(renderer, source, attr){ -465 this.renderer = renderer; -466 this.gl = renderer.gl; -467 this.program = this._createProgram(this.gl, source.v, source.f); -468 -469 attr = attr||{}; -470 this.attributes = attr.attributes||[]; -471 this.uniforms = attr.uniforms||[]; -472 }; -473 -474 Shader.prototype = { -475 active:function(){ -476 var that = this; -477 var renderer = that.renderer; -478 var gl = that.gl; -479 var program = that.program; +168 var vertexs = this._createVertexs(image, rect[0], rect[1], sw, sh, 0, 0, w, h); +169 var index = this.batchIndex * this.positionStride; +170 var float32Array = this.float32Array; +171 var uint32Array = this.uint32Array; +172 +173 var tint = (target.tint >> 16) + (target.tint & 0xff00) + ((target.tint & 0xff) << 16) + (target.__webglRenderAlpha * 255 << 24); +174 +175 float32Array[index + 0] = vertexs[0];//x +176 float32Array[index + 1] = vertexs[1];//y +177 float32Array[index + 2] = vertexs[2];//uvx +178 float32Array[index + 3] = vertexs[3];//uvy +179 uint32Array[index + 4] = tint;//tint +180 +181 float32Array[index + 5] = vertexs[4]; +182 float32Array[index + 6] = vertexs[5]; +183 float32Array[index + 7] = vertexs[6]; +184 float32Array[index + 8] = vertexs[7]; +185 uint32Array[index + 9] = tint; +186 +187 float32Array[index + 10] = vertexs[8]; +188 float32Array[index + 11] = vertexs[9]; +189 float32Array[index + 12] = vertexs[10]; +190 float32Array[index + 13] = vertexs[11]; +191 uint32Array[index + 14] = tint; +192 +193 float32Array[index + 15] = vertexs[12]; +194 float32Array[index + 16] = vertexs[13]; +195 float32Array[index + 17] = vertexs[14]; +196 float32Array[index + 18] = vertexs[15]; +197 uint32Array[index + 19] = tint; +198 +199 var matrix = target.__webglWorldMatrix; +200 for(var i = 0;i < 4;i ++){ +201 var x = float32Array[index + i*5]; +202 var y = float32Array[index + i*5 + 1]; +203 +204 float32Array[index + i*5] = matrix.a*x + matrix.c*y + matrix.tx; +205 float32Array[index + i*5 + 1] = matrix.b*x + matrix.d*y + matrix.ty; +206 } +207 +208 target.__textureImage = image; +209 this.sprites[this.batchIndex++] = target; +210 } +211 }, +212 +213 /** +214 * @private +215 * @see Renderer#endDraw +216 */ +217 endDraw: function(target){ +218 if(target === this.stage){ +219 this._renderBatches(); +220 } +221 }, +222 /** +223 * @private +224 * @see Renderer#transform +225 */ +226 transform: function(target){ +227 var drawable = target.drawable; +228 if(drawable && drawable.domElement){ +229 Hilo.setElementStyleByView(target); +230 return; +231 } +232 +233 var scaleX = target.scaleX, +234 scaleY = target.scaleY; +235 +236 if(target === this.stage){ +237 var style = this.canvas.style, +238 oldScaleX = target._scaleX, +239 oldScaleY = target._scaleY, +240 isStyleChange = false; +241 +242 if((!oldScaleX && scaleX != 1) || (oldScaleX && oldScaleX != scaleX)){ +243 target._scaleX = scaleX; +244 style.width = scaleX * target.width + "px"; +245 isStyleChange = true; +246 } +247 if((!oldScaleY && scaleY != 1) || (oldScaleY && oldScaleY != scaleY)){ +248 target._scaleY = scaleY; +249 style.height = scaleY * target.height + "px"; +250 isStyleChange = true; +251 } +252 if(isStyleChange){ +253 target.updateViewport(); +254 } +255 target.__webglWorldMatrix = target.__webglWorldMatrix||new Matrix(1, 0, 0, 1, 0, 0); +256 } +257 else if(target.parent){ +258 target.__webglWorldMatrix = target.__webglWorldMatrix||new Matrix(1, 0, 0, 1, 0, 0); +259 this._setConcatenatedMatrix(target, target.parent); +260 } +261 +262 if(target.alpha > 0) { +263 if(target.parent && target.parent.__webglRenderAlpha){ +264 target.__webglRenderAlpha = target.alpha * target.parent.__webglRenderAlpha; +265 } +266 else{ +267 target.__webglRenderAlpha = target.alpha; +268 } +269 } +270 }, +271 +272 /** +273 * @private +274 * @see Renderer#remove +275 */ +276 remove: function(target){ +277 var drawable = target.drawable; +278 var elem = drawable && drawable.domElement; +279 +280 if(elem){ +281 var parentElem = elem.parentNode; +282 if(parentElem){ +283 parentElem.removeChild(elem); +284 } +285 } +286 }, +287 +288 /** +289 * @private +290 * @see Renderer#clear +291 */ +292 clear: function(x, y, width, height){ +293 this.gl.clear(this.gl.COLOR_BUFFER_BIT); +294 }, +295 +296 /** +297 * @private +298 * @see Renderer#resize +299 */ +300 resize: function(width, height){ +301 if(this.width !== width || this.height !== height){ +302 var canvas = this.canvas; +303 var stage = this.stage; +304 var style = canvas.style; +305 +306 this.width = canvas.width = width; +307 this.height = canvas.height = height; +308 +309 style.width = stage.width * stage.scaleX + 'px'; +310 style.height = stage.height * stage.scaleY + 'px'; +311 +312 this.gl.viewport(0, 0, width, height); +313 +314 this.canvasHalfWidth = width * .5; +315 this.canvasHalfHeight = height * .5; +316 +317 this._uploadProjectionTransform(true); +318 } +319 }, +320 _renderBatches:function(){ +321 var gl = this.gl; +322 gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.uint32Array.subarray(0, this.batchIndex * this.positionStride)); +323 var startIndex = 0; +324 var batchNum = 0; +325 var preTextureImage = null; +326 for(var i = 0;i < this.batchIndex;i ++){ +327 var sprite = this.sprites[i]; +328 if(preTextureImage && preTextureImage !== sprite.__textureImage){ +329 this._renderBatch(startIndex, i); +330 startIndex = i; +331 batchNum = 1; +332 } +333 preTextureImage = sprite.__textureImage; +334 } +335 this._renderBatch(startIndex, this.batchIndex); +336 this.batchIndex = 0; +337 }, +338 _renderBatch:function(start, end){ +339 var gl = this.gl; +340 var num = end - start; +341 if(num > 0){ +342 gl.bindTexture(gl.TEXTURE_2D, this._getTexture(this.sprites[start])); +343 gl.drawElements(gl.TRIANGLES, num * 6, gl.UNSIGNED_SHORT, start * 6 * 2); +344 } +345 }, +346 _uploadProjectionTransform:function(force){ +347 if(!this._projectionTransformElements||force){ +348 this._projectionTransformElements = new Float32Array([ +349 1/this.canvasHalfWidth, 0, 0, +350 0, -1/this.canvasHalfHeight, 0, +351 -1, 1, 1, +352 ]); +353 } +354 +355 this.gl.uniformMatrix3fv(this.u_projectionTransform, false, this._projectionTransformElements); +356 }, +357 _initShaders:function(){ +358 var VSHADER_SOURCE ='\ +359 attribute vec2 a_position;\n\ +360 attribute vec2 a_TexCoord;\n\ +361 attribute vec4 a_tint;\n\ +362 uniform mat3 u_projectionTransform;\n\ +363 varying vec2 v_TexCoord;\n\ +364 varying vec4 v_tint;\n\ +365 void main(){\n\ +366 gl_Position = vec4((u_projectionTransform * vec3(a_position, 1.0)).xy, 1.0, 1.0);\n\ +367 v_TexCoord = a_TexCoord;\n\ +368 v_tint = vec4(a_tint.rgb * a_tint.a, a_tint.a);\n\ +369 }\n\ +370 '; +371 +372 var FSHADER_SOURCE = '\n\ +373 precision mediump float;\n\ +374 uniform sampler2D u_Sampler;\n\ +375 varying vec2 v_TexCoord;\n\ +376 varying vec4 v_tint;\n\ +377 void main(){\n\ +378 gl_FragColor = texture2D(u_Sampler, v_TexCoord) * v_tint;\n\ +379 }\n\ +380 '; +381 +382 this.defaultShader = new Shader(this, { +383 v:VSHADER_SOURCE, +384 f:FSHADER_SOURCE +385 },{ +386 attributes:["a_position", "a_TexCoord", "a_tint"], +387 uniforms:["u_projectionTransform", "u_Sampler"] +388 }); +389 }, +390 _createVertexs:function(img, tx, ty, tw, th, x, y, w, h){ +391 var tempVertexs = this.__tempVertexs||[]; +392 var width = img.width; +393 var height = img.height; +394 +395 tw = tw/width; +396 th = th/height; +397 tx = tx/width; +398 ty = ty/height; +399 +400 w = w; +401 h = h; +402 x = x; +403 y = y; +404 +405 if(tw + tx > 1){ +406 tw = 1 - tx; +407 } +408 +409 if(th + ty > 1){ +410 th = 1 - ty; +411 } +412 +413 var index = 0; +414 tempVertexs[index++] = x; tempVertexs[index++] = y; tempVertexs[index++] = tx; tempVertexs[index++] = ty; +415 tempVertexs[index++] = x+w;tempVertexs[index++] = y; tempVertexs[index++] = tx+tw; tempVertexs[index++] = ty; +416 tempVertexs[index++] = x; tempVertexs[index++] = y+h; tempVertexs[index++] = tx;tempVertexs[index++] = ty+th; +417 tempVertexs[index++] = x+w;tempVertexs[index++] = y+h;tempVertexs[index++] = tx+tw;tempVertexs[index++] = ty+th; +418 +419 return tempVertexs; +420 }, +421 _setConcatenatedMatrix:function(view, ancestor){ +422 var mtx = view.__webglWorldMatrix; +423 var cos = 1, sin = 0, +424 rotation = view.rotation % 360, +425 pivotX = view.pivotX, pivotY = view.pivotY, +426 scaleX = view.scaleX, scaleY = view.scaleY, +427 transform = view.transform; +428 +429 if (transform) { +430 mtx.copy(transform); +431 } +432 else { +433 if(rotation){ +434 var r = rotation * DEG2RAD; +435 cos = Math.cos(r); +436 sin = Math.sin(r); +437 } +438 +439 var pos = view.getAlignPosition(); +440 +441 mtx.a = cos*scaleX; +442 mtx.b = sin*scaleX; +443 mtx.c = -sin*scaleY; +444 mtx.d = cos*scaleY; +445 mtx.tx = pos.x - mtx.a * pivotX - mtx.c * pivotY; +446 mtx.ty = pos.y - mtx.b * pivotX - mtx.d * pivotY; +447 } +448 +449 mtx.concat(ancestor.__webglWorldMatrix); +450 }, +451 _getTexture:function(sprite){ +452 var image = sprite.__textureImage; +453 var texture = this._cacheTexture[image.src]; +454 if(!texture){ +455 texture = this.activeShader.uploadTexture(image); +456 } +457 return texture; +458 } +459 }); +460 +461 /** +462 * shader +463 * @param {WebGLRenderer} renderer [description] +464 * @param {Object} source +465 * @param {String} source.v 顶点shader +466 * @param {String} source.f 片段shader +467 * @param {Object} attr +468 * @param {Array} attr.attributes attribute数组 +469 * @param {Array} attr.uniforms uniform数组 +470 */ +471 var Shader = function(renderer, source, attr){ +472 this.renderer = renderer; +473 this.gl = renderer.gl; +474 this.program = this._createProgram(this.gl, source.v, source.f); +475 +476 attr = attr||{}; +477 this.attributes = attr.attributes||[]; +478 this.uniforms = attr.uniforms||[]; +479 }; 480 -481 if(program && gl){ -482 renderer.activeShader = that; -483 gl.useProgram(program); -484 that.attributes.forEach(function(attribute){ -485 renderer[attribute] = gl.getAttribLocation(program, attribute); -486 gl.enableVertexAttribArray(renderer[attribute]); -487 }); -488 -489 that.uniforms.forEach(function(uniform){ -490 renderer[uniform] = gl.getUniformLocation(program, uniform); -491 }); -492 -493 if(that.width !== renderer.width || that.height !== renderer.height){ -494 that.width = renderer.width; -495 that.height = renderer.height; -496 renderer._uploadProjectionTransform(); -497 } -498 } -499 }, -500 uploadTexture:function(image){ -501 var gl = this.gl; -502 var renderer = this.renderer; -503 var texture = gl.createTexture(); -504 var u_Sampler = renderer.u_Sampler; -505 -506 gl.activeTexture(gl.TEXTURE0); -507 gl.bindTexture(gl.TEXTURE_2D, texture); -508 -509 // gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1); -510 gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1); -511 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); +481 Shader.prototype = { +482 active:function(){ +483 var that = this; +484 var renderer = that.renderer; +485 var gl = that.gl; +486 var program = that.program; +487 +488 if(program && gl){ +489 renderer.activeShader = that; +490 gl.useProgram(program); +491 that.attributes.forEach(function(attribute){ +492 renderer[attribute] = gl.getAttribLocation(program, attribute); +493 gl.enableVertexAttribArray(renderer[attribute]); +494 }); +495 +496 that.uniforms.forEach(function(uniform){ +497 renderer[uniform] = gl.getUniformLocation(program, uniform); +498 }); +499 +500 if(that.width !== renderer.width || that.height !== renderer.height){ +501 that.width = renderer.width; +502 that.height = renderer.height; +503 renderer._uploadProjectionTransform(); +504 } +505 } +506 }, +507 uploadTexture:function(image){ +508 var gl = this.gl; +509 var renderer = this.renderer; +510 var texture = gl.createTexture(); +511 var u_Sampler = renderer.u_Sampler; 512 -513 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); -514 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); -515 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); -516 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); -517 gl.uniform1i(u_Sampler, 0); -518 gl.bindTexture(gl.TEXTURE_2D, null); +513 gl.activeTexture(gl.TEXTURE0); +514 gl.bindTexture(gl.TEXTURE_2D, texture); +515 +516 // gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1); +517 gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1); +518 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); 519 -520 this.renderer._cacheTexture[image.src] = texture; -521 return texture; -522 }, -523 _createProgram:function(gl, vshader, fshader){ -524 var vertexShader = this._createShader(gl, gl.VERTEX_SHADER, vshader); -525 var fragmentShader = this._createShader(gl, gl.FRAGMENT_SHADER, fshader); -526 if (!vertexShader || !fragmentShader) { -527 return null; -528 } -529 -530 var program = gl.createProgram(); -531 if (program) { -532 gl.attachShader(program, vertexShader); -533 gl.attachShader(program, fragmentShader); -534 -535 gl.linkProgram(program); +520 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); +521 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); +522 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); +523 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); +524 gl.uniform1i(u_Sampler, 0); +525 gl.bindTexture(gl.TEXTURE_2D, null); +526 +527 this.renderer._cacheTexture[image.src] = texture; +528 return texture; +529 }, +530 _createProgram:function(gl, vshader, fshader){ +531 var vertexShader = this._createShader(gl, gl.VERTEX_SHADER, vshader); +532 var fragmentShader = this._createShader(gl, gl.FRAGMENT_SHADER, fshader); +533 if (!vertexShader || !fragmentShader) { +534 return null; +535 } 536 -537 gl.deleteShader(fragmentShader); -538 gl.deleteShader(vertexShader); -539 var linked = gl.getProgramParameter(program, gl.LINK_STATUS); -540 if (!linked) { -541 var error = gl.getProgramInfoLog(program); -542 console.log('Failed to link program: ' + error); -543 gl.deleteProgram(program); -544 return null; -545 } -546 } -547 return program; -548 }, -549 _createShader:function(gl, type, source){ -550 var shader = gl.createShader(type); -551 if(shader){ -552 gl.shaderSource(shader, source); -553 gl.compileShader(shader); -554 -555 var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS); -556 if (!compiled) { -557 var error = gl.getShaderInfoLog(shader); -558 console.log('Failed to compile shader: ' + error); -559 gl.deleteShader(shader); -560 return null; -561 } -562 } -563 return shader; -564 } -565 }; \ No newline at end of file +537 var program = gl.createProgram(); +538 if (program) { +539 gl.attachShader(program, vertexShader); +540 gl.attachShader(program, fragmentShader); +541 +542 gl.linkProgram(program); +543 +544 gl.deleteShader(fragmentShader); +545 gl.deleteShader(vertexShader); +546 var linked = gl.getProgramParameter(program, gl.LINK_STATUS); +547 if (!linked) { +548 var error = gl.getProgramInfoLog(program); +549 console.log('Failed to link program: ' + error); +550 gl.deleteProgram(program); +551 return null; +552 } +553 } +554 return program; +555 }, +556 _createShader:function(gl, type, source){ +557 var shader = gl.createShader(type); +558 if(shader){ +559 gl.shaderSource(shader, source); +560 gl.compileShader(shader); +561 +562 var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS); +563 if (!compiled) { +564 var error = gl.getShaderInfoLog(shader); +565 console.log('Failed to compile shader: ' + error); +566 gl.deleteShader(shader); +567 return null; +568 } +569 } +570 return shader; +571 } +572 }; \ No newline at end of file diff --git a/docs/api-zh/symbols/src/docs_api-zh_code_view_Text.js.html b/docs/api-zh/symbols/src/docs_api-zh_code_view_Text.js.html index 9b4dfdb2..3b3fb48c 100644 --- a/docs/api-zh/symbols/src/docs_api-zh_code_view_Text.js.html +++ b/docs/api-zh/symbols/src/docs_api-zh_code_view_Text.js.html @@ -50,7 +50,7 @@ 43 this._fontHeight = Text.measureFontHeight(this.font); 44 }, 45 - 46 text: null, + 46 text: '', 47 color: '#000', 48 textAlign: null, 49 textVAlign: null, diff --git a/package.json b/package.json index 0422fe90..9a5ed031 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Hilo", - "version": "1.3.0", + "version": "1.4.0", "description": "Hilo Game Framework", "author": "Hilo Dev Team", "license": "MIT",