diff --git a/CHANGELOG.md b/CHANGELOG.md index e68b08a3..2de34c34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ + +## [1.0.4](https://github.com/hiloteam/hilo/compare/v1.0.3...v1.0.4) (2017-04-28) + + +### Bug Fixes + +* Tween Ease.Back bug ([1ecd93c](https://github.com/hiloteam/hilo/commit/1ecd93c)) + ## [1.0.3](https://github.com/hiloteam/hilo/compare/v1.0.2...v1.0.3) (2017-04-26) @@ -15,6 +23,7 @@ ### Features +* loadQueue add support for webp (#76)([6b00c62](https://github.com/hiloteam/hilo/commit/6b00c62)) * add typescript definitions ([#83](https://github.com/hiloteam/hilo/issues/83)) ([cd3f4d6](https://github.com/hiloteam/hilo/commit/cd3f4d6)) * graphics.drawSVGPath supports all attributes except Arcs, close [#85](https://github.com/hiloteam/hilo/issues/85) ([2002f04](https://github.com/hiloteam/hilo/commit/2002f04)), closes [#85](https://github.com/hiloteam/hilo/issues/85) diff --git a/build/amd/hilo-amd.js b/build/amd/hilo-amd.js index 2916ba25..51b44ef7 100644 --- a/build/amd/hilo-amd.js +++ b/build/amd/hilo-amd.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -24,7 +24,7 @@ return { * Hilo version * @type String */ - version:'1.0.2', + version:'1.0.4', /** * @language=en * Gets a globally unique id. Such as Stage1, Bitmap2 etc. @@ -376,7 +376,7 @@ return Hilo; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -559,7 +559,7 @@ return Class; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -739,7 +739,7 @@ return Matrix; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -892,7 +892,7 @@ return EventMixin; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -970,7 +970,7 @@ return Drawable; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1063,7 +1063,7 @@ return Renderer; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1302,7 +1302,7 @@ return CanvasRenderer; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1484,7 +1484,7 @@ return DOMRenderer; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2052,7 +2052,7 @@ return WebGLRenderer; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2477,7 +2477,7 @@ return View; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2503,7 +2503,7 @@ var CacheMixin = /** @lends CacheMixin# */ { * @param {Boolean} forceUpdate is force update cache. */ cache: function(forceUpdate){ - if(forceUpdate || this._cacheDirty || !this._cacheImage){ + if(forceUpdate || this._cacheDirty || !this.drawable){ this.updateCache(); } }, @@ -2522,10 +2522,10 @@ var CacheMixin = /** @lends CacheMixin# */ { _cacheCanvas.width = this.width; _cacheCanvas.height = this.height; this._draw(_cacheContext); - this._cacheImage = new Image(); - this._cacheImage.src = _cacheCanvas.toDataURL(); this.drawable = this.drawable||new Drawable(); - this.drawable.init(this._cacheImage); + this.drawable.init({ + image:_cacheCanvas.toDataURL() + }); this._cacheDirty = false; } }, @@ -2543,7 +2543,7 @@ return CacheMixin; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2917,7 +2917,7 @@ return Container; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3182,7 +3182,7 @@ return Stage; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3260,7 +3260,7 @@ return Bitmap; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3531,7 +3531,7 @@ return Sprite; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3632,7 +3632,7 @@ return DOMElement; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3965,7 +3965,7 @@ return Class.create(/** @lends Graphics.prototype */{ /** * @language=en - * Draw a path from the SVG data given by parameters. + * Draw a path from the SVG data given by parameters. Not support Arcs. * Demo: *

var path = 'M250 150 L150 350 L350 350 Z';

*

var shape = new Hilo.Graphics({width:500, height:500});

@@ -3975,30 +3975,137 @@ return Class.create(/** @lends Graphics.prototype */{ */ drawSVGPath: function(pathData){ var me = this, addAction = me._addAction, - path = pathData.split(/,| (?=[a-zA-Z])/); - + path = pathData.replace(/,/g, ' ').replace(/-/g, ' -').split(/(?=[a-zA-Z])/); addAction.call(me, ['beginPath']); + var currentPoint = {x:0, y:0}; + var lastControlPoint = {x:0, y:0}; + var lastCmd; for(var i = 0, len = path.length; i < len; i++){ - var str = path[i], cmd = str[0].toUpperCase(), p = str.substring(1).split(/,| /); - if(p[0].length == 0) p.shift(); + var str = path[i]; + if(!str.length){ + continue; + } + var realCmd = str[0]; + var cmd = realCmd.toUpperCase(); + var p = this._getSVGParams(str); + var useRelative = cmd !== realCmd; switch(cmd){ case 'M': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['moveTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; case 'L': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['lineTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; - case 'C': - addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + case 'H': + if(useRelative){ + p[0] += currentPoint.x; + } + addAction.call(me, ['lineTo', p[0], currentPoint.y]); + currentPoint.x = p[0]; + break; + case 'V': + if(useRelative){ + p[0] += currentPoint.y; + } + addAction.call(me, ['lineTo', currentPoint.x, p[0]]); + currentPoint.y = p[0]; break; case 'Z': addAction.call(me, ['closePath']); break; + case 'C': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + lastControlPoint.x = p[2]; + lastControlPoint.y = p[3]; + this._setCurrentPoint(currentPoint, p[4], p[5]); + break; + case 'S': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + if(lastCmd === 'C' || lastCmd === 'S'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['bezierCurveTo', controlPoint.x, controlPoint.y, p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'Q': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['quadraticCurveTo', p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'T': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + var controlPoint; + if(lastCmd === 'Q' || lastCmd === 'T'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['quadraticCurveTo', controlPoint.x, controlPoint.y, p[0], p[1]]); + lastControlPoint = controlPoint; + this._setCurrentPoint(currentPoint, p[0], p[1]); + break; } + lastCmd = cmd; + } return me; }, + _getSVGParams:function(str){ + var p = str.substring(1).replace(/[\s]+$|^[\s]+/g, '').split(/[\s]+/); + if(p[0].length == 0) { + p.shift(); + } + for(var i = 0, l = p.length;i < l;i ++){ + p[i] = parseFloat(p[i]); + } + return p; + }, + _convertToAbsolute:function(currentPoint, data){ + for(var i = 0, l = data.length;i < l;i ++){ + if(i%2 === 0){ + data[i] += currentPoint.x; + } + else{ + data[i] += currentPoint.y; + } + } + }, + _setCurrentPoint:function(currentPoint, x, y){ + currentPoint.x = x; + currentPoint.y = y; + }, + _getReflectionPoint:function(centerPoint, point){ + return { + x:centerPoint.x * 2 - point.x, + y:centerPoint.y * 2 - point.y + }; + }, /** * @language=en @@ -4078,7 +4185,7 @@ return Graphics; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4331,7 +4438,7 @@ return Text; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4515,7 +4622,7 @@ return BitmapText; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4693,7 +4800,7 @@ return Button; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4930,7 +5037,7 @@ return TextureAtlas; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4977,13 +5084,11 @@ var Ticker = Class.create(/** @lends Ticker.prototype */{ window[Hilo.browser.jsVendor + 'RequestAnimationFrame']; var runLoop; - if(useRAF && raf){ - var tick = function(){ - self._tick(); - }; + if(useRAF && raf && interval < 17){ + this._useRAF = true; runLoop = function(){ - self._intervalId = setTimeout(runLoop, interval); - raf(tick); + self._intervalId = raf(runLoop); + self._tick(); }; }else{ runLoop = function(){ @@ -4992,6 +5097,7 @@ var Ticker = Class.create(/** @lends Ticker.prototype */{ }; } + this._paused = false; runLoop(); }, @@ -5000,9 +5106,17 @@ var Ticker = Class.create(/** @lends Ticker.prototype */{ * Stop the ticker. */ stop: function(){ - clearTimeout(this._intervalId); + if(this._useRAF){ + var cancelRAF = window.cancelAnimationFrame || + window[Hilo.browser.jsVendor + 'CancelAnimationFrame']; + cancelRAF(this._intervalId); + } + else{ + clearTimeout(this._intervalId); + } this._intervalId = null; this._lastTime = 0; + this._paused = true; }, /** @@ -5148,7 +5262,7 @@ return Ticker; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5196,7 +5310,7 @@ if (!fnProto.bind) { }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5307,7 +5421,7 @@ return drag; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5394,7 +5508,7 @@ return Class.create(/** @lends Tween.prototype */{ }, target: null, - duration: 0, + duration: 1000, delay: 0, paused: false, loop: false, @@ -5546,11 +5660,15 @@ return Class.create(/** @lends Tween.prototype */{ //elapsed ratio var ratio = elapsed / me.duration, complete = false, callback; - ratio = ratio <= 0 ? 0 : ratio >= 1 ? 1 : me.ease ? me.ease(ratio) : ratio; + ratio = ratio <= 0 ? 0 : ratio >= 1 ? 1 : ratio; + var easeRatio = me.ease ? me.ease(ratio) : ratio; if(me.reverse){ //backward - if(me._reverseFlag < 0) ratio = 1 - ratio; + if(me._reverseFlag < 0) { + ratio = 1 - ratio; + easeRatio = 1 - easeRatio; + } //forward if(ratio < 1e-7){ //repeat complete or not loop @@ -5569,7 +5687,7 @@ return Class.create(/** @lends Tween.prototype */{ me.time = elapsed; //render & update callback - me._render(ratio); + me._render(easeRatio); (callback = me.onUpdate) && callback.call(me, ratio, me); //check if complete @@ -5696,6 +5814,7 @@ return Class.create(/** @lends Tween.prototype */{ * @returns {Tween|Array} An tween instance or an array of tween instance. */ fromTo: function(target, fromProps, toProps, params){ + params = params || {}; var isArray = target instanceof Array; target = isArray ? target : [target]; @@ -5744,7 +5863,7 @@ return Tween; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6016,7 +6135,7 @@ return Ease; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6064,7 +6183,7 @@ return ImageLoader; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6131,7 +6250,7 @@ return ScriptLoader; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6380,7 +6499,7 @@ return LoadQueue; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6583,7 +6702,7 @@ return HTMLAudio; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6900,7 +7019,7 @@ return WebAudio; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6998,7 +7117,7 @@ return WebSound; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7091,7 +7210,7 @@ return Camera; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7278,7 +7397,7 @@ return Camera3d; }); /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 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 8f30b36e..472a7eea 100644 --- a/build/amd/hilo-amd.min.js +++ b/build/amd/hilo-amd.min.js @@ -1,8 +1,8 @@ /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ -define("hilo/core/Hilo",function(){var t=function(){var e=window,i=document,r=i.documentElement,n=0;return{version:"1.0.2",getUid:function(t){var e=++n;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){for(var r in e)i&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t},browser:function(){var t=navigator.userAgent,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 e,supportCanvas:null!=i.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in e,supportDeviceMotion:"ondevicemotion"in e};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=i.createElement("div"),c=l.style,u=void 0!=c[s+"Transform"],d=void 0!=c[s+"Perspective"];return d&&(l.id="test3d",c=i.createElement("style"),c.textContent="@media ("+h+"transform-3d){#test3d{height:3px}}",i.head.appendChild(c),r.appendChild(l),d=3==l.offsetHeight,i.head.removeChild(c),r.removeChild(l)),n.supportTransform=u,n.supportTransform3D=d,n}(),event:function(){var t="ontouchstart"in e;return{POINTER_START:t?"touchstart":"mousedown",POINTER_MOVE:t?"touchmove":"mousemove",POINTER_END:t?"touchend":"mouseup"}}(),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 i;try{i=t.getBoundingClientRect()}catch(n){i={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var a=(e.pageXOffset||r.scrollLeft)-(r.clientLeft||0)||0,o=(e.pageYOffset||r.scrollTop)-(r.clientTop||0)||0,s=e.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=i.top||0,p=i.left||0,v=i.right||0,m=i.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 r,n,a,o=i.createElement(t);for(r in e)if(n=e[r],"style"===r)for(a in n)o.style[a]=n[a];else o[r]=n;return o},getElement:function(t){return i.getElementById(t)},setElementStyleByView:function(e){var i=e.drawable,r=i.domElement.style,n=e._stateCache||(e._stateCache={}),a=t.browser.jsVendor,o="px",s=!1;if(this.cacheStateIfChanged(e,["visible"],n)&&(r.display=e.visible?"":"none"),this.cacheStateIfChanged(e,["alpha"],n)&&(r.opacity=e.alpha),e.visible&&!(e.alpha<=0)){this.cacheStateIfChanged(e,["width"],n)&&(r.width=e.width+o),this.cacheStateIfChanged(e,["height"],n)&&(r.height=e.height+o),this.cacheStateIfChanged(e,["depth"],n)&&(r.zIndex=e.depth+1),(s=this.cacheStateIfChanged(e,["pivotX","pivotY"],n))&&(r[a+"TransformOrigin"]=e.pivotX+o+" "+e.pivotY+o),(this.cacheStateIfChanged(e,["x","y","rotation","scaleX","scaleY"],n)||s)&&(r[a+"Transform"]=this.getTransformCSS(e)),this.cacheStateIfChanged(e,["background"],n)&&(r.backgroundColor=e.background),r.pointerEvents||(r.pointerEvents="none");var h=i.image;if(h){var l=h.src;l!==n.image&&(n.image=l,r.backgroundImage="url("+l+")");var c=i.rect;if(c){var u=c[0],d=c[1];u!==n.sx&&(n.sx=u,r.backgroundPositionX=-u+o),d!==n.sy&&(n.sy=d,r.backgroundPositionY=-d+o)}}var f=e.mask;if(f){var p=f.drawable.domElement.style.backgroundImage;p!==n.maskImage&&(n.maskImage=p,r[a+"MaskImage"]=p,r[a+"MaskRepeat"]="no-repeat");var v=f.x,m=f.y;v===n.maskX&&m===n.maskY||(n.maskX=v,n.maskY=m,r[a+"MaskPosition"]=v+o+" "+m+o)}}},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/Hilo","hilo/core/Class"],function(t,e){var i=e.create({constructor:function(t){this.init(t)},image:null,rect:null,init:function(e){var r=this,n=r.image;i.isDrawable(e)?r.image=e:t.copy(r,e,!0);var a=r.image;if("string"==typeof a){if(!n||a!==n.getAttribute("src")){r.image=null;var o=new Image;return 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/Hilo","hilo/core/Class"],function(t,e){var i=e.create({constructor:function(e){e=e||{},t.copy(this,e,!0)},renderType:null,canvas:null,stage:null,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),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.mask;v&&(v._render(this),r.clip());var m=t.align;if(m)if("function"==typeof m)t.align();else{var g=t.parent;if(g){var _=t.width,x=t.height,y=g.width,w=g.height;switch(m){case"TL":c=0,u=0;break;case"T":c=y-_>>1,u=0;break;case"TR":c=y-_,u=0;break;case"L":c=0,u=w-x>>1;break;case"C":c=y-_>>1,u=w-x>>1;break;case"R":c=y-_,u=w-x>>1;break;case"BL":c=0,u=w-x;break;case"B":c=y-_>>1,u=w-x;break;case"BR":c=y-_,u=w-x}}}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/renderer/Renderer","hilo/geom/Matrix"],function(t,e,i){var r=Math.PI/180,n=t.create({Extends:e,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){n.superclass.constructor.call(this,t);var e=this;this.gl=this.canvas.getContext("webgl")||this.canvas.getContext("experimental-webgl"),this.maxBatchNum=n.MAX_BATCH_NUM,this.positionStride=4*n.ATTRIBUTE_NUM;var i=this.maxBatchNum*n.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 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 Hilo.setElementStyleByView(t);var r=t.scaleX,n=t.scaleY;if(t===this.stage){var a=this.canvas.style,o=t._scaleX,s=t._scaleY,h=!1;(!o&&1!=r||o&&o!=r)&&(t._scaleX=r,a.width=r*t.width+"px",h=!0),(!s&&1!=n||s&&s!=n)&&(t._scaleY=n,a.height=n*t.height+"px",h=!0),h&&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,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 a(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,n=1,a=0,o=t.rotation%360,s=t.pivotX,h=t.pivotY,l=t.scaleX,c=t.scaleY;if(o){var u=o*r;n=Math.cos(u),a=Math.sin(u)}i.a=n*l,i.b=a*l,i.c=-a*c,i.d=n*c,i.tx=t.x-i.a*s-i.c*h,i.ty=t.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}}),a=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 a.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}},n}),define("hilo/view/View",["hilo/core/Hilo","hilo/core/Class","hilo/event/EventMixin","hilo/geom/Matrix"],function(t,e,i,r){var n=function(){function n(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"),t.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,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=r.x&&t<=r.x+r.width&&e>=r.y&&e<=r.y+r.height;return a&&i&&(a=n(t,e,r)),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=a(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(e){if(e.eventCurrentTarget=this,this.fire(e),"mousemove"==e.type){if(!this.__mouseOver){this.__mouseOver=!0;var i=t.copy({},e);i.type="mouseover",this.fire(i)}}else"mouseout"==e.type&&(this.__mouseOver=!1);var r=this.parent;e._stopped||e._stopPropagationed||!r||("mouseout"==e.type||"touchout"==e.type?r.hitTestPoint(e.stageX,e.stageY,!0)||r._fireMouseEvent(e):r._fireMouseEvent(e))},onUpdate:null,render:function(t,e){t.draw(this)},toString:function(){return t.viewToString(this)}})}();return n}),define("hilo/view/CacheMixin",["hilo/core/Hilo","hilo/view/Drawable"],function(t,e){var i,r,n={_cacheDirty:!0,cache:function(t){(t||this._cacheDirty||!this._cacheImage)&&this.updateCache()},updateCache:function(){t.browser.supportCanvas&&(i||(i=document.createElement("canvas"),r=i.getContext("2d")),i.width=this.width,i.height=this.height,this._draw(r),this._cacheImage=new Image,this._cacheImage.src=i.toDataURL(),this.drawable=this.drawable||new e,this.drawable.init(this._cacheImage),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="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,r=t.canvas,n=this.drawable.domElement,a=this.depth,o=r.nextSibling;if(n.parentNode)return;for(;o&&3!=o.nodeType&&(i=parseInt(o.style.zIndex)||0,!(i<=0||i>a));)o=o.nextSibling;r.parentNode.insertBefore(this.drawable.domElement,o)}else t.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},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:n.ease?n.ease(s):s,n.reverse&&(n._reverseFlag<0&&(s=1-s),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))),0==n.time&&(o=n.onStart)&&o.call(n,n),n.time=a,n._render(s),(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&&c<=t?(l._render(s),l.time=a,e.add(l)):h&&(c<0||c>t)&&l.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"],function(t,e,i,r,n){var a=function(){function a(t,e){return e?t+2*(Math.random()-.5)*e:t}for(var o=["x","y","vx","vy","ax","ay","rotation","rotationV","scale","scaleV","alpha","alphaV","life"],s=[],h=0,l=o.length;h=this._emitTime&&(this._currentRunTime=0,this._emitTime=a(this.emitTime,this.emitTimeVar),this._emit()),this._totalRunTime>=this.totalTime&&this.stop())},_emit:function(){for(var t=a(this.emitNum,this.emitNumVar)>>0,e=0;e=0;e--)this.children[e].destroy()}}),p=e.create({Extends:i,constructor:function(e){this.id=this.id||e.id||t.getUid("Particle"),p.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(),d.push(this)},init:function(t){this.system=t.system,this._died=!1,this._time=0,this.alpha=1;for(var e=0,i=s.length;e>0]),this.setImage(t.image,o),void 0!==t.pivotX&&(this.pivotX=t.pivotX*o[2]),void 0!==t.pivotY&&(this.pivotY=t.pivotY*o[3])}},Statics:{create:function(t){if(d.length>0){var e=d.pop();return e.init(t),e}return new p(t)}}});return f}();return a}); \ No newline at end of file +define("hilo/core/Hilo",function(){var t=function(){var e=window,i=document,r=i.documentElement,n=0;return{version:"1.0.4",getUid:function(t){var e=++n;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){for(var r in e)i&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t},browser:function(){var t=navigator.userAgent,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 e,supportCanvas:null!=i.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in e,supportDeviceMotion:"ondevicemotion"in e};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=i.createElement("div"),c=l.style,u=void 0!=c[s+"Transform"],d=void 0!=c[s+"Perspective"];return d&&(l.id="test3d",c=i.createElement("style"),c.textContent="@media ("+h+"transform-3d){#test3d{height:3px}}",i.head.appendChild(c),r.appendChild(l),d=3==l.offsetHeight,i.head.removeChild(c),r.removeChild(l)),n.supportTransform=u,n.supportTransform3D=d,n}(),event:function(){var t="ontouchstart"in e;return{POINTER_START:t?"touchstart":"mousedown",POINTER_MOVE:t?"touchmove":"mousemove",POINTER_END:t?"touchend":"mouseup"}}(),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 i;try{i=t.getBoundingClientRect()}catch(n){i={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var a=(e.pageXOffset||r.scrollLeft)-(r.clientLeft||0)||0,o=(e.pageYOffset||r.scrollTop)-(r.clientTop||0)||0,s=e.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=i.top||0,v=i.left||0,p=i.right||0,m=i.bottom||0;return{left:v+a+l,top:f+o+c,width:p-u-v-l,height:m-d-f-c}},createElement:function(t,e){var r,n,a,o=i.createElement(t);for(r in e)if(n=e[r],"style"===r)for(a in n)o.style[a]=n[a];else o[r]=n;return o},getElement:function(t){return i.getElementById(t)},setElementStyleByView:function(e){var i=e.drawable,r=i.domElement.style,n=e._stateCache||(e._stateCache={}),a=t.browser.jsVendor,o="px",s=!1;if(this.cacheStateIfChanged(e,["visible"],n)&&(r.display=e.visible?"":"none"),this.cacheStateIfChanged(e,["alpha"],n)&&(r.opacity=e.alpha),e.visible&&!(e.alpha<=0)){this.cacheStateIfChanged(e,["width"],n)&&(r.width=e.width+o),this.cacheStateIfChanged(e,["height"],n)&&(r.height=e.height+o),this.cacheStateIfChanged(e,["depth"],n)&&(r.zIndex=e.depth+1),(s=this.cacheStateIfChanged(e,["pivotX","pivotY"],n))&&(r[a+"TransformOrigin"]=e.pivotX+o+" "+e.pivotY+o),(this.cacheStateIfChanged(e,["x","y","rotation","scaleX","scaleY"],n)||s)&&(r[a+"Transform"]=this.getTransformCSS(e)),this.cacheStateIfChanged(e,["background"],n)&&(r.backgroundColor=e.background),r.pointerEvents||(r.pointerEvents="none");var h=i.image;if(h){var l=h.src;l!==n.image&&(n.image=l,r.backgroundImage="url("+l+")");var c=i.rect;if(c){var u=c[0],d=c[1];u!==n.sx&&(n.sx=u,r.backgroundPositionX=-u+o),d!==n.sy&&(n.sy=d,r.backgroundPositionY=-d+o)}}var f=e.mask;if(f){var v=f.drawable.domElement.style.backgroundImage;v!==n.maskImage&&(n.maskImage=v,r[a+"MaskImage"]=v,r[a+"MaskRepeat"]="no-repeat");var p=f.x,m=f.y;p===n.maskX&&m===n.maskY||(n.maskX=p,n.maskY=m,r[a+"MaskPosition"]=p+o+" "+m+o)}}},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/Hilo","hilo/core/Class"],function(t,e){var i=e.create({constructor:function(t){this.init(t)},image:null,rect:null,init:function(e){var r=this,n=r.image;i.isDrawable(e)?r.image=e:t.copy(r,e,!0);var a=r.image;if("string"==typeof a){if(!n||a!==n.getAttribute("src")){r.image=null;var o=new Image;return 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/Hilo","hilo/core/Class"],function(t,e){var i=e.create({constructor:function(e){e=e||{},t.copy(this,e,!0)},renderType:null,canvas:null,stage:null,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),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,v=t.rotation%360,p=t.mask;p&&(p._render(this),r.clip());var m=t.align;if(m)if("function"==typeof m)t.align();else{var _=t.parent;if(_){var g=t.width,x=t.height,y=_.width,w=_.height;switch(m){case"TL":c=0,u=0;break;case"T":c=y-g>>1,u=0;break;case"TR":c=y-g,u=0;break;case"L":c=0,u=w-x>>1;break;case"C":c=y-g>>1,u=w-x>>1;break;case"R":c=y-g,u=w-x>>1;break;case"BL":c=0,u=w-x;break;case"B":c=y-g>>1,u=w-x;break;case"BR":c=y-g,u=w-x}}}0==c&&0==u||r.translate(c,u),0!=v&&r.rotate(v*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/renderer/Renderer","hilo/geom/Matrix"],function(t,e,i){var r=Math.PI/180,n=t.create({Extends:e,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){n.superclass.constructor.call(this,t);var e=this;this.gl=this.canvas.getContext("webgl")||this.canvas.getContext("experimental-webgl"),this.maxBatchNum=n.MAX_BATCH_NUM,this.positionStride=4*n.ATTRIBUTE_NUM;var i=this.maxBatchNum*n.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 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,v=0;v<4;v++){var p=c[l+5*v],m=c[l+5*v+1];c[l+5*v]=f.a*p+f.c*m+f.tx,c[l+5*v+1]=f.b*p+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 Hilo.setElementStyleByView(t);var r=t.scaleX,n=t.scaleY;if(t===this.stage){var a=this.canvas.style,o=t._scaleX,s=t._scaleY,h=!1;(!o&&1!=r||o&&o!=r)&&(t._scaleX=r,a.width=r*t.width+"px",h=!0),(!s&&1!=n||s&&s!=n)&&(t._scaleY=n,a.height=n*t.height+"px",h=!0),h&&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,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 a(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,n=1,a=0,o=t.rotation%360,s=t.pivotX,h=t.pivotY,l=t.scaleX,c=t.scaleY;if(o){var u=o*r;n=Math.cos(u),a=Math.sin(u)}i.a=n*l,i.b=a*l,i.c=-a*c,i.d=n*c,i.tx=t.x-i.a*s-i.c*h,i.ty=t.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}}),a=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 a.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}},n}),define("hilo/view/View",["hilo/core/Hilo","hilo/core/Class","hilo/event/EventMixin","hilo/geom/Matrix"],function(t,e,i,r){var n=function(){function n(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 v=i[(c+l-1)%c];(v.ye||v.y>e&&d.ys?s=c:cl?l=c:c=0)return!1;u>i.overlap&&(i.overlap=u,i.normal.x=v.x,i.normal.y=v.y)}return i}return e.create({Mixes:i,constructor:function(e){e=e||{},this.id=this.id||e.id||t.getUid("View"),t.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,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=r.x&&t<=r.x+r.width&&e>=r.y&&e<=r.y+r.height;return a&&i&&(a=n(t,e,r)),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=a(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(e){if(e.eventCurrentTarget=this,this.fire(e),"mousemove"==e.type){if(!this.__mouseOver){this.__mouseOver=!0;var i=t.copy({},e);i.type="mouseover",this.fire(i)}}else"mouseout"==e.type&&(this.__mouseOver=!1);var r=this.parent;e._stopped||e._stopPropagationed||!r||("mouseout"==e.type||"touchout"==e.type?r.hitTestPoint(e.stageX,e.stageY,!0)||r._fireMouseEvent(e):r._fireMouseEvent(e))},onUpdate:null,render:function(t,e){t.draw(this)},toString:function(){return t.viewToString(this)}})}();return n}),define("hilo/view/CacheMixin",["hilo/core/Hilo","hilo/view/Drawable"],function(t,e){var i,r,n={_cacheDirty:!0,cache:function(t){(t||this._cacheDirty||!this.drawable)&&this.updateCache()},updateCache:function(){t.browser.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 e,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="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,r=t.canvas,n=this.drawable.domElement,a=this.depth,o=r.nextSibling;if(n.parentNode)return;for(;o&&3!=o.nodeType&&(i=parseInt(o.style.zIndex)||0,!(i<=0||i>a));)o=o.nextSibling;r.parentNode.insertBefore(this.drawable.domElement,o)}else t.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},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<_&&(l=_),c+=u,m=p):(_=f,m+=p),v==s-1&&(d.push({text:m,y:c}),m!==p&&l>1;break;case"bottom":g=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))),0==n.time&&(o=n.onStart)&&o.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"],function(t,e,i,r,n){var a=function(){function a(t,e){return e?t+2*(Math.random()-.5)*e:t}for(var o=["x","y","vx","vy","ax","ay","rotation","rotationV","scale","scaleV","alpha","alphaV","life"],s=[],h=0,l=o.length;h=this._emitTime&&(this._currentRunTime=0,this._emitTime=a(this.emitTime,this.emitTimeVar),this._emit()),this._totalRunTime>=this.totalTime&&this.stop())},_emit:function(){for(var t=a(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(),d.push(this)},init:function(t){this.system=t.system,this._died=!1,this._time=0,this.alpha=1;for(var e=0,i=s.length;e>0]),this.setImage(t.image,o),void 0!==t.pivotX&&(this.pivotX=t.pivotX*o[2]),void 0!==t.pivotY&&(this.pivotY=t.pivotY*o[3])}},Statics:{create:function(t){if(d.length>0){var e=d.pop();return e.init(t),e}return new v(t)}}});return f}();return a}); \ No newline at end of file diff --git a/build/amd/hilo-amd.zip b/build/amd/hilo-amd.zip index 06544f6f..fdd2fd36 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 dc9c159c..d69b53bc 100644 --- a/build/amd/hilo/core/Class.js +++ b/build/amd/hilo/core/Class.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 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 52a8deae..1ed3277b 100644 --- a/build/amd/hilo/core/Class.min.js +++ b/build/amd/hilo/core/Class.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 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 1cbb6f3b..a38d44cb 100644 --- a/build/amd/hilo/core/Hilo.js +++ b/build/amd/hilo/core/Hilo.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -24,7 +24,7 @@ return { * Hilo version * @type String */ - version:'1.0.2', + version:'1.0.4', /** * @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 f685b43d..c3580701 100644 --- a/build/amd/hilo/core/Hilo.min.js +++ b/build/amd/hilo/core/Hilo.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ -define("hilo/core/Hilo",function(){var t=function(){var e=window,o=document,r=o.documentElement,a=0;return{version:"1.0.2",getUid:function(t){var e=++a;if(t){var o=t.charCodeAt(t.length-1);return o>=48&&o<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,o=t;o;)e=e?o.id+"."+e:o.id,o=o.parent;return e},copy:function(t,e,o){for(var r in e)o&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t},browser:function(){var t=navigator.userAgent,a={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 e,supportCanvas:null!=o.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in e,supportDeviceMotion:"ondevicemotion"in e};try{var i="hilo";localStorage.setItem(i,i),localStorage.removeItem(i),a.supportStorage=!0}catch(n){}var s=a.jsVendor=a.webkit?"webkit":a.firefox?"webkit":a.opera?"o":a.ie?"ms":"",d=a.cssVendor="-"+s+"-",h=o.createElement("div"),c=h.style,p=void 0!=c[s+"Transform"],f=void 0!=c[s+"Perspective"];return f&&(h.id="test3d",c=o.createElement("style"),c.textContent="@media ("+d+"transform-3d){#test3d{height:3px}}",o.head.appendChild(c),r.appendChild(h),f=3==h.offsetHeight,o.head.removeChild(c),r.removeChild(h)),a.supportTransform=p,a.supportTransform3D=f,a}(),event:function(){var t="ontouchstart"in e;return{POINTER_START:t?"touchstart":"mousedown",POINTER_MOVE:t?"touchmove":"mousemove",POINTER_END:t?"touchend":"mouseup"}}(),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 o;try{o=t.getBoundingClientRect()}catch(a){o={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var i=(e.pageXOffset||r.scrollLeft)-(r.clientLeft||0)||0,n=(e.pageYOffset||r.scrollTop)-(r.clientTop||0)||0,s=e.getComputedStyle?getComputedStyle(t):t.currentStyle,d=parseInt,h=d(s.paddingLeft)+d(s.borderLeftWidth)||0,c=d(s.paddingTop)+d(s.borderTopWidth)||0,p=d(s.paddingRight)+d(s.borderRightWidth)||0,f=d(s.paddingBottom)+d(s.borderBottomWidth)||0,l=o.top||0,g=o.left||0,m=o.right||0,u=o.bottom||0;return{left:g+i+h,top:l+n+c,width:m-p-g-h,height:u-f-l-c}},createElement:function(t,e){var r,a,i,n=o.createElement(t);for(r in e)if(a=e[r],"style"===r)for(i in a)n.style[i]=a[i];else n[r]=a;return n},getElement:function(t){return o.getElementById(t)},setElementStyleByView:function(e){var o=e.drawable,r=o.domElement.style,a=e._stateCache||(e._stateCache={}),i=t.browser.jsVendor,n="px",s=!1;if(this.cacheStateIfChanged(e,["visible"],a)&&(r.display=e.visible?"":"none"),this.cacheStateIfChanged(e,["alpha"],a)&&(r.opacity=e.alpha),e.visible&&!(e.alpha<=0)){this.cacheStateIfChanged(e,["width"],a)&&(r.width=e.width+n),this.cacheStateIfChanged(e,["height"],a)&&(r.height=e.height+n),this.cacheStateIfChanged(e,["depth"],a)&&(r.zIndex=e.depth+1),(s=this.cacheStateIfChanged(e,["pivotX","pivotY"],a))&&(r[i+"TransformOrigin"]=e.pivotX+n+" "+e.pivotY+n),(this.cacheStateIfChanged(e,["x","y","rotation","scaleX","scaleY"],a)||s)&&(r[i+"Transform"]=this.getTransformCSS(e)),this.cacheStateIfChanged(e,["background"],a)&&(r.backgroundColor=e.background),r.pointerEvents||(r.pointerEvents="none");var d=o.image;if(d){var h=d.src;h!==a.image&&(a.image=h,r.backgroundImage="url("+h+")");var c=o.rect;if(c){var p=c[0],f=c[1];p!==a.sx&&(a.sx=p,r.backgroundPositionX=-p+n),f!==a.sy&&(a.sy=f,r.backgroundPositionY=-f+n)}}var l=e.mask;if(l){var g=l.drawable.domElement.style.backgroundImage;g!==a.maskImage&&(a.maskImage=g,r[i+"MaskImage"]=g,r[i+"MaskRepeat"]="no-repeat");var m=l.x,u=l.y;m===a.maskX&&u===a.maskY||(a.maskX=m,a.maskY=u,r[i+"MaskPosition"]=m+n+" "+u+n)}}},cacheStateIfChanged:function(t,e,o){var r,a,i,n,s=!1;for(r=0,a=e.length;r=48&&o<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,o=t;o;)e=e?o.id+"."+e:o.id,o=o.parent;return e},copy:function(t,e,o){for(var r in e)o&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t},browser:function(){var t=navigator.userAgent,a={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 e,supportCanvas:null!=o.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in e,supportDeviceMotion:"ondevicemotion"in e};try{var i="hilo";localStorage.setItem(i,i),localStorage.removeItem(i),a.supportStorage=!0}catch(n){}var s=a.jsVendor=a.webkit?"webkit":a.firefox?"webkit":a.opera?"o":a.ie?"ms":"",d=a.cssVendor="-"+s+"-",h=o.createElement("div"),c=h.style,p=void 0!=c[s+"Transform"],f=void 0!=c[s+"Perspective"];return f&&(h.id="test3d",c=o.createElement("style"),c.textContent="@media ("+d+"transform-3d){#test3d{height:3px}}",o.head.appendChild(c),r.appendChild(h),f=3==h.offsetHeight,o.head.removeChild(c),r.removeChild(h)),a.supportTransform=p,a.supportTransform3D=f,a}(),event:function(){var t="ontouchstart"in e;return{POINTER_START:t?"touchstart":"mousedown",POINTER_MOVE:t?"touchmove":"mousemove",POINTER_END:t?"touchend":"mouseup"}}(),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 o;try{o=t.getBoundingClientRect()}catch(a){o={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var i=(e.pageXOffset||r.scrollLeft)-(r.clientLeft||0)||0,n=(e.pageYOffset||r.scrollTop)-(r.clientTop||0)||0,s=e.getComputedStyle?getComputedStyle(t):t.currentStyle,d=parseInt,h=d(s.paddingLeft)+d(s.borderLeftWidth)||0,c=d(s.paddingTop)+d(s.borderTopWidth)||0,p=d(s.paddingRight)+d(s.borderRightWidth)||0,f=d(s.paddingBottom)+d(s.borderBottomWidth)||0,l=o.top||0,g=o.left||0,m=o.right||0,u=o.bottom||0;return{left:g+i+h,top:l+n+c,width:m-p-g-h,height:u-f-l-c}},createElement:function(t,e){var r,a,i,n=o.createElement(t);for(r in e)if(a=e[r],"style"===r)for(i in a)n.style[i]=a[i];else n[r]=a;return n},getElement:function(t){return o.getElementById(t)},setElementStyleByView:function(e){var o=e.drawable,r=o.domElement.style,a=e._stateCache||(e._stateCache={}),i=t.browser.jsVendor,n="px",s=!1;if(this.cacheStateIfChanged(e,["visible"],a)&&(r.display=e.visible?"":"none"),this.cacheStateIfChanged(e,["alpha"],a)&&(r.opacity=e.alpha),e.visible&&!(e.alpha<=0)){this.cacheStateIfChanged(e,["width"],a)&&(r.width=e.width+n),this.cacheStateIfChanged(e,["height"],a)&&(r.height=e.height+n),this.cacheStateIfChanged(e,["depth"],a)&&(r.zIndex=e.depth+1),(s=this.cacheStateIfChanged(e,["pivotX","pivotY"],a))&&(r[i+"TransformOrigin"]=e.pivotX+n+" "+e.pivotY+n),(this.cacheStateIfChanged(e,["x","y","rotation","scaleX","scaleY"],a)||s)&&(r[i+"Transform"]=this.getTransformCSS(e)),this.cacheStateIfChanged(e,["background"],a)&&(r.backgroundColor=e.background),r.pointerEvents||(r.pointerEvents="none");var d=o.image;if(d){var h=d.src;h!==a.image&&(a.image=h,r.backgroundImage="url("+h+")");var c=o.rect;if(c){var p=c[0],f=c[1];p!==a.sx&&(a.sx=p,r.backgroundPositionX=-p+n),f!==a.sy&&(a.sy=f,r.backgroundPositionY=-f+n)}}var l=e.mask;if(l){var g=l.drawable.domElement.style.backgroundImage;g!==a.maskImage&&(a.maskImage=g,r[i+"MaskImage"]=g,r[i+"MaskRepeat"]="no-repeat");var m=l.x,u=l.y;m===a.maskX&&u===a.maskY||(a.maskX=m,a.maskY=u,r[i+"MaskPosition"]=m+n+" "+u+n)}}},cacheStateIfChanged:function(t,e,o){var r,a,i,n,s=!1;for(r=0,a=e.length;r= 1 ? 1 : me.ease ? me.ease(ratio) : ratio; + ratio = ratio <= 0 ? 0 : ratio >= 1 ? 1 : ratio; + var easeRatio = me.ease ? me.ease(ratio) : ratio; if(me.reverse){ //backward - if(me._reverseFlag < 0) ratio = 1 - ratio; + if(me._reverseFlag < 0) { + ratio = 1 - ratio; + easeRatio = 1 - easeRatio; + } //forward if(ratio < 1e-7){ //repeat complete or not loop @@ -261,7 +265,7 @@ return Class.create(/** @lends Tween.prototype */{ me.time = elapsed; //render & update callback - me._render(ratio); + me._render(easeRatio); (callback = me.onUpdate) && callback.call(me, ratio, me); //check if complete @@ -388,6 +392,7 @@ return Class.create(/** @lends Tween.prototype */{ * @returns {Tween|Array} An tween instance or an array of tween instance. */ fromTo: function(target, fromProps, toProps, params){ + params = params || {}; var isArray = target instanceof Array; target = isArray ? target : [target]; diff --git a/build/amd/hilo/tween/Tween.min.js b/build/amd/hilo/tween/Tween.min.js index 40dd22d2..81dde67c 100644 --- a/build/amd/hilo/tween/Tween.min.js +++ b/build/amd/hilo/tween/Tween.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ -define("hilo/tween/Tween",["hilo/core/Class"],function(e){var t=function(){function r(){return+new Date}return e.create({constructor:function(e,t,r,a){var n=this;n.target=e,n._startTime=0,n._seekTime=0,n._pausedTime=0,n._pausedStartTime=0,n._reverseFlag=1,n._repeatCount=0,3==arguments.length&&(a=r,r=t,t=null);for(var i in a)n[i]=a[i];n.setProps(t,r),!a.duration&&a.time&&(n.duration=a.time||0,n.time=0)},target:null,duration:0,delay:0,paused:!1,loop:!1,reverse:!1,repeat:0,repeatDelay:0,ease:null,time:0,onStart:null,onUpdate:null,onComplete:null,setProps:function(e,t){var r=this,a=r.target,n=e||t,i=r._fromProps={},s=r._toProps={};e=e||a,t=t||a;for(var u in n)s[u]=t[u]||0,a[u]=i[u]=e[u]||0;return r},start:function(){var e=this;return e._startTime=r()+e.delay,e._seekTime=0,e._pausedTime=0,e.paused=!1,t.add(e),e},stop:function(){return t.remove(this),this},pause:function(){var e=this;return e.paused=!0,e._pausedStartTime=r(),e},resume:function(){var e=this;return e.paused=!1,e._pausedStartTime&&(e._pausedTime+=r()-e._pausedStartTime),e._pausedStartTime=0,e},seek:function(e,a){var n=this,i=r();return n._startTime=i,n._seekTime=e,n._pausedTime=0,void 0!==a&&(n.paused=a),n._update(i,!0),t.add(n),n},link:function(e){var r,a,n=this,i=e.delay,s=n._startTime;return"string"==typeof i&&(r=0==i.indexOf("+"),a=0==i.indexOf("-"),i=r||a?Number(i.substr(1))*(r?1:-1):Number(i)),e.delay=i,e._startTime=r||a?s+n.duration+i:s+i,n._next=e,t.remove(e),n},_render:function(e){var t,r=this,a=r.target,n=r._fromProps;for(t in n)a[t]=n[t]+(r._toProps[t]-n[t])*e},_update:function(e,a){var n=this;if(!n.paused||a){var i=e-n._startTime-n._pausedTime+n._seekTime;if(!(i<0)){var s,u=i/n.duration,o=!1;u=u<=0?0:u>=1?1:n.ease?n.ease(u):u,n.reverse&&(n._reverseFlag<0&&(u=1-u),u<1e-7&&(n.repeat>0&&n._repeatCount++>=n.repeat||0==n.repeat&&!n.loop?o=!0:(n._startTime=r(),n._pausedTime=0,n._reverseFlag*=-1))),0==n.time&&(s=n.onStart)&&s.call(n,n),n.time=i,n._render(u),(s=n.onUpdate)&&s.call(n,u,n),u>=1&&(n.reverse?(n._startTime=r(),n._pausedTime=0,n._reverseFlag*=-1):n.loop||n.repeat>0&&n._repeatCount++0&&p<=e?(l._render(u),l.time=i,t.add(l)):o&&(p<0||p>e)&&l.start()}return o?((s=n.onComplete)&&s.call(n,n),!0):void 0}}},Statics:{_tweens:[],tick:function(){var e,a,n=t._tweens,i=n.length;for(a=0;a-1&&n.splice(r,1);else for(r=0;r=1?1:u;var l=n.ease?n.ease(u):u;n.reverse&&(n._reverseFlag<0&&(u=1-u,l=1-l),u<1e-7&&(n.repeat>0&&n._repeatCount++>=n.repeat||0==n.repeat&&!n.loop?o=!0:(n._startTime=r(),n._pausedTime=0,n._reverseFlag*=-1))),0==n.time&&(s=n.onStart)&&s.call(n,n),n.time=i,n._render(l),(s=n.onUpdate)&&s.call(n,u,n),u>=1&&(n.reverse?(n._startTime=r(),n._pausedTime=0,n._reverseFlag*=-1):n.loop||n.repeat>0&&n._repeatCount++0&&d<=e?(p._render(u),p.time=i,t.add(p)):o&&(d<0||d>e)&&p.start()}return o?((s=n.onComplete)&&s.call(n,n),!0):void 0}}},Statics:{_tweens:[],tick:function(){var e,a,n=t._tweens,i=n.length;for(a=0;a-1&&n.splice(r,1);else for(r=0;r=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=e.slice(0),s=0,r=n.length;s=0&&i.splice(e,1)},nextTick:function(t){var i=this,e={tick:function(n){i.removeTick(e),t()}};return i.addTick(e),e},timeout:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var i=(new Date).getTime(),r=i-n;r>=0&&(e.removeTick(s),t())}};return e.addTick(s),s},interval:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var e=(new Date).getTime(),s=e-n;s>=0&&(s=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=e.slice(0),s=0,r=n.length;s=0&&i.splice(e,1)},nextTick:function(t){var i=this,e={tick:function(n){i.removeTick(e),t()}};return i.addTick(e),e},timeout:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var i=(new Date).getTime(),r=i-n;r>=0&&(e.removeTick(s),t())}};return e.addTick(s),s},interval:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var e=(new Date).getTime(),s=e-n;s>=0&&(svar path = 'M250 150 L150 350 L350 350 Z';

*

var shape = new Hilo.Graphics({width:500, height:500});

@@ -342,30 +342,137 @@ return Class.create(/** @lends Graphics.prototype */{ */ drawSVGPath: function(pathData){ var me = this, addAction = me._addAction, - path = pathData.split(/,| (?=[a-zA-Z])/); - + path = pathData.replace(/,/g, ' ').replace(/-/g, ' -').split(/(?=[a-zA-Z])/); addAction.call(me, ['beginPath']); + var currentPoint = {x:0, y:0}; + var lastControlPoint = {x:0, y:0}; + var lastCmd; for(var i = 0, len = path.length; i < len; i++){ - var str = path[i], cmd = str[0].toUpperCase(), p = str.substring(1).split(/,| /); - if(p[0].length == 0) p.shift(); + var str = path[i]; + if(!str.length){ + continue; + } + var realCmd = str[0]; + var cmd = realCmd.toUpperCase(); + var p = this._getSVGParams(str); + var useRelative = cmd !== realCmd; switch(cmd){ case 'M': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['moveTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; case 'L': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['lineTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; - case 'C': - addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + case 'H': + if(useRelative){ + p[0] += currentPoint.x; + } + addAction.call(me, ['lineTo', p[0], currentPoint.y]); + currentPoint.x = p[0]; + break; + case 'V': + if(useRelative){ + p[0] += currentPoint.y; + } + addAction.call(me, ['lineTo', currentPoint.x, p[0]]); + currentPoint.y = p[0]; break; case 'Z': addAction.call(me, ['closePath']); break; + case 'C': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + lastControlPoint.x = p[2]; + lastControlPoint.y = p[3]; + this._setCurrentPoint(currentPoint, p[4], p[5]); + break; + case 'S': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + if(lastCmd === 'C' || lastCmd === 'S'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['bezierCurveTo', controlPoint.x, controlPoint.y, p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'Q': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['quadraticCurveTo', p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'T': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + var controlPoint; + if(lastCmd === 'Q' || lastCmd === 'T'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['quadraticCurveTo', controlPoint.x, controlPoint.y, p[0], p[1]]); + lastControlPoint = controlPoint; + this._setCurrentPoint(currentPoint, p[0], p[1]); + break; } + lastCmd = cmd; + } return me; }, + _getSVGParams:function(str){ + var p = str.substring(1).replace(/[\s]+$|^[\s]+/g, '').split(/[\s]+/); + if(p[0].length == 0) { + p.shift(); + } + for(var i = 0, l = p.length;i < l;i ++){ + p[i] = parseFloat(p[i]); + } + return p; + }, + _convertToAbsolute:function(currentPoint, data){ + for(var i = 0, l = data.length;i < l;i ++){ + if(i%2 === 0){ + data[i] += currentPoint.x; + } + else{ + data[i] += currentPoint.y; + } + } + }, + _setCurrentPoint:function(currentPoint, x, y){ + currentPoint.x = x; + currentPoint.y = y; + }, + _getReflectionPoint:function(centerPoint, point){ + return { + x:centerPoint.x * 2 - point.x, + y:centerPoint.y * 2 - point.y + }; + }, /** * @language=en diff --git a/build/amd/hilo/view/Graphics.min.js b/build/amd/hilo/view/Graphics.min.js index abf19442..5b1e23ba 100644 --- a/build/amd/hilo/view/Graphics.min.js +++ b/build/amd/hilo/view/Graphics.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ -define("hilo/view/Graphics",["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/CacheMixin"],function(i,l,t,e){var a=function(){var n=document.createElement("canvas"),r=n.getContext&&n.getContext("2d");return l.create({Extends:t,Mixes:e,constructor:function(l){l=l||{},this.id=this.id||l.id||i.getUid("Graphics"),a.superclass.constructor.call(this,l),this._actions=[]},lineWidth:1,lineAlpha:1,lineCap:null,lineJoin:null,miterLimit:10,hasStroke:!1,strokeStyle:"0",hasFill:!1,fillStyle:"0",fillAlpha:0,lineStyle:function(i,l,t,e,a,n){var r=this,o=r._addAction;return o.call(r,["lineWidth",r.lineWidth=i||1]),o.call(r,["strokeStyle",r.strokeStyle=l||"0"]),o.call(r,["lineAlpha",r.lineAlpha=t||1]),void 0!=e&&o.call(r,["lineCap",r.lineCap=e]),void 0!=a&&o.call(r,["lineJoin",r.lineJoin=a]),void 0!=n&&o.call(r,["miterLimit",r.miterLimit=n]),r.hasStroke=!0,r},beginFill:function(i,l){var t=this,e=t._addAction;return e.call(t,["fillStyle",t.fillStyle=i]),e.call(t,["fillAlpha",t.fillAlpha=l||1]),t.hasFill=!0,t},endFill:function(){var i=this,l=i._addAction;return i.hasStroke&&l.call(i,["stroke"]),i.hasFill&&l.call(i,["fill"]),i.setCacheDirty(!0),i},beginLinearGradientFill:function(i,l,t,e,a,n){for(var o=this,c=r.createLinearGradient(i,l,t,e),h=0,d=a.length;h1?n.slice(1):null;"function"==typeof i[r]?i[r].apply(i,o):i[r]=n[1]}},render:function(i,l){var t=this;"canvas"===i.renderType?t._draw(i.context):(t.cache(),i.draw(t))},clear:function(){var i=this;return i._actions.length=0,i.lineWidth=1,i.lineAlpha=1,i.lineCap=null,i.lineJoin=null,i.miterLimit=10,i.hasStroke=!1,i.strokeStyle="0",i.hasFill=!1,i.fillStyle="0",i.fillAlpha=1,i.setCacheDirty(!0),i},_addAction:function(i){var l=this;return l._actions.push(i),l}})}();return a}); \ No newline at end of file +define("hilo/view/Graphics",["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/CacheMixin"],function(t,e,i,l){var n=function(){var a=document.createElement("canvas"),r=a.getContext&&a.getContext("2d");return e.create({Extends:i,Mixes:l,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,l,n,a){var r=this,o=r._addAction;return o.call(r,["lineWidth",r.lineWidth=t||1]),o.call(r,["strokeStyle",r.strokeStyle=e||"0"]),o.call(r,["lineAlpha",r.lineAlpha=i||1]),void 0!=l&&o.call(r,["lineCap",r.lineCap=l]),void 0!=n&&o.call(r,["lineJoin",r.lineJoin=n]),void 0!=a&&o.call(r,["miterLimit",r.miterLimit=a]),r.hasStroke=!0,r},beginFill:function(t,e){var i=this,l=i._addAction;return l.call(i,["fillStyle",i.fillStyle=t]),l.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,l,n,a){for(var o=this,c=r.createLinearGradient(t,e,i,l),s=0,h=n.length;s1?a.slice(1):null;"function"==typeof t[r]?t[r].apply(t,o):t[r]=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}); \ No newline at end of file diff --git a/build/amd/hilo/view/Sprite.js b/build/amd/hilo/view/Sprite.js index d49987b6..0226889b 100644 --- a/build/amd/hilo/view/Sprite.js +++ b/build/amd/hilo/view/Sprite.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 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 73b045a9..65fff019 100644 --- a/build/amd/hilo/view/Sprite.min.js +++ b/build/amd/hilo/view/Sprite.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 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 23b92f4e..d2c2d774 100644 --- a/build/amd/hilo/view/Stage.js +++ b/build/amd/hilo/view/Stage.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 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 576ad473..2247d8ed 100644 --- a/build/amd/hilo/view/Stage.min.js +++ b/build/amd/hilo/view/Stage.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 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 fe461799..fd79165c 100644 --- a/build/amd/hilo/view/Text.js +++ b/build/amd/hilo/view/Text.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/Text.min.js b/build/amd/hilo/view/Text.min.js index 4d546f70..5a99bf77 100644 --- a/build/amd/hilo/view/Text.min.js +++ b/build/amd/hilo/view/Text.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 for amd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/amd/hilo/view/View.js b/build/amd/hilo/view/View.js index 5a108e2c..34d5dde2 100644 --- a/build/amd/hilo/view/View.js +++ b/build/amd/hilo/view/View.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 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 4d550c01..e247a347 100644 --- a/build/amd/hilo/view/View.min.js +++ b/build/amd/hilo/view/View.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for amd + * Hilo 1.0.4 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 e7689bd0..c8d9b126 100644 --- a/build/cmd/hilo-cmd.js +++ b/build/cmd/hilo-cmd.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -24,7 +24,7 @@ return { * Hilo version * @type String */ - version:'1.0.2', + version:'1.0.4', /** * @language=en * Gets a globally unique id. Such as Stage1, Bitmap2 etc. @@ -376,7 +376,7 @@ return Hilo; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -559,7 +559,7 @@ return Class; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -741,7 +741,7 @@ return Matrix; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -896,7 +896,7 @@ return EventMixin; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -977,7 +977,7 @@ return Drawable; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1073,7 +1073,7 @@ return Renderer; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1316,7 +1316,7 @@ return CanvasRenderer; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1503,7 +1503,7 @@ return DOMRenderer; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2075,7 +2075,7 @@ return WebGLRenderer; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2505,7 +2505,7 @@ return View; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2534,7 +2534,7 @@ var CacheMixin = /** @lends CacheMixin# */ { * @param {Boolean} forceUpdate is force update cache. */ cache: function(forceUpdate){ - if(forceUpdate || this._cacheDirty || !this._cacheImage){ + if(forceUpdate || this._cacheDirty || !this.drawable){ this.updateCache(); } }, @@ -2553,10 +2553,10 @@ var CacheMixin = /** @lends CacheMixin# */ { _cacheCanvas.width = this.width; _cacheCanvas.height = this.height; this._draw(_cacheContext); - this._cacheImage = new Image(); - this._cacheImage.src = _cacheCanvas.toDataURL(); this.drawable = this.drawable||new Drawable(); - this.drawable.init(this._cacheImage); + this.drawable.init({ + image:_cacheCanvas.toDataURL() + }); this._cacheDirty = false; } }, @@ -2574,7 +2574,7 @@ return CacheMixin; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2952,7 +2952,7 @@ return Container; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3224,7 +3224,7 @@ return Stage; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3307,7 +3307,7 @@ return Bitmap; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3583,7 +3583,7 @@ return Sprite; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3689,7 +3689,7 @@ return DOMElement; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4027,7 +4027,7 @@ return Class.create(/** @lends Graphics.prototype */{ /** * @language=en - * Draw a path from the SVG data given by parameters. + * Draw a path from the SVG data given by parameters. Not support Arcs. * Demo: *

var path = 'M250 150 L150 350 L350 350 Z';

*

var shape = new Hilo.Graphics({width:500, height:500});

@@ -4037,30 +4037,137 @@ return Class.create(/** @lends Graphics.prototype */{ */ drawSVGPath: function(pathData){ var me = this, addAction = me._addAction, - path = pathData.split(/,| (?=[a-zA-Z])/); - + path = pathData.replace(/,/g, ' ').replace(/-/g, ' -').split(/(?=[a-zA-Z])/); addAction.call(me, ['beginPath']); + var currentPoint = {x:0, y:0}; + var lastControlPoint = {x:0, y:0}; + var lastCmd; for(var i = 0, len = path.length; i < len; i++){ - var str = path[i], cmd = str[0].toUpperCase(), p = str.substring(1).split(/,| /); - if(p[0].length == 0) p.shift(); + var str = path[i]; + if(!str.length){ + continue; + } + var realCmd = str[0]; + var cmd = realCmd.toUpperCase(); + var p = this._getSVGParams(str); + var useRelative = cmd !== realCmd; switch(cmd){ case 'M': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['moveTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; case 'L': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['lineTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; - case 'C': - addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + case 'H': + if(useRelative){ + p[0] += currentPoint.x; + } + addAction.call(me, ['lineTo', p[0], currentPoint.y]); + currentPoint.x = p[0]; + break; + case 'V': + if(useRelative){ + p[0] += currentPoint.y; + } + addAction.call(me, ['lineTo', currentPoint.x, p[0]]); + currentPoint.y = p[0]; break; case 'Z': addAction.call(me, ['closePath']); break; + case 'C': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + lastControlPoint.x = p[2]; + lastControlPoint.y = p[3]; + this._setCurrentPoint(currentPoint, p[4], p[5]); + break; + case 'S': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + if(lastCmd === 'C' || lastCmd === 'S'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['bezierCurveTo', controlPoint.x, controlPoint.y, p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'Q': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['quadraticCurveTo', p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'T': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + var controlPoint; + if(lastCmd === 'Q' || lastCmd === 'T'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['quadraticCurveTo', controlPoint.x, controlPoint.y, p[0], p[1]]); + lastControlPoint = controlPoint; + this._setCurrentPoint(currentPoint, p[0], p[1]); + break; } + lastCmd = cmd; + } return me; }, + _getSVGParams:function(str){ + var p = str.substring(1).replace(/[\s]+$|^[\s]+/g, '').split(/[\s]+/); + if(p[0].length == 0) { + p.shift(); + } + for(var i = 0, l = p.length;i < l;i ++){ + p[i] = parseFloat(p[i]); + } + return p; + }, + _convertToAbsolute:function(currentPoint, data){ + for(var i = 0, l = data.length;i < l;i ++){ + if(i%2 === 0){ + data[i] += currentPoint.x; + } + else{ + data[i] += currentPoint.y; + } + } + }, + _setCurrentPoint:function(currentPoint, x, y){ + currentPoint.x = x; + currentPoint.y = y; + }, + _getReflectionPoint:function(centerPoint, point){ + return { + x:centerPoint.x * 2 - point.x, + y:centerPoint.y * 2 - point.y + }; + }, /** * @language=en @@ -4140,7 +4247,7 @@ return Graphics; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4398,7 +4505,7 @@ return Text; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4587,7 +4694,7 @@ return BitmapText; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4770,7 +4877,7 @@ return Button; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5009,7 +5116,7 @@ return TextureAtlas; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5059,13 +5166,11 @@ var Ticker = Class.create(/** @lends Ticker.prototype */{ window[Hilo.browser.jsVendor + 'RequestAnimationFrame']; var runLoop; - if(useRAF && raf){ - var tick = function(){ - self._tick(); - }; + if(useRAF && raf && interval < 17){ + this._useRAF = true; runLoop = function(){ - self._intervalId = setTimeout(runLoop, interval); - raf(tick); + self._intervalId = raf(runLoop); + self._tick(); }; }else{ runLoop = function(){ @@ -5074,6 +5179,7 @@ var Ticker = Class.create(/** @lends Ticker.prototype */{ }; } + this._paused = false; runLoop(); }, @@ -5082,9 +5188,17 @@ var Ticker = Class.create(/** @lends Ticker.prototype */{ * Stop the ticker. */ stop: function(){ - clearTimeout(this._intervalId); + if(this._useRAF){ + var cancelRAF = window.cancelAnimationFrame || + window[Hilo.browser.jsVendor + 'CancelAnimationFrame']; + cancelRAF(this._intervalId); + } + else{ + clearTimeout(this._intervalId); + } this._intervalId = null; this._lastTime = 0; + this._paused = true; }, /** @@ -5230,7 +5344,7 @@ return Ticker; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5278,7 +5392,7 @@ if (!fnProto.bind) { }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5391,7 +5505,7 @@ return drag; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5480,7 +5594,7 @@ return Class.create(/** @lends Tween.prototype */{ }, target: null, - duration: 0, + duration: 1000, delay: 0, paused: false, loop: false, @@ -5632,11 +5746,15 @@ return Class.create(/** @lends Tween.prototype */{ //elapsed ratio var ratio = elapsed / me.duration, complete = false, callback; - ratio = ratio <= 0 ? 0 : ratio >= 1 ? 1 : me.ease ? me.ease(ratio) : ratio; + ratio = ratio <= 0 ? 0 : ratio >= 1 ? 1 : ratio; + var easeRatio = me.ease ? me.ease(ratio) : ratio; if(me.reverse){ //backward - if(me._reverseFlag < 0) ratio = 1 - ratio; + if(me._reverseFlag < 0) { + ratio = 1 - ratio; + easeRatio = 1 - easeRatio; + } //forward if(ratio < 1e-7){ //repeat complete or not loop @@ -5655,7 +5773,7 @@ return Class.create(/** @lends Tween.prototype */{ me.time = elapsed; //render & update callback - me._render(ratio); + me._render(easeRatio); (callback = me.onUpdate) && callback.call(me, ratio, me); //check if complete @@ -5782,6 +5900,7 @@ return Class.create(/** @lends Tween.prototype */{ * @returns {Tween|Array} An tween instance or an array of tween instance. */ fromTo: function(target, fromProps, toProps, params){ + params = params || {}; var isArray = target instanceof Array; target = isArray ? target : [target]; @@ -5830,7 +5949,7 @@ return Tween; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6102,7 +6221,7 @@ return Ease; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6152,7 +6271,7 @@ return ImageLoader; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6221,7 +6340,7 @@ return ScriptLoader; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6475,7 +6594,7 @@ return LoadQueue; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6682,7 +6801,7 @@ return HTMLAudio; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7003,7 +7122,7 @@ return WebAudio; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7105,7 +7224,7 @@ return WebSound; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7201,7 +7320,7 @@ return Camera; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7391,7 +7510,7 @@ return Camera3d; }); /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 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 2b527a8d..c12c0fa8 100644 --- a/build/cmd/hilo-cmd.min.js +++ b/build/cmd/hilo-cmd.min.js @@ -1,8 +1,8 @@ /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ -define(function(t,e,i){var r=function(){var t=window,e=document,i=e.documentElement,n=0;return{version:"1.0.2",getUid:function(t){var e=++n;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){for(var r in e)i&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t},browser:function(){var r=navigator.userAgent,n={iphone:/iphone/i.test(r),ipad:/ipad/i.test(r),ipod:/ipod/i.test(r),ios:/iphone|ipad|ipod/i.test(r),android:/android/i.test(r),webkit:/webkit/i.test(r),chrome:/chrome/i.test(r),safari:/safari/i.test(r),firefox:/firefox/i.test(r),ie:/msie/i.test(r),opera:/opera/i.test(r),supportTouch:"ontouchstart"in t,supportCanvas:null!=e.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in t,supportDeviceMotion:"ondevicemotion"in t};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"];return d&&(l.id="test3d",c=e.createElement("style"),c.textContent="@media ("+h+"transform-3d){#test3d{height:3px}}",e.head.appendChild(c),i.appendChild(l),d=3==l.offsetHeight,e.head.removeChild(c),i.removeChild(l)),n.supportTransform=u,n.supportTransform3D=d,n}(),event:function(){var e="ontouchstart"in t;return{POINTER_START:e?"touchstart":"mousedown",POINTER_MOVE:e?"touchmove":"mousemove",POINTER_END:e?"touchend":"mouseup"}}(),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 r;try{r=e.getBoundingClientRect()}catch(n){r={top:e.offsetTop,left:e.offsetLeft,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}}var a=(t.pageXOffset||i.scrollLeft)-(i.clientLeft||0)||0,o=(t.pageYOffset||i.scrollTop)-(i.clientTop||0)||0,s=t.getComputedStyle?getComputedStyle(e):e.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=r.top||0,p=r.left||0,v=r.right||0,m=r.bottom||0;return{left:p+a+l,top:f+o+c,width:v-u-p-l,height:m-d-f-c}},createElement:function(t,i){var r,n,a,o=e.createElement(t);for(r in i)if(n=i[r],"style"===r)for(a in n)o.style[a]=n[a];else o[r]=n;return o},getElement:function(t){return e.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,i=e.domElement.style,n=t._stateCache||(t._stateCache={}),a=r.browser.jsVendor,o="px",s=!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)){this.cacheStateIfChanged(t,["width"],n)&&(i.width=t.width+o),this.cacheStateIfChanged(t,["height"],n)&&(i.height=t.height+o),this.cacheStateIfChanged(t,["depth"],n)&&(i.zIndex=t.depth+1),(s=this.cacheStateIfChanged(t,["pivotX","pivotY"],n))&&(i[a+"TransformOrigin"]=t.pivotX+o+" "+t.pivotY+o),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],n)||s)&&(i[a+"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 l=h.src;l!==n.image&&(n.image=l,i.backgroundImage="url("+l+")");var c=e.rect;if(c){var u=c[0],d=c[1];u!==n.sx&&(n.sx=u,i.backgroundPositionX=-u+o),d!==n.sy&&(n.sy=d,i.backgroundPositionY=-d+o)}}var f=t.mask;if(f){var p=f.drawable.domElement.style.backgroundImage;p!==n.maskImage&&(n.maskImage=p,i[a+"MaskImage"]=p,i[a+"MaskRepeat"]="no-repeat");var v=f.x,m=f.y;v===n.maskX&&m===n.maskY||(n.maskX=v,n.maskY=m,i[a+"MaskPosition"]=v+o+" "+m+o)}}},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/Hilo"),n=t("hilo/core/Class"),a=n.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:r.copy(e,t,!0);var n=e.image;if("string"==typeof n){if(!i||n!==i.getAttribute("src")){e.image=null;var o=new Image;return o.onload=function(){o.onload=null,e.init(o)},void(o.src=n)}n=e.image=i}n&&!e.rect&&(e.rect=[0,0,n.width,n.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/Hilo"),n=t("hilo/core/Class"),a=n.create({constructor:function(t){t=t||{},r.copy(this,t,!0)},renderType:null,canvas:null,stage:null,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),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.mask;v&&(v._render(this),i.clip());var m=t.align;if(m)if("function"==typeof m)t.align();else{var g=t.parent;if(g){var _=t.width,x=t.height,y=g.width,w=g.height;switch(m){case"TL":c=0,u=0;break;case"T":c=y-_>>1,u=0;break;case"TR":c=y-_,u=0;break;case"L":c=0,u=w-x>>1;break;case"C":c=y-_>>1,u=w-x>>1;break;case"R":c=y-_,u=w-x>>1;break;case"BL":c=0,u=w-x;break;case"B":c=y-_>>1,u=w-x;break;case"BR":c=y-_,u=w-x}}}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/renderer/Renderer"),a=t("hilo/geom/Matrix"),o=Math.PI/180,s=r.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){s.superclass.constructor.call(this,t);var e=this;this.gl=this.canvas.getContext("webgl")||this.canvas.getContext("experimental-webgl"),this.maxBatchNum=s.MAX_BATCH_NUM,this.positionStride=4*s.ATTRIBUTE_NUM;var i=this.maxBatchNum*s.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 Hilo.setElementStyleByView(t);var i=t.scaleX,r=t.scaleY;if(t===this.stage){var n=this.canvas.style,o=t._scaleX,s=t._scaleY,h=!1;(!o&&1!=i||o&&o!=i)&&(t._scaleX=i,n.width=i*t.width+"px",h=!0),(!s&&1!=r||s&&s!=r)&&(t._scaleY=r,n.height=r*t.height+"px",h=!0),h&&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,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 h(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,s=t.pivotX,h=t.pivotY,l=t.scaleX,c=t.scaleY;if(a){var u=a*o;r=Math.cos(u),n=Math.sin(u)}i.a=r*l,i.b=n*l,i.c=-n*c,i.d=r*c,i.tx=t.x-i.a*s-i.c*h,i.ty=t.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}}),h=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 h.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}},s}),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=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"),r.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,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=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=r.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 s}),define(function(t,e,i){var r,n,a=t("hilo/core/Hilo"),o=t("hilo/view/Drawable"),s={_cacheDirty:!0,cache:function(t){(t||this._cacheDirty||!this._cacheImage)&&this.updateCache()},updateCache:function(){a.browser.supportCanvas&&(r||(r=document.createElement("canvas"),n=r.getContext("2d")),r.width=this.width,r.height=this.height,this._draw(n),this._cacheImage=new Image,this._cacheImage.src=r.toDataURL(),this.drawable=this.drawable||new o,this.drawable.init(this._cacheImage),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="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,r=t.canvas,n=this.drawable.domElement,a=this.depth,o=r.nextSibling;if(n.parentNode)return;for(;o&&3!=o.nodeType&&(i=parseInt(o.style.zIndex)||0,!(i<=0||i>a));)o=o.nextSibling;r.parentNode.insertBefore(this.drawable.domElement,o)}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},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:r.ease?r.ease(s):s,r.reverse&&(r._reverseFlag<0&&(s=1-s),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))),0==r.time&&(o=r.onStart)&&o.call(r,r),r.time=a,r._render(s),(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&&c<=e?(l._render(s),l.time=a,n.add(l)):h&&(c<0||c>e)&&l.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=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=[],h=0,l=e.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()}}),p=n.create({Extends:a,constructor:function(t){this.id=this.id||t.id||r.getUid("Particle"),p.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(),d.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(d.length>0){var e=d.pop();return e.init(t),e}return new p(t)}}});return f}();return h}); \ No newline at end of file +define(function(t,e,i){var r=function(){var t=window,e=document,i=e.documentElement,n=0;return{version:"1.0.4",getUid:function(t){var e=++n;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){for(var r in e)i&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t},browser:function(){var r=navigator.userAgent,n={iphone:/iphone/i.test(r),ipad:/ipad/i.test(r),ipod:/ipod/i.test(r),ios:/iphone|ipad|ipod/i.test(r),android:/android/i.test(r),webkit:/webkit/i.test(r),chrome:/chrome/i.test(r),safari:/safari/i.test(r),firefox:/firefox/i.test(r),ie:/msie/i.test(r),opera:/opera/i.test(r),supportTouch:"ontouchstart"in t,supportCanvas:null!=e.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in t,supportDeviceMotion:"ondevicemotion"in t};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"];return d&&(l.id="test3d",c=e.createElement("style"),c.textContent="@media ("+h+"transform-3d){#test3d{height:3px}}",e.head.appendChild(c),i.appendChild(l),d=3==l.offsetHeight,e.head.removeChild(c),i.removeChild(l)),n.supportTransform=u,n.supportTransform3D=d,n}(),event:function(){var e="ontouchstart"in t;return{POINTER_START:e?"touchstart":"mousedown",POINTER_MOVE:e?"touchmove":"mousemove",POINTER_END:e?"touchend":"mouseup"}}(),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 r;try{r=e.getBoundingClientRect()}catch(n){r={top:e.offsetTop,left:e.offsetLeft,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}}var a=(t.pageXOffset||i.scrollLeft)-(i.clientLeft||0)||0,o=(t.pageYOffset||i.scrollTop)-(i.clientTop||0)||0,s=t.getComputedStyle?getComputedStyle(e):e.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=r.top||0,v=r.left||0,p=r.right||0,m=r.bottom||0;return{left:v+a+l,top:f+o+c,width:p-u-v-l,height:m-d-f-c}},createElement:function(t,i){var r,n,a,o=e.createElement(t);for(r in i)if(n=i[r],"style"===r)for(a in n)o.style[a]=n[a];else o[r]=n;return o},getElement:function(t){return e.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,i=e.domElement.style,n=t._stateCache||(t._stateCache={}),a=r.browser.jsVendor,o="px",s=!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)){this.cacheStateIfChanged(t,["width"],n)&&(i.width=t.width+o),this.cacheStateIfChanged(t,["height"],n)&&(i.height=t.height+o),this.cacheStateIfChanged(t,["depth"],n)&&(i.zIndex=t.depth+1),(s=this.cacheStateIfChanged(t,["pivotX","pivotY"],n))&&(i[a+"TransformOrigin"]=t.pivotX+o+" "+t.pivotY+o),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],n)||s)&&(i[a+"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 l=h.src;l!==n.image&&(n.image=l,i.backgroundImage="url("+l+")");var c=e.rect;if(c){var u=c[0],d=c[1];u!==n.sx&&(n.sx=u,i.backgroundPositionX=-u+o),d!==n.sy&&(n.sy=d,i.backgroundPositionY=-d+o)}}var f=t.mask;if(f){var v=f.drawable.domElement.style.backgroundImage;v!==n.maskImage&&(n.maskImage=v,i[a+"MaskImage"]=v,i[a+"MaskRepeat"]="no-repeat");var p=f.x,m=f.y;p===n.maskX&&m===n.maskY||(n.maskX=p,n.maskY=m,i[a+"MaskPosition"]=p+o+" "+m+o)}}},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/Hilo"),n=t("hilo/core/Class"),a=n.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:r.copy(e,t,!0);var n=e.image;if("string"==typeof n){if(!i||n!==i.getAttribute("src")){e.image=null;var o=new Image;return o.onload=function(){o.onload=null,e.init(o)},void(o.src=n)}n=e.image=i}n&&!e.rect&&(e.rect=[0,0,n.width,n.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/Hilo"),n=t("hilo/core/Class"),a=n.create({constructor:function(t){t=t||{},r.copy(this,t,!0)},renderType:null,canvas:null,stage:null,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),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,v=t.rotation%360,p=t.mask;p&&(p._render(this),i.clip());var m=t.align;if(m)if("function"==typeof m)t.align();else{var _=t.parent;if(_){var g=t.width,x=t.height,y=_.width,w=_.height;switch(m){case"TL":c=0,u=0;break;case"T":c=y-g>>1,u=0;break;case"TR":c=y-g,u=0;break;case"L":c=0,u=w-x>>1;break;case"C":c=y-g>>1,u=w-x>>1;break;case"R":c=y-g,u=w-x>>1;break;case"BL":c=0,u=w-x;break;case"B":c=y-g>>1,u=w-x;break;case"BR":c=y-g,u=w-x}}}0==c&&0==u||i.translate(c,u),0!=v&&i.rotate(v*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/renderer/Renderer"),a=t("hilo/geom/Matrix"),o=Math.PI/180,s=r.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){s.superclass.constructor.call(this,t);var e=this;this.gl=this.canvas.getContext("webgl")||this.canvas.getContext("experimental-webgl"),this.maxBatchNum=s.MAX_BATCH_NUM,this.positionStride=4*s.ATTRIBUTE_NUM;var i=this.maxBatchNum*s.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,v=0;v<4;v++){var p=c[l+5*v],m=c[l+5*v+1];c[l+5*v]=f.a*p+f.c*m+f.tx,c[l+5*v+1]=f.b*p+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 Hilo.setElementStyleByView(t);var i=t.scaleX,r=t.scaleY;if(t===this.stage){var n=this.canvas.style,o=t._scaleX,s=t._scaleY,h=!1;(!o&&1!=i||o&&o!=i)&&(t._scaleX=i,n.width=i*t.width+"px",h=!0),(!s&&1!=r||s&&s!=r)&&(t._scaleY=r,n.height=r*t.height+"px",h=!0),h&&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,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 h(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,s=t.pivotX,h=t.pivotY,l=t.scaleX,c=t.scaleY;if(a){var u=a*o;r=Math.cos(u),n=Math.sin(u)}i.a=r*l,i.b=n*l,i.c=-n*c,i.d=r*c,i.tx=t.x-i.a*s-i.c*h,i.ty=t.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}}),h=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 h.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}},s}),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=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 v=i[(c+l-1)%c];(v.ye||v.y>e&&d.ys?s=c:cl?l=c:c=0)return!1;u>i.overlap&&(i.overlap=u,i.normal.x=v.x,i.normal.y=v.y)}return i}return n.create({Mixes:a,constructor:function(t){t=t||{},this.id=this.id||t.id||r.getUid("View"),r.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,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=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=r.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 s}),define(function(t,e,i){var r,n,a=t("hilo/core/Hilo"),o=t("hilo/view/Drawable"),s={_cacheDirty:!0,cache:function(t){(t||this._cacheDirty||!this.drawable)&&this.updateCache()},updateCache:function(){a.browser.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 o,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="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,r=t.canvas,n=this.drawable.domElement,a=this.depth,o=r.nextSibling;if(n.parentNode)return;for(;o&&3!=o.nodeType&&(i=parseInt(o.style.zIndex)||0,!(i<=0||i>a));)o=o.nextSibling;r.parentNode.insertBefore(this.drawable.domElement,o)}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},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<_&&(l=_),c+=u,m=p):(_=f,m+=p),v==s-1&&(d.push({text:m,y:c}),m!==p&&l>1;break;case"bottom":g=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))),0==r.time&&(o=r.onStart)&&o.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=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=[],h=0,l=e.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=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(),d.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(d.length>0){var e=d.pop();return e.init(t),e}return new v(t)}}});return f}();return h}); \ No newline at end of file diff --git a/build/cmd/hilo-cmd.zip b/build/cmd/hilo-cmd.zip index 7d124a79..1dbe245b 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 03c787b4..81a6383a 100644 --- a/build/cmd/hilo/core/Class.js +++ b/build/cmd/hilo/core/Class.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 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 5ca7de15..788237da 100644 --- a/build/cmd/hilo/core/Class.min.js +++ b/build/cmd/hilo/core/Class.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 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 b95982b3..1e8d295d 100644 --- a/build/cmd/hilo/core/Hilo.js +++ b/build/cmd/hilo/core/Hilo.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -24,7 +24,7 @@ return { * Hilo version * @type String */ - version:'1.0.2', + version:'1.0.4', /** * @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 f02d07ba..a8b5c4b7 100644 --- a/build/cmd/hilo/core/Hilo.min.js +++ b/build/cmd/hilo/core/Hilo.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ -define(function(t,e,o){var r=function(){var t=window,e=document,o=e.documentElement,a=0;return{version:"1.0.2",getUid:function(t){var e=++a;if(t){var o=t.charCodeAt(t.length-1);return o>=48&&o<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,o=t;o;)e=e?o.id+"."+e:o.id,o=o.parent;return e},copy:function(t,e,o){for(var r in e)o&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t},browser:function(){var r=navigator.userAgent,a={iphone:/iphone/i.test(r),ipad:/ipad/i.test(r),ipod:/ipod/i.test(r),ios:/iphone|ipad|ipod/i.test(r),android:/android/i.test(r),webkit:/webkit/i.test(r),chrome:/chrome/i.test(r),safari:/safari/i.test(r),firefox:/firefox/i.test(r),ie:/msie/i.test(r),opera:/opera/i.test(r),supportTouch:"ontouchstart"in t,supportCanvas:null!=e.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in t,supportDeviceMotion:"ondevicemotion"in t};try{var i="hilo";localStorage.setItem(i,i),localStorage.removeItem(i),a.supportStorage=!0}catch(n){}var s=a.jsVendor=a.webkit?"webkit":a.firefox?"webkit":a.opera?"o":a.ie?"ms":"",d=a.cssVendor="-"+s+"-",h=e.createElement("div"),c=h.style,p=void 0!=c[s+"Transform"],f=void 0!=c[s+"Perspective"];return f&&(h.id="test3d",c=e.createElement("style"),c.textContent="@media ("+d+"transform-3d){#test3d{height:3px}}",e.head.appendChild(c),o.appendChild(h),f=3==h.offsetHeight,e.head.removeChild(c),o.removeChild(h)),a.supportTransform=p,a.supportTransform3D=f,a}(),event:function(){var e="ontouchstart"in t;return{POINTER_START:e?"touchstart":"mousedown",POINTER_MOVE:e?"touchmove":"mousemove",POINTER_END:e?"touchend":"mouseup"}}(),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 r;try{r=e.getBoundingClientRect()}catch(a){r={top:e.offsetTop,left:e.offsetLeft,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}}var i=(t.pageXOffset||o.scrollLeft)-(o.clientLeft||0)||0,n=(t.pageYOffset||o.scrollTop)-(o.clientTop||0)||0,s=t.getComputedStyle?getComputedStyle(e):e.currentStyle,d=parseInt,h=d(s.paddingLeft)+d(s.borderLeftWidth)||0,c=d(s.paddingTop)+d(s.borderTopWidth)||0,p=d(s.paddingRight)+d(s.borderRightWidth)||0,f=d(s.paddingBottom)+d(s.borderBottomWidth)||0,g=r.top||0,l=r.left||0,m=r.right||0,u=r.bottom||0;return{left:l+i+h,top:g+n+c,width:m-p-l-h,height:u-f-g-c}},createElement:function(t,o){var r,a,i,n=e.createElement(t);for(r in o)if(a=o[r],"style"===r)for(i in a)n.style[i]=a[i];else n[r]=a;return n},getElement:function(t){return e.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,o=e.domElement.style,a=t._stateCache||(t._stateCache={}),i=r.browser.jsVendor,n="px",s=!1;if(this.cacheStateIfChanged(t,["visible"],a)&&(o.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],a)&&(o.opacity=t.alpha),t.visible&&!(t.alpha<=0)){this.cacheStateIfChanged(t,["width"],a)&&(o.width=t.width+n),this.cacheStateIfChanged(t,["height"],a)&&(o.height=t.height+n),this.cacheStateIfChanged(t,["depth"],a)&&(o.zIndex=t.depth+1),(s=this.cacheStateIfChanged(t,["pivotX","pivotY"],a))&&(o[i+"TransformOrigin"]=t.pivotX+n+" "+t.pivotY+n),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],a)||s)&&(o[i+"Transform"]=this.getTransformCSS(t)),this.cacheStateIfChanged(t,["background"],a)&&(o.backgroundColor=t.background),o.pointerEvents||(o.pointerEvents="none");var d=e.image;if(d){var h=d.src;h!==a.image&&(a.image=h,o.backgroundImage="url("+h+")");var c=e.rect;if(c){var p=c[0],f=c[1];p!==a.sx&&(a.sx=p,o.backgroundPositionX=-p+n),f!==a.sy&&(a.sy=f,o.backgroundPositionY=-f+n)}}var g=t.mask;if(g){var l=g.drawable.domElement.style.backgroundImage;l!==a.maskImage&&(a.maskImage=l,o[i+"MaskImage"]=l,o[i+"MaskRepeat"]="no-repeat");var m=g.x,u=g.y;m===a.maskX&&u===a.maskY||(a.maskX=m,a.maskY=u,o[i+"MaskPosition"]=m+n+" "+u+n)}}},cacheStateIfChanged:function(t,e,o){var r,a,i,n,s=!1;for(r=0,a=e.length;r=48&&o<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,o=t;o;)e=e?o.id+"."+e:o.id,o=o.parent;return e},copy:function(t,e,o){for(var r in e)o&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t},browser:function(){var r=navigator.userAgent,a={iphone:/iphone/i.test(r),ipad:/ipad/i.test(r),ipod:/ipod/i.test(r),ios:/iphone|ipad|ipod/i.test(r),android:/android/i.test(r),webkit:/webkit/i.test(r),chrome:/chrome/i.test(r),safari:/safari/i.test(r),firefox:/firefox/i.test(r),ie:/msie/i.test(r),opera:/opera/i.test(r),supportTouch:"ontouchstart"in t,supportCanvas:null!=e.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in t,supportDeviceMotion:"ondevicemotion"in t};try{var i="hilo";localStorage.setItem(i,i),localStorage.removeItem(i),a.supportStorage=!0}catch(n){}var s=a.jsVendor=a.webkit?"webkit":a.firefox?"webkit":a.opera?"o":a.ie?"ms":"",d=a.cssVendor="-"+s+"-",h=e.createElement("div"),c=h.style,p=void 0!=c[s+"Transform"],f=void 0!=c[s+"Perspective"];return f&&(h.id="test3d",c=e.createElement("style"),c.textContent="@media ("+d+"transform-3d){#test3d{height:3px}}",e.head.appendChild(c),o.appendChild(h),f=3==h.offsetHeight,e.head.removeChild(c),o.removeChild(h)),a.supportTransform=p,a.supportTransform3D=f,a}(),event:function(){var e="ontouchstart"in t;return{POINTER_START:e?"touchstart":"mousedown",POINTER_MOVE:e?"touchmove":"mousemove",POINTER_END:e?"touchend":"mouseup"}}(),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 r;try{r=e.getBoundingClientRect()}catch(a){r={top:e.offsetTop,left:e.offsetLeft,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}}var i=(t.pageXOffset||o.scrollLeft)-(o.clientLeft||0)||0,n=(t.pageYOffset||o.scrollTop)-(o.clientTop||0)||0,s=t.getComputedStyle?getComputedStyle(e):e.currentStyle,d=parseInt,h=d(s.paddingLeft)+d(s.borderLeftWidth)||0,c=d(s.paddingTop)+d(s.borderTopWidth)||0,p=d(s.paddingRight)+d(s.borderRightWidth)||0,f=d(s.paddingBottom)+d(s.borderBottomWidth)||0,g=r.top||0,l=r.left||0,m=r.right||0,u=r.bottom||0;return{left:l+i+h,top:g+n+c,width:m-p-l-h,height:u-f-g-c}},createElement:function(t,o){var r,a,i,n=e.createElement(t);for(r in o)if(a=o[r],"style"===r)for(i in a)n.style[i]=a[i];else n[r]=a;return n},getElement:function(t){return e.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,o=e.domElement.style,a=t._stateCache||(t._stateCache={}),i=r.browser.jsVendor,n="px",s=!1;if(this.cacheStateIfChanged(t,["visible"],a)&&(o.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],a)&&(o.opacity=t.alpha),t.visible&&!(t.alpha<=0)){this.cacheStateIfChanged(t,["width"],a)&&(o.width=t.width+n),this.cacheStateIfChanged(t,["height"],a)&&(o.height=t.height+n),this.cacheStateIfChanged(t,["depth"],a)&&(o.zIndex=t.depth+1),(s=this.cacheStateIfChanged(t,["pivotX","pivotY"],a))&&(o[i+"TransformOrigin"]=t.pivotX+n+" "+t.pivotY+n),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],a)||s)&&(o[i+"Transform"]=this.getTransformCSS(t)),this.cacheStateIfChanged(t,["background"],a)&&(o.backgroundColor=t.background),o.pointerEvents||(o.pointerEvents="none");var d=e.image;if(d){var h=d.src;h!==a.image&&(a.image=h,o.backgroundImage="url("+h+")");var c=e.rect;if(c){var p=c[0],f=c[1];p!==a.sx&&(a.sx=p,o.backgroundPositionX=-p+n),f!==a.sy&&(a.sy=f,o.backgroundPositionY=-f+n)}}var g=t.mask;if(g){var l=g.drawable.domElement.style.backgroundImage;l!==a.maskImage&&(a.maskImage=l,o[i+"MaskImage"]=l,o[i+"MaskRepeat"]="no-repeat");var m=g.x,u=g.y;m===a.maskX&&u===a.maskY||(a.maskX=m,a.maskY=u,o[i+"MaskPosition"]=m+n+" "+u+n)}}},cacheStateIfChanged:function(t,e,o){var r,a,i,n,s=!1;for(r=0,a=e.length;r= 1 ? 1 : me.ease ? me.ease(ratio) : ratio; + ratio = ratio <= 0 ? 0 : ratio >= 1 ? 1 : ratio; + var easeRatio = me.ease ? me.ease(ratio) : ratio; if(me.reverse){ //backward - if(me._reverseFlag < 0) ratio = 1 - ratio; + if(me._reverseFlag < 0) { + ratio = 1 - ratio; + easeRatio = 1 - easeRatio; + } //forward if(ratio < 1e-7){ //repeat complete or not loop @@ -263,7 +267,7 @@ return Class.create(/** @lends Tween.prototype */{ me.time = elapsed; //render & update callback - me._render(ratio); + me._render(easeRatio); (callback = me.onUpdate) && callback.call(me, ratio, me); //check if complete @@ -390,6 +394,7 @@ return Class.create(/** @lends Tween.prototype */{ * @returns {Tween|Array} An tween instance or an array of tween instance. */ fromTo: function(target, fromProps, toProps, params){ + params = params || {}; var isArray = target instanceof Array; target = isArray ? target : [target]; diff --git a/build/cmd/hilo/tween/Tween.min.js b/build/cmd/hilo/tween/Tween.min.js index 3122d3e5..2a241faf 100644 --- a/build/cmd/hilo/tween/Tween.min.js +++ b/build/cmd/hilo/tween/Tween.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ -define(function(e,t,r){var a=e("hilo/core/Class"),n=function(){function e(){return+new Date}return a.create({constructor:function(e,t,r,a){var n=this;n.target=e,n._startTime=0,n._seekTime=0,n._pausedTime=0,n._pausedStartTime=0,n._reverseFlag=1,n._repeatCount=0,3==arguments.length&&(a=r,r=t,t=null);for(var i in a)n[i]=a[i];n.setProps(t,r),!a.duration&&a.time&&(n.duration=a.time||0,n.time=0)},target:null,duration:0,delay:0,paused:!1,loop:!1,reverse:!1,repeat:0,repeatDelay:0,ease:null,time:0,onStart:null,onUpdate:null,onComplete:null,setProps:function(e,t){var r=this,a=r.target,n=e||t,i=r._fromProps={},s=r._toProps={};e=e||a,t=t||a;for(var u in n)s[u]=t[u]||0,a[u]=i[u]=e[u]||0;return r},start:function(){var t=this;return t._startTime=e()+t.delay,t._seekTime=0,t._pausedTime=0,t.paused=!1,n.add(t),t},stop:function(){return n.remove(this),this},pause:function(){var t=this;return t.paused=!0,t._pausedStartTime=e(),t},resume:function(){var t=this;return t.paused=!1,t._pausedStartTime&&(t._pausedTime+=e()-t._pausedStartTime),t._pausedStartTime=0,t},seek:function(t,r){var a=this,i=e();return a._startTime=i,a._seekTime=t,a._pausedTime=0,void 0!==r&&(a.paused=r),a._update(i,!0),n.add(a),a},link:function(e){var t,r,a=this,i=e.delay,s=a._startTime;return"string"==typeof i&&(t=0==i.indexOf("+"),r=0==i.indexOf("-"),i=t||r?Number(i.substr(1))*(t?1:-1):Number(i)),e.delay=i,e._startTime=t||r?s+a.duration+i:s+i,a._next=e,n.remove(e),a},_render:function(e){var t,r=this,a=r.target,n=r._fromProps;for(t in n)a[t]=n[t]+(r._toProps[t]-n[t])*e},_update:function(t,r){var a=this;if(!a.paused||r){var i=t-a._startTime-a._pausedTime+a._seekTime;if(!(i<0)){var s,u=i/a.duration,o=!1;u=u<=0?0:u>=1?1:a.ease?a.ease(u):u,a.reverse&&(a._reverseFlag<0&&(u=1-u),u<1e-7&&(a.repeat>0&&a._repeatCount++>=a.repeat||0==a.repeat&&!a.loop?o=!0:(a._startTime=e(),a._pausedTime=0,a._reverseFlag*=-1))),0==a.time&&(s=a.onStart)&&s.call(a,a),a.time=i,a._render(u),(s=a.onUpdate)&&s.call(a,u,a),u>=1&&(a.reverse?(a._startTime=e(),a._pausedTime=0,a._reverseFlag*=-1):a.loop||a.repeat>0&&a._repeatCount++0&&p<=t?(l._render(u),l.time=i,n.add(l)):o&&(p<0||p>t)&&l.start()}return o?((s=a.onComplete)&&s.call(a,a),!0):void 0}}},Statics:{_tweens:[],tick:function(){var t,r,a=n._tweens,i=a.length;for(r=0;r-1&&a.splice(t,1);else for(t=0;t=1?1:u;var l=a.ease?a.ease(u):u;a.reverse&&(a._reverseFlag<0&&(u=1-u,l=1-l),u<1e-7&&(a.repeat>0&&a._repeatCount++>=a.repeat||0==a.repeat&&!a.loop?o=!0:(a._startTime=e(),a._pausedTime=0,a._reverseFlag*=-1))),0==a.time&&(s=a.onStart)&&s.call(a,a),a.time=i,a._render(l),(s=a.onUpdate)&&s.call(a,u,a),u>=1&&(a.reverse?(a._startTime=e(),a._pausedTime=0,a._reverseFlag*=-1):a.loop||a.repeat>0&&a._repeatCount++0&&d<=t?(p._render(u),p.time=i,n.add(p)):o&&(d<0||d>t)&&p.start()}return o?((s=a.onComplete)&&s.call(a,a),!0):void 0}}},Statics:{_tweens:[],tick:function(){var t,r,a=n._tweens,i=a.length;for(r=0;r-1&&a.splice(t,1);else for(t=0;t=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=e.slice(0),s=0,r=n.length;s=0&&i.splice(e,1)},nextTick:function(t){var i=this,e={tick:function(n){i.removeTick(e),t()}};return i.addTick(e),e},timeout:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var i=(new Date).getTime(),r=i-n;r>=0&&(e.removeTick(s),t())}};return e.addTick(s),s},interval:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var e=(new Date).getTime(),s=e-n;s>=0&&(s=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=e.slice(0),s=0,r=n.length;s=0&&i.splice(e,1)},nextTick:function(t){var i=this,e={tick:function(n){i.removeTick(e),t()}};return i.addTick(e),e},timeout:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var i=(new Date).getTime(),r=i-n;r>=0&&(e.removeTick(s),t())}};return e.addTick(s),s},interval:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var e=(new Date).getTime(),s=e-n;s>=0&&(svar path = 'M250 150 L150 350 L350 350 Z';

*

var shape = new Hilo.Graphics({width:500, height:500});

@@ -347,30 +347,137 @@ return Class.create(/** @lends Graphics.prototype */{ */ drawSVGPath: function(pathData){ var me = this, addAction = me._addAction, - path = pathData.split(/,| (?=[a-zA-Z])/); - + path = pathData.replace(/,/g, ' ').replace(/-/g, ' -').split(/(?=[a-zA-Z])/); addAction.call(me, ['beginPath']); + var currentPoint = {x:0, y:0}; + var lastControlPoint = {x:0, y:0}; + var lastCmd; for(var i = 0, len = path.length; i < len; i++){ - var str = path[i], cmd = str[0].toUpperCase(), p = str.substring(1).split(/,| /); - if(p[0].length == 0) p.shift(); + var str = path[i]; + if(!str.length){ + continue; + } + var realCmd = str[0]; + var cmd = realCmd.toUpperCase(); + var p = this._getSVGParams(str); + var useRelative = cmd !== realCmd; switch(cmd){ case 'M': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['moveTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; case 'L': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['lineTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; - case 'C': - addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + case 'H': + if(useRelative){ + p[0] += currentPoint.x; + } + addAction.call(me, ['lineTo', p[0], currentPoint.y]); + currentPoint.x = p[0]; + break; + case 'V': + if(useRelative){ + p[0] += currentPoint.y; + } + addAction.call(me, ['lineTo', currentPoint.x, p[0]]); + currentPoint.y = p[0]; break; case 'Z': addAction.call(me, ['closePath']); break; + case 'C': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + lastControlPoint.x = p[2]; + lastControlPoint.y = p[3]; + this._setCurrentPoint(currentPoint, p[4], p[5]); + break; + case 'S': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + if(lastCmd === 'C' || lastCmd === 'S'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['bezierCurveTo', controlPoint.x, controlPoint.y, p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'Q': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['quadraticCurveTo', p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'T': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + var controlPoint; + if(lastCmd === 'Q' || lastCmd === 'T'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['quadraticCurveTo', controlPoint.x, controlPoint.y, p[0], p[1]]); + lastControlPoint = controlPoint; + this._setCurrentPoint(currentPoint, p[0], p[1]); + break; } + lastCmd = cmd; + } return me; }, + _getSVGParams:function(str){ + var p = str.substring(1).replace(/[\s]+$|^[\s]+/g, '').split(/[\s]+/); + if(p[0].length == 0) { + p.shift(); + } + for(var i = 0, l = p.length;i < l;i ++){ + p[i] = parseFloat(p[i]); + } + return p; + }, + _convertToAbsolute:function(currentPoint, data){ + for(var i = 0, l = data.length;i < l;i ++){ + if(i%2 === 0){ + data[i] += currentPoint.x; + } + else{ + data[i] += currentPoint.y; + } + } + }, + _setCurrentPoint:function(currentPoint, x, y){ + currentPoint.x = x; + currentPoint.y = y; + }, + _getReflectionPoint:function(centerPoint, point){ + return { + x:centerPoint.x * 2 - point.x, + y:centerPoint.y * 2 - point.y + }; + }, /** * @language=en diff --git a/build/cmd/hilo/view/Graphics.min.js b/build/cmd/hilo/view/Graphics.min.js index 5dd6c932..c84ae5ef 100644 --- a/build/cmd/hilo/view/Graphics.min.js +++ b/build/cmd/hilo/view/Graphics.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ -define(function(l,i,t){var e=l("hilo/core/Hilo"),n=l("hilo/core/Class"),a=l("hilo/view/View"),r=l("hilo/view/CacheMixin"),o=function(){var l=document.createElement("canvas"),i=l.getContext&&l.getContext("2d");return n.create({Extends:a,Mixes:r,constructor:function(l){l=l||{},this.id=this.id||l.id||e.getUid("Graphics"),o.superclass.constructor.call(this,l),this._actions=[]},lineWidth:1,lineAlpha:1,lineCap:null,lineJoin:null,miterLimit:10,hasStroke:!1,strokeStyle:"0",hasFill:!1,fillStyle:"0",fillAlpha:0,lineStyle:function(l,i,t,e,n,a){var r=this,o=r._addAction;return o.call(r,["lineWidth",r.lineWidth=l||1]),o.call(r,["strokeStyle",r.strokeStyle=i||"0"]),o.call(r,["lineAlpha",r.lineAlpha=t||1]),void 0!=e&&o.call(r,["lineCap",r.lineCap=e]),void 0!=n&&o.call(r,["lineJoin",r.lineJoin=n]),void 0!=a&&o.call(r,["miterLimit",r.miterLimit=a]),r.hasStroke=!0,r},beginFill:function(l,i){var t=this,e=t._addAction;return e.call(t,["fillStyle",t.fillStyle=l]),e.call(t,["fillAlpha",t.fillAlpha=i||1]),t.hasFill=!0,t},endFill:function(){var l=this,i=l._addAction;return l.hasStroke&&i.call(l,["stroke"]),l.hasFill&&i.call(l,["fill"]),l.setCacheDirty(!0),l},beginLinearGradientFill:function(l,t,e,n,a,r){for(var o=this,c=i.createLinearGradient(l,t,e,n),h=0,d=a.length;h1?a.slice(1):null;"function"==typeof l[r]?l[r].apply(l,o):l[r]=a[1]}},render:function(l,i){var t=this;"canvas"===l.renderType?t._draw(l.context):(t.cache(),l.draw(t))},clear:function(){var l=this;return l._actions.length=0,l.lineWidth=1,l.lineAlpha=1,l.lineCap=null,l.lineJoin=null,l.miterLimit=10,l.hasStroke=!1,l.strokeStyle="0",l.hasFill=!1,l.fillStyle="0",l.fillAlpha=1,l.setCacheDirty(!0),l},_addAction:function(l){var i=this;return i._actions.push(l),i}})}();return o}); \ No newline at end of file +define(function(t,e,i){var l=t("hilo/core/Hilo"),n=t("hilo/core/Class"),a=t("hilo/view/View"),r=t("hilo/view/CacheMixin"),o=function(){var t=document.createElement("canvas"),e=t.getContext&&t.getContext("2d");return n.create({Extends:a,Mixes:r,constructor:function(t){t=t||{},this.id=this.id||t.id||l.getUid("Graphics"),o.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,l,n,a){var r=this,o=r._addAction;return o.call(r,["lineWidth",r.lineWidth=t||1]),o.call(r,["strokeStyle",r.strokeStyle=e||"0"]),o.call(r,["lineAlpha",r.lineAlpha=i||1]),void 0!=l&&o.call(r,["lineCap",r.lineCap=l]),void 0!=n&&o.call(r,["lineJoin",r.lineJoin=n]),void 0!=a&&o.call(r,["miterLimit",r.miterLimit=a]),r.hasStroke=!0,r},beginFill:function(t,e){var i=this,l=i._addAction;return l.call(i,["fillStyle",i.fillStyle=t]),l.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,l,n,a,r){for(var o=this,c=e.createLinearGradient(t,i,l,n),s=0,h=a.length;s1?a.slice(1):null;"function"==typeof t[r]?t[r].apply(t,o):t[r]=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 o}); \ No newline at end of file diff --git a/build/cmd/hilo/view/Sprite.js b/build/cmd/hilo/view/Sprite.js index 68dec668..60feca7a 100644 --- a/build/cmd/hilo/view/Sprite.js +++ b/build/cmd/hilo/view/Sprite.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 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 21e48144..c36134a1 100644 --- a/build/cmd/hilo/view/Sprite.min.js +++ b/build/cmd/hilo/view/Sprite.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 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 f1c77d88..95f75c45 100644 --- a/build/cmd/hilo/view/Stage.js +++ b/build/cmd/hilo/view/Stage.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 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 3c32e514..029627bb 100644 --- a/build/cmd/hilo/view/Stage.min.js +++ b/build/cmd/hilo/view/Stage.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 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 2a1cb2ab..6f7791cf 100644 --- a/build/cmd/hilo/view/Text.js +++ b/build/cmd/hilo/view/Text.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/Text.min.js b/build/cmd/hilo/view/Text.min.js index 4b4f3952..d195e4cd 100644 --- a/build/cmd/hilo/view/Text.min.js +++ b/build/cmd/hilo/view/Text.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 for cmd * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/cmd/hilo/view/View.js b/build/cmd/hilo/view/View.js index 756698f7..f6556e1f 100644 --- a/build/cmd/hilo/view/View.js +++ b/build/cmd/hilo/view/View.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 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 73ce7648..2d1c2e56 100644 --- a/build/cmd/hilo/view/View.min.js +++ b/build/cmd/hilo/view/View.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for cmd + * Hilo 1.0.4 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 86ed9672..536e2f28 100644 --- a/build/commonjs/core/Class.js +++ b/build/commonjs/core/Class.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for commonjs + * Hilo 1.0.4 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 00036361..60db1960 100644 --- a/build/commonjs/core/Class.min.js +++ b/build/commonjs/core/Class.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for commonjs + * Hilo 1.0.4 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 8942939c..b909e6f8 100644 --- a/build/commonjs/core/Hilo.js +++ b/build/commonjs/core/Hilo.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for commonjs + * Hilo 1.0.4 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -22,7 +22,7 @@ return { * Hilo version * @type String */ - version:'1.0.2', + version:'1.0.4', /** * @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 01f4a051..a65293b7 100644 --- a/build/commonjs/core/Hilo.min.js +++ b/build/commonjs/core/Hilo.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.0.2 for commonjs + * Hilo 1.0.4 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ -var Hilo=function(){var t=window,e=document,o=e.documentElement,r=0;return{version:"1.0.2",getUid:function(t){var e=++r;if(t){var o=t.charCodeAt(t.length-1);return o>=48&&o<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,o=t;o;)e=e?o.id+"."+e:o.id,o=o.parent;return e},copy:function(t,e,o){for(var r in e)o&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t},browser:function(){var r=navigator.userAgent,a={iphone:/iphone/i.test(r),ipad:/ipad/i.test(r),ipod:/ipod/i.test(r),ios:/iphone|ipad|ipod/i.test(r),android:/android/i.test(r),webkit:/webkit/i.test(r),chrome:/chrome/i.test(r),safari:/safari/i.test(r),firefox:/firefox/i.test(r),ie:/msie/i.test(r),opera:/opera/i.test(r),supportTouch:"ontouchstart"in t,supportCanvas:null!=e.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in t,supportDeviceMotion:"ondevicemotion"in t};try{var i="hilo";localStorage.setItem(i,i),localStorage.removeItem(i),a.supportStorage=!0}catch(n){}var s=a.jsVendor=a.webkit?"webkit":a.firefox?"webkit":a.opera?"o":a.ie?"ms":"",d=a.cssVendor="-"+s+"-",h=e.createElement("div"),c=h.style,p=void 0!=c[s+"Transform"],f=void 0!=c[s+"Perspective"];return f&&(h.id="test3d",c=e.createElement("style"),c.textContent="@media ("+d+"transform-3d){#test3d{height:3px}}",e.head.appendChild(c),o.appendChild(h),f=3==h.offsetHeight,e.head.removeChild(c),o.removeChild(h)),a.supportTransform=p,a.supportTransform3D=f,a}(),event:function(){var e="ontouchstart"in t;return{POINTER_START:e?"touchstart":"mousedown",POINTER_MOVE:e?"touchmove":"mousemove",POINTER_END:e?"touchend":"mouseup"}}(),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 r;try{r=e.getBoundingClientRect()}catch(a){r={top:e.offsetTop,left:e.offsetLeft,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}}var i=(t.pageXOffset||o.scrollLeft)-(o.clientLeft||0)||0,n=(t.pageYOffset||o.scrollTop)-(o.clientTop||0)||0,s=t.getComputedStyle?getComputedStyle(e):e.currentStyle,d=parseInt,h=d(s.paddingLeft)+d(s.borderLeftWidth)||0,c=d(s.paddingTop)+d(s.borderTopWidth)||0,p=d(s.paddingRight)+d(s.borderRightWidth)||0,f=d(s.paddingBottom)+d(s.borderBottomWidth)||0,l=r.top||0,g=r.left||0,m=r.right||0,u=r.bottom||0;return{left:g+i+h,top:l+n+c,width:m-p-g-h,height:u-f-l-c}},createElement:function(t,o){var r,a,i,n=e.createElement(t);for(r in o)if(a=o[r],"style"===r)for(i in a)n.style[i]=a[i];else n[r]=a;return n},getElement:function(t){return e.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,o=e.domElement.style,r=t._stateCache||(t._stateCache={}),a=Hilo.browser.jsVendor,i="px",n=!1;if(this.cacheStateIfChanged(t,["visible"],r)&&(o.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],r)&&(o.opacity=t.alpha),t.visible&&!(t.alpha<=0)){this.cacheStateIfChanged(t,["width"],r)&&(o.width=t.width+i),this.cacheStateIfChanged(t,["height"],r)&&(o.height=t.height+i),this.cacheStateIfChanged(t,["depth"],r)&&(o.zIndex=t.depth+1),(n=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(o[a+"TransformOrigin"]=t.pivotX+i+" "+t.pivotY+i),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],r)||n)&&(o[a+"Transform"]=this.getTransformCSS(t)),this.cacheStateIfChanged(t,["background"],r)&&(o.backgroundColor=t.background),o.pointerEvents||(o.pointerEvents="none");var s=e.image;if(s){var d=s.src;d!==r.image&&(r.image=d,o.backgroundImage="url("+d+")");var h=e.rect;if(h){var c=h[0],p=h[1];c!==r.sx&&(r.sx=c,o.backgroundPositionX=-c+i),p!==r.sy&&(r.sy=p,o.backgroundPositionY=-p+i)}}var f=t.mask;if(f){var l=f.drawable.domElement.style.backgroundImage;l!==r.maskImage&&(r.maskImage=l,o[a+"MaskImage"]=l,o[a+"MaskRepeat"]="no-repeat");var g=f.x,m=f.y;g===r.maskX&&m===r.maskY||(r.maskX=g,r.maskY=m,o[a+"MaskPosition"]=g+i+" "+m+i)}}},cacheStateIfChanged:function(t,e,o){var r,a,i,n,s=!1;for(r=0,a=e.length;r=48&&o<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,o=t;o;)e=e?o.id+"."+e:o.id,o=o.parent;return e},copy:function(t,e,o){for(var r in e)o&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t},browser:function(){var r=navigator.userAgent,a={iphone:/iphone/i.test(r),ipad:/ipad/i.test(r),ipod:/ipod/i.test(r),ios:/iphone|ipad|ipod/i.test(r),android:/android/i.test(r),webkit:/webkit/i.test(r),chrome:/chrome/i.test(r),safari:/safari/i.test(r),firefox:/firefox/i.test(r),ie:/msie/i.test(r),opera:/opera/i.test(r),supportTouch:"ontouchstart"in t,supportCanvas:null!=e.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in t,supportDeviceMotion:"ondevicemotion"in t};try{var i="hilo";localStorage.setItem(i,i),localStorage.removeItem(i),a.supportStorage=!0}catch(n){}var s=a.jsVendor=a.webkit?"webkit":a.firefox?"webkit":a.opera?"o":a.ie?"ms":"",d=a.cssVendor="-"+s+"-",h=e.createElement("div"),c=h.style,p=void 0!=c[s+"Transform"],f=void 0!=c[s+"Perspective"];return f&&(h.id="test3d",c=e.createElement("style"),c.textContent="@media ("+d+"transform-3d){#test3d{height:3px}}",e.head.appendChild(c),o.appendChild(h),f=3==h.offsetHeight,e.head.removeChild(c),o.removeChild(h)),a.supportTransform=p,a.supportTransform3D=f,a}(),event:function(){var e="ontouchstart"in t;return{POINTER_START:e?"touchstart":"mousedown",POINTER_MOVE:e?"touchmove":"mousemove",POINTER_END:e?"touchend":"mouseup"}}(),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 r;try{r=e.getBoundingClientRect()}catch(a){r={top:e.offsetTop,left:e.offsetLeft,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}}var i=(t.pageXOffset||o.scrollLeft)-(o.clientLeft||0)||0,n=(t.pageYOffset||o.scrollTop)-(o.clientTop||0)||0,s=t.getComputedStyle?getComputedStyle(e):e.currentStyle,d=parseInt,h=d(s.paddingLeft)+d(s.borderLeftWidth)||0,c=d(s.paddingTop)+d(s.borderTopWidth)||0,p=d(s.paddingRight)+d(s.borderRightWidth)||0,f=d(s.paddingBottom)+d(s.borderBottomWidth)||0,l=r.top||0,g=r.left||0,m=r.right||0,u=r.bottom||0;return{left:g+i+h,top:l+n+c,width:m-p-g-h,height:u-f-l-c}},createElement:function(t,o){var r,a,i,n=e.createElement(t);for(r in o)if(a=o[r],"style"===r)for(i in a)n.style[i]=a[i];else n[r]=a;return n},getElement:function(t){return e.getElementById(t)},setElementStyleByView:function(t){var e=t.drawable,o=e.domElement.style,r=t._stateCache||(t._stateCache={}),a=Hilo.browser.jsVendor,i="px",n=!1;if(this.cacheStateIfChanged(t,["visible"],r)&&(o.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],r)&&(o.opacity=t.alpha),t.visible&&!(t.alpha<=0)){this.cacheStateIfChanged(t,["width"],r)&&(o.width=t.width+i),this.cacheStateIfChanged(t,["height"],r)&&(o.height=t.height+i),this.cacheStateIfChanged(t,["depth"],r)&&(o.zIndex=t.depth+1),(n=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(o[a+"TransformOrigin"]=t.pivotX+i+" "+t.pivotY+i),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],r)||n)&&(o[a+"Transform"]=this.getTransformCSS(t)),this.cacheStateIfChanged(t,["background"],r)&&(o.backgroundColor=t.background),o.pointerEvents||(o.pointerEvents="none");var s=e.image;if(s){var d=s.src;d!==r.image&&(r.image=d,o.backgroundImage="url("+d+")");var h=e.rect;if(h){var c=h[0],p=h[1];c!==r.sx&&(r.sx=c,o.backgroundPositionX=-c+i),p!==r.sy&&(r.sy=p,o.backgroundPositionY=-p+i)}}var f=t.mask;if(f){var l=f.drawable.domElement.style.backgroundImage;l!==r.maskImage&&(r.maskImage=l,o[a+"MaskImage"]=l,o[a+"MaskRepeat"]="no-repeat");var g=f.x,m=f.y;g===r.maskX&&m===r.maskY||(r.maskX=g,r.maskY=m,o[a+"MaskPosition"]=g+i+" "+m+i)}}},cacheStateIfChanged:function(t,e,o){var r,a,i,n,s=!1;for(r=0,a=e.length;r= 1 ? 1 : me.ease ? me.ease(ratio) : ratio; + ratio = ratio <= 0 ? 0 : ratio >= 1 ? 1 : ratio; + var easeRatio = me.ease ? me.ease(ratio) : ratio; if(me.reverse){ //backward - if(me._reverseFlag < 0) ratio = 1 - ratio; + if(me._reverseFlag < 0) { + ratio = 1 - ratio; + easeRatio = 1 - easeRatio; + } //forward if(ratio < 1e-7){ //repeat complete or not loop @@ -261,7 +265,7 @@ return Class.create(/** @lends Tween.prototype */{ me.time = elapsed; //render & update callback - me._render(ratio); + me._render(easeRatio); (callback = me.onUpdate) && callback.call(me, ratio, me); //check if complete @@ -388,6 +392,7 @@ return Class.create(/** @lends Tween.prototype */{ * @returns {Tween|Array} An tween instance or an array of tween instance. */ fromTo: function(target, fromProps, toProps, params){ + params = params || {}; var isArray = target instanceof Array; target = isArray ? target : [target]; diff --git a/build/commonjs/tween/Tween.min.js b/build/commonjs/tween/Tween.min.js index 5a8e81fb..04b13a19 100644 --- a/build/commonjs/tween/Tween.min.js +++ b/build/commonjs/tween/Tween.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.0.2 for commonjs + * Hilo 1.0.4 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ -var Class=require("../core/Class"),Tween=function(){function e(){return+new Date}return Class.create({constructor:function(e,t,r,n){var a=this;a.target=e,a._startTime=0,a._seekTime=0,a._pausedTime=0,a._pausedStartTime=0,a._reverseFlag=1,a._repeatCount=0,3==arguments.length&&(n=r,r=t,t=null);for(var s in n)a[s]=n[s];a.setProps(t,r),!n.duration&&n.time&&(a.duration=n.time||0,a.time=0)},target:null,duration:0,delay:0,paused:!1,loop:!1,reverse:!1,repeat:0,repeatDelay:0,ease:null,time:0,onStart:null,onUpdate:null,onComplete:null,setProps:function(e,t){var r=this,n=r.target,a=e||t,s=r._fromProps={},i=r._toProps={};e=e||n,t=t||n;for(var u in a)i[u]=t[u]||0,n[u]=s[u]=e[u]||0;return r},start:function(){var t=this;return t._startTime=e()+t.delay,t._seekTime=0,t._pausedTime=0,t.paused=!1,Tween.add(t),t},stop:function(){return Tween.remove(this),this},pause:function(){var t=this;return t.paused=!0,t._pausedStartTime=e(),t},resume:function(){var t=this;return t.paused=!1,t._pausedStartTime&&(t._pausedTime+=e()-t._pausedStartTime),t._pausedStartTime=0,t},seek:function(t,r){var n=this,a=e();return n._startTime=a,n._seekTime=t,n._pausedTime=0,void 0!==r&&(n.paused=r),n._update(a,!0),Tween.add(n),n},link:function(e){var t,r,n=this,a=e.delay,s=n._startTime;return"string"==typeof a&&(t=0==a.indexOf("+"),r=0==a.indexOf("-"),a=t||r?Number(a.substr(1))*(t?1:-1):Number(a)),e.delay=a,e._startTime=t||r?s+n.duration+a:s+a,n._next=e,Tween.remove(e),n},_render:function(e){var t,r=this,n=r.target,a=r._fromProps;for(t in a)n[t]=a[t]+(r._toProps[t]-a[t])*e},_update:function(t,r){var n=this;if(!n.paused||r){var a=t-n._startTime-n._pausedTime+n._seekTime;if(!(a<0)){var s,i=a/n.duration,u=!1;i=i<=0?0:i>=1?1:n.ease?n.ease(i):i,n.reverse&&(n._reverseFlag<0&&(i=1-i),i<1e-7&&(n.repeat>0&&n._repeatCount++>=n.repeat||0==n.repeat&&!n.loop?u=!0:(n._startTime=e(),n._pausedTime=0,n._reverseFlag*=-1))),0==n.time&&(s=n.onStart)&&s.call(n,n),n.time=a,n._render(i),(s=n.onUpdate)&&s.call(n,i,n),i>=1&&(n.reverse?(n._startTime=e(),n._pausedTime=0,n._reverseFlag*=-1):n.loop||n.repeat>0&&n._repeatCount++0&&l<=t?(o._render(i),o.time=a,Tween.add(o)):u&&(l<0||l>t)&&o.start()}return u?((s=n.onComplete)&&s.call(n,n),!0):void 0}}},Statics:{_tweens:[],tick:function(){var t,r,n=Tween._tweens,a=n.length;for(r=0;r-1&&n.splice(t,1);else for(t=0;t=1?1:i;var o=n.ease?n.ease(i):i;n.reverse&&(n._reverseFlag<0&&(i=1-i,o=1-o),i<1e-7&&(n.repeat>0&&n._repeatCount++>=n.repeat||0==n.repeat&&!n.loop?u=!0:(n._startTime=e(),n._pausedTime=0,n._reverseFlag*=-1))),0==n.time&&(s=n.onStart)&&s.call(n,n),n.time=a,n._render(o),(s=n.onUpdate)&&s.call(n,i,n),i>=1&&(n.reverse?(n._startTime=e(),n._pausedTime=0,n._reverseFlag*=-1):n.loop||n.repeat>0&&n._repeatCount++0&&p<=t?(l._render(i),l.time=a,Tween.add(l)):u&&(p<0||p>t)&&l.start()}return u?((s=n.onComplete)&&s.call(n,n),!0):void 0}}},Statics:{_tweens:[],tick:function(){var t,r,n=Tween._tweens,a=n.length;for(r=0;r-1&&n.splice(t,1);else for(t=0;t=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=e.slice(0),s=0,r=n.length;s=0&&i.splice(e,1)},nextTick:function(t){var i=this,e={tick:function(n){i.removeTick(e),t()}};return i.addTick(e),e},timeout:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var i=(new Date).getTime(),r=i-n;r>=0&&(e.removeTick(s),t())}};return e.addTick(s),s},interval:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var e=(new Date).getTime(),s=e-n;s>=0&&(s=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=e.slice(0),s=0,r=n.length;s=0&&i.splice(e,1)},nextTick:function(t){var i=this,e={tick:function(n){i.removeTick(e),t()}};return i.addTick(e),e},timeout:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var i=(new Date).getTime(),r=i-n;r>=0&&(e.removeTick(s),t())}};return e.addTick(s),s},interval:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var e=(new Date).getTime(),s=e-n;s>=0&&(svar path = 'M250 150 L150 350 L350 350 Z';

*

var shape = new Hilo.Graphics({width:500, height:500});

@@ -345,30 +345,137 @@ return Class.create(/** @lends Graphics.prototype */{ */ drawSVGPath: function(pathData){ var me = this, addAction = me._addAction, - path = pathData.split(/,| (?=[a-zA-Z])/); - + path = pathData.replace(/,/g, ' ').replace(/-/g, ' -').split(/(?=[a-zA-Z])/); addAction.call(me, ['beginPath']); + var currentPoint = {x:0, y:0}; + var lastControlPoint = {x:0, y:0}; + var lastCmd; for(var i = 0, len = path.length; i < len; i++){ - var str = path[i], cmd = str[0].toUpperCase(), p = str.substring(1).split(/,| /); - if(p[0].length == 0) p.shift(); + var str = path[i]; + if(!str.length){ + continue; + } + var realCmd = str[0]; + var cmd = realCmd.toUpperCase(); + var p = this._getSVGParams(str); + var useRelative = cmd !== realCmd; switch(cmd){ case 'M': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['moveTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; case 'L': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['lineTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; - case 'C': - addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + case 'H': + if(useRelative){ + p[0] += currentPoint.x; + } + addAction.call(me, ['lineTo', p[0], currentPoint.y]); + currentPoint.x = p[0]; + break; + case 'V': + if(useRelative){ + p[0] += currentPoint.y; + } + addAction.call(me, ['lineTo', currentPoint.x, p[0]]); + currentPoint.y = p[0]; break; case 'Z': addAction.call(me, ['closePath']); break; + case 'C': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + lastControlPoint.x = p[2]; + lastControlPoint.y = p[3]; + this._setCurrentPoint(currentPoint, p[4], p[5]); + break; + case 'S': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + if(lastCmd === 'C' || lastCmd === 'S'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['bezierCurveTo', controlPoint.x, controlPoint.y, p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'Q': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['quadraticCurveTo', p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'T': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + var controlPoint; + if(lastCmd === 'Q' || lastCmd === 'T'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['quadraticCurveTo', controlPoint.x, controlPoint.y, p[0], p[1]]); + lastControlPoint = controlPoint; + this._setCurrentPoint(currentPoint, p[0], p[1]); + break; } + lastCmd = cmd; + } return me; }, + _getSVGParams:function(str){ + var p = str.substring(1).replace(/[\s]+$|^[\s]+/g, '').split(/[\s]+/); + if(p[0].length == 0) { + p.shift(); + } + for(var i = 0, l = p.length;i < l;i ++){ + p[i] = parseFloat(p[i]); + } + return p; + }, + _convertToAbsolute:function(currentPoint, data){ + for(var i = 0, l = data.length;i < l;i ++){ + if(i%2 === 0){ + data[i] += currentPoint.x; + } + else{ + data[i] += currentPoint.y; + } + } + }, + _setCurrentPoint:function(currentPoint, x, y){ + currentPoint.x = x; + currentPoint.y = y; + }, + _getReflectionPoint:function(centerPoint, point){ + return { + x:centerPoint.x * 2 - point.x, + y:centerPoint.y * 2 - point.y + }; + }, /** * @language=en diff --git a/build/commonjs/view/Graphics.min.js b/build/commonjs/view/Graphics.min.js index edcdcb67..afbd874b 100644 --- a/build/commonjs/view/Graphics.min.js +++ b/build/commonjs/view/Graphics.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.0.2 for commonjs + * Hilo 1.0.4 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ -var Hilo=require("../core/Hilo"),Class=require("../core/Class"),View=require("./View"),CacheMixin=require("./CacheMixin"),Graphics=function(){var i=document.createElement("canvas"),l=i.getContext&&i.getContext("2d");return Class.create({Extends:View,Mixes:CacheMixin,constructor:function(i){i=i||{},this.id=this.id||i.id||Hilo.getUid("Graphics"),Graphics.superclass.constructor.call(this,i),this._actions=[]},lineWidth:1,lineAlpha:1,lineCap:null,lineJoin:null,miterLimit:10,hasStroke:!1,strokeStyle:"0",hasFill:!1,fillStyle:"0",fillAlpha:0,lineStyle:function(i,l,t,e,a,n){var r=this,c=r._addAction;return c.call(r,["lineWidth",r.lineWidth=i||1]),c.call(r,["strokeStyle",r.strokeStyle=l||"0"]),c.call(r,["lineAlpha",r.lineAlpha=t||1]),void 0!=e&&c.call(r,["lineCap",r.lineCap=e]),void 0!=a&&c.call(r,["lineJoin",r.lineJoin=a]),void 0!=n&&c.call(r,["miterLimit",r.miterLimit=n]),r.hasStroke=!0,r},beginFill:function(i,l){var t=this,e=t._addAction;return e.call(t,["fillStyle",t.fillStyle=i]),e.call(t,["fillAlpha",t.fillAlpha=l||1]),t.hasFill=!0,t},endFill:function(){var i=this,l=i._addAction;return i.hasStroke&&l.call(i,["stroke"]),i.hasFill&&l.call(i,["fill"]),i.setCacheDirty(!0),i},beginLinearGradientFill:function(i,t,e,a,n,r){for(var c=this,o=l.createLinearGradient(i,t,e,a),s=0,h=n.length;s1?n.slice(1):null;"function"==typeof i[r]?i[r].apply(i,c):i[r]=n[1]}},render:function(i,l){var t=this;"canvas"===i.renderType?t._draw(i.context):(t.cache(),i.draw(t))},clear:function(){var i=this;return i._actions.length=0,i.lineWidth=1,i.lineAlpha=1,i.lineCap=null,i.lineJoin=null,i.miterLimit=10,i.hasStroke=!1,i.strokeStyle="0",i.hasFill=!1,i.fillStyle="0",i.fillAlpha=1,i.setCacheDirty(!0),i},_addAction:function(i){var l=this;return l._actions.push(i),l}})}();module.exports=Graphics; \ No newline at end of file +var Hilo=require("../core/Hilo"),Class=require("../core/Class"),View=require("./View"),CacheMixin=require("./CacheMixin"),Graphics=function(){var t=document.createElement("canvas"),e=t.getContext&&t.getContext("2d");return Class.create({Extends:View,Mixes:CacheMixin,constructor:function(t){t=t||{},this.id=this.id||t.id||Hilo.getUid("Graphics"),Graphics.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,l,r,n){var a=this,o=a._addAction;return o.call(a,["lineWidth",a.lineWidth=t||1]),o.call(a,["strokeStyle",a.strokeStyle=e||"0"]),o.call(a,["lineAlpha",a.lineAlpha=i||1]),void 0!=l&&o.call(a,["lineCap",a.lineCap=l]),void 0!=r&&o.call(a,["lineJoin",a.lineJoin=r]),void 0!=n&&o.call(a,["miterLimit",a.miterLimit=n]),a.hasStroke=!0,a},beginFill:function(t,e){var i=this,l=i._addAction;return l.call(i,["fillStyle",i.fillStyle=t]),l.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,l,r,n,a){for(var o=this,c=e.createLinearGradient(t,i,l,r),s=0,h=n.length;s1?n.slice(1):null;"function"==typeof t[a]?t[a].apply(t,o):t[a]=n[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}})}();module.exports=Graphics; \ No newline at end of file diff --git a/build/commonjs/view/Sprite.js b/build/commonjs/view/Sprite.js index e689d959..25d9b8e7 100644 --- a/build/commonjs/view/Sprite.js +++ b/build/commonjs/view/Sprite.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for commonjs + * Hilo 1.0.4 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 1d9d6983..9a580f6e 100644 --- a/build/commonjs/view/Sprite.min.js +++ b/build/commonjs/view/Sprite.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for commonjs + * Hilo 1.0.4 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 f46c0dd2..fa05d333 100644 --- a/build/commonjs/view/Stage.js +++ b/build/commonjs/view/Stage.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for commonjs + * Hilo 1.0.4 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 a991e87c..5559ab32 100644 --- a/build/commonjs/view/Stage.min.js +++ b/build/commonjs/view/Stage.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for commonjs + * Hilo 1.0.4 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 3f866e61..dada6b30 100644 --- a/build/commonjs/view/Text.js +++ b/build/commonjs/view/Text.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for commonjs + * Hilo 1.0.4 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/Text.min.js b/build/commonjs/view/Text.min.js index f2e2f9d7..dbaf7683 100644 --- a/build/commonjs/view/Text.min.js +++ b/build/commonjs/view/Text.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for commonjs + * Hilo 1.0.4 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/commonjs/view/View.js b/build/commonjs/view/View.js index 071e3eb2..ba440ac9 100644 --- a/build/commonjs/view/View.js +++ b/build/commonjs/view/View.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for commonjs + * Hilo 1.0.4 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 2e67c936..8c9c98a5 100644 --- a/build/commonjs/view/View.min.js +++ b/build/commonjs/view/View.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for commonjs + * Hilo 1.0.4 for commonjs * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/flash/hilo-flash.js b/build/flash/hilo-flash.js index c582f4aa..90dc3170 100644 --- a/build/flash/hilo-flash.js +++ b/build/flash/hilo-flash.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for flashAdaptor + * Hilo 1.0.4 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 076e5e98..d1647528 100644 --- a/build/flash/hilo-flash.min.js +++ b/build/flash/hilo-flash.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for flashAdaptor + * Hilo 1.0.4 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 b9878e60..729a48a3 100644 --- a/build/kissy/hilo-kissy.js +++ b/build/kissy/hilo-kissy.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -24,7 +24,7 @@ return { * Hilo version * @type String */ - version:'1.0.2', + version:'1.0.4', /** * @language=en * Gets a globally unique id. Such as Stage1, Bitmap2 etc. @@ -376,7 +376,7 @@ return Hilo; }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -559,7 +559,7 @@ return Class; }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -741,7 +741,7 @@ return Matrix; requires: ['hilo/core/Class'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -896,7 +896,7 @@ return EventMixin; requires: ['hilo/core/Class'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -976,7 +976,7 @@ return Drawable; requires: ['hilo/core/Hilo', 'hilo/core/Class'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1071,7 +1071,7 @@ return Renderer; requires: ['hilo/core/Hilo', 'hilo/core/Class'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1312,7 +1312,7 @@ return CanvasRenderer; requires: ['hilo/core/Class', 'hilo/core/Hilo', 'hilo/renderer/Renderer'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1496,7 +1496,7 @@ return DOMRenderer; requires: ['hilo/core/Class', 'hilo/core/Hilo', 'hilo/renderer/Renderer', 'hilo/view/Drawable'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2066,7 +2066,7 @@ return WebGLRenderer; requires: ['hilo/core/Class', 'hilo/renderer/Renderer', 'hilo/geom/Matrix'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2493,7 +2493,7 @@ return View; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/event/EventMixin', 'hilo/geom/Matrix'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2519,7 +2519,7 @@ var CacheMixin = /** @lends CacheMixin# */ { * @param {Boolean} forceUpdate is force update cache. */ cache: function(forceUpdate){ - if(forceUpdate || this._cacheDirty || !this._cacheImage){ + if(forceUpdate || this._cacheDirty || !this.drawable){ this.updateCache(); } }, @@ -2538,10 +2538,10 @@ var CacheMixin = /** @lends CacheMixin# */ { _cacheCanvas.width = this.width; _cacheCanvas.height = this.height; this._draw(_cacheContext); - this._cacheImage = new Image(); - this._cacheImage.src = _cacheCanvas.toDataURL(); this.drawable = this.drawable||new Drawable(); - this.drawable.init(this._cacheImage); + this.drawable.init({ + image:_cacheCanvas.toDataURL() + }); this._cacheDirty = false; } }, @@ -2561,7 +2561,7 @@ return CacheMixin; requires: ['hilo/core/Hilo', 'hilo/view/Drawable'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2937,7 +2937,7 @@ return Container; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/view/View'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3204,7 +3204,7 @@ return Stage; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/view/Container', 'hilo/renderer/CanvasRenderer', 'hilo/renderer/DOMRenderer', 'hilo/renderer/WebGLRenderer'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3284,7 +3284,7 @@ return Bitmap; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/view/View', 'hilo/view/Drawable'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3557,7 +3557,7 @@ return Sprite; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/view/View', 'hilo/view/Drawable'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3660,7 +3660,7 @@ return DOMElement; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/view/View', 'hilo/view/Drawable'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3993,7 +3993,7 @@ return Class.create(/** @lends Graphics.prototype */{ /** * @language=en - * Draw a path from the SVG data given by parameters. + * Draw a path from the SVG data given by parameters. Not support Arcs. * Demo: *

var path = 'M250 150 L150 350 L350 350 Z';

*

var shape = new Hilo.Graphics({width:500, height:500});

@@ -4003,30 +4003,137 @@ return Class.create(/** @lends Graphics.prototype */{ */ drawSVGPath: function(pathData){ var me = this, addAction = me._addAction, - path = pathData.split(/,| (?=[a-zA-Z])/); - + path = pathData.replace(/,/g, ' ').replace(/-/g, ' -').split(/(?=[a-zA-Z])/); addAction.call(me, ['beginPath']); + var currentPoint = {x:0, y:0}; + var lastControlPoint = {x:0, y:0}; + var lastCmd; for(var i = 0, len = path.length; i < len; i++){ - var str = path[i], cmd = str[0].toUpperCase(), p = str.substring(1).split(/,| /); - if(p[0].length == 0) p.shift(); + var str = path[i]; + if(!str.length){ + continue; + } + var realCmd = str[0]; + var cmd = realCmd.toUpperCase(); + var p = this._getSVGParams(str); + var useRelative = cmd !== realCmd; switch(cmd){ case 'M': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['moveTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; case 'L': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['lineTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; - case 'C': - addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + case 'H': + if(useRelative){ + p[0] += currentPoint.x; + } + addAction.call(me, ['lineTo', p[0], currentPoint.y]); + currentPoint.x = p[0]; + break; + case 'V': + if(useRelative){ + p[0] += currentPoint.y; + } + addAction.call(me, ['lineTo', currentPoint.x, p[0]]); + currentPoint.y = p[0]; break; case 'Z': addAction.call(me, ['closePath']); break; + case 'C': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + lastControlPoint.x = p[2]; + lastControlPoint.y = p[3]; + this._setCurrentPoint(currentPoint, p[4], p[5]); + break; + case 'S': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + if(lastCmd === 'C' || lastCmd === 'S'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['bezierCurveTo', controlPoint.x, controlPoint.y, p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'Q': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['quadraticCurveTo', p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'T': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + var controlPoint; + if(lastCmd === 'Q' || lastCmd === 'T'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['quadraticCurveTo', controlPoint.x, controlPoint.y, p[0], p[1]]); + lastControlPoint = controlPoint; + this._setCurrentPoint(currentPoint, p[0], p[1]); + break; } + lastCmd = cmd; + } return me; }, + _getSVGParams:function(str){ + var p = str.substring(1).replace(/[\s]+$|^[\s]+/g, '').split(/[\s]+/); + if(p[0].length == 0) { + p.shift(); + } + for(var i = 0, l = p.length;i < l;i ++){ + p[i] = parseFloat(p[i]); + } + return p; + }, + _convertToAbsolute:function(currentPoint, data){ + for(var i = 0, l = data.length;i < l;i ++){ + if(i%2 === 0){ + data[i] += currentPoint.x; + } + else{ + data[i] += currentPoint.y; + } + } + }, + _setCurrentPoint:function(currentPoint, x, y){ + currentPoint.x = x; + currentPoint.y = y; + }, + _getReflectionPoint:function(centerPoint, point){ + return { + x:centerPoint.x * 2 - point.x, + y:centerPoint.y * 2 - point.y + }; + }, /** * @language=en @@ -4108,7 +4215,7 @@ return Graphics; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/view/View', 'hilo/view/CacheMixin'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4363,7 +4470,7 @@ return Text; requires: ['hilo/core/Class', 'hilo/core/Hilo', 'hilo/view/View', 'hilo/view/CacheMixin'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4549,7 +4656,7 @@ return BitmapText; requires: ['hilo/core/Class', 'hilo/core/Hilo', 'hilo/view/Container', 'hilo/view/Bitmap'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4729,7 +4836,7 @@ return Button; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/view/View', 'hilo/view/Drawable'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4968,7 +5075,7 @@ return TextureAtlas; requires: ['hilo/core/Class'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5015,13 +5122,11 @@ var Ticker = Class.create(/** @lends Ticker.prototype */{ window[Hilo.browser.jsVendor + 'RequestAnimationFrame']; var runLoop; - if(useRAF && raf){ - var tick = function(){ - self._tick(); - }; + if(useRAF && raf && interval < 17){ + this._useRAF = true; runLoop = function(){ - self._intervalId = setTimeout(runLoop, interval); - raf(tick); + self._intervalId = raf(runLoop); + self._tick(); }; }else{ runLoop = function(){ @@ -5030,6 +5135,7 @@ var Ticker = Class.create(/** @lends Ticker.prototype */{ }; } + this._paused = false; runLoop(); }, @@ -5038,9 +5144,17 @@ var Ticker = Class.create(/** @lends Ticker.prototype */{ * Stop the ticker. */ stop: function(){ - clearTimeout(this._intervalId); + if(this._useRAF){ + var cancelRAF = window.cancelAnimationFrame || + window[Hilo.browser.jsVendor + 'CancelAnimationFrame']; + cancelRAF(this._intervalId); + } + else{ + clearTimeout(this._intervalId); + } this._intervalId = null; this._lastTime = 0; + this._paused = true; }, /** @@ -5188,7 +5302,7 @@ return Ticker; requires: ['hilo/core/Class', 'hilo/core/Hilo'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5236,7 +5350,7 @@ if (!fnProto.bind) { }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5349,7 +5463,7 @@ return drag; requires: ['hilo/core/Hilo'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5436,7 +5550,7 @@ return Class.create(/** @lends Tween.prototype */{ }, target: null, - duration: 0, + duration: 1000, delay: 0, paused: false, loop: false, @@ -5588,11 +5702,15 @@ return Class.create(/** @lends Tween.prototype */{ //elapsed ratio var ratio = elapsed / me.duration, complete = false, callback; - ratio = ratio <= 0 ? 0 : ratio >= 1 ? 1 : me.ease ? me.ease(ratio) : ratio; + ratio = ratio <= 0 ? 0 : ratio >= 1 ? 1 : ratio; + var easeRatio = me.ease ? me.ease(ratio) : ratio; if(me.reverse){ //backward - if(me._reverseFlag < 0) ratio = 1 - ratio; + if(me._reverseFlag < 0) { + ratio = 1 - ratio; + easeRatio = 1 - easeRatio; + } //forward if(ratio < 1e-7){ //repeat complete or not loop @@ -5611,7 +5729,7 @@ return Class.create(/** @lends Tween.prototype */{ me.time = elapsed; //render & update callback - me._render(ratio); + me._render(easeRatio); (callback = me.onUpdate) && callback.call(me, ratio, me); //check if complete @@ -5738,6 +5856,7 @@ return Class.create(/** @lends Tween.prototype */{ * @returns {Tween|Array} An tween instance or an array of tween instance. */ fromTo: function(target, fromProps, toProps, params){ + params = params || {}; var isArray = target instanceof Array; target = isArray ? target : [target]; @@ -5788,7 +5907,7 @@ return Tween; requires: ['hilo/core/Class'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6060,7 +6179,7 @@ return Ease; }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6110,7 +6229,7 @@ return ImageLoader; requires: ['hilo/core/Class'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6179,7 +6298,7 @@ return ScriptLoader; requires: ['hilo/core/Class'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6430,7 +6549,7 @@ return LoadQueue; requires: ['hilo/core/Class', 'hilo/event/EventMixin', 'hilo/loader/ImageLoader', 'hilo/loader/ScriptLoader'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6635,7 +6754,7 @@ return HTMLAudio; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/event/EventMixin'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6954,7 +7073,7 @@ return WebAudio; requires: ['hilo/core/Hilo', 'hilo/core/Class', 'hilo/event/EventMixin'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7054,7 +7173,7 @@ return WebSound; requires: ['hilo/core/Hilo', 'hilo/media/HTMLAudio', 'hilo/media/WebAudio'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7149,7 +7268,7 @@ return Camera; requires: ['hilo/core/Hilo', 'hilo/core/Class'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7338,7 +7457,7 @@ return Camera3d; requires: ['hilo/core/Hilo', 'hilo/core/Class'] }); /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 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 bd019737..4d93af76 100644 --- a/build/kissy/hilo-kissy.min.js +++ b/build/kissy/hilo-kissy.min.js @@ -1,8 +1,8 @@ /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ -KISSY.add("hilo/core/Hilo",function(t){var e=function(){var t=window,i=document,r=i.documentElement,n=0;return{version:"1.0.2",getUid:function(t){var e=++n;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){for(var r in e)i&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t},browser:function(){var e=navigator.userAgent,n={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 t,supportCanvas:null!=i.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in t,supportDeviceMotion:"ondevicemotion"in t};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=i.createElement("div"),c=l.style,u=void 0!=c[s+"Transform"],d=void 0!=c[s+"Perspective"];return d&&(l.id="test3d",c=i.createElement("style"),c.textContent="@media ("+h+"transform-3d){#test3d{height:3px}}",i.head.appendChild(c),r.appendChild(l),d=3==l.offsetHeight,i.head.removeChild(c),r.removeChild(l)),n.supportTransform=u,n.supportTransform3D=d,n}(),event:function(){var e="ontouchstart"in t;return{POINTER_START:e?"touchstart":"mousedown",POINTER_MOVE:e?"touchmove":"mousemove",POINTER_END:e?"touchend":"mouseup"}}(),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 i;try{i=e.getBoundingClientRect()}catch(n){i={top:e.offsetTop,left:e.offsetLeft,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}}var a=(t.pageXOffset||r.scrollLeft)-(r.clientLeft||0)||0,o=(t.pageYOffset||r.scrollTop)-(r.clientTop||0)||0,s=t.getComputedStyle?getComputedStyle(e):e.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=i.top||0,p=i.left||0,v=i.right||0,m=i.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 r,n,a,o=i.createElement(t);for(r in e)if(n=e[r],"style"===r)for(a in n)o.style[a]=n[a];else o[r]=n;return o},getElement:function(t){return i.getElementById(t)},setElementStyleByView:function(t){var i=t.drawable,r=i.domElement.style,n=t._stateCache||(t._stateCache={}),a=e.browser.jsVendor,o="px",s=!1;if(this.cacheStateIfChanged(t,["visible"],n)&&(r.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],n)&&(r.opacity=t.alpha),t.visible&&!(t.alpha<=0)){this.cacheStateIfChanged(t,["width"],n)&&(r.width=t.width+o),this.cacheStateIfChanged(t,["height"],n)&&(r.height=t.height+o),this.cacheStateIfChanged(t,["depth"],n)&&(r.zIndex=t.depth+1),(s=this.cacheStateIfChanged(t,["pivotX","pivotY"],n))&&(r[a+"TransformOrigin"]=t.pivotX+o+" "+t.pivotY+o),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],n)||s)&&(r[a+"Transform"]=this.getTransformCSS(t)),this.cacheStateIfChanged(t,["background"],n)&&(r.backgroundColor=t.background),r.pointerEvents||(r.pointerEvents="none");var h=i.image;if(h){var l=h.src;l!==n.image&&(n.image=l,r.backgroundImage="url("+l+")");var c=i.rect;if(c){var u=c[0],d=c[1];u!==n.sx&&(n.sx=u,r.backgroundPositionX=-u+o),d!==n.sy&&(n.sy=d,r.backgroundPositionY=-d+o)}}var f=t.mask;if(f){var p=f.drawable.domElement.style.backgroundImage;p!==n.maskImage&&(n.maskImage=p,r[a+"MaskImage"]=p,r[a+"MaskRepeat"]="no-repeat");var v=f.x,m=f.y;v===n.maskX&&m===n.maskY||(n.maskX=v,n.maskY=m,r[a+"MaskPosition"]=v+o+" "+m+o)}}},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=i.create({constructor:function(t){this.init(t)},image:null,rect:null,init:function(t){var i=this,n=i.image;r.isDrawable(t)?i.image=t:e.copy(i,t,!0);var a=i.image;if("string"==typeof a){if(!n||a!==n.getAttribute("src")){i.image=null;var o=new Image;return o.onload=function(){o.onload=null,i.init(o)},void(o.src=a)}a=i.image=n}a&&!i.rect&&(i.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/Hilo","hilo/core/Class"]}),KISSY.add("hilo/renderer/Renderer",function(t,e,i){var r=i.create({constructor:function(t){t=t||{},e.copy(this,t,!0)},renderType:null,canvas:null,stage:null,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/Hilo","hilo/core/Class"]}),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),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.mask;v&&(v._render(this),r.clip());var m=t.align;if(m)if("function"==typeof m)t.align();else{var g=t.parent;if(g){var _=t.width,x=t.height,y=g.width,w=g.height;switch(m){case"TL":c=0,u=0;break;case"T":c=y-_>>1,u=0;break;case"TR":c=y-_,u=0;break;case"L":c=0,u=w-x>>1;break;case"C":c=y-_>>1,u=w-x>>1;break;case"R":c=y-_,u=w-x>>1;break;case"BL":c=0,u=w-x;break;case"B":c=y-_>>1,u=w-x;break;case"BR":c=y-_,u=w-x}}}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){var n=Math.PI/180,a=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}},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 e=t.drawable;if(e&&e.domElement)return void Hilo.setElementStyleByView(t);var i=t.scaleX,n=t.scaleY;if(t===this.stage){var a=this.canvas.style,o=t._scaleX,s=t._scaleY,h=!1;(!o&&1!=i||o&&o!=i)&&(t._scaleX=i,a.width=i*t.width+"px",h=!0),(!s&&1!=n||s&&s!=n)&&(t._scaleY=n,a.height=n*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 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;if(o){var u=o*n;r=Math.cos(u),a=Math.sin(u)}i.a=r*l,i.b=a*l,i.c=-a*c,i.d=r*c,i.tx=t.x-i.a*s-i.c*h,i.ty=t.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},{requires:["hilo/core/Class","hilo/renderer/Renderer","hilo/geom/Matrix"]}),KISSY.add("hilo/view/View",function(t,e,i,r,n){var a=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"),e.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,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=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=a(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 i=e.copy({},t);i.type="mouseover",this.fire(i)}}else"mouseout"==t.type&&(this.__mouseOver=!1);var r=this.parent;t._stopped||t._stopPropagationed||!r||("mouseout"==t.type||"touchout"==t.type?r.hitTestPoint(t.stageX,t.stageY,!0)||r._fireMouseEvent(t):r._fireMouseEvent(t))},onUpdate:null,render:function(t,e){t.draw(this)},toString:function(){return e.viewToString(this)}})}();return a},{requires:["hilo/core/Hilo","hilo/core/Class","hilo/event/EventMixin","hilo/geom/Matrix"]}),KISSY.add("hilo/view/CacheMixin",function(t,e,i){var r,n,a={_cacheDirty:!0,cache:function(t){(t||this._cacheDirty||!this._cacheImage)&&this.updateCache()},updateCache:function(){e.browser.supportCanvas&&(r||(r=document.createElement("canvas"),n=r.getContext("2d")),r.width=this.width,r.height=this.height,this._draw(n),this._cacheImage=new Image,this._cacheImage.src=r.toDataURL(),this.drawable=this.drawable||new i,this.drawable.init(this._cacheImage),this._cacheDirty=!1)},setCacheDirty:function(t){this._cacheDirty=t}};return a},{requires:["hilo/core/Hilo","hilo/view/Drawable"]}),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="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,r=t.canvas,n=this.drawable.domElement,a=this.depth,o=r.nextSibling;if(n.parentNode)return;for(;o&&3!=o.nodeType&&(i=parseInt(o.style.zIndex)||0,!(i<=0||i>a));)o=o.nextSibling;r.parentNode.insertBefore(this.drawable.domElement,o)}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},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:n.ease?n.ease(s):s,n.reverse&&(n._reverseFlag<0&&(s=1-s),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))),0==n.time&&(o=n.onStart)&&o.call(n,n),n.time=a,n._render(s),(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&&c<=e?(l._render(s),l.time=a,i.add(l)):h&&(c<0||c>e)&&l.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/Hilo","hilo/core/Class"]}),KISSY.add("hilo/game/ParticleSystem",function(t,e,i,r,n,a){var o=function(){function t(t,e){return e?t+2*(Math.random()-.5)*e:t}for(var o=["x","y","vx","vy","ax","ay","rotation","rotationV","scale","scaleV","alpha","alphaV","life"],s=[],h=0,l=o.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()}}),p=i.create({Extends:r,constructor:function(t){this.id=this.id||t.id||e.getUid("Particle"),p.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(),d.push(this)},init:function(e){this.system=e.system,this._died=!1,this._time=0,this.alpha=1;for(var i=0,r=s.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(d.length>0){var e=d.pop();return e.init(t),e}return new p(t)}}});return f}();return o},{requires:["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/Container","hilo/view/Drawable"]}); \ No newline at end of file +KISSY.add("hilo/core/Hilo",function(t){var e=function(){var t=window,i=document,r=i.documentElement,n=0;return{version:"1.0.4",getUid:function(t){var e=++n;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){for(var r in e)i&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t},browser:function(){var e=navigator.userAgent,n={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 t,supportCanvas:null!=i.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in t,supportDeviceMotion:"ondevicemotion"in t};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=i.createElement("div"),c=l.style,u=void 0!=c[s+"Transform"],d=void 0!=c[s+"Perspective"];return d&&(l.id="test3d",c=i.createElement("style"),c.textContent="@media ("+h+"transform-3d){#test3d{height:3px}}",i.head.appendChild(c),r.appendChild(l),d=3==l.offsetHeight,i.head.removeChild(c),r.removeChild(l)),n.supportTransform=u,n.supportTransform3D=d,n}(),event:function(){var e="ontouchstart"in t;return{POINTER_START:e?"touchstart":"mousedown",POINTER_MOVE:e?"touchmove":"mousemove",POINTER_END:e?"touchend":"mouseup"}}(),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 i;try{i=e.getBoundingClientRect()}catch(n){i={top:e.offsetTop,left:e.offsetLeft,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}}var a=(t.pageXOffset||r.scrollLeft)-(r.clientLeft||0)||0,o=(t.pageYOffset||r.scrollTop)-(r.clientTop||0)||0,s=t.getComputedStyle?getComputedStyle(e):e.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=i.top||0,v=i.left||0,p=i.right||0,m=i.bottom||0;return{left:v+a+l,top:f+o+c,width:p-u-v-l,height:m-d-f-c}},createElement:function(t,e){var r,n,a,o=i.createElement(t);for(r in e)if(n=e[r],"style"===r)for(a in n)o.style[a]=n[a];else o[r]=n;return o},getElement:function(t){return i.getElementById(t)},setElementStyleByView:function(t){var i=t.drawable,r=i.domElement.style,n=t._stateCache||(t._stateCache={}),a=e.browser.jsVendor,o="px",s=!1;if(this.cacheStateIfChanged(t,["visible"],n)&&(r.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],n)&&(r.opacity=t.alpha),t.visible&&!(t.alpha<=0)){this.cacheStateIfChanged(t,["width"],n)&&(r.width=t.width+o),this.cacheStateIfChanged(t,["height"],n)&&(r.height=t.height+o),this.cacheStateIfChanged(t,["depth"],n)&&(r.zIndex=t.depth+1),(s=this.cacheStateIfChanged(t,["pivotX","pivotY"],n))&&(r[a+"TransformOrigin"]=t.pivotX+o+" "+t.pivotY+o),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],n)||s)&&(r[a+"Transform"]=this.getTransformCSS(t)),this.cacheStateIfChanged(t,["background"],n)&&(r.backgroundColor=t.background),r.pointerEvents||(r.pointerEvents="none");var h=i.image;if(h){var l=h.src;l!==n.image&&(n.image=l,r.backgroundImage="url("+l+")");var c=i.rect;if(c){var u=c[0],d=c[1];u!==n.sx&&(n.sx=u,r.backgroundPositionX=-u+o),d!==n.sy&&(n.sy=d,r.backgroundPositionY=-d+o)}}var f=t.mask;if(f){var v=f.drawable.domElement.style.backgroundImage;v!==n.maskImage&&(n.maskImage=v,r[a+"MaskImage"]=v,r[a+"MaskRepeat"]="no-repeat");var p=f.x,m=f.y;p===n.maskX&&m===n.maskY||(n.maskX=p,n.maskY=m,r[a+"MaskPosition"]=p+o+" "+m+o)}}},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=i.create({constructor:function(t){this.init(t)},image:null,rect:null,init:function(t){var i=this,n=i.image;r.isDrawable(t)?i.image=t:e.copy(i,t,!0);var a=i.image;if("string"==typeof a){if(!n||a!==n.getAttribute("src")){i.image=null;var o=new Image;return o.onload=function(){o.onload=null,i.init(o)},void(o.src=a)}a=i.image=n}a&&!i.rect&&(i.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/Hilo","hilo/core/Class"]}),KISSY.add("hilo/renderer/Renderer",function(t,e,i){var r=i.create({constructor:function(t){t=t||{},e.copy(this,t,!0)},renderType:null,canvas:null,stage:null,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/Hilo","hilo/core/Class"]}),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),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,v=t.rotation%360,p=t.mask;p&&(p._render(this),r.clip());var m=t.align;if(m)if("function"==typeof m)t.align();else{var _=t.parent;if(_){var g=t.width,x=t.height,y=_.width,w=_.height;switch(m){case"TL":c=0,u=0;break;case"T":c=y-g>>1,u=0;break;case"TR":c=y-g,u=0;break;case"L":c=0,u=w-x>>1;break;case"C":c=y-g>>1,u=w-x>>1;break;case"R":c=y-g,u=w-x>>1;break;case"BL":c=0,u=w-x;break;case"B":c=y-g>>1,u=w-x;break;case"BR":c=y-g,u=w-x}}}0==c&&0==u||r.translate(c,u),0!=v&&r.rotate(v*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){var n=Math.PI/180,a=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}},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,v=0;v<4;v++){var p=c[l+5*v],m=c[l+5*v+1];c[l+5*v]=f.a*p+f.c*m+f.tx,c[l+5*v+1]=f.b*p+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 Hilo.setElementStyleByView(t);var i=t.scaleX,n=t.scaleY;if(t===this.stage){var a=this.canvas.style,o=t._scaleX,s=t._scaleY,h=!1;(!o&&1!=i||o&&o!=i)&&(t._scaleX=i,a.width=i*t.width+"px",h=!0),(!s&&1!=n||s&&s!=n)&&(t._scaleY=n,a.height=n*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 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;if(o){var u=o*n;r=Math.cos(u),a=Math.sin(u)}i.a=r*l,i.b=a*l,i.c=-a*c,i.d=r*c,i.tx=t.x-i.a*s-i.c*h,i.ty=t.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},{requires:["hilo/core/Class","hilo/renderer/Renderer","hilo/geom/Matrix"]}),KISSY.add("hilo/view/View",function(t,e,i,r,n){var a=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 v=i[(c+l-1)%c];(v.ye||v.y>e&&d.ys?s=c:cl?l=c:c=0)return!1;u>i.overlap&&(i.overlap=u,i.normal.x=v.x,i.normal.y=v.y)}return i}return i.create({Mixes:r,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("View"),e.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,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=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=a(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 i=e.copy({},t);i.type="mouseover",this.fire(i)}}else"mouseout"==t.type&&(this.__mouseOver=!1);var r=this.parent;t._stopped||t._stopPropagationed||!r||("mouseout"==t.type||"touchout"==t.type?r.hitTestPoint(t.stageX,t.stageY,!0)||r._fireMouseEvent(t):r._fireMouseEvent(t))},onUpdate:null,render:function(t,e){t.draw(this)},toString:function(){return e.viewToString(this)}})}();return a},{requires:["hilo/core/Hilo","hilo/core/Class","hilo/event/EventMixin","hilo/geom/Matrix"]}),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(){e.browser.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 i,this.drawable.init({image:r.toDataURL()}),this._cacheDirty=!1)},setCacheDirty:function(t){this._cacheDirty=t}};return a},{requires:["hilo/core/Hilo","hilo/view/Drawable"]}),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="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,r=t.canvas,n=this.drawable.domElement,a=this.depth,o=r.nextSibling;if(n.parentNode)return;for(;o&&3!=o.nodeType&&(i=parseInt(o.style.zIndex)||0,!(i<=0||i>a));)o=o.nextSibling;r.parentNode.insertBefore(this.drawable.domElement,o)}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},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<_&&(l=_),c+=u,m=p):(_=f,m+=p),v==s-1&&(d.push({text:m,y:c}),m!==p&&l>1;break;case"bottom":g=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))),0==n.time&&(o=n.onStart)&&o.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/Hilo","hilo/core/Class"]}),KISSY.add("hilo/game/ParticleSystem",function(t,e,i,r,n,a){var o=function(){function t(t,e){return e?t+2*(Math.random()-.5)*e:t}for(var o=["x","y","vx","vy","ax","ay","rotation","rotationV","scale","scaleV","alpha","alphaV","life"],s=[],h=0,l=o.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: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(),d.push(this)},init:function(e){this.system=e.system,this._died=!1,this._time=0,this.alpha=1;for(var i=0,r=s.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(d.length>0){var e=d.pop();return e.init(t),e}return new v(t)}}});return f}();return o},{requires:["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/Container","hilo/view/Drawable"]}); \ No newline at end of file diff --git a/build/kissy/hilo-kissy.zip b/build/kissy/hilo-kissy.zip index efc15add..1ce0bdf5 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 f737bb36..9144c84d 100644 --- a/build/kissy/hilo/core/Class.js +++ b/build/kissy/hilo/core/Class.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 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 e7e2aa2d..1278bc22 100644 --- a/build/kissy/hilo/core/Class.min.js +++ b/build/kissy/hilo/core/Class.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 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 2d0c5eef..4dcd97bd 100644 --- a/build/kissy/hilo/core/Hilo.js +++ b/build/kissy/hilo/core/Hilo.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -24,7 +24,7 @@ return { * Hilo version * @type String */ - version:'1.0.2', + version:'1.0.4', /** * @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 983d2faf..07b9331d 100644 --- a/build/kissy/hilo/core/Hilo.min.js +++ b/build/kissy/hilo/core/Hilo.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ -KISSY.add("hilo/core/Hilo",function(t){var e=function(){var t=window,o=document,r=o.documentElement,a=0;return{version:"1.0.2",getUid:function(t){var e=++a;if(t){var o=t.charCodeAt(t.length-1);return o>=48&&o<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,o=t;o;)e=e?o.id+"."+e:o.id,o=o.parent;return e},copy:function(t,e,o){for(var r in e)o&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t},browser:function(){var e=navigator.userAgent,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 t,supportCanvas:null!=o.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in t,supportDeviceMotion:"ondevicemotion"in t};try{var i="hilo";localStorage.setItem(i,i),localStorage.removeItem(i),a.supportStorage=!0}catch(n){}var s=a.jsVendor=a.webkit?"webkit":a.firefox?"webkit":a.opera?"o":a.ie?"ms":"",d=a.cssVendor="-"+s+"-",h=o.createElement("div"),c=h.style,p=void 0!=c[s+"Transform"],f=void 0!=c[s+"Perspective"];return f&&(h.id="test3d",c=o.createElement("style"),c.textContent="@media ("+d+"transform-3d){#test3d{height:3px}}",o.head.appendChild(c),r.appendChild(h),f=3==h.offsetHeight,o.head.removeChild(c),r.removeChild(h)),a.supportTransform=p,a.supportTransform3D=f,a}(),event:function(){var e="ontouchstart"in t;return{POINTER_START:e?"touchstart":"mousedown",POINTER_MOVE:e?"touchmove":"mousemove",POINTER_END:e?"touchend":"mouseup"}}(),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 o;try{o=e.getBoundingClientRect()}catch(a){o={top:e.offsetTop,left:e.offsetLeft,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}}var i=(t.pageXOffset||r.scrollLeft)-(r.clientLeft||0)||0,n=(t.pageYOffset||r.scrollTop)-(r.clientTop||0)||0,s=t.getComputedStyle?getComputedStyle(e):e.currentStyle,d=parseInt,h=d(s.paddingLeft)+d(s.borderLeftWidth)||0,c=d(s.paddingTop)+d(s.borderTopWidth)||0,p=d(s.paddingRight)+d(s.borderRightWidth)||0,f=d(s.paddingBottom)+d(s.borderBottomWidth)||0,l=o.top||0,g=o.left||0,m=o.right||0,u=o.bottom||0;return{left:g+i+h,top:l+n+c,width:m-p-g-h,height:u-f-l-c}},createElement:function(t,e){var r,a,i,n=o.createElement(t);for(r in e)if(a=e[r],"style"===r)for(i in a)n.style[i]=a[i];else n[r]=a;return n},getElement:function(t){return o.getElementById(t)},setElementStyleByView:function(t){var o=t.drawable,r=o.domElement.style,a=t._stateCache||(t._stateCache={}),i=e.browser.jsVendor,n="px",s=!1;if(this.cacheStateIfChanged(t,["visible"],a)&&(r.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],a)&&(r.opacity=t.alpha),t.visible&&!(t.alpha<=0)){this.cacheStateIfChanged(t,["width"],a)&&(r.width=t.width+n),this.cacheStateIfChanged(t,["height"],a)&&(r.height=t.height+n),this.cacheStateIfChanged(t,["depth"],a)&&(r.zIndex=t.depth+1),(s=this.cacheStateIfChanged(t,["pivotX","pivotY"],a))&&(r[i+"TransformOrigin"]=t.pivotX+n+" "+t.pivotY+n),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],a)||s)&&(r[i+"Transform"]=this.getTransformCSS(t)),this.cacheStateIfChanged(t,["background"],a)&&(r.backgroundColor=t.background),r.pointerEvents||(r.pointerEvents="none");var d=o.image;if(d){var h=d.src;h!==a.image&&(a.image=h,r.backgroundImage="url("+h+")");var c=o.rect;if(c){var p=c[0],f=c[1];p!==a.sx&&(a.sx=p,r.backgroundPositionX=-p+n),f!==a.sy&&(a.sy=f,r.backgroundPositionY=-f+n)}}var l=t.mask;if(l){var g=l.drawable.domElement.style.backgroundImage;g!==a.maskImage&&(a.maskImage=g,r[i+"MaskImage"]=g,r[i+"MaskRepeat"]="no-repeat");var m=l.x,u=l.y;m===a.maskX&&u===a.maskY||(a.maskX=m,a.maskY=u,r[i+"MaskPosition"]=m+n+" "+u+n)}}},cacheStateIfChanged:function(t,e,o){var r,a,i,n,s=!1;for(r=0,a=e.length;r=48&&o<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,o=t;o;)e=e?o.id+"."+e:o.id,o=o.parent;return e},copy:function(t,e,o){for(var r in e)o&&!t.hasOwnProperty(r)&&void 0===t[r]||(t[r]=e[r]);return t},browser:function(){var e=navigator.userAgent,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 t,supportCanvas:null!=o.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in t,supportDeviceMotion:"ondevicemotion"in t};try{var i="hilo";localStorage.setItem(i,i),localStorage.removeItem(i),a.supportStorage=!0}catch(n){}var s=a.jsVendor=a.webkit?"webkit":a.firefox?"webkit":a.opera?"o":a.ie?"ms":"",d=a.cssVendor="-"+s+"-",h=o.createElement("div"),c=h.style,p=void 0!=c[s+"Transform"],f=void 0!=c[s+"Perspective"];return f&&(h.id="test3d",c=o.createElement("style"),c.textContent="@media ("+d+"transform-3d){#test3d{height:3px}}",o.head.appendChild(c),r.appendChild(h),f=3==h.offsetHeight,o.head.removeChild(c),r.removeChild(h)),a.supportTransform=p,a.supportTransform3D=f,a}(),event:function(){var e="ontouchstart"in t;return{POINTER_START:e?"touchstart":"mousedown",POINTER_MOVE:e?"touchmove":"mousemove",POINTER_END:e?"touchend":"mouseup"}}(),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 o;try{o=e.getBoundingClientRect()}catch(a){o={top:e.offsetTop,left:e.offsetLeft,right:e.offsetLeft+e.offsetWidth,bottom:e.offsetTop+e.offsetHeight}}var i=(t.pageXOffset||r.scrollLeft)-(r.clientLeft||0)||0,n=(t.pageYOffset||r.scrollTop)-(r.clientTop||0)||0,s=t.getComputedStyle?getComputedStyle(e):e.currentStyle,d=parseInt,h=d(s.paddingLeft)+d(s.borderLeftWidth)||0,c=d(s.paddingTop)+d(s.borderTopWidth)||0,p=d(s.paddingRight)+d(s.borderRightWidth)||0,f=d(s.paddingBottom)+d(s.borderBottomWidth)||0,l=o.top||0,g=o.left||0,m=o.right||0,u=o.bottom||0;return{left:g+i+h,top:l+n+c,width:m-p-g-h,height:u-f-l-c}},createElement:function(t,e){var r,a,i,n=o.createElement(t);for(r in e)if(a=e[r],"style"===r)for(i in a)n.style[i]=a[i];else n[r]=a;return n},getElement:function(t){return o.getElementById(t)},setElementStyleByView:function(t){var o=t.drawable,r=o.domElement.style,a=t._stateCache||(t._stateCache={}),i=e.browser.jsVendor,n="px",s=!1;if(this.cacheStateIfChanged(t,["visible"],a)&&(r.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],a)&&(r.opacity=t.alpha),t.visible&&!(t.alpha<=0)){this.cacheStateIfChanged(t,["width"],a)&&(r.width=t.width+n),this.cacheStateIfChanged(t,["height"],a)&&(r.height=t.height+n),this.cacheStateIfChanged(t,["depth"],a)&&(r.zIndex=t.depth+1),(s=this.cacheStateIfChanged(t,["pivotX","pivotY"],a))&&(r[i+"TransformOrigin"]=t.pivotX+n+" "+t.pivotY+n),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],a)||s)&&(r[i+"Transform"]=this.getTransformCSS(t)),this.cacheStateIfChanged(t,["background"],a)&&(r.backgroundColor=t.background),r.pointerEvents||(r.pointerEvents="none");var d=o.image;if(d){var h=d.src;h!==a.image&&(a.image=h,r.backgroundImage="url("+h+")");var c=o.rect;if(c){var p=c[0],f=c[1];p!==a.sx&&(a.sx=p,r.backgroundPositionX=-p+n),f!==a.sy&&(a.sy=f,r.backgroundPositionY=-f+n)}}var l=t.mask;if(l){var g=l.drawable.domElement.style.backgroundImage;g!==a.maskImage&&(a.maskImage=g,r[i+"MaskImage"]=g,r[i+"MaskRepeat"]="no-repeat");var m=l.x,u=l.y;m===a.maskX&&u===a.maskY||(a.maskX=m,a.maskY=u,r[i+"MaskPosition"]=m+n+" "+u+n)}}},cacheStateIfChanged:function(t,e,o){var r,a,i,n,s=!1;for(r=0,a=e.length;r= 1 ? 1 : me.ease ? me.ease(ratio) : ratio; + ratio = ratio <= 0 ? 0 : ratio >= 1 ? 1 : ratio; + var easeRatio = me.ease ? me.ease(ratio) : ratio; if(me.reverse){ //backward - if(me._reverseFlag < 0) ratio = 1 - ratio; + if(me._reverseFlag < 0) { + ratio = 1 - ratio; + easeRatio = 1 - easeRatio; + } //forward if(ratio < 1e-7){ //repeat complete or not loop @@ -261,7 +265,7 @@ return Class.create(/** @lends Tween.prototype */{ me.time = elapsed; //render & update callback - me._render(ratio); + me._render(easeRatio); (callback = me.onUpdate) && callback.call(me, ratio, me); //check if complete @@ -388,6 +392,7 @@ return Class.create(/** @lends Tween.prototype */{ * @returns {Tween|Array} An tween instance or an array of tween instance. */ fromTo: function(target, fromProps, toProps, params){ + params = params || {}; var isArray = target instanceof Array; target = isArray ? target : [target]; diff --git a/build/kissy/hilo/tween/Tween.min.js b/build/kissy/hilo/tween/Tween.min.js index 66097fb0..25f9eac4 100644 --- a/build/kissy/hilo/tween/Tween.min.js +++ b/build/kissy/hilo/tween/Tween.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ -KISSY.add("hilo/tween/Tween",function(e,t){var r=function(){function e(){return+new Date}return t.create({constructor:function(e,t,r,a){var n=this;n.target=e,n._startTime=0,n._seekTime=0,n._pausedTime=0,n._pausedStartTime=0,n._reverseFlag=1,n._repeatCount=0,3==arguments.length&&(a=r,r=t,t=null);for(var i in a)n[i]=a[i];n.setProps(t,r),!a.duration&&a.time&&(n.duration=a.time||0,n.time=0)},target:null,duration:0,delay:0,paused:!1,loop:!1,reverse:!1,repeat:0,repeatDelay:0,ease:null,time:0,onStart:null,onUpdate:null,onComplete:null,setProps:function(e,t){var r=this,a=r.target,n=e||t,i=r._fromProps={},s=r._toProps={};e=e||a,t=t||a;for(var u in n)s[u]=t[u]||0,a[u]=i[u]=e[u]||0;return r},start:function(){var t=this;return t._startTime=e()+t.delay,t._seekTime=0,t._pausedTime=0,t.paused=!1,r.add(t),t},stop:function(){return r.remove(this),this},pause:function(){var t=this;return t.paused=!0,t._pausedStartTime=e(),t},resume:function(){var t=this;return t.paused=!1,t._pausedStartTime&&(t._pausedTime+=e()-t._pausedStartTime),t._pausedStartTime=0,t},seek:function(t,a){var n=this,i=e();return n._startTime=i,n._seekTime=t,n._pausedTime=0,void 0!==a&&(n.paused=a),n._update(i,!0),r.add(n),n},link:function(e){var t,a,n=this,i=e.delay,s=n._startTime;return"string"==typeof i&&(t=0==i.indexOf("+"),a=0==i.indexOf("-"),i=t||a?Number(i.substr(1))*(t?1:-1):Number(i)),e.delay=i,e._startTime=t||a?s+n.duration+i:s+i,n._next=e,r.remove(e),n},_render:function(e){var t,r=this,a=r.target,n=r._fromProps;for(t in n)a[t]=n[t]+(r._toProps[t]-n[t])*e},_update:function(t,a){var n=this;if(!n.paused||a){var i=t-n._startTime-n._pausedTime+n._seekTime;if(!(i<0)){var s,u=i/n.duration,o=!1;u=u<=0?0:u>=1?1:n.ease?n.ease(u):u,n.reverse&&(n._reverseFlag<0&&(u=1-u),u<1e-7&&(n.repeat>0&&n._repeatCount++>=n.repeat||0==n.repeat&&!n.loop?o=!0:(n._startTime=e(),n._pausedTime=0,n._reverseFlag*=-1))),0==n.time&&(s=n.onStart)&&s.call(n,n),n.time=i,n._render(u),(s=n.onUpdate)&&s.call(n,u,n),u>=1&&(n.reverse?(n._startTime=e(),n._pausedTime=0,n._reverseFlag*=-1):n.loop||n.repeat>0&&n._repeatCount++0&&d<=t?(l._render(u),l.time=i,r.add(l)):o&&(d<0||d>t)&&l.start()}return o?((s=n.onComplete)&&s.call(n,n),!0):void 0}}},Statics:{_tweens:[],tick:function(){var t,a,n=r._tweens,i=n.length;for(a=0;a-1&&n.splice(t,1);else for(t=0;t=1?1:u;var l=n.ease?n.ease(u):u;n.reverse&&(n._reverseFlag<0&&(u=1-u,l=1-l),u<1e-7&&(n.repeat>0&&n._repeatCount++>=n.repeat||0==n.repeat&&!n.loop?o=!0:(n._startTime=e(),n._pausedTime=0,n._reverseFlag*=-1))),0==n.time&&(s=n.onStart)&&s.call(n,n),n.time=i,n._render(l),(s=n.onUpdate)&&s.call(n,u,n),u>=1&&(n.reverse?(n._startTime=e(),n._pausedTime=0,n._reverseFlag*=-1):n.loop||n.repeat>0&&n._repeatCount++0&&p<=t?(d._render(u),d.time=i,r.add(d)):o&&(p<0||p>t)&&d.start()}return o?((s=n.onComplete)&&s.call(n,n),!0):void 0}}},Statics:{_tweens:[],tick:function(){var t,a,n=r._tweens,i=n.length;for(a=0;a-1&&n.splice(t,1);else for(t=0;t=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=e.slice(0),r=0,s=n.length;r=0&&i.splice(e,1)},nextTick:function(t){var i=this,e={tick:function(n){i.removeTick(e),t()}};return i.addTick(e),e},timeout:function(t,i){var e=this,n=(new Date).getTime()+i,r={tick:function(){var i=(new Date).getTime(),s=i-n;s>=0&&(e.removeTick(r),t())}};return e.addTick(r),r},interval:function(t,i){var e=this,n=(new Date).getTime()+i,r={tick:function(){var e=(new Date).getTime(),r=e-n;r>=0&&(r=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=e.slice(0),s=0,r=n.length;s=0&&i.splice(e,1)},nextTick:function(t){var i=this,e={tick:function(n){i.removeTick(e),t()}};return i.addTick(e),e},timeout:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var i=(new Date).getTime(),r=i-n;r>=0&&(e.removeTick(s),t())}};return e.addTick(s),s},interval:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var e=(new Date).getTime(),s=e-n;s>=0&&(svar path = 'M250 150 L150 350 L350 350 Z';

*

var shape = new Hilo.Graphics({width:500, height:500});

@@ -342,30 +342,137 @@ return Class.create(/** @lends Graphics.prototype */{ */ drawSVGPath: function(pathData){ var me = this, addAction = me._addAction, - path = pathData.split(/,| (?=[a-zA-Z])/); - + path = pathData.replace(/,/g, ' ').replace(/-/g, ' -').split(/(?=[a-zA-Z])/); addAction.call(me, ['beginPath']); + var currentPoint = {x:0, y:0}; + var lastControlPoint = {x:0, y:0}; + var lastCmd; for(var i = 0, len = path.length; i < len; i++){ - var str = path[i], cmd = str[0].toUpperCase(), p = str.substring(1).split(/,| /); - if(p[0].length == 0) p.shift(); + var str = path[i]; + if(!str.length){ + continue; + } + var realCmd = str[0]; + var cmd = realCmd.toUpperCase(); + var p = this._getSVGParams(str); + var useRelative = cmd !== realCmd; switch(cmd){ case 'M': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['moveTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; case 'L': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['lineTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; - case 'C': - addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + case 'H': + if(useRelative){ + p[0] += currentPoint.x; + } + addAction.call(me, ['lineTo', p[0], currentPoint.y]); + currentPoint.x = p[0]; + break; + case 'V': + if(useRelative){ + p[0] += currentPoint.y; + } + addAction.call(me, ['lineTo', currentPoint.x, p[0]]); + currentPoint.y = p[0]; break; case 'Z': addAction.call(me, ['closePath']); break; + case 'C': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + lastControlPoint.x = p[2]; + lastControlPoint.y = p[3]; + this._setCurrentPoint(currentPoint, p[4], p[5]); + break; + case 'S': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + if(lastCmd === 'C' || lastCmd === 'S'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['bezierCurveTo', controlPoint.x, controlPoint.y, p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'Q': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['quadraticCurveTo', p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'T': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + var controlPoint; + if(lastCmd === 'Q' || lastCmd === 'T'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['quadraticCurveTo', controlPoint.x, controlPoint.y, p[0], p[1]]); + lastControlPoint = controlPoint; + this._setCurrentPoint(currentPoint, p[0], p[1]); + break; } + lastCmd = cmd; + } return me; }, + _getSVGParams:function(str){ + var p = str.substring(1).replace(/[\s]+$|^[\s]+/g, '').split(/[\s]+/); + if(p[0].length == 0) { + p.shift(); + } + for(var i = 0, l = p.length;i < l;i ++){ + p[i] = parseFloat(p[i]); + } + return p; + }, + _convertToAbsolute:function(currentPoint, data){ + for(var i = 0, l = data.length;i < l;i ++){ + if(i%2 === 0){ + data[i] += currentPoint.x; + } + else{ + data[i] += currentPoint.y; + } + } + }, + _setCurrentPoint:function(currentPoint, x, y){ + currentPoint.x = x; + currentPoint.y = y; + }, + _getReflectionPoint:function(centerPoint, point){ + return { + x:centerPoint.x * 2 - point.x, + y:centerPoint.y * 2 - point.y + }; + }, /** * @language=en diff --git a/build/kissy/hilo/view/Graphics.min.js b/build/kissy/hilo/view/Graphics.min.js index 023d5ce4..db551615 100644 --- a/build/kissy/hilo/view/Graphics.min.js +++ b/build/kissy/hilo/view/Graphics.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ -KISSY.add("hilo/view/Graphics",function(i,l,t,e,a){var n=function(){var i=document.createElement("canvas"),r=i.getContext&&i.getContext("2d");return t.create({Extends:e,Mixes:a,constructor:function(i){i=i||{},this.id=this.id||i.id||l.getUid("Graphics"),n.superclass.constructor.call(this,i),this._actions=[]},lineWidth:1,lineAlpha:1,lineCap:null,lineJoin:null,miterLimit:10,hasStroke:!1,strokeStyle:"0",hasFill:!1,fillStyle:"0",fillAlpha:0,lineStyle:function(i,l,t,e,a,n){var r=this,o=r._addAction;return o.call(r,["lineWidth",r.lineWidth=i||1]),o.call(r,["strokeStyle",r.strokeStyle=l||"0"]),o.call(r,["lineAlpha",r.lineAlpha=t||1]),void 0!=e&&o.call(r,["lineCap",r.lineCap=e]),void 0!=a&&o.call(r,["lineJoin",r.lineJoin=a]),void 0!=n&&o.call(r,["miterLimit",r.miterLimit=n]),r.hasStroke=!0,r},beginFill:function(i,l){var t=this,e=t._addAction;return e.call(t,["fillStyle",t.fillStyle=i]),e.call(t,["fillAlpha",t.fillAlpha=l||1]),t.hasFill=!0,t},endFill:function(){var i=this,l=i._addAction;return i.hasStroke&&l.call(i,["stroke"]),i.hasFill&&l.call(i,["fill"]),i.setCacheDirty(!0),i},beginLinearGradientFill:function(i,l,t,e,a,n){for(var o=this,c=r.createLinearGradient(i,l,t,e),h=0,d=a.length;h1?n.slice(1):null;"function"==typeof i[r]?i[r].apply(i,o):i[r]=n[1]}},render:function(i,l){var t=this;"canvas"===i.renderType?t._draw(i.context):(t.cache(),i.draw(t))},clear:function(){var i=this;return i._actions.length=0,i.lineWidth=1,i.lineAlpha=1,i.lineCap=null,i.lineJoin=null,i.miterLimit=10,i.hasStroke=!1,i.strokeStyle="0",i.hasFill=!1,i.fillStyle="0",i.fillAlpha=1,i.setCacheDirty(!0),i},_addAction:function(i){var l=this;return l._actions.push(i),l}})}();return n},{requires:["hilo/core/Hilo","hilo/core/Class","hilo/view/View","hilo/view/CacheMixin"]}); \ No newline at end of file +KISSY.add("hilo/view/Graphics",function(t,e,i,l,n){var a=function(){var t=document.createElement("canvas"),r=t.getContext&&t.getContext("2d");return i.create({Extends:l,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,l,n,a){var r=this,o=r._addAction;return o.call(r,["lineWidth",r.lineWidth=t||1]),o.call(r,["strokeStyle",r.strokeStyle=e||"0"]),o.call(r,["lineAlpha",r.lineAlpha=i||1]),void 0!=l&&o.call(r,["lineCap",r.lineCap=l]),void 0!=n&&o.call(r,["lineJoin",r.lineJoin=n]),void 0!=a&&o.call(r,["miterLimit",r.miterLimit=a]),r.hasStroke=!0,r},beginFill:function(t,e){var i=this,l=i._addAction;return l.call(i,["fillStyle",i.fillStyle=t]),l.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,l,n,a){for(var o=this,c=r.createLinearGradient(t,e,i,l),s=0,h=n.length;s1?a.slice(1):null;"function"==typeof t[r]?t[r].apply(t,o):t[r]=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"]}); \ No newline at end of file diff --git a/build/kissy/hilo/view/Sprite.js b/build/kissy/hilo/view/Sprite.js index 129a16b9..d3470882 100644 --- a/build/kissy/hilo/view/Sprite.js +++ b/build/kissy/hilo/view/Sprite.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 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 951face5..0c219b59 100644 --- a/build/kissy/hilo/view/Sprite.min.js +++ b/build/kissy/hilo/view/Sprite.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 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 39cad0ef..8eb50210 100644 --- a/build/kissy/hilo/view/Stage.js +++ b/build/kissy/hilo/view/Stage.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 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 c70a6698..0b9efc59 100644 --- a/build/kissy/hilo/view/Stage.min.js +++ b/build/kissy/hilo/view/Stage.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 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 b2aebe7e..ce1ba7f5 100644 --- a/build/kissy/hilo/view/Text.js +++ b/build/kissy/hilo/view/Text.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/Text.min.js b/build/kissy/hilo/view/Text.min.js index c8acfdc8..d5cce0e5 100644 --- a/build/kissy/hilo/view/Text.min.js +++ b/build/kissy/hilo/view/Text.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/kissy/hilo/view/View.js b/build/kissy/hilo/view/View.js index 980f18ba..574d2042 100644 --- a/build/kissy/hilo/view/View.js +++ b/build/kissy/hilo/view/View.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 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 f0fb748a..7ad3f302 100644 --- a/build/kissy/hilo/view/View.min.js +++ b/build/kissy/hilo/view/View.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for kissy + * Hilo 1.0.4 for kissy * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo-standalone.js b/build/standalone/hilo-standalone.js index 2f195363..27f63643 100644 --- a/build/standalone/hilo-standalone.js +++ b/build/standalone/hilo-standalone.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -23,7 +23,7 @@ return { * Hilo version * @type String */ - version:'1.0.2', + version:'1.0.4', /** * @language=en * Gets a globally unique id. Such as Stage1, Bitmap2 etc. @@ -373,7 +373,7 @@ return { window.Hilo = Hilo; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -554,7 +554,7 @@ return {create:create, mix:mix}; Hilo.Class = Class; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -733,7 +733,7 @@ var Matrix = Class.create(/** @lends Matrix.prototype */{ Hilo.Matrix = Matrix; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -885,7 +885,7 @@ if(RawEvent){ Hilo.EventMixin = EventMixin; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -962,7 +962,7 @@ var Drawable = Class.create(/** @lends Drawable.prototype */{ Hilo.Drawable = Drawable; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1054,7 +1054,7 @@ var Renderer = Class.create(/** @lends Renderer.prototype */{ Hilo.Renderer = Renderer; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1293,7 +1293,7 @@ var CanvasRenderer = Class.create(/** @lends CanvasRenderer.prototype */{ Hilo.CanvasRenderer = CanvasRenderer; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -1476,7 +1476,7 @@ function createDOMDrawable(view, imageObj){ Hilo.DOMRenderer = DOMRenderer; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2045,7 +2045,7 @@ Shader.prototype = { Hilo.WebGLRenderer = WebGLRenderer; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2471,7 +2471,7 @@ function doSATCheck(poly1, poly2, result){ Hilo.View = View; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2498,7 +2498,7 @@ var CacheMixin = /** @lends CacheMixin# */ { * @param {Boolean} forceUpdate is force update cache. */ cache: function(forceUpdate){ - if(forceUpdate || this._cacheDirty || !this._cacheImage){ + if(forceUpdate || this._cacheDirty || !this.drawable){ this.updateCache(); } }, @@ -2517,10 +2517,10 @@ var CacheMixin = /** @lends CacheMixin# */ { _cacheCanvas.width = this.width; _cacheCanvas.height = this.height; this._draw(_cacheContext); - this._cacheImage = new Image(); - this._cacheImage.src = _cacheCanvas.toDataURL(); this.drawable = this.drawable||new Drawable(); - this.drawable.init(this._cacheImage); + this.drawable.init({ + image:_cacheCanvas.toDataURL() + }); this._cacheDirty = false; } }, @@ -2536,7 +2536,7 @@ var CacheMixin = /** @lends CacheMixin# */ { Hilo.CacheMixin = CacheMixin; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -2910,7 +2910,7 @@ var Container = Class.create(/** @lends Container.prototype */{ Hilo.Container = Container; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3178,7 +3178,7 @@ var Stage = Class.create(/** @lends Stage.prototype */{ Hilo.Stage = Stage; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3257,7 +3257,7 @@ var Drawable = Hilo.Drawable; Hilo.Bitmap = Bitmap; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3529,7 +3529,7 @@ var Sprite = Class.create(/** @lends Sprite.prototype */{ Hilo.Sprite = Sprite; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3631,7 +3631,7 @@ var DOMElement = Class.create(/** @lends DOMElement.prototype */{ Hilo.DOMElement = DOMElement; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -3967,7 +3967,7 @@ return Class.create(/** @lends Graphics.prototype */{ /** * @language=en - * Draw a path from the SVG data given by parameters. + * Draw a path from the SVG data given by parameters. Not support Arcs. * Demo: *

var path = 'M250 150 L150 350 L350 350 Z';

*

var shape = new Hilo.Graphics({width:500, height:500});

@@ -3977,30 +3977,137 @@ return Class.create(/** @lends Graphics.prototype */{ */ drawSVGPath: function(pathData){ var me = this, addAction = me._addAction, - path = pathData.split(/,| (?=[a-zA-Z])/); - + path = pathData.replace(/,/g, ' ').replace(/-/g, ' -').split(/(?=[a-zA-Z])/); addAction.call(me, ['beginPath']); + var currentPoint = {x:0, y:0}; + var lastControlPoint = {x:0, y:0}; + var lastCmd; for(var i = 0, len = path.length; i < len; i++){ - var str = path[i], cmd = str[0].toUpperCase(), p = str.substring(1).split(/,| /); - if(p[0].length == 0) p.shift(); + var str = path[i]; + if(!str.length){ + continue; + } + var realCmd = str[0]; + var cmd = realCmd.toUpperCase(); + var p = this._getSVGParams(str); + var useRelative = cmd !== realCmd; switch(cmd){ case 'M': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['moveTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; case 'L': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['lineTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; - case 'C': - addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + case 'H': + if(useRelative){ + p[0] += currentPoint.x; + } + addAction.call(me, ['lineTo', p[0], currentPoint.y]); + currentPoint.x = p[0]; + break; + case 'V': + if(useRelative){ + p[0] += currentPoint.y; + } + addAction.call(me, ['lineTo', currentPoint.x, p[0]]); + currentPoint.y = p[0]; break; case 'Z': addAction.call(me, ['closePath']); break; + case 'C': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + lastControlPoint.x = p[2]; + lastControlPoint.y = p[3]; + this._setCurrentPoint(currentPoint, p[4], p[5]); + break; + case 'S': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + if(lastCmd === 'C' || lastCmd === 'S'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['bezierCurveTo', controlPoint.x, controlPoint.y, p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'Q': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['quadraticCurveTo', p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'T': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + var controlPoint; + if(lastCmd === 'Q' || lastCmd === 'T'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['quadraticCurveTo', controlPoint.x, controlPoint.y, p[0], p[1]]); + lastControlPoint = controlPoint; + this._setCurrentPoint(currentPoint, p[0], p[1]); + break; } + lastCmd = cmd; + } return me; }, + _getSVGParams:function(str){ + var p = str.substring(1).replace(/[\s]+$|^[\s]+/g, '').split(/[\s]+/); + if(p[0].length == 0) { + p.shift(); + } + for(var i = 0, l = p.length;i < l;i ++){ + p[i] = parseFloat(p[i]); + } + return p; + }, + _convertToAbsolute:function(currentPoint, data){ + for(var i = 0, l = data.length;i < l;i ++){ + if(i%2 === 0){ + data[i] += currentPoint.x; + } + else{ + data[i] += currentPoint.y; + } + } + }, + _setCurrentPoint:function(currentPoint, x, y){ + currentPoint.x = x; + currentPoint.y = y; + }, + _getReflectionPoint:function(centerPoint, point){ + return { + x:centerPoint.x * 2 - point.x, + y:centerPoint.y * 2 - point.y + }; + }, /** * @language=en @@ -4078,7 +4185,7 @@ return Class.create(/** @lends Graphics.prototype */{ Hilo.Graphics = Graphics; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4332,7 +4439,7 @@ var Text = Class.create(/** @lends Text.prototype */{ Hilo.Text = Text; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4517,7 +4624,7 @@ var BitmapText = Class.create(/** @lends BitmapText.prototype */{ Hilo.BitmapText = BitmapText; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4696,7 +4803,7 @@ var Drawable = Hilo.Drawable; Hilo.Button = Button; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4932,7 +5039,7 @@ function isNumber(value){ Hilo.TextureAtlas = TextureAtlas; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -4980,13 +5087,11 @@ var Ticker = Class.create(/** @lends Ticker.prototype */{ window[Hilo.browser.jsVendor + 'RequestAnimationFrame']; var runLoop; - if(useRAF && raf){ - var tick = function(){ - self._tick(); - }; + if(useRAF && raf && interval < 17){ + this._useRAF = true; runLoop = function(){ - self._intervalId = setTimeout(runLoop, interval); - raf(tick); + self._intervalId = raf(runLoop); + self._tick(); }; }else{ runLoop = function(){ @@ -4995,6 +5100,7 @@ var Ticker = Class.create(/** @lends Ticker.prototype */{ }; } + this._paused = false; runLoop(); }, @@ -5003,9 +5109,17 @@ var Ticker = Class.create(/** @lends Ticker.prototype */{ * Stop the ticker. */ stop: function(){ - clearTimeout(this._intervalId); + if(this._useRAF){ + var cancelRAF = window.cancelAnimationFrame || + window[Hilo.browser.jsVendor + 'CancelAnimationFrame']; + cancelRAF(this._intervalId); + } + else{ + clearTimeout(this._intervalId); + } this._intervalId = null; this._lastTime = 0; + this._paused = true; }, /** @@ -5149,7 +5263,7 @@ var Ticker = Class.create(/** @lends Ticker.prototype */{ Hilo.Ticker = Ticker; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5197,7 +5311,7 @@ if (!fnProto.bind) { Hilo.undefined = undefined; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5306,7 +5420,7 @@ var drag = { Hilo.drag = drag; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -5394,7 +5508,7 @@ return Class.create(/** @lends Tween.prototype */{ }, target: null, - duration: 0, + duration: 1000, delay: 0, paused: false, loop: false, @@ -5546,11 +5660,15 @@ return Class.create(/** @lends Tween.prototype */{ //elapsed ratio var ratio = elapsed / me.duration, complete = false, callback; - ratio = ratio <= 0 ? 0 : ratio >= 1 ? 1 : me.ease ? me.ease(ratio) : ratio; + ratio = ratio <= 0 ? 0 : ratio >= 1 ? 1 : ratio; + var easeRatio = me.ease ? me.ease(ratio) : ratio; if(me.reverse){ //backward - if(me._reverseFlag < 0) ratio = 1 - ratio; + if(me._reverseFlag < 0) { + ratio = 1 - ratio; + easeRatio = 1 - easeRatio; + } //forward if(ratio < 1e-7){ //repeat complete or not loop @@ -5569,7 +5687,7 @@ return Class.create(/** @lends Tween.prototype */{ me.time = elapsed; //render & update callback - me._render(ratio); + me._render(easeRatio); (callback = me.onUpdate) && callback.call(me, ratio, me); //check if complete @@ -5696,6 +5814,7 @@ return Class.create(/** @lends Tween.prototype */{ * @returns {Tween|Array} An tween instance or an array of tween instance. */ fromTo: function(target, fromProps, toProps, params){ + params = params || {}; var isArray = target instanceof Array; target = isArray ? target : [target]; @@ -5742,7 +5861,7 @@ return Class.create(/** @lends Tween.prototype */{ Hilo.Tween = Tween; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6012,7 +6131,7 @@ return { Hilo.Ease = Ease; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6059,7 +6178,7 @@ var ImageLoader = Class.create({ Hilo.ImageLoader = ImageLoader; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6125,7 +6244,7 @@ var ScriptLoader = Class.create({ Hilo.ScriptLoader = ScriptLoader; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6376,7 +6495,7 @@ function getExtension(src){ Hilo.LoadQueue = LoadQueue; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6579,7 +6698,7 @@ var HTMLAudio = Class.create(/** @lends HTMLAudio.prototype */{ Hilo.HTMLAudio = HTMLAudio; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6896,7 +7015,7 @@ return Class.create(/** @lends WebAudio.prototype */{ Hilo.WebAudio = WebAudio; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -6994,7 +7113,7 @@ var WebSound = { Hilo.WebSound = WebSound; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7086,7 +7205,7 @@ var Camera = Class.create(/** @lends Camera.prototype */{ Hilo.Camera = Camera; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -7272,7 +7391,7 @@ var Camera3d = (function(){ Hilo.Camera3d = Camera3d; })(window); /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 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 7ba776f5..e5773c1c 100644 --- a/build/standalone/hilo-standalone.min.js +++ b/build/standalone/hilo-standalone.min.js @@ -1,8 +1,8 @@ /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ -!function(t){var e=function(){var i=t,n=document,r=n.documentElement,a=0;return{version:"1.0.2",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,e,i){for(var n in e)i&&!t.hasOwnProperty(n)&&void 0===t[n]||(t[n]=e[n]);return t},browser:function(){var t=navigator.userAgent,e={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!=n.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in i,supportDeviceMotion:"ondevicemotion"in i};try{var a="hilo";localStorage.setItem(a,a),localStorage.removeItem(a),e.supportStorage=!0}catch(s){}var o=e.jsVendor=e.webkit?"webkit":e.firefox?"webkit":e.opera?"o":e.ie?"ms":"",h=e.cssVendor="-"+o+"-",l=n.createElement("div"),c=l.style,u=void 0!=c[o+"Transform"],d=void 0!=c[o+"Perspective"];return d&&(l.id="test3d",c=n.createElement("style"),c.textContent="@media ("+h+"transform-3d){#test3d{height:3px}}",n.head.appendChild(c),r.appendChild(l),d=3==l.offsetHeight,n.head.removeChild(c),r.removeChild(l)),e.supportTransform=u,e.supportTransform3D=d,e}(),event:function(){var t="ontouchstart"in i;return{POINTER_START:t?"touchstart":"mousedown",POINTER_MOVE:t?"touchmove":"mousemove",POINTER_END:t?"touchend":"mouseup"}}(),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(n){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var a=(i.pageXOffset||r.scrollLeft)-(r.clientLeft||0)||0,s=(i.pageYOffset||r.scrollTop)-(r.clientTop||0)||0,o=i.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+a+l,top:f+s+c,width:v-u-p-l,height:m-d-f-c}},createElement:function(t,e){var i,r,a,s=n.createElement(t);for(i in e)if(r=e[i],"style"===i)for(a in r)s.style[a]=r[a];else s[i]=r;return s},getElement:function(t){return n.getElementById(t)},setElementStyleByView:function(t){var i=t.drawable,n=i.domElement.style,r=t._stateCache||(t._stateCache={}),a=e.browser.jsVendor,s="px",o=!1;if(this.cacheStateIfChanged(t,["visible"],r)&&(n.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],r)&&(n.opacity=t.alpha),t.visible&&!(t.alpha<=0)){this.cacheStateIfChanged(t,["width"],r)&&(n.width=t.width+s),this.cacheStateIfChanged(t,["height"],r)&&(n.height=t.height+s),this.cacheStateIfChanged(t,["depth"],r)&&(n.zIndex=t.depth+1),(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(n[a+"TransformOrigin"]=t.pivotX+s+" "+t.pivotY+s),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],r)||o)&&(n[a+"Transform"]=this.getTransformCSS(t)),this.cacheStateIfChanged(t,["background"],r)&&(n.backgroundColor=t.background),n.pointerEvents||(n.pointerEvents="none");var h=i.image;if(h){var l=h.src;l!==r.image&&(r.image=l,n.backgroundImage="url("+l+")");var c=i.rect;if(c){var u=c[0],d=c[1];u!==r.sx&&(r.sx=u,n.backgroundPositionX=-u+s),d!==r.sy&&(r.sy=d,n.backgroundPositionY=-d+s)}}var f=t.mask;if(f){var p=f.drawable.domElement.style.backgroundImage;p!==r.maskImage&&(r.maskImage=p,n[a+"MaskImage"]=p,n[a+"MaskRepeat"]="no-repeat");var v=f.x,m=f.y;v===r.maskX&&m===r.maskY||(r.maskX=v,r.maskY=m,n[a+"MaskPosition"]=v+s+" "+m+s)}}},cacheStateIfChanged:function(t,e,i){var n,r,a,s,o=!1;for(n=0,r=e.length;n=6?(e=o[0],i=o[1],n=o[2],r=o[3],a=o[4],s=o[5]):(e=t.a,i=t.b,n=t.c,r=t.d,a=t.tx,s=t.ty),this.a=h*e+l*n,this.b=h*i+l*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+s,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),n=this.a,r=this.b,a=this.c,s=this.d,o=this.tx,h=this.ty;return this.a=n*i-r*e,this.b=n*e+r*i,this.c=a*i-s*e,this.d=a*e+s*i,this.tx=o*i-h*e,this.ty=o*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,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)}});e.Matrix=n}(window),function(t){var e=t.Hilo,i=e.Class,n={_listeners:null,on:function(t,e,i){for(var n=this._listeners=this._listeners||{},r=n[t]=n[t]||[],a=0,s=r.length;a-1&&s.splice(c,1)}}return 0==s.length&&delete a[n],!0}return!1}},r=i.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}}),a=t.Event;if(a){var s=a.prototype,o=s.stopImmediatePropagation;s.stopImmediatePropagation=function(){o&&o.call(this),this._stopped=!0}}e.EventMixin=n}(window),function(t){var e=t.Hilo,i=e.Class,n=i.create({constructor:function(t){this.init(t)},image:null,rect:null,init:function(t){var i=this,r=i.image;n.isDrawable(t)?i.image=t:e.copy(i,t,!0);var a=i.image;if("string"==typeof a){if(!r||a!==r.getAttribute("src")){i.image=null;var s=new Image;return s.onload=function(){s.onload=null,i.init(s)},void(s.src=a)}a=i.image=r}a&&!i.rect&&(i.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}}});e.Drawable=n}(window),function(t){var e=t.Hilo,i=e.Class,n=i.create({constructor:function(t){t=t||{},e.copy(this,t,!0)},renderType:null,canvas:null,stage:null,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){}});e.Renderer=n}(window),function(t){var e=t.Hilo,i=e.Class,n=e.Renderer,r=i.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),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,s=a&&a.image;if(s){var o=a.rect,h=o[2],l=o[3],c=o[4],u=o[5];if(!h||!l)return;i||n||(i=t.width=h,n=t.height=l),(c||u)&&e.translate(c-.5*h,u-.5*l),e.drawImage(s,o[0],o[1],h,l,0,0,i,n)}},endDraw:function(t){this.context.restore()},transform:function(t){var i=t.drawable;if(i&&i.domElement)return void e.setElementStyleByView(t);var n=this.context,r=t.scaleX,a=t.scaleY;if(t===this.stage){var s=this.canvas.style,o=t._scaleX,h=t._scaleY,l=!1;(!o&&1!=r||o&&o!=r)&&(t._scaleX=r,s.width=r*t.width+"px",l=!0),(!h&&1!=a||h&&h!=a)&&(t._scaleY=a,s.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.mask;v&&(v._render(this),n.clip());var m=t.align;if(m)if("function"==typeof m)t.align();else{var g=t.parent;if(g){var _=t.width,x=t.height,y=g.width,w=g.height;switch(m){case"TL":c=0,u=0;break;case"T":c=y-_>>1,u=0;break;case"TR":c=y-_,u=0;break;case"L":c=0,u=w-x>>1;break;case"C":c=y-_>>1,u=w-x>>1;break;case"R":c=y-_,u=w-x>>1;break;case"BL":c=0,u=w-x;break;case"B":c=y-_>>1,u=w-x;break;case"BR":c=y-_,u=w-x}}}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"}});e.CanvasRenderer=r}(window),function(t){var e=t.Hilo,i=e.Class,n=e.Renderer,r=e.Drawable,a=function(){function t(t,i){var n=t.tagName||"div",r=i.image,a=t.width||r&&r.width,s=t.height||r&&r.height,o=e.createElement(n),h=o.style;if(t.id&&(o.id=t.id),h.position="absolute",h.left=(t.left||0)+"px",h.top=(t.top||0)+"px",h.width=a+"px",h.height=s+"px","canvas"==n){if(o.width=a,o.height=s,r){var l=o.getContext("2d"),c=i.rect||[0,0,a,s];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 o}return i.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(e.setElementStyleByView(t),t===this.stage){var i=this.canvas.style,n=t._scaleX,r=t._scaleY,a=t.scaleX,s=t.scaleY;(!n&&1!=a||n&&n!=a)&&(t._scaleX=a,i.width=a*t.width+"px"),(!r&&1!=s||r&&r!=s)&&(t._scaleY=s,i.height=s*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")}})}();e.DOMRenderer=a}(window),function(t){var e=t.Hilo,i=e.Class,n=e.Renderer,r=e.Matrix,a=Math.PI/180,s=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}},renderType:"webgl",gl:null,_isContextLost:!1,_cacheTexture:{},constructor:function(t){s.superclass.constructor.call(this,t);var e=this;this.gl=this.canvas.getContext("webgl")||this.canvas.getContext("experimental-webgl"),this.maxBatchNum=s.MAX_BATCH_NUM,this.positionStride=4*s.ATTRIBUTE_NUM;var i=this.maxBatchNum*s.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,s=a[2],o=a[3];e||i||(e=t.width=s,i=t.height=o),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(r,a[0],a[1],s,o,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=r,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 s=this.canvas.style,o=t._scaleX,h=t._scaleY,l=!1;(!o&&1!=n||o&&o!=n)&&(t._scaleX=n,s.width=n*t.width+"px",l=!0),(!h&&1!=a||h&&h!=a)&&(t._scaleY=a,s.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 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 o(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,s,o,h){var l=this.__tempVertexs||[],c=t.width,u=t.height;n/=c,r/=u,e/=c,i/=u,o=o,h=h,a=a,s=s,n+e>1&&(n=1-e),r+i>1&&(r=1-i);var d=0;return l[d++]=a,l[d++]=s,l[d++]=e,l[d++]=i,l[d++]=a+o,l[d++]=s,l[d++]=e+n,l[d++]=i,l[d++]=a,l[d++]=s+h,l[d++]=e,l[d++]=i+r,l[d++]=a+o,l[d++]=s+h,l[d++]=e+n,l[d++]=i+r,l},_setConcatenatedMatrix:function(t,e){var i=t.__webglWorldMatrix,n=1,r=0,s=t.rotation%360,o=t.pivotX,h=t.pivotY,l=t.scaleX,c=t.scaleY;if(s){var u=s*a;n=Math.cos(u),r=Math.sin(u)}i.a=n*l,i.b=r*l,i.c=-r*c,i.d=n*c,i.tx=t.x-i.a*o-i.c*h,i.ty=t.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}}),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||[]};o.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 s=t.getProgramParameter(a,t.LINK_STATUS);if(!s){var o=t.getProgramInfoLog(a);return console.log("Failed to link program: "+o),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}},e.WebGLRenderer=s}(window),function(t){var e=t.Hilo,i=e.Class,n=e.EventMixin,r=e.Matrix,a=function(){function t(t,e,i){for(var n,r,a,s,o=0,h=!1,l=0,c=i.length;ld.x?(n=d.x,r=u.x):(n=u.x,r=d.x),t>=n&&t<=r))h=!0;else if(u.y>d.y?(a=d.y,s=u.y):(a=u.y,s=d.y),!(es)){var f=(e-u.y)*(d.x-u.x)/(d.y-u.y)+u.x;if(f>t?o++:f==t&&(h=!0),u.x>t&&u.y==e){var p=i[(c+l-1)%c];(p.ye||p.y>e&&d.yo?o=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:n,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("View"),e.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,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,s,o=this.width,h=this.height,l=this.getConcatenatedMatrix(),c=this.boundsArea||[{x:0,y:0},{x:o,y:0},{x:o,y:h},{x:0,y:h}],u=[],d=0,f=c.length;de?n=e:ri?a=i:s=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=a(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 i=e.copy({},t);i.type="mouseover",this.fire(i)}}else"mouseout"==t.type&&(this.__mouseOver=!1);var n=this.parent;t._stopped||t._stopPropagationed||!n||("mouseout"==t.type||"touchout"==t.type?n.hitTestPoint(t.stageX,t.stageY,!0)||n._fireMouseEvent(t):n._fireMouseEvent(t))},onUpdate:null,render:function(t,e){t.draw(this)},toString:function(){return e.viewToString(this)}})}();e.View=a}(window),function(t){var e,i,n=t.Hilo,r=n.Drawable,a={_cacheDirty:!0,cache:function(t){(t||this._cacheDirty||!this._cacheImage)&&this.updateCache()},updateCache:function(){n.browser.supportCanvas&&(e||(e=document.createElement("canvas"),i=e.getContext("2d")),e.width=this.width,e.height=this.height,this._draw(i),this._cacheImage=new Image,this._cacheImage.src=e.toDataURL(),this.drawable=this.drawable||new r,this.drawable.init(this._cacheImage),this._cacheDirty=!1)},setCacheDirty:function(t){this._cacheDirty=t}};n.CacheMixin=a}(window),function(t){var e=t.Hilo,i=e.Class,n=e.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 s=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;l--)if(a=h[l],!(!a||!a.visible||a.alpha<=0||r&&!a.pointerEnabled))if(a.children&&a.children.length&&(!r||a.pointerChildren)&&(s=a.getViewAtPoint(t,e,i,n,r)),s){if(!n)return s;s.length&&(o=o.concat(s))}else if(a.hitTestPoint(t,e,i)){if(!n)return a;o.push(a)}return n&&o.length?o:null},render:function(t,e){r.superclass.render.call(this,t,e);var i,n,a,s=this.children.slice(0);for(i=0,n=s.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,s=this._frameElapsed,o=0!=n||this.drawable?s+(this.timeBased?t:1):0;return s=this._frameElapsed=o=i-1)&&this.stop(),this.paused||0!=s||(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});e.Sprite=a}(window),function(t){var e=t.Hilo,i=e.Class,n=e.View,r=e.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="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,n=t.canvas,r=this.drawable.domElement,a=this.depth,s=n.nextSibling;if(r.parentNode)return;for(;s&&3!=s.nodeType&&(i=parseInt(s.style.zIndex)||0,!(i<=0||i>a));)s=s.nextSibling;n.parentNode.insertBefore(this.drawable.domElement,s)}else t.draw(this)}});e.DOMElement=a}(window),function(t){var e=t.Hilo,i=e.Class,n=e.View,r=e.CacheMixin,a=function(){var t=document.createElement("canvas"),s=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 s=this,o=s._addAction;return o.call(s,["lineWidth",s.lineWidth=t||1]),o.call(s,["strokeStyle",s.strokeStyle=e||"0"]),o.call(s,["lineAlpha",s.lineAlpha=i||1]),void 0!=n&&o.call(s,["lineCap",s.lineCap=n]),void 0!=r&&o.call(s,["lineJoin",s.lineJoin=r]),void 0!=a&&o.call(s,["miterLimit",s.miterLimit=a]),s.hasStroke=!0,s},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 o=this,h=s.createLinearGradient(t,e,i,n),l=0,c=r.length;l1?a.slice(1):null;"function"==typeof t[s]?t[s].apply(t,o):t[s]=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}})}();e.Graphics=a}(window),function(t){var e=t.Hilo,i=e.Class,n=e.View,r=e.CacheMixin,a=i.create({Extends:n,Mixes:r,constructor:function(t){t=t||{},this.id=this.id||t.id||e.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,s,o,h=i.split(/\r\n|\r|\n|/),l=0,c=0,u=e._fontHeight+e.lineSpacing,d=[];for(n=0,s=h.length;ne.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,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 i,n=document.documentElement,r=e.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return n.appendChild(r),i=r.offsetHeight,n.removeChild(r),i}}});e.Text=a}(window),function(t){var e=t.Hilo,i=e.Class,n=e.Container,r=e.Bitmap,a=i.create({Extends:n,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("BitmapText"),a.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(),n=i.length;if(e.text!=i){e.text=i;var r,a,s,o,h=0,l=0,c=0;for(r=0;r0?e.letterSpacing:0),e.children[r]?(o=e.children[r],o.setImage(s.image,s.rect)):(o=e._createBitmap(s),e.addChild(o)),o.x=c,h=c+s.rect[2],l=Math.max(l,s.rect[3]));for(r=e.children.length-1;r>=n;r--)e._releaseBitmap(e.children[r]),e.children[r].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 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:r.ease?r.ease(o):o,r.reverse&&(r._reverseFlag<0&&(o=1-o),o<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))),0==r.time&&(s=r.onStart)&&s.call(r,r),r.time=a,r._render(o),(s=r.onUpdate)&&s.call(r,o,r),o>=1&&(r.reverse?(r._startTime=t(),r._pausedTime=0,r._reverseFlag*=-1):r.loop||r.repeat>0&&r._repeatCount++0&&c<=e?(l._render(o),l.time=a,n.add(l)):h&&(c<0||c>e)&&l.start()}return h?((s=r.onComplete)&&s.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 s}();e.Camera3d=n}(window),function(t){var e=t.Hilo,i=e.Class,n=e.View,r=e.Container,a=e.Drawable,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"],o=[],h=0,l=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()}}),p=i.create({Extends:n,constructor:function(t){this.id=this.id||t.id||e.getUid("Particle"),p.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(),d.push(this)},init:function(e){this.system=e.system,this._died=!1,this._time=0,this.alpha=1;for(var i=0,n=o.length;i>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(d.length>0){var e=d.pop();return e.init(t),e}return new p(t)}}});return f}();e.ParticleSystem=s}(window); \ No newline at end of file +!function(t){var e=function(){var i=t,n=document,r=n.documentElement,a=0;return{version:"1.0.4",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,e,i){for(var n in e)i&&!t.hasOwnProperty(n)&&void 0===t[n]||(t[n]=e[n]);return t},browser:function(){var t=navigator.userAgent,e={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!=n.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in i,supportDeviceMotion:"ondevicemotion"in i};try{var a="hilo";localStorage.setItem(a,a),localStorage.removeItem(a),e.supportStorage=!0}catch(s){}var o=e.jsVendor=e.webkit?"webkit":e.firefox?"webkit":e.opera?"o":e.ie?"ms":"",h=e.cssVendor="-"+o+"-",l=n.createElement("div"),c=l.style,u=void 0!=c[o+"Transform"],d=void 0!=c[o+"Perspective"];return d&&(l.id="test3d",c=n.createElement("style"),c.textContent="@media ("+h+"transform-3d){#test3d{height:3px}}",n.head.appendChild(c),r.appendChild(l),d=3==l.offsetHeight,n.head.removeChild(c),r.removeChild(l)),e.supportTransform=u,e.supportTransform3D=d,e}(),event:function(){var t="ontouchstart"in i;return{POINTER_START:t?"touchstart":"mousedown",POINTER_MOVE:t?"touchmove":"mousemove",POINTER_END:t?"touchend":"mouseup"}}(),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(n){e={top:t.offsetTop,left:t.offsetLeft,right:t.offsetLeft+t.offsetWidth,bottom:t.offsetTop+t.offsetHeight}}var a=(i.pageXOffset||r.scrollLeft)-(r.clientLeft||0)||0,s=(i.pageYOffset||r.scrollTop)-(r.clientTop||0)||0,o=i.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+a+l,top:f+s+c,width:v-u-p-l,height:m-d-f-c}},createElement:function(t,e){var i,r,a,s=n.createElement(t);for(i in e)if(r=e[i],"style"===i)for(a in r)s.style[a]=r[a];else s[i]=r;return s},getElement:function(t){return n.getElementById(t)},setElementStyleByView:function(t){var i=t.drawable,n=i.domElement.style,r=t._stateCache||(t._stateCache={}),a=e.browser.jsVendor,s="px",o=!1;if(this.cacheStateIfChanged(t,["visible"],r)&&(n.display=t.visible?"":"none"),this.cacheStateIfChanged(t,["alpha"],r)&&(n.opacity=t.alpha),t.visible&&!(t.alpha<=0)){this.cacheStateIfChanged(t,["width"],r)&&(n.width=t.width+s),this.cacheStateIfChanged(t,["height"],r)&&(n.height=t.height+s),this.cacheStateIfChanged(t,["depth"],r)&&(n.zIndex=t.depth+1),(o=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(n[a+"TransformOrigin"]=t.pivotX+s+" "+t.pivotY+s),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],r)||o)&&(n[a+"Transform"]=this.getTransformCSS(t)),this.cacheStateIfChanged(t,["background"],r)&&(n.backgroundColor=t.background),n.pointerEvents||(n.pointerEvents="none");var h=i.image;if(h){var l=h.src;l!==r.image&&(r.image=l,n.backgroundImage="url("+l+")");var c=i.rect;if(c){var u=c[0],d=c[1];u!==r.sx&&(r.sx=u,n.backgroundPositionX=-u+s),d!==r.sy&&(r.sy=d,n.backgroundPositionY=-d+s)}}var f=t.mask;if(f){var p=f.drawable.domElement.style.backgroundImage;p!==r.maskImage&&(r.maskImage=p,n[a+"MaskImage"]=p,n[a+"MaskRepeat"]="no-repeat");var v=f.x,m=f.y;v===r.maskX&&m===r.maskY||(r.maskX=v,r.maskY=m,n[a+"MaskPosition"]=v+s+" "+m+s)}}},cacheStateIfChanged:function(t,e,i){var n,r,a,s,o=!1;for(n=0,r=e.length;n=6?(e=o[0],i=o[1],n=o[2],r=o[3],a=o[4],s=o[5]):(e=t.a,i=t.b,n=t.c,r=t.d,a=t.tx,s=t.ty),this.a=h*e+l*n,this.b=h*i+l*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+s,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),n=this.a,r=this.b,a=this.c,s=this.d,o=this.tx,h=this.ty;return this.a=n*i-r*e,this.b=n*e+r*i,this.c=a*i-s*e,this.d=a*e+s*i,this.tx=o*i-h*e,this.ty=o*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,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)}});e.Matrix=n}(window),function(t){var e=t.Hilo,i=e.Class,n={_listeners:null,on:function(t,e,i){for(var n=this._listeners=this._listeners||{},r=n[t]=n[t]||[],a=0,s=r.length;a-1&&s.splice(c,1)}}return 0==s.length&&delete a[n],!0}return!1}},r=i.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}}),a=t.Event;if(a){var s=a.prototype,o=s.stopImmediatePropagation;s.stopImmediatePropagation=function(){o&&o.call(this),this._stopped=!0}}e.EventMixin=n}(window),function(t){var e=t.Hilo,i=e.Class,n=i.create({constructor:function(t){this.init(t)},image:null,rect:null,init:function(t){var i=this,r=i.image;n.isDrawable(t)?i.image=t:e.copy(i,t,!0);var a=i.image;if("string"==typeof a){if(!r||a!==r.getAttribute("src")){i.image=null;var s=new Image;return s.onload=function(){s.onload=null,i.init(s)},void(s.src=a)}a=i.image=r}a&&!i.rect&&(i.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}}});e.Drawable=n}(window),function(t){var e=t.Hilo,i=e.Class,n=i.create({constructor:function(t){t=t||{},e.copy(this,t,!0)},renderType:null,canvas:null,stage:null,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){}});e.Renderer=n}(window),function(t){var e=t.Hilo,i=e.Class,n=e.Renderer,r=i.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),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,s=a&&a.image;if(s){var o=a.rect,h=o[2],l=o[3],c=o[4],u=o[5];if(!h||!l)return;i||n||(i=t.width=h,n=t.height=l),(c||u)&&e.translate(c-.5*h,u-.5*l),e.drawImage(s,o[0],o[1],h,l,0,0,i,n)}},endDraw:function(t){this.context.restore()},transform:function(t){var i=t.drawable;if(i&&i.domElement)return void e.setElementStyleByView(t);var n=this.context,r=t.scaleX,a=t.scaleY;if(t===this.stage){var s=this.canvas.style,o=t._scaleX,h=t._scaleY,l=!1;(!o&&1!=r||o&&o!=r)&&(t._scaleX=r,s.width=r*t.width+"px",l=!0),(!h&&1!=a||h&&h!=a)&&(t._scaleY=a,s.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.mask;v&&(v._render(this),n.clip());var m=t.align;if(m)if("function"==typeof m)t.align();else{var _=t.parent;if(_){var g=t.width,x=t.height,y=_.width,w=_.height;switch(m){case"TL":c=0,u=0;break;case"T":c=y-g>>1,u=0;break;case"TR":c=y-g,u=0;break;case"L":c=0,u=w-x>>1;break;case"C":c=y-g>>1,u=w-x>>1;break;case"R":c=y-g,u=w-x>>1;break;case"BL":c=0,u=w-x;break;case"B":c=y-g>>1,u=w-x;break;case"BR":c=y-g,u=w-x}}}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"}});e.CanvasRenderer=r}(window),function(t){var e=t.Hilo,i=e.Class,n=e.Renderer,r=e.Drawable,a=function(){function t(t,i){var n=t.tagName||"div",r=i.image,a=t.width||r&&r.width,s=t.height||r&&r.height,o=e.createElement(n),h=o.style;if(t.id&&(o.id=t.id),h.position="absolute",h.left=(t.left||0)+"px",h.top=(t.top||0)+"px",h.width=a+"px",h.height=s+"px","canvas"==n){if(o.width=a,o.height=s,r){var l=o.getContext("2d"),c=i.rect||[0,0,a,s];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 o}return i.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(e.setElementStyleByView(t),t===this.stage){var i=this.canvas.style,n=t._scaleX,r=t._scaleY,a=t.scaleX,s=t.scaleY;(!n&&1!=a||n&&n!=a)&&(t._scaleX=a,i.width=a*t.width+"px"),(!r&&1!=s||r&&r!=s)&&(t._scaleY=s,i.height=s*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")}})}();e.DOMRenderer=a}(window),function(t){var e=t.Hilo,i=e.Class,n=e.Renderer,r=e.Matrix,a=Math.PI/180,s=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}},renderType:"webgl",gl:null,_isContextLost:!1,_cacheTexture:{},constructor:function(t){s.superclass.constructor.call(this,t);var e=this;this.gl=this.canvas.getContext("webgl")||this.canvas.getContext("experimental-webgl"),this.maxBatchNum=s.MAX_BATCH_NUM,this.positionStride=4*s.ATTRIBUTE_NUM;var i=this.maxBatchNum*s.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,s=a[2],o=a[3];e||i||(e=t.width=s,i=t.height=o),this.batchIndex>=this.maxBatchNum&&this._renderBatches();var h=this._createVertexs(r,a[0],a[1],s,o,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=r,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 s=this.canvas.style,o=t._scaleX,h=t._scaleY,l=!1;(!o&&1!=n||o&&o!=n)&&(t._scaleX=n,s.width=n*t.width+"px",l=!0),(!h&&1!=a||h&&h!=a)&&(t._scaleY=a,s.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 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 o(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,s,o,h){var l=this.__tempVertexs||[],c=t.width,u=t.height;n/=c,r/=u,e/=c,i/=u,o=o,h=h,a=a,s=s,n+e>1&&(n=1-e),r+i>1&&(r=1-i);var d=0;return l[d++]=a,l[d++]=s,l[d++]=e,l[d++]=i,l[d++]=a+o,l[d++]=s,l[d++]=e+n,l[d++]=i,l[d++]=a,l[d++]=s+h,l[d++]=e,l[d++]=i+r,l[d++]=a+o,l[d++]=s+h,l[d++]=e+n,l[d++]=i+r,l},_setConcatenatedMatrix:function(t,e){var i=t.__webglWorldMatrix,n=1,r=0,s=t.rotation%360,o=t.pivotX,h=t.pivotY,l=t.scaleX,c=t.scaleY;if(s){var u=s*a;n=Math.cos(u),r=Math.sin(u)}i.a=n*l,i.b=r*l,i.c=-r*c,i.d=n*c,i.tx=t.x-i.a*o-i.c*h,i.ty=t.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}}),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||[]};o.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 s=t.getProgramParameter(a,t.LINK_STATUS);if(!s){var o=t.getProgramInfoLog(a);return console.log("Failed to link program: "+o),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}},e.WebGLRenderer=s}(window),function(t){var e=t.Hilo,i=e.Class,n=e.EventMixin,r=e.Matrix,a=function(){function t(t,e,i){for(var n,r,a,s,o=0,h=!1,l=0,c=i.length;ld.x?(n=d.x,r=u.x):(n=u.x,r=d.x),t>=n&&t<=r))h=!0;else if(u.y>d.y?(a=d.y,s=u.y):(a=u.y,s=d.y),!(es)){var f=(e-u.y)*(d.x-u.x)/(d.y-u.y)+u.x;if(f>t?o++:f==t&&(h=!0),u.x>t&&u.y==e){var p=i[(c+l-1)%c];(p.ye||p.y>e&&d.yo?o=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:n,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("View"),e.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,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,s,o=this.width,h=this.height,l=this.getConcatenatedMatrix(),c=this.boundsArea||[{x:0,y:0},{x:o,y:0},{x:o,y:h},{x:0,y:h}],u=[],d=0,f=c.length;de?n=e:ri?a=i:s=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=a(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 i=e.copy({},t);i.type="mouseover",this.fire(i)}}else"mouseout"==t.type&&(this.__mouseOver=!1);var n=this.parent;t._stopped||t._stopPropagationed||!n||("mouseout"==t.type||"touchout"==t.type?n.hitTestPoint(t.stageX,t.stageY,!0)||n._fireMouseEvent(t):n._fireMouseEvent(t))},onUpdate:null,render:function(t,e){t.draw(this)},toString:function(){return e.viewToString(this)}})}();e.View=a}(window),function(t){var e,i,n=t.Hilo,r=n.Drawable,a={_cacheDirty:!0,cache:function(t){(t||this._cacheDirty||!this.drawable)&&this.updateCache()},updateCache:function(){n.browser.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 r,this.drawable.init({image:e.toDataURL()}),this._cacheDirty=!1)},setCacheDirty:function(t){this._cacheDirty=t}};n.CacheMixin=a}(window),function(t){var e=t.Hilo,i=e.Class,n=e.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 s=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;l--)if(a=h[l],!(!a||!a.visible||a.alpha<=0||r&&!a.pointerEnabled))if(a.children&&a.children.length&&(!r||a.pointerChildren)&&(s=a.getViewAtPoint(t,e,i,n,r)),s){if(!n)return s;s.length&&(o=o.concat(s))}else if(a.hitTestPoint(t,e,i)){if(!n)return a;o.push(a)}return n&&o.length?o:null},render:function(t,e){r.superclass.render.call(this,t,e);var i,n,a,s=this.children.slice(0);for(i=0,n=s.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,s=this._frameElapsed,o=0!=n||this.drawable?s+(this.timeBased?t:1):0;return s=this._frameElapsed=o=i-1)&&this.stop(),this.paused||0!=s||(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});e.Sprite=a}(window),function(t){var e=t.Hilo,i=e.Class,n=e.View,r=e.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="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,n=t.canvas,r=this.drawable.domElement,a=this.depth,s=n.nextSibling;if(r.parentNode)return;for(;s&&3!=s.nodeType&&(i=parseInt(s.style.zIndex)||0,!(i<=0||i>a));)s=s.nextSibling;n.parentNode.insertBefore(this.drawable.domElement,s)}else t.draw(this)}});e.DOMElement=a}(window),function(t){var e=t.Hilo,i=e.Class,n=e.View,r=e.CacheMixin,a=function(){var t=document.createElement("canvas"),s=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 s=this,o=s._addAction;return o.call(s,["lineWidth",s.lineWidth=t||1]),o.call(s,["strokeStyle",s.strokeStyle=e||"0"]),o.call(s,["lineAlpha",s.lineAlpha=i||1]),void 0!=n&&o.call(s,["lineCap",s.lineCap=n]),void 0!=r&&o.call(s,["lineJoin",s.lineJoin=r]),void 0!=a&&o.call(s,["miterLimit",s.miterLimit=a]),s.hasStroke=!0,s},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 o=this,h=s.createLinearGradient(t,e,i,n),l=0,c=r.length;l1?a.slice(1):null;"function"==typeof t[s]?t[s].apply(t,o):t[s]=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}})}();e.Graphics=a}(window),function(t){var e=t.Hilo,i=e.Class,n=e.View,r=e.CacheMixin,a=i.create({Extends:n,Mixes:r,constructor:function(t){t=t||{},this.id=this.id||t.id||e.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,s,o,h=i.split(/\r\n|\r|\n|/),l=0,c=0,u=e._fontHeight+e.lineSpacing,d=[];for(n=0,s=h.length;ne.maxWidth?(d.push({text:m,y:c}),l<_&&(l=_),c+=u,m=v):(_=f,m+=v),p==o-1&&(d.push({text:m,y:c}),m!==v&&l>1;break;case"bottom":g=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 i,n=document.documentElement,r=e.createElement("div",{style:{font:t,position:"absolute"},innerHTML:"M"});return n.appendChild(r),i=r.offsetHeight,n.removeChild(r),i}}});e.Text=a}(window),function(t){var e=t.Hilo,i=e.Class,n=e.Container,r=e.Bitmap,a=i.create({Extends:n,constructor:function(t){t=t||{},this.id=this.id||t.id||e.getUid("BitmapText"),a.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(),n=i.length;if(e.text!=i){e.text=i;var r,a,s,o,h=0,l=0,c=0;for(r=0;r0?e.letterSpacing:0),e.children[r]?(o=e.children[r],o.setImage(s.image,s.rect)):(o=e._createBitmap(s),e.addChild(o)),o.x=c,h=c+s.rect[2],l=Math.max(l,s.rect[3]));for(r=e.children.length-1;r>=n;r--)e._releaseBitmap(e.children[r]),e.children[r].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 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:o;var l=r.ease?r.ease(o):o;r.reverse&&(r._reverseFlag<0&&(o=1-o,l=1-l),o<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))),0==r.time&&(s=r.onStart)&&s.call(r,r),r.time=a,r._render(l),(s=r.onUpdate)&&s.call(r,o,r),o>=1&&(r.reverse?(r._startTime=t(),r._pausedTime=0,r._reverseFlag*=-1):r.loop||r.repeat>0&&r._repeatCount++0&&u<=e?(c._render(o),c.time=a,n.add(c)):h&&(u<0||u>e)&&c.start()}return h?((s=r.onComplete)&&s.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 s}();e.Camera3d=n}(window),function(t){var e=t.Hilo,i=e.Class,n=e.View,r=e.Container,a=e.Drawable,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"],o=[],h=0,l=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()}}),p=i.create({Extends:n,constructor:function(t){this.id=this.id||t.id||e.getUid("Particle"),p.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(),d.push(this)},init:function(e){this.system=e.system,this._died=!1,this._time=0,this.alpha=1;for(var i=0,n=o.length;i>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(d.length>0){var e=d.pop();return e.init(t),e}return new p(t)}}});return f}();e.ParticleSystem=s}(window); \ No newline at end of file diff --git a/build/standalone/hilo-standalone.zip b/build/standalone/hilo-standalone.zip index f154449d..f903f589 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 e8012945..e115be0b 100644 --- a/build/standalone/hilo/core/Class.js +++ b/build/standalone/hilo/core/Class.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 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 61c86bec..0d6cc209 100644 --- a/build/standalone/hilo/core/Class.min.js +++ b/build/standalone/hilo/core/Class.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 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 2d57e569..7136d451 100644 --- a/build/standalone/hilo/core/Hilo.js +++ b/build/standalone/hilo/core/Hilo.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ @@ -23,7 +23,7 @@ return { * Hilo version * @type String */ - version:'1.0.2', + version:'1.0.4', /** * @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 8b7063e3..bb3107cf 100644 --- a/build/standalone/hilo/core/Hilo.min.js +++ b/build/standalone/hilo/core/Hilo.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ -!function(t){var e=function(){var o=t,a=document,r=a.documentElement,i=0;return{version:"1.0.2",getUid:function(t){var e=++i;if(t){var o=t.charCodeAt(t.length-1);return o>=48&&o<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,o=t;o;)e=e?o.id+"."+e:o.id,o=o.parent;return e},copy:function(t,e,o){for(var a in e)o&&!t.hasOwnProperty(a)&&void 0===t[a]||(t[a]=e[a]);return t},browser:function(){var t=navigator.userAgent,e={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 o,supportCanvas:null!=a.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in o,supportDeviceMotion:"ondevicemotion"in o};try{var i="hilo";localStorage.setItem(i,i),localStorage.removeItem(i),e.supportStorage=!0}catch(n){}var s=e.jsVendor=e.webkit?"webkit":e.firefox?"webkit":e.opera?"o":e.ie?"ms":"",d=e.cssVendor="-"+s+"-",h=a.createElement("div"),c=h.style,p=void 0!=c[s+"Transform"],f=void 0!=c[s+"Perspective"];return f&&(h.id="test3d",c=a.createElement("style"),c.textContent="@media ("+d+"transform-3d){#test3d{height:3px}}",a.head.appendChild(c),r.appendChild(h),f=3==h.offsetHeight,a.head.removeChild(c),r.removeChild(h)),e.supportTransform=p,e.supportTransform3D=f,e}(),event:function(){var t="ontouchstart"in o;return{POINTER_START:t?"touchstart":"mousedown",POINTER_MOVE:t?"touchmove":"mousemove",POINTER_END:t?"touchend":"mouseup"}}(),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 i=(o.pageXOffset||r.scrollLeft)-(r.clientLeft||0)||0,n=(o.pageYOffset||r.scrollTop)-(r.clientTop||0)||0,s=o.getComputedStyle?getComputedStyle(t):t.currentStyle,d=parseInt,h=d(s.paddingLeft)+d(s.borderLeftWidth)||0,c=d(s.paddingTop)+d(s.borderTopWidth)||0,p=d(s.paddingRight)+d(s.borderRightWidth)||0,f=d(s.paddingBottom)+d(s.borderBottomWidth)||0,l=e.top||0,g=e.left||0,m=e.right||0,u=e.bottom||0;return{left:g+i+h,top:l+n+c,width:m-p-g-h,height:u-f-l-c}},createElement:function(t,e){var o,r,i,n=a.createElement(t);for(o in e)if(r=e[o],"style"===o)for(i in r)n.style[i]=r[i];else n[o]=r;return n},getElement:function(t){return a.getElementById(t)},setElementStyleByView:function(t){var o=t.drawable,a=o.domElement.style,r=t._stateCache||(t._stateCache={}),i=e.browser.jsVendor,n="px",s=!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)){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),(s=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(a[i+"TransformOrigin"]=t.pivotX+n+" "+t.pivotY+n),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],r)||s)&&(a[i+"Transform"]=this.getTransformCSS(t)),this.cacheStateIfChanged(t,["background"],r)&&(a.backgroundColor=t.background),a.pointerEvents||(a.pointerEvents="none");var d=o.image;if(d){var h=d.src;h!==r.image&&(r.image=h,a.backgroundImage="url("+h+")");var c=o.rect;if(c){var p=c[0],f=c[1];p!==r.sx&&(r.sx=p,a.backgroundPositionX=-p+n),f!==r.sy&&(r.sy=f,a.backgroundPositionY=-f+n)}}var l=t.mask;if(l){var g=l.drawable.domElement.style.backgroundImage;g!==r.maskImage&&(r.maskImage=g,a[i+"MaskImage"]=g,a[i+"MaskRepeat"]="no-repeat");var m=l.x,u=l.y;m===r.maskX&&u===r.maskY||(r.maskX=m,r.maskY=u,a[i+"MaskPosition"]=m+n+" "+u+n)}}},cacheStateIfChanged:function(t,e,o){var a,r,i,n,s=!1;for(a=0,r=e.length;a=48&&o<=57&&(t+="_"),t+e}return e},viewToString:function(t){for(var e,o=t;o;)e=e?o.id+"."+e:o.id,o=o.parent;return e},copy:function(t,e,o){for(var a in e)o&&!t.hasOwnProperty(a)&&void 0===t[a]||(t[a]=e[a]);return t},browser:function(){var t=navigator.userAgent,e={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 o,supportCanvas:null!=a.createElement("canvas").getContext,supportStorage:!1,supportOrientation:"orientation"in o,supportDeviceMotion:"ondevicemotion"in o};try{var i="hilo";localStorage.setItem(i,i),localStorage.removeItem(i),e.supportStorage=!0}catch(n){}var s=e.jsVendor=e.webkit?"webkit":e.firefox?"webkit":e.opera?"o":e.ie?"ms":"",d=e.cssVendor="-"+s+"-",h=a.createElement("div"),c=h.style,p=void 0!=c[s+"Transform"],f=void 0!=c[s+"Perspective"];return f&&(h.id="test3d",c=a.createElement("style"),c.textContent="@media ("+d+"transform-3d){#test3d{height:3px}}",a.head.appendChild(c),r.appendChild(h),f=3==h.offsetHeight,a.head.removeChild(c),r.removeChild(h)),e.supportTransform=p,e.supportTransform3D=f,e}(),event:function(){var t="ontouchstart"in o;return{POINTER_START:t?"touchstart":"mousedown",POINTER_MOVE:t?"touchmove":"mousemove",POINTER_END:t?"touchend":"mouseup"}}(),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 i=(o.pageXOffset||r.scrollLeft)-(r.clientLeft||0)||0,n=(o.pageYOffset||r.scrollTop)-(r.clientTop||0)||0,s=o.getComputedStyle?getComputedStyle(t):t.currentStyle,d=parseInt,h=d(s.paddingLeft)+d(s.borderLeftWidth)||0,c=d(s.paddingTop)+d(s.borderTopWidth)||0,p=d(s.paddingRight)+d(s.borderRightWidth)||0,f=d(s.paddingBottom)+d(s.borderBottomWidth)||0,l=e.top||0,g=e.left||0,m=e.right||0,u=e.bottom||0;return{left:g+i+h,top:l+n+c,width:m-p-g-h,height:u-f-l-c}},createElement:function(t,e){var o,r,i,n=a.createElement(t);for(o in e)if(r=e[o],"style"===o)for(i in r)n.style[i]=r[i];else n[o]=r;return n},getElement:function(t){return a.getElementById(t)},setElementStyleByView:function(t){var o=t.drawable,a=o.domElement.style,r=t._stateCache||(t._stateCache={}),i=e.browser.jsVendor,n="px",s=!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)){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),(s=this.cacheStateIfChanged(t,["pivotX","pivotY"],r))&&(a[i+"TransformOrigin"]=t.pivotX+n+" "+t.pivotY+n),(this.cacheStateIfChanged(t,["x","y","rotation","scaleX","scaleY"],r)||s)&&(a[i+"Transform"]=this.getTransformCSS(t)),this.cacheStateIfChanged(t,["background"],r)&&(a.backgroundColor=t.background),a.pointerEvents||(a.pointerEvents="none");var d=o.image;if(d){var h=d.src;h!==r.image&&(r.image=h,a.backgroundImage="url("+h+")");var c=o.rect;if(c){var p=c[0],f=c[1];p!==r.sx&&(r.sx=p,a.backgroundPositionX=-p+n),f!==r.sy&&(r.sy=f,a.backgroundPositionY=-f+n)}}var l=t.mask;if(l){var g=l.drawable.domElement.style.backgroundImage;g!==r.maskImage&&(r.maskImage=g,a[i+"MaskImage"]=g,a[i+"MaskRepeat"]="no-repeat");var m=l.x,u=l.y;m===r.maskX&&u===r.maskY||(r.maskX=m,r.maskY=u,a[i+"MaskPosition"]=m+n+" "+u+n)}}},cacheStateIfChanged:function(t,e,o){var a,r,i,n,s=!1;for(a=0,r=e.length;a= 1 ? 1 : me.ease ? me.ease(ratio) : ratio; + ratio = ratio <= 0 ? 0 : ratio >= 1 ? 1 : ratio; + var easeRatio = me.ease ? me.ease(ratio) : ratio; if(me.reverse){ //backward - if(me._reverseFlag < 0) ratio = 1 - ratio; + if(me._reverseFlag < 0) { + ratio = 1 - ratio; + easeRatio = 1 - easeRatio; + } //forward if(ratio < 1e-7){ //repeat complete or not loop @@ -262,7 +266,7 @@ return Class.create(/** @lends Tween.prototype */{ me.time = elapsed; //render & update callback - me._render(ratio); + me._render(easeRatio); (callback = me.onUpdate) && callback.call(me, ratio, me); //check if complete @@ -389,6 +393,7 @@ return Class.create(/** @lends Tween.prototype */{ * @returns {Tween|Array} An tween instance or an array of tween instance. */ fromTo: function(target, fromProps, toProps, params){ + params = params || {}; var isArray = target instanceof Array; target = isArray ? target : [target]; diff --git a/build/standalone/hilo/tween/Tween.min.js b/build/standalone/hilo/tween/Tween.min.js index 0f055c63..3ac417f7 100644 --- a/build/standalone/hilo/tween/Tween.min.js +++ b/build/standalone/hilo/tween/Tween.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ -!function(e){var t=e.Hilo,r=t.Class,a=function(){function e(){return+new Date}return r.create({constructor:function(e,t,r,a){var n=this;n.target=e,n._startTime=0,n._seekTime=0,n._pausedTime=0,n._pausedStartTime=0,n._reverseFlag=1,n._repeatCount=0,3==arguments.length&&(a=r,r=t,t=null);for(var i in a)n[i]=a[i];n.setProps(t,r),!a.duration&&a.time&&(n.duration=a.time||0,n.time=0)},target:null,duration:0,delay:0,paused:!1,loop:!1,reverse:!1,repeat:0,repeatDelay:0,ease:null,time:0,onStart:null,onUpdate:null,onComplete:null,setProps:function(e,t){var r=this,a=r.target,n=e||t,i=r._fromProps={},s=r._toProps={};e=e||a,t=t||a;for(var u in n)s[u]=t[u]||0,a[u]=i[u]=e[u]||0;return r},start:function(){var t=this;return t._startTime=e()+t.delay,t._seekTime=0,t._pausedTime=0,t.paused=!1,a.add(t),t},stop:function(){return a.remove(this),this},pause:function(){var t=this;return t.paused=!0,t._pausedStartTime=e(),t},resume:function(){var t=this;return t.paused=!1,t._pausedStartTime&&(t._pausedTime+=e()-t._pausedStartTime),t._pausedStartTime=0,t},seek:function(t,r){var n=this,i=e();return n._startTime=i,n._seekTime=t,n._pausedTime=0,void 0!==r&&(n.paused=r),n._update(i,!0),a.add(n),n},link:function(e){var t,r,n=this,i=e.delay,s=n._startTime;return"string"==typeof i&&(t=0==i.indexOf("+"),r=0==i.indexOf("-"),i=t||r?Number(i.substr(1))*(t?1:-1):Number(i)),e.delay=i,e._startTime=t||r?s+n.duration+i:s+i,n._next=e,a.remove(e),n},_render:function(e){var t,r=this,a=r.target,n=r._fromProps;for(t in n)a[t]=n[t]+(r._toProps[t]-n[t])*e},_update:function(t,r){var n=this;if(!n.paused||r){var i=t-n._startTime-n._pausedTime+n._seekTime;if(!(i<0)){var s,u=i/n.duration,o=!1;u=u<=0?0:u>=1?1:n.ease?n.ease(u):u,n.reverse&&(n._reverseFlag<0&&(u=1-u),u<1e-7&&(n.repeat>0&&n._repeatCount++>=n.repeat||0==n.repeat&&!n.loop?o=!0:(n._startTime=e(),n._pausedTime=0,n._reverseFlag*=-1))),0==n.time&&(s=n.onStart)&&s.call(n,n),n.time=i,n._render(u),(s=n.onUpdate)&&s.call(n,u,n),u>=1&&(n.reverse?(n._startTime=e(),n._pausedTime=0,n._reverseFlag*=-1):n.loop||n.repeat>0&&n._repeatCount++0&&p<=t?(l._render(u),l.time=i,a.add(l)):o&&(p<0||p>t)&&l.start()}return o?((s=n.onComplete)&&s.call(n,n),!0):void 0}}},Statics:{_tweens:[],tick:function(){var t,r,n=a._tweens,i=n.length;for(r=0;r-1&&n.splice(t,1);else for(t=0;t=1?1:u;var l=n.ease?n.ease(u):u;n.reverse&&(n._reverseFlag<0&&(u=1-u,l=1-l),u<1e-7&&(n.repeat>0&&n._repeatCount++>=n.repeat||0==n.repeat&&!n.loop?o=!0:(n._startTime=e(),n._pausedTime=0,n._reverseFlag*=-1))),0==n.time&&(s=n.onStart)&&s.call(n,n),n.time=i,n._render(l),(s=n.onUpdate)&&s.call(n,u,n),u>=1&&(n.reverse?(n._startTime=e(),n._pausedTime=0,n._reverseFlag*=-1):n.loop||n.repeat>0&&n._repeatCount++0&&d<=t?(p._render(u),p.time=i,a.add(p)):o&&(d<0||d>t)&&p.start()}return o?((s=n.onComplete)&&s.call(n,n),!0):void 0}}},Statics:{_tweens:[],tick:function(){var t,r,n=a._tweens,i=n.length;for(r=0;r-1&&n.splice(t,1);else for(t=0;t=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=e.slice(0),s=0,r=n.length;s=0&&i.splice(e,1)},nextTick:function(t){var i=this,e={tick:function(n){i.removeTick(e),t()}};return i.addTick(e),e},timeout:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var i=(new Date).getTime(),r=i-n;r>=0&&(e.removeTick(s),t())}};return e.addTick(s),s},interval:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var e=(new Date).getTime(),s=e-n;s>=0&&(s=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=e.slice(0),s=0,r=n.length;s=0&&i.splice(e,1)},nextTick:function(t){var i=this,e={tick:function(n){i.removeTick(e),t()}};return i.addTick(e),e},timeout:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var i=(new Date).getTime(),r=i-n;r>=0&&(e.removeTick(s),t())}};return e.addTick(s),s},interval:function(t,i){var e=this,n=(new Date).getTime()+i,s={tick:function(){var e=(new Date).getTime(),s=e-n;s>=0&&(svar path = 'M250 150 L150 350 L350 350 Z';

*

var shape = new Hilo.Graphics({width:500, height:500});

@@ -345,30 +345,137 @@ return Class.create(/** @lends Graphics.prototype */{ */ drawSVGPath: function(pathData){ var me = this, addAction = me._addAction, - path = pathData.split(/,| (?=[a-zA-Z])/); - + path = pathData.replace(/,/g, ' ').replace(/-/g, ' -').split(/(?=[a-zA-Z])/); addAction.call(me, ['beginPath']); + var currentPoint = {x:0, y:0}; + var lastControlPoint = {x:0, y:0}; + var lastCmd; for(var i = 0, len = path.length; i < len; i++){ - var str = path[i], cmd = str[0].toUpperCase(), p = str.substring(1).split(/,| /); - if(p[0].length == 0) p.shift(); + var str = path[i]; + if(!str.length){ + continue; + } + var realCmd = str[0]; + var cmd = realCmd.toUpperCase(); + var p = this._getSVGParams(str); + var useRelative = cmd !== realCmd; switch(cmd){ case 'M': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['moveTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; case 'L': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } addAction.call(me, ['lineTo', p[0], p[1]]); + this._setCurrentPoint(currentPoint, p[0], p[1]); break; - case 'C': - addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + case 'H': + if(useRelative){ + p[0] += currentPoint.x; + } + addAction.call(me, ['lineTo', p[0], currentPoint.y]); + currentPoint.x = p[0]; + break; + case 'V': + if(useRelative){ + p[0] += currentPoint.y; + } + addAction.call(me, ['lineTo', currentPoint.x, p[0]]); + currentPoint.y = p[0]; break; case 'Z': addAction.call(me, ['closePath']); break; + case 'C': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['bezierCurveTo', p[0], p[1], p[2], p[3], p[4], p[5]]); + lastControlPoint.x = p[2]; + lastControlPoint.y = p[3]; + this._setCurrentPoint(currentPoint, p[4], p[5]); + break; + case 'S': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + if(lastCmd === 'C' || lastCmd === 'S'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['bezierCurveTo', controlPoint.x, controlPoint.y, p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'Q': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + addAction.call(me, ['quadraticCurveTo', p[0], p[1], p[2], p[3]]); + lastControlPoint.x = p[0]; + lastControlPoint.y = p[1]; + this._setCurrentPoint(currentPoint, p[2], p[3]); + break; + case 'T': + if(useRelative){ + this._convertToAbsolute(currentPoint, p); + } + var controlPoint; + if(lastCmd === 'Q' || lastCmd === 'T'){ + controlPoint = this._getReflectionPoint(currentPoint, lastControlPoint); + } + else{ + controlPoint = currentPoint; + } + addAction.call(me, ['quadraticCurveTo', controlPoint.x, controlPoint.y, p[0], p[1]]); + lastControlPoint = controlPoint; + this._setCurrentPoint(currentPoint, p[0], p[1]); + break; } + lastCmd = cmd; + } return me; }, + _getSVGParams:function(str){ + var p = str.substring(1).replace(/[\s]+$|^[\s]+/g, '').split(/[\s]+/); + if(p[0].length == 0) { + p.shift(); + } + for(var i = 0, l = p.length;i < l;i ++){ + p[i] = parseFloat(p[i]); + } + return p; + }, + _convertToAbsolute:function(currentPoint, data){ + for(var i = 0, l = data.length;i < l;i ++){ + if(i%2 === 0){ + data[i] += currentPoint.x; + } + else{ + data[i] += currentPoint.y; + } + } + }, + _setCurrentPoint:function(currentPoint, x, y){ + currentPoint.x = x; + currentPoint.y = y; + }, + _getReflectionPoint:function(centerPoint, point){ + return { + x:centerPoint.x * 2 - point.x, + y:centerPoint.y * 2 - point.y + }; + }, /** * @language=en diff --git a/build/standalone/hilo/view/Graphics.min.js b/build/standalone/hilo/view/Graphics.min.js index 7b4c254b..a9b92ed2 100644 --- a/build/standalone/hilo/view/Graphics.min.js +++ b/build/standalone/hilo/view/Graphics.min.js @@ -1,6 +1,6 @@ /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ -!function(t){var l=t.Hilo,i=l.Class,e=l.View,a=l.CacheMixin,n=function(){var t=document.createElement("canvas"),r=t.getContext&&t.getContext("2d");return i.create({Extends:e,Mixes:a,constructor:function(t){t=t||{},this.id=this.id||t.id||l.getUid("Graphics"),n.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,l,i,e,a,n){var r=this,c=r._addAction;return c.call(r,["lineWidth",r.lineWidth=t||1]),c.call(r,["strokeStyle",r.strokeStyle=l||"0"]),c.call(r,["lineAlpha",r.lineAlpha=i||1]),void 0!=e&&c.call(r,["lineCap",r.lineCap=e]),void 0!=a&&c.call(r,["lineJoin",r.lineJoin=a]),void 0!=n&&c.call(r,["miterLimit",r.miterLimit=n]),r.hasStroke=!0,r},beginFill:function(t,l){var i=this,e=i._addAction;return e.call(i,["fillStyle",i.fillStyle=t]),e.call(i,["fillAlpha",i.fillAlpha=l||1]),i.hasFill=!0,i},endFill:function(){var t=this,l=t._addAction;return t.hasStroke&&l.call(t,["stroke"]),t.hasFill&&l.call(t,["fill"]),t.setCacheDirty(!0),t},beginLinearGradientFill:function(t,l,i,e,a,n){for(var c=this,o=r.createLinearGradient(t,l,i,e),d=0,h=a.length;d1?n.slice(1):null;"function"==typeof t[r]?t[r].apply(t,c):t[r]=n[1]}},render:function(t,l){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 l=this;return l._actions.push(t),l}})}();l.Graphics=n}(window); \ No newline at end of file +!function(t){var e=t.Hilo,i=e.Class,l=e.View,n=e.CacheMixin,a=function(){var t=document.createElement("canvas"),r=t.getContext&&t.getContext("2d");return i.create({Extends:l,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,l,n,a){var r=this,o=r._addAction;return o.call(r,["lineWidth",r.lineWidth=t||1]),o.call(r,["strokeStyle",r.strokeStyle=e||"0"]),o.call(r,["lineAlpha",r.lineAlpha=i||1]),void 0!=l&&o.call(r,["lineCap",r.lineCap=l]),void 0!=n&&o.call(r,["lineJoin",r.lineJoin=n]),void 0!=a&&o.call(r,["miterLimit",r.miterLimit=a]),r.hasStroke=!0,r},beginFill:function(t,e){var i=this,l=i._addAction;return l.call(i,["fillStyle",i.fillStyle=t]),l.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,l,n,a){for(var o=this,c=r.createLinearGradient(t,e,i,l),s=0,h=n.length;s1?a.slice(1):null;"function"==typeof t[r]?t[r].apply(t,o):t[r]=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}})}();e.Graphics=a}(window); \ No newline at end of file diff --git a/build/standalone/hilo/view/Sprite.js b/build/standalone/hilo/view/Sprite.js index b13cbd76..745e633d 100644 --- a/build/standalone/hilo/view/Sprite.js +++ b/build/standalone/hilo/view/Sprite.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 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 8b55b9aa..d76bec0b 100644 --- a/build/standalone/hilo/view/Sprite.min.js +++ b/build/standalone/hilo/view/Sprite.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 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 04ef6d09..eb4ae235 100644 --- a/build/standalone/hilo/view/Stage.js +++ b/build/standalone/hilo/view/Stage.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 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 720ea81a..e8ae2092 100644 --- a/build/standalone/hilo/view/Stage.min.js +++ b/build/standalone/hilo/view/Stage.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 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 5ab3aa1b..e6b48359 100644 --- a/build/standalone/hilo/view/Text.js +++ b/build/standalone/hilo/view/Text.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/Text.min.js b/build/standalone/hilo/view/Text.min.js index a82a2d63..c2ab8b26 100644 --- a/build/standalone/hilo/view/Text.min.js +++ b/build/standalone/hilo/view/Text.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/build/standalone/hilo/view/View.js b/build/standalone/hilo/view/View.js index 070ca3ee..8d51f090 100644 --- a/build/standalone/hilo/view/View.js +++ b/build/standalone/hilo/view/View.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 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 15a2a161..bb4acb22 100644 --- a/build/standalone/hilo/view/View.min.js +++ b/build/standalone/hilo/view/View.min.js @@ -1,5 +1,5 @@ /** - * Hilo 1.0.2 for standalone + * Hilo 1.0.4 for standalone * Copyright 2016 alibaba.com * Licensed under the MIT License */ diff --git a/package.json b/package.json index 2cc9249a..edb39677 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Hilo", - "version": "1.0.3", + "version": "1.0.4", "description": "Hilo Game Framework", "author": "Hilo Dev Team", "license": "MIT",