text: /**
   * Hilo 1.4.0 for commonjs
   * Copyright 2016 alibaba.com
   * Licensed under the MIT License
   */
  var Class=require("../core/Class"),Hilo=require("../core/Hilo"),Renderer=require("./Renderer"),CanvasRenderer=Class.create({Extends:Renderer,constructor:function(e){CanvasRenderer.superclass.constructor.call(this,e),this.context=this.canvas.getContext("2d")},renderType:"canvas",context:null,startDraw:function(e){return!!(e.visible&&e.alpha>0)&&(e===this.stage&&this.context.clearRect(0,0,e.width,e.height),e.blendMode!==this.blendMode&&(this.context.globalCompositeOperation=this.blendMode=e.blendMode),this.context.save(),!0)},draw:function(e){var t=this.context,a=e.width,r=e.height,i=e.background;i&&(t.fillStyle=i,t.fillRect(0,0,a,r));var n=e.drawable,s=n&&n.image;if(s){var l=n.rect,o=l[2],c=l[3],h=l[4],d=l[5];if(!o||!c)return;a||r||(a=e.width=o,r=e.height=c),(h||d)&&t.translate(h-.5*o,d-.5*c),t.drawImage(s,l[0],l[1],o,c,0,0,a,r)}},endDraw:function(e){this.context.restore()},transform:function(e){var t=e.drawable;if(t&&t.domElement)return void Hilo.setElementStyleByView(e);var a=this.context,r=e.scaleX,i=e.scaleY;if(e===this.stage){var n=this.canvas.style,s=e._scaleX,l=e._scaleY,o=!1;(!s&&1!=r||s&&s!=r)&&(e._scaleX=r,n.width=r*e.width+"px",o=!0),(!l&&1!=i||l&&l!=i)&&(e._scaleY=i,n.height=i*e.height+"px",o=!0),o&&e.updateViewport()}else{var c=e.x,h=e.y,d=e.pivotX,v=e.pivotY,u=e.rotation%360,g=e.transform,f=e.mask;f&&(f._render(this),a.clip());var p=e.align;if(p){var x=e.getAlignPosition();c=x.x,h=x.y}g?a.transform(g.a,g.b,g.c,g.d,g.tx,g.ty):(0==c&&0==h||a.translate(c,h),0!=u&&a.rotate(u*Math.PI/180),1==r&&1==i||a.scale(r,i),0==d&&0==v||a.translate(-d,-v))}e.alpha>0&&(a.globalAlpha*=e.alpha)},remove:function(e){var t=e.drawable,a=t&&t.domElement;if(a){var r=a.parentNode;r&&r.removeChild(a)}},clear:function(e,t,a,r){this.context.clearRect(e,t,a,r)},resize:function(e,t){var a=this.canvas,r=this.stage,i=a.style;a.width=e,a.height=t,i.width=r.width*r.scaleX+"px",i.height=r.height*r.scaleY+"px"}});module.exports=CanvasRenderer;