@pixi/canvas-graphics
Advanced tools
Comparing version 6.4.2 to 6.5.0-rc
/*! | ||
* @pixi/canvas-graphics - v6.4.2 | ||
* Compiled Thu, 02 Jun 2022 15:39:26 UTC | ||
* @pixi/canvas-graphics - v6.5.0-rc | ||
* Compiled Thu, 14 Jul 2022 18:30:46 UTC | ||
* | ||
@@ -556,2 +556,7 @@ * @pixi/canvas-graphics is licensed under the MIT License. | ||
}; | ||
/** @ignore */ | ||
CanvasGraphicsRenderer.extension = { | ||
name: 'graphics', | ||
type: core.ExtensionType.CanvasRendererPlugin, | ||
}; | ||
return CanvasGraphicsRenderer; | ||
@@ -558,0 +563,0 @@ }()); |
/*! | ||
* @pixi/canvas-graphics - v6.4.2 | ||
* Compiled Thu, 02 Jun 2022 15:39:26 UTC | ||
* @pixi/canvas-graphics - v6.5.0-rc | ||
* Compiled Thu, 14 Jul 2022 18:30:46 UTC | ||
* | ||
@@ -8,3 +8,3 @@ * @pixi/canvas-graphics is licensed under the MIT License. | ||
*/ | ||
this.PIXI=this.PIXI||{};var _pixi_canvas_graphics=function(e,t,i,a,r){"use strict";var n,l=function(){function e(){}return e.offsetPolygon=function(t,i){var a=[],r=t.length;i=e.isPolygonClockwise(t)?i:-1*i;for(var n=0;n<r;n+=2){var l=n-2;l<0&&(l+=r);var o=(n+2)%r,s=t[n]-t[l],h=t[n+1]-t[l+1],v=Math.sqrt(s*s+h*h);s/=v,h/=v;var g=-(h*=i),c=s*=i,p=[t[l]+g,t[l+1]+c],f=[t[n]+g,t[n+1]+c],u=t[o]-t[n],d=t[o+1]-t[n+1];u/=v=Math.sqrt(u*u+d*d),d/=v;var T=-(d*=i),m=u*=i,y=[t[n]+T,t[n+1]+m],x=[t[o]+T,t[o+1]+m],b=e.findIntersection(p[0],p[1],f[0],f[1],y[0],y[1],x[0],x[1]);b&&a.push.apply(a,b)}return a},e.findIntersection=function(e,t,i,a,r,n,l,o){var s=(o-n)*(i-e)-(l-r)*(a-t),h=(l-r)*(t-n)-(o-n)*(e-r);if(0===s)return 0===h&&0===(i-e)*(t-n)-(a-t)*(e-r)?[(e+i)/2,(t+a)/2]:null;var v=h/s;return[e+v*(i-e),t+v*(a-t)]},e.isPolygonClockwise=function(e){for(var t=0,i=0,a=e.length-2;i<e.length;a=i,i+=2)t+=(e[i]-e[a])*(e[i+1]+e[a+1]);return t>0},e}(),o=function(){function e(e){this._svgMatrix=null,this._tempMatrix=new i.Matrix,this.renderer=e}return e.prototype._calcCanvasStyle=function(e,r){var n;return e.texture&&e.texture.baseTexture!==t.Texture.WHITE.baseTexture?e.texture.valid?(n=a.canvasUtils.getTintedPattern(e.texture,r),this.setPatternTransform(n,e.matrix||i.Matrix.IDENTITY)):n="#808080":n="#"+("00000"+(0|r).toString(16)).slice(-6),n},e.prototype.render=function(e){var t=this.renderer,a=t.context,r=e.worldAlpha,n=e.transform.worldTransform;t.setContextTransform(n),t.setBlendMode(e.blendMode);for(var l,o,s=e.geometry.graphicsData,h=(e.tint>>16&255)/255,v=(e.tint>>8&255)/255,g=(255&e.tint)/255,c=0;c<s.length;c++){var p=s[c],f=p.shape,u=p.fillStyle,d=p.lineStyle,T=0|p.fillStyle.color,m=0|p.lineStyle.color;if(p.matrix&&t.setContextTransform(n.copyTo(this._tempMatrix).append(p.matrix)),u.visible){var y=((T>>16&255)/255*h*255<<16)+((T>>8&255)/255*v*255<<8)+(255&T)/255*g*255;l=this._calcCanvasStyle(u,y)}if(d.visible){var x=((m>>16&255)/255*h*255<<16)+((m>>8&255)/255*v*255<<8)+(255&m)/255*g*255;o=this._calcCanvasStyle(d,x)}if(a.lineWidth=d.width,a.lineCap=d.cap,a.lineJoin=d.join,a.miterLimit=d.miterLimit,p.type===i.SHAPES.POLY){a.beginPath();var b=(R=f).points,P=p.holes,S=void 0,M=void 0,C=void 0,_=void 0,w=void 0;a.moveTo(b[0],b[1]);for(var I=2;I<b.length;I+=2)a.lineTo(b[I],b[I+1]);if(R.closeStroke&&a.closePath(),P.length>0){w=[],S=0,C=b[0],_=b[1];for(I=2;I+2<b.length;I+=2)S+=(b[I]-C)*(b[I+3]-_)-(b[I+2]-C)*(b[I+1]-_);for(var k=0;k<P.length;k++)if(b=P[k].shape.points){M=0,C=b[0],_=b[1];for(I=2;I+2<b.length;I+=2)M+=(b[I]-C)*(b[I+3]-_)-(b[I+2]-C)*(b[I+1]-_);if(M*S<0){a.moveTo(b[0],b[1]);for(I=2;I<b.length;I+=2)a.lineTo(b[I],b[I+1])}else{a.moveTo(b[b.length-2],b[b.length-1]);for(I=b.length-4;I>=0;I-=2)a.lineTo(b[I],b[I+1])}P[k].shape.closeStroke&&a.closePath(),w[k]=M*S<0}}u.visible&&(a.globalAlpha=u.alpha*r,a.fillStyle=l,a.fill()),d.visible&&this.paintPolygonStroke(R,d,o,P,w,r,a)}else if(p.type===i.SHAPES.RECT){var R=f;if(u.visible&&(a.globalAlpha=u.alpha*r,a.fillStyle=l,a.fillRect(R.x,R.y,R.width,R.height)),d.visible){var A=d.width*(.5-(1-d.alignment)),E=R.width+2*A,q=R.height+2*A;a.globalAlpha=d.alpha*r,a.strokeStyle=o,a.strokeRect(R.x-A,R.y-A,E,q)}}else if(p.type===i.SHAPES.CIRC){R=f;if(a.beginPath(),a.arc(R.x,R.y,R.radius,0,2*Math.PI),a.closePath(),u.visible&&(a.globalAlpha=u.alpha*r,a.fillStyle=l,a.fill()),d.visible){if(.5!==d.alignment){A=d.width*(.5-(1-d.alignment));a.beginPath(),a.arc(R.x,R.y,R.radius+A,0,2*Math.PI),a.closePath()}a.globalAlpha=d.alpha*r,a.strokeStyle=o,a.stroke()}}else if(p.type===i.SHAPES.ELIP){R=f;if((W=1===d.alignment)||this.paintEllipse(R,u,d,l,r,a),d.visible){if(.5!==d.alignment){var z=.5522848,G=(A=d.width*(.5-(1-d.alignment)),2*(R.width+A)),X=2*(R.height+A),H=R.x-G/2,L=R.y-X/2,j=G/2*z,D=X/2*z,O=H+G,B=L+X,N=H+G/2,V=L+X/2;a.beginPath(),a.moveTo(H,V),a.bezierCurveTo(H,V-D,N-j,L,N,L),a.bezierCurveTo(N+j,L,O,V-D,O,V),a.bezierCurveTo(O,V+D,N+j,B,N,B),a.bezierCurveTo(N-j,B,H,V+D,H,V),a.closePath()}a.globalAlpha=d.alpha*r,a.strokeStyle=o,a.stroke()}W&&this.paintEllipse(R,u,d,l,r,a)}else if(p.type===i.SHAPES.RREC){var W;R=f;if((W=1===d.alignment)||this.paintRoundedRectangle(R,u,d,l,r,a),d.visible){if(.5!==d.alignment){E=R.width,q=R.height,A=d.width*(.5-(1-d.alignment));var Y=R.x-A,J=R.y-A,U=R.width+2*A,F=R.height+2*A,K=A*(d.alignment>=1?Math.min(U/E,F/q):Math.min(E/U,q/F)),Q=R.radius+K,Z=Math.min(U,F)/2;Q=Q>Z?Z:Q,a.beginPath(),a.moveTo(Y,J+Q),a.lineTo(Y,J+F-Q),a.quadraticCurveTo(Y,J+F,Y+Q,J+F),a.lineTo(Y+U-Q,J+F),a.quadraticCurveTo(Y+U,J+F,Y+U,J+F-Q),a.lineTo(Y+U,J+Q),a.quadraticCurveTo(Y+U,J,Y+U-Q,J),a.lineTo(Y+Q,J),a.quadraticCurveTo(Y,J,Y,J+Q),a.closePath()}a.globalAlpha=d.alpha*r,a.strokeStyle=o,a.stroke()}W&&this.paintRoundedRectangle(R,u,d,l,r,a)}}},e.prototype.paintPolygonStroke=function(e,t,i,a,r,n,o){if(.5!==t.alignment){var s=t.width*(.5-(1-t.alignment)),h=l.offsetPolygon(e.points,s),v=void 0;o.beginPath(),o.moveTo(h[0],h[1]);for(var g=2;g<h.length;g+=2)o.lineTo(h[g],h[g+1]);e.closeStroke&&o.closePath();for(var c=0;c<a.length;c++){if(v=a[c].shape.points,h=l.offsetPolygon(v,s),r[c]){o.moveTo(h[0],h[1]);for(g=2;g<h.length;g+=2)o.lineTo(h[g],h[g+1])}else{o.moveTo(h[h.length-2],h[h.length-1]);for(g=h.length-4;g>=0;g-=2)o.lineTo(h[g],h[g+1])}a[c].shape.closeStroke&&o.closePath()}}o.globalAlpha=t.alpha*n,o.strokeStyle=i,o.stroke()},e.prototype.paintEllipse=function(e,t,i,a,r,n){var l=2*e.width,o=2*e.height,s=e.x-l/2,h=e.y-o/2,v=.5522848,g=l/2*v,c=o/2*v,p=s+l,f=h+o,u=s+l/2,d=h+o/2;0===i.alignment&&n.save(),n.beginPath(),n.moveTo(s,d),n.bezierCurveTo(s,d-c,u-g,h,u,h),n.bezierCurveTo(u+g,h,p,d-c,p,d),n.bezierCurveTo(p,d+c,u+g,f,u,f),n.bezierCurveTo(u-g,f,s,d+c,s,d),n.closePath(),0===i.alignment&&n.clip(),t.visible&&(n.globalAlpha=t.alpha*r,n.fillStyle=a,n.fill()),0===i.alignment&&n.restore()},e.prototype.paintRoundedRectangle=function(e,t,i,a,r,n){var l=e.x,o=e.y,s=e.width,h=e.height,v=e.radius,g=Math.min(s,h)/2;v=v>g?g:v,0===i.alignment&&n.save(),n.beginPath(),n.moveTo(l,o+v),n.lineTo(l,o+h-v),n.quadraticCurveTo(l,o+h,l+v,o+h),n.lineTo(l+s-v,o+h),n.quadraticCurveTo(l+s,o+h,l+s,o+h-v),n.lineTo(l+s,o+v),n.quadraticCurveTo(l+s,o,l+s-v,o),n.lineTo(l+v,o),n.quadraticCurveTo(l,o,l,o+v),n.closePath(),0===i.alignment&&n.clip(),t.visible&&(n.globalAlpha=t.alpha*r,n.fillStyle=a,n.fill()),0===i.alignment&&n.restore()},e.prototype.setPatternTransform=function(e,t){if(!1!==this._svgMatrix){if(!this._svgMatrix){var i=document.createElementNS("http://www.w3.org/2000/svg","svg");if(i&&i.createSVGMatrix&&(this._svgMatrix=i.createSVGMatrix()),!this._svgMatrix||!e.setTransform)return void(this._svgMatrix=!1)}this._svgMatrix.a=t.a,this._svgMatrix.b=t.b,this._svgMatrix.c=t.c,this._svgMatrix.d=t.d,this._svgMatrix.e=t.tx,this._svgMatrix.f=t.ty,e.setTransform(this._svgMatrix.inverse())}},e.prototype.destroy=function(){this.renderer=null,this._svgMatrix=null,this._tempMatrix=null},e}(),s=new i.Matrix;return r.Graphics.prototype.generateCanvasTexture=function(e,i){void 0===i&&(i=1);var r=this.getLocalBounds(),l=t.RenderTexture.create({width:r.width,height:r.height,scaleMode:e,resolution:i});n||(n=new a.CanvasRenderer),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(s),s.invert(),s.tx-=r.x,s.ty-=r.y,n.render(this,{renderTexture:l,clear:!0,transform:s});var o=t.Texture.from(l.baseTexture._canvasRenderTarget.canvas,{scaleMode:e});return o.baseTexture.setResolution(i),o},r.Graphics.prototype.cachedGraphicsData=[],r.Graphics.prototype._renderCanvas=function(e){!0!==this.isMask&&(this.finishPoly(),e.plugins.graphics.render(this))},e.CanvasGraphicsRenderer=o,Object.defineProperty(e,"__esModule",{value:!0}),e}({},PIXI,PIXI,PIXI,PIXI);Object.assign(this.PIXI,_pixi_canvas_graphics); | ||
this.PIXI=this.PIXI||{};var _pixi_canvas_graphics=function(e,t,i,a,r){"use strict";var n,o=function(){function e(){}return e.offsetPolygon=function(t,i){var a=[],r=t.length;i=e.isPolygonClockwise(t)?i:-1*i;for(var n=0;n<r;n+=2){var o=n-2;o<0&&(o+=r);var l=(n+2)%r,s=t[n]-t[o],h=t[n+1]-t[o+1],v=Math.sqrt(s*s+h*h);s/=v,h/=v;var g=-(h*=i),c=s*=i,p=[t[o]+g,t[o+1]+c],f=[t[n]+g,t[n+1]+c],u=t[l]-t[n],d=t[l+1]-t[n+1];u/=v=Math.sqrt(u*u+d*d),d/=v;var T=-(d*=i),m=u*=i,y=[t[n]+T,t[n+1]+m],x=[t[l]+T,t[l+1]+m],b=e.findIntersection(p[0],p[1],f[0],f[1],y[0],y[1],x[0],x[1]);b&&a.push.apply(a,b)}return a},e.findIntersection=function(e,t,i,a,r,n,o,l){var s=(l-n)*(i-e)-(o-r)*(a-t),h=(o-r)*(t-n)-(l-n)*(e-r);if(0===s)return 0===h&&0===(i-e)*(t-n)-(a-t)*(e-r)?[(e+i)/2,(t+a)/2]:null;var v=h/s;return[e+v*(i-e),t+v*(a-t)]},e.isPolygonClockwise=function(e){for(var t=0,i=0,a=e.length-2;i<e.length;a=i,i+=2)t+=(e[i]-e[a])*(e[i+1]+e[a+1]);return t>0},e}(),l=function(){function e(e){this._svgMatrix=null,this._tempMatrix=new i.Matrix,this.renderer=e}return e.prototype._calcCanvasStyle=function(e,r){var n;return e.texture&&e.texture.baseTexture!==t.Texture.WHITE.baseTexture?e.texture.valid?(n=a.canvasUtils.getTintedPattern(e.texture,r),this.setPatternTransform(n,e.matrix||i.Matrix.IDENTITY)):n="#808080":n="#"+("00000"+(0|r).toString(16)).slice(-6),n},e.prototype.render=function(e){var t=this.renderer,a=t.context,r=e.worldAlpha,n=e.transform.worldTransform;t.setContextTransform(n),t.setBlendMode(e.blendMode);for(var o,l,s=e.geometry.graphicsData,h=(e.tint>>16&255)/255,v=(e.tint>>8&255)/255,g=(255&e.tint)/255,c=0;c<s.length;c++){var p=s[c],f=p.shape,u=p.fillStyle,d=p.lineStyle,T=0|p.fillStyle.color,m=0|p.lineStyle.color;if(p.matrix&&t.setContextTransform(n.copyTo(this._tempMatrix).append(p.matrix)),u.visible){var y=((T>>16&255)/255*h*255<<16)+((T>>8&255)/255*v*255<<8)+(255&T)/255*g*255;o=this._calcCanvasStyle(u,y)}if(d.visible){var x=((m>>16&255)/255*h*255<<16)+((m>>8&255)/255*v*255<<8)+(255&m)/255*g*255;l=this._calcCanvasStyle(d,x)}if(a.lineWidth=d.width,a.lineCap=d.cap,a.lineJoin=d.join,a.miterLimit=d.miterLimit,p.type===i.SHAPES.POLY){a.beginPath();var b=(R=f).points,P=p.holes,S=void 0,M=void 0,C=void 0,_=void 0,w=void 0;a.moveTo(b[0],b[1]);for(var I=2;I<b.length;I+=2)a.lineTo(b[I],b[I+1]);if(R.closeStroke&&a.closePath(),P.length>0){w=[],S=0,C=b[0],_=b[1];for(I=2;I+2<b.length;I+=2)S+=(b[I]-C)*(b[I+3]-_)-(b[I+2]-C)*(b[I+1]-_);for(var k=0;k<P.length;k++)if(b=P[k].shape.points){M=0,C=b[0],_=b[1];for(I=2;I+2<b.length;I+=2)M+=(b[I]-C)*(b[I+3]-_)-(b[I+2]-C)*(b[I+1]-_);if(M*S<0){a.moveTo(b[0],b[1]);for(I=2;I<b.length;I+=2)a.lineTo(b[I],b[I+1])}else{a.moveTo(b[b.length-2],b[b.length-1]);for(I=b.length-4;I>=0;I-=2)a.lineTo(b[I],b[I+1])}P[k].shape.closeStroke&&a.closePath(),w[k]=M*S<0}}u.visible&&(a.globalAlpha=u.alpha*r,a.fillStyle=o,a.fill()),d.visible&&this.paintPolygonStroke(R,d,l,P,w,r,a)}else if(p.type===i.SHAPES.RECT){var R=f;if(u.visible&&(a.globalAlpha=u.alpha*r,a.fillStyle=o,a.fillRect(R.x,R.y,R.width,R.height)),d.visible){var A=d.width*(.5-(1-d.alignment)),E=R.width+2*A,q=R.height+2*A;a.globalAlpha=d.alpha*r,a.strokeStyle=l,a.strokeRect(R.x-A,R.y-A,E,q)}}else if(p.type===i.SHAPES.CIRC){R=f;if(a.beginPath(),a.arc(R.x,R.y,R.radius,0,2*Math.PI),a.closePath(),u.visible&&(a.globalAlpha=u.alpha*r,a.fillStyle=o,a.fill()),d.visible){if(.5!==d.alignment){A=d.width*(.5-(1-d.alignment));a.beginPath(),a.arc(R.x,R.y,R.radius+A,0,2*Math.PI),a.closePath()}a.globalAlpha=d.alpha*r,a.strokeStyle=l,a.stroke()}}else if(p.type===i.SHAPES.ELIP){R=f;if((W=1===d.alignment)||this.paintEllipse(R,u,d,o,r,a),d.visible){if(.5!==d.alignment){var z=.5522848,G=(A=d.width*(.5-(1-d.alignment)),2*(R.width+A)),X=2*(R.height+A),H=R.x-G/2,L=R.y-X/2,j=G/2*z,D=X/2*z,O=H+G,B=L+X,N=H+G/2,V=L+X/2;a.beginPath(),a.moveTo(H,V),a.bezierCurveTo(H,V-D,N-j,L,N,L),a.bezierCurveTo(N+j,L,O,V-D,O,V),a.bezierCurveTo(O,V+D,N+j,B,N,B),a.bezierCurveTo(N-j,B,H,V+D,H,V),a.closePath()}a.globalAlpha=d.alpha*r,a.strokeStyle=l,a.stroke()}W&&this.paintEllipse(R,u,d,o,r,a)}else if(p.type===i.SHAPES.RREC){var W;R=f;if((W=1===d.alignment)||this.paintRoundedRectangle(R,u,d,o,r,a),d.visible){if(.5!==d.alignment){E=R.width,q=R.height,A=d.width*(.5-(1-d.alignment));var Y=R.x-A,J=R.y-A,U=R.width+2*A,F=R.height+2*A,K=A*(d.alignment>=1?Math.min(U/E,F/q):Math.min(E/U,q/F)),Q=R.radius+K,Z=Math.min(U,F)/2;Q=Q>Z?Z:Q,a.beginPath(),a.moveTo(Y,J+Q),a.lineTo(Y,J+F-Q),a.quadraticCurveTo(Y,J+F,Y+Q,J+F),a.lineTo(Y+U-Q,J+F),a.quadraticCurveTo(Y+U,J+F,Y+U,J+F-Q),a.lineTo(Y+U,J+Q),a.quadraticCurveTo(Y+U,J,Y+U-Q,J),a.lineTo(Y+Q,J),a.quadraticCurveTo(Y,J,Y,J+Q),a.closePath()}a.globalAlpha=d.alpha*r,a.strokeStyle=l,a.stroke()}W&&this.paintRoundedRectangle(R,u,d,o,r,a)}}},e.prototype.paintPolygonStroke=function(e,t,i,a,r,n,l){if(.5!==t.alignment){var s=t.width*(.5-(1-t.alignment)),h=o.offsetPolygon(e.points,s),v=void 0;l.beginPath(),l.moveTo(h[0],h[1]);for(var g=2;g<h.length;g+=2)l.lineTo(h[g],h[g+1]);e.closeStroke&&l.closePath();for(var c=0;c<a.length;c++){if(v=a[c].shape.points,h=o.offsetPolygon(v,s),r[c]){l.moveTo(h[0],h[1]);for(g=2;g<h.length;g+=2)l.lineTo(h[g],h[g+1])}else{l.moveTo(h[h.length-2],h[h.length-1]);for(g=h.length-4;g>=0;g-=2)l.lineTo(h[g],h[g+1])}a[c].shape.closeStroke&&l.closePath()}}l.globalAlpha=t.alpha*n,l.strokeStyle=i,l.stroke()},e.prototype.paintEllipse=function(e,t,i,a,r,n){var o=2*e.width,l=2*e.height,s=e.x-o/2,h=e.y-l/2,v=.5522848,g=o/2*v,c=l/2*v,p=s+o,f=h+l,u=s+o/2,d=h+l/2;0===i.alignment&&n.save(),n.beginPath(),n.moveTo(s,d),n.bezierCurveTo(s,d-c,u-g,h,u,h),n.bezierCurveTo(u+g,h,p,d-c,p,d),n.bezierCurveTo(p,d+c,u+g,f,u,f),n.bezierCurveTo(u-g,f,s,d+c,s,d),n.closePath(),0===i.alignment&&n.clip(),t.visible&&(n.globalAlpha=t.alpha*r,n.fillStyle=a,n.fill()),0===i.alignment&&n.restore()},e.prototype.paintRoundedRectangle=function(e,t,i,a,r,n){var o=e.x,l=e.y,s=e.width,h=e.height,v=e.radius,g=Math.min(s,h)/2;v=v>g?g:v,0===i.alignment&&n.save(),n.beginPath(),n.moveTo(o,l+v),n.lineTo(o,l+h-v),n.quadraticCurveTo(o,l+h,o+v,l+h),n.lineTo(o+s-v,l+h),n.quadraticCurveTo(o+s,l+h,o+s,l+h-v),n.lineTo(o+s,l+v),n.quadraticCurveTo(o+s,l,o+s-v,l),n.lineTo(o+v,l),n.quadraticCurveTo(o,l,o,l+v),n.closePath(),0===i.alignment&&n.clip(),t.visible&&(n.globalAlpha=t.alpha*r,n.fillStyle=a,n.fill()),0===i.alignment&&n.restore()},e.prototype.setPatternTransform=function(e,t){if(!1!==this._svgMatrix){if(!this._svgMatrix){var i=document.createElementNS("http://www.w3.org/2000/svg","svg");if(i&&i.createSVGMatrix&&(this._svgMatrix=i.createSVGMatrix()),!this._svgMatrix||!e.setTransform)return void(this._svgMatrix=!1)}this._svgMatrix.a=t.a,this._svgMatrix.b=t.b,this._svgMatrix.c=t.c,this._svgMatrix.d=t.d,this._svgMatrix.e=t.tx,this._svgMatrix.f=t.ty,e.setTransform(this._svgMatrix.inverse())}},e.prototype.destroy=function(){this.renderer=null,this._svgMatrix=null,this._tempMatrix=null},e.extension={name:"graphics",type:t.ExtensionType.CanvasRendererPlugin},e}(),s=new i.Matrix;return r.Graphics.prototype.generateCanvasTexture=function(e,i){void 0===i&&(i=1);var r=this.getLocalBounds(),o=t.RenderTexture.create({width:r.width,height:r.height,scaleMode:e,resolution:i});n||(n=new a.CanvasRenderer),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(s),s.invert(),s.tx-=r.x,s.ty-=r.y,n.render(this,{renderTexture:o,clear:!0,transform:s});var l=t.Texture.from(o.baseTexture._canvasRenderTarget.canvas,{scaleMode:e});return l.baseTexture.setResolution(i),l},r.Graphics.prototype.cachedGraphicsData=[],r.Graphics.prototype._renderCanvas=function(e){!0!==this.isMask&&(this.finishPoly(),e.plugins.graphics.render(this))},e.CanvasGraphicsRenderer=l,Object.defineProperty(e,"__esModule",{value:!0}),e}({},PIXI,PIXI,PIXI,PIXI);Object.assign(this.PIXI,_pixi_canvas_graphics); | ||
//# sourceMappingURL=canvas-graphics.min.js.map |
/*! | ||
* @pixi/canvas-graphics - v6.4.2 | ||
* Compiled Thu, 02 Jun 2022 15:39:26 UTC | ||
* @pixi/canvas-graphics - v6.5.0-rc | ||
* Compiled Thu, 14 Jul 2022 18:30:46 UTC | ||
* | ||
@@ -561,2 +561,7 @@ * @pixi/canvas-graphics is licensed under the MIT License. | ||
}; | ||
/** @ignore */ | ||
CanvasGraphicsRenderer.extension = { | ||
name: 'graphics', | ||
type: core.ExtensionType.CanvasRendererPlugin, | ||
}; | ||
return CanvasGraphicsRenderer; | ||
@@ -563,0 +568,0 @@ }()); |
/*! | ||
* @pixi/canvas-graphics - v6.4.2 | ||
* Compiled Thu, 02 Jun 2022 15:39:26 UTC | ||
* @pixi/canvas-graphics - v6.5.0-rc | ||
* Compiled Thu, 14 Jul 2022 18:30:46 UTC | ||
* | ||
@@ -8,3 +8,3 @@ * @pixi/canvas-graphics is licensed under the MIT License. | ||
*/ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("@pixi/core"),i=require("@pixi/math"),r=require("@pixi/canvas-renderer"),a=require("@pixi/graphics"),n=function(){function e(){}return e.offsetPolygon=function(t,i){var r=[],a=t.length;i=e.isPolygonClockwise(t)?i:-1*i;for(var n=0;n<a;n+=2){var o=n-2;o<0&&(o+=a);var l=(n+2)%a,s=t[n]-t[o],h=t[n+1]-t[o+1],v=Math.sqrt(s*s+h*h);s/=v,h/=v;var g=-(h*=i),p=s*=i,c=[t[o]+g,t[o+1]+p],f=[t[n]+g,t[n+1]+p],u=t[l]-t[n],d=t[l+1]-t[n+1];u/=v=Math.sqrt(u*u+d*d),d/=v;var T=-(d*=i),m=u*=i,x=[t[n]+T,t[n+1]+m],y=[t[l]+T,t[l+1]+m],b=e.findIntersection(c[0],c[1],f[0],f[1],x[0],x[1],y[0],y[1]);b&&r.push.apply(r,b)}return r},e.findIntersection=function(e,t,i,r,a,n,o,l){var s=(l-n)*(i-e)-(o-a)*(r-t),h=(o-a)*(t-n)-(l-n)*(e-a);if(0===s)return 0===h&&0===(i-e)*(t-n)-(r-t)*(e-a)?[(e+i)/2,(t+r)/2]:null;var v=h/s;return[e+v*(i-e),t+v*(r-t)]},e.isPolygonClockwise=function(e){for(var t=0,i=0,r=e.length-2;i<e.length;r=i,i+=2)t+=(e[i]-e[r])*(e[i+1]+e[r+1]);return t>0},e}(),o=function(){function e(e){this._svgMatrix=null,this._tempMatrix=new i.Matrix,this.renderer=e}return e.prototype._calcCanvasStyle=function(e,a){var n;return e.texture&&e.texture.baseTexture!==t.Texture.WHITE.baseTexture?e.texture.valid?(n=r.canvasUtils.getTintedPattern(e.texture,a),this.setPatternTransform(n,e.matrix||i.Matrix.IDENTITY)):n="#808080":n="#"+("00000"+(0|a).toString(16)).slice(-6),n},e.prototype.render=function(e){var t=this.renderer,r=t.context,a=e.worldAlpha,n=e.transform.worldTransform;t.setContextTransform(n),t.setBlendMode(e.blendMode);for(var o,l,s=e.geometry.graphicsData,h=(e.tint>>16&255)/255,v=(e.tint>>8&255)/255,g=(255&e.tint)/255,p=0;p<s.length;p++){var c=s[p],f=c.shape,u=c.fillStyle,d=c.lineStyle,T=0|c.fillStyle.color,m=0|c.lineStyle.color;if(c.matrix&&t.setContextTransform(n.copyTo(this._tempMatrix).append(c.matrix)),u.visible){var x=((T>>16&255)/255*h*255<<16)+((T>>8&255)/255*v*255<<8)+(255&T)/255*g*255;o=this._calcCanvasStyle(u,x)}if(d.visible){var y=((m>>16&255)/255*h*255<<16)+((m>>8&255)/255*v*255<<8)+(255&m)/255*g*255;l=this._calcCanvasStyle(d,y)}if(r.lineWidth=d.width,r.lineCap=d.cap,r.lineJoin=d.join,r.miterLimit=d.miterLimit,c.type===i.SHAPES.POLY){r.beginPath();var b=(A=f).points,P=c.holes,S=void 0,M=void 0,C=void 0,w=void 0,_=void 0;r.moveTo(b[0],b[1]);for(var k=2;k<b.length;k+=2)r.lineTo(b[k],b[k+1]);if(A.closeStroke&&r.closePath(),P.length>0){_=[],S=0,C=b[0],w=b[1];for(k=2;k+2<b.length;k+=2)S+=(b[k]-C)*(b[k+3]-w)-(b[k+2]-C)*(b[k+1]-w);for(var R=0;R<P.length;R++)if(b=P[R].shape.points){M=0,C=b[0],w=b[1];for(k=2;k+2<b.length;k+=2)M+=(b[k]-C)*(b[k+3]-w)-(b[k+2]-C)*(b[k+1]-w);if(M*S<0){r.moveTo(b[0],b[1]);for(k=2;k<b.length;k+=2)r.lineTo(b[k],b[k+1])}else{r.moveTo(b[b.length-2],b[b.length-1]);for(k=b.length-4;k>=0;k-=2)r.lineTo(b[k],b[k+1])}P[R].shape.closeStroke&&r.closePath(),_[R]=M*S<0}}u.visible&&(r.globalAlpha=u.alpha*a,r.fillStyle=o,r.fill()),d.visible&&this.paintPolygonStroke(A,d,l,P,_,a,r)}else if(c.type===i.SHAPES.RECT){var A=f;if(u.visible&&(r.globalAlpha=u.alpha*a,r.fillStyle=o,r.fillRect(A.x,A.y,A.width,A.height)),d.visible){var q=d.width*(.5-(1-d.alignment)),E=A.width+2*q,I=A.height+2*q;r.globalAlpha=d.alpha*a,r.strokeStyle=l,r.strokeRect(A.x-q,A.y-q,E,I)}}else if(c.type===i.SHAPES.CIRC){A=f;if(r.beginPath(),r.arc(A.x,A.y,A.radius,0,2*Math.PI),r.closePath(),u.visible&&(r.globalAlpha=u.alpha*a,r.fillStyle=o,r.fill()),d.visible){if(.5!==d.alignment){q=d.width*(.5-(1-d.alignment));r.beginPath(),r.arc(A.x,A.y,A.radius+q,0,2*Math.PI),r.closePath()}r.globalAlpha=d.alpha*a,r.strokeStyle=l,r.stroke()}}else if(c.type===i.SHAPES.ELIP){A=f;if((Y=1===d.alignment)||this.paintEllipse(A,u,d,o,a,r),d.visible){if(.5!==d.alignment){var z=.5522848,G=(q=d.width*(.5-(1-d.alignment)),2*(A.width+q)),H=2*(A.height+q),L=A.x-G/2,D=A.y-H/2,j=G/2*z,B=H/2*z,N=L+G,O=D+H,V=L+G/2,W=D+H/2;r.beginPath(),r.moveTo(L,W),r.bezierCurveTo(L,W-B,V-j,D,V,D),r.bezierCurveTo(V+j,D,N,W-B,N,W),r.bezierCurveTo(N,W+B,V+j,O,V,O),r.bezierCurveTo(V-j,O,L,W+B,L,W),r.closePath()}r.globalAlpha=d.alpha*a,r.strokeStyle=l,r.stroke()}Y&&this.paintEllipse(A,u,d,o,a,r)}else if(c.type===i.SHAPES.RREC){var Y;A=f;if((Y=1===d.alignment)||this.paintRoundedRectangle(A,u,d,o,a,r),d.visible){if(.5!==d.alignment){E=A.width,I=A.height,q=d.width*(.5-(1-d.alignment));var J=A.x-q,U=A.y-q,F=A.width+2*q,K=A.height+2*q,Q=q*(d.alignment>=1?Math.min(F/E,K/I):Math.min(E/F,I/K)),X=A.radius+Q,Z=Math.min(F,K)/2;X=X>Z?Z:X,r.beginPath(),r.moveTo(J,U+X),r.lineTo(J,U+K-X),r.quadraticCurveTo(J,U+K,J+X,U+K),r.lineTo(J+F-X,U+K),r.quadraticCurveTo(J+F,U+K,J+F,U+K-X),r.lineTo(J+F,U+X),r.quadraticCurveTo(J+F,U,J+F-X,U),r.lineTo(J+X,U),r.quadraticCurveTo(J,U,J,U+X),r.closePath()}r.globalAlpha=d.alpha*a,r.strokeStyle=l,r.stroke()}Y&&this.paintRoundedRectangle(A,u,d,o,a,r)}}},e.prototype.paintPolygonStroke=function(e,t,i,r,a,o,l){if(.5!==t.alignment){var s=t.width*(.5-(1-t.alignment)),h=n.offsetPolygon(e.points,s),v=void 0;l.beginPath(),l.moveTo(h[0],h[1]);for(var g=2;g<h.length;g+=2)l.lineTo(h[g],h[g+1]);e.closeStroke&&l.closePath();for(var p=0;p<r.length;p++){if(v=r[p].shape.points,h=n.offsetPolygon(v,s),a[p]){l.moveTo(h[0],h[1]);for(g=2;g<h.length;g+=2)l.lineTo(h[g],h[g+1])}else{l.moveTo(h[h.length-2],h[h.length-1]);for(g=h.length-4;g>=0;g-=2)l.lineTo(h[g],h[g+1])}r[p].shape.closeStroke&&l.closePath()}}l.globalAlpha=t.alpha*o,l.strokeStyle=i,l.stroke()},e.prototype.paintEllipse=function(e,t,i,r,a,n){var o=2*e.width,l=2*e.height,s=e.x-o/2,h=e.y-l/2,v=.5522848,g=o/2*v,p=l/2*v,c=s+o,f=h+l,u=s+o/2,d=h+l/2;0===i.alignment&&n.save(),n.beginPath(),n.moveTo(s,d),n.bezierCurveTo(s,d-p,u-g,h,u,h),n.bezierCurveTo(u+g,h,c,d-p,c,d),n.bezierCurveTo(c,d+p,u+g,f,u,f),n.bezierCurveTo(u-g,f,s,d+p,s,d),n.closePath(),0===i.alignment&&n.clip(),t.visible&&(n.globalAlpha=t.alpha*a,n.fillStyle=r,n.fill()),0===i.alignment&&n.restore()},e.prototype.paintRoundedRectangle=function(e,t,i,r,a,n){var o=e.x,l=e.y,s=e.width,h=e.height,v=e.radius,g=Math.min(s,h)/2;v=v>g?g:v,0===i.alignment&&n.save(),n.beginPath(),n.moveTo(o,l+v),n.lineTo(o,l+h-v),n.quadraticCurveTo(o,l+h,o+v,l+h),n.lineTo(o+s-v,l+h),n.quadraticCurveTo(o+s,l+h,o+s,l+h-v),n.lineTo(o+s,l+v),n.quadraticCurveTo(o+s,l,o+s-v,l),n.lineTo(o+v,l),n.quadraticCurveTo(o,l,o,l+v),n.closePath(),0===i.alignment&&n.clip(),t.visible&&(n.globalAlpha=t.alpha*a,n.fillStyle=r,n.fill()),0===i.alignment&&n.restore()},e.prototype.setPatternTransform=function(e,t){if(!1!==this._svgMatrix){if(!this._svgMatrix){var i=document.createElementNS("http://www.w3.org/2000/svg","svg");if(i&&i.createSVGMatrix&&(this._svgMatrix=i.createSVGMatrix()),!this._svgMatrix||!e.setTransform)return void(this._svgMatrix=!1)}this._svgMatrix.a=t.a,this._svgMatrix.b=t.b,this._svgMatrix.c=t.c,this._svgMatrix.d=t.d,this._svgMatrix.e=t.tx,this._svgMatrix.f=t.ty,e.setTransform(this._svgMatrix.inverse())}},e.prototype.destroy=function(){this.renderer=null,this._svgMatrix=null,this._tempMatrix=null},e}(),l=new i.Matrix;a.Graphics.prototype.generateCanvasTexture=function(i,a){void 0===a&&(a=1);var n=this.getLocalBounds(),o=t.RenderTexture.create({width:n.width,height:n.height,scaleMode:i,resolution:a});e||(e=new r.CanvasRenderer),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(l),l.invert(),l.tx-=n.x,l.ty-=n.y,e.render(this,{renderTexture:o,clear:!0,transform:l});var s=t.Texture.from(o.baseTexture._canvasRenderTarget.canvas,{scaleMode:i});return s.baseTexture.setResolution(a),s},a.Graphics.prototype.cachedGraphicsData=[],a.Graphics.prototype._renderCanvas=function(e){!0!==this.isMask&&(this.finishPoly(),e.plugins.graphics.render(this))},exports.CanvasGraphicsRenderer=o; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("@pixi/core"),i=require("@pixi/math"),r=require("@pixi/canvas-renderer"),a=require("@pixi/graphics"),n=function(){function e(){}return e.offsetPolygon=function(t,i){var r=[],a=t.length;i=e.isPolygonClockwise(t)?i:-1*i;for(var n=0;n<a;n+=2){var o=n-2;o<0&&(o+=a);var l=(n+2)%a,s=t[n]-t[o],h=t[n+1]-t[o+1],v=Math.sqrt(s*s+h*h);s/=v,h/=v;var g=-(h*=i),p=s*=i,c=[t[o]+g,t[o+1]+p],f=[t[n]+g,t[n+1]+p],u=t[l]-t[n],d=t[l+1]-t[n+1];u/=v=Math.sqrt(u*u+d*d),d/=v;var T=-(d*=i),m=u*=i,x=[t[n]+T,t[n+1]+m],y=[t[l]+T,t[l+1]+m],b=e.findIntersection(c[0],c[1],f[0],f[1],x[0],x[1],y[0],y[1]);b&&r.push.apply(r,b)}return r},e.findIntersection=function(e,t,i,r,a,n,o,l){var s=(l-n)*(i-e)-(o-a)*(r-t),h=(o-a)*(t-n)-(l-n)*(e-a);if(0===s)return 0===h&&0===(i-e)*(t-n)-(r-t)*(e-a)?[(e+i)/2,(t+r)/2]:null;var v=h/s;return[e+v*(i-e),t+v*(r-t)]},e.isPolygonClockwise=function(e){for(var t=0,i=0,r=e.length-2;i<e.length;r=i,i+=2)t+=(e[i]-e[r])*(e[i+1]+e[r+1]);return t>0},e}(),o=function(){function e(e){this._svgMatrix=null,this._tempMatrix=new i.Matrix,this.renderer=e}return e.prototype._calcCanvasStyle=function(e,a){var n;return e.texture&&e.texture.baseTexture!==t.Texture.WHITE.baseTexture?e.texture.valid?(n=r.canvasUtils.getTintedPattern(e.texture,a),this.setPatternTransform(n,e.matrix||i.Matrix.IDENTITY)):n="#808080":n="#"+("00000"+(0|a).toString(16)).slice(-6),n},e.prototype.render=function(e){var t=this.renderer,r=t.context,a=e.worldAlpha,n=e.transform.worldTransform;t.setContextTransform(n),t.setBlendMode(e.blendMode);for(var o,l,s=e.geometry.graphicsData,h=(e.tint>>16&255)/255,v=(e.tint>>8&255)/255,g=(255&e.tint)/255,p=0;p<s.length;p++){var c=s[p],f=c.shape,u=c.fillStyle,d=c.lineStyle,T=0|c.fillStyle.color,m=0|c.lineStyle.color;if(c.matrix&&t.setContextTransform(n.copyTo(this._tempMatrix).append(c.matrix)),u.visible){var x=((T>>16&255)/255*h*255<<16)+((T>>8&255)/255*v*255<<8)+(255&T)/255*g*255;o=this._calcCanvasStyle(u,x)}if(d.visible){var y=((m>>16&255)/255*h*255<<16)+((m>>8&255)/255*v*255<<8)+(255&m)/255*g*255;l=this._calcCanvasStyle(d,y)}if(r.lineWidth=d.width,r.lineCap=d.cap,r.lineJoin=d.join,r.miterLimit=d.miterLimit,c.type===i.SHAPES.POLY){r.beginPath();var b=(A=f).points,P=c.holes,S=void 0,M=void 0,C=void 0,w=void 0,_=void 0;r.moveTo(b[0],b[1]);for(var k=2;k<b.length;k+=2)r.lineTo(b[k],b[k+1]);if(A.closeStroke&&r.closePath(),P.length>0){_=[],S=0,C=b[0],w=b[1];for(k=2;k+2<b.length;k+=2)S+=(b[k]-C)*(b[k+3]-w)-(b[k+2]-C)*(b[k+1]-w);for(var R=0;R<P.length;R++)if(b=P[R].shape.points){M=0,C=b[0],w=b[1];for(k=2;k+2<b.length;k+=2)M+=(b[k]-C)*(b[k+3]-w)-(b[k+2]-C)*(b[k+1]-w);if(M*S<0){r.moveTo(b[0],b[1]);for(k=2;k<b.length;k+=2)r.lineTo(b[k],b[k+1])}else{r.moveTo(b[b.length-2],b[b.length-1]);for(k=b.length-4;k>=0;k-=2)r.lineTo(b[k],b[k+1])}P[R].shape.closeStroke&&r.closePath(),_[R]=M*S<0}}u.visible&&(r.globalAlpha=u.alpha*a,r.fillStyle=o,r.fill()),d.visible&&this.paintPolygonStroke(A,d,l,P,_,a,r)}else if(c.type===i.SHAPES.RECT){var A=f;if(u.visible&&(r.globalAlpha=u.alpha*a,r.fillStyle=o,r.fillRect(A.x,A.y,A.width,A.height)),d.visible){var E=d.width*(.5-(1-d.alignment)),q=A.width+2*E,I=A.height+2*E;r.globalAlpha=d.alpha*a,r.strokeStyle=l,r.strokeRect(A.x-E,A.y-E,q,I)}}else if(c.type===i.SHAPES.CIRC){A=f;if(r.beginPath(),r.arc(A.x,A.y,A.radius,0,2*Math.PI),r.closePath(),u.visible&&(r.globalAlpha=u.alpha*a,r.fillStyle=o,r.fill()),d.visible){if(.5!==d.alignment){E=d.width*(.5-(1-d.alignment));r.beginPath(),r.arc(A.x,A.y,A.radius+E,0,2*Math.PI),r.closePath()}r.globalAlpha=d.alpha*a,r.strokeStyle=l,r.stroke()}}else if(c.type===i.SHAPES.ELIP){A=f;if((Y=1===d.alignment)||this.paintEllipse(A,u,d,o,a,r),d.visible){if(.5!==d.alignment){var z=.5522848,G=(E=d.width*(.5-(1-d.alignment)),2*(A.width+E)),H=2*(A.height+E),L=A.x-G/2,D=A.y-H/2,j=G/2*z,B=H/2*z,N=L+G,O=D+H,V=L+G/2,W=D+H/2;r.beginPath(),r.moveTo(L,W),r.bezierCurveTo(L,W-B,V-j,D,V,D),r.bezierCurveTo(V+j,D,N,W-B,N,W),r.bezierCurveTo(N,W+B,V+j,O,V,O),r.bezierCurveTo(V-j,O,L,W+B,L,W),r.closePath()}r.globalAlpha=d.alpha*a,r.strokeStyle=l,r.stroke()}Y&&this.paintEllipse(A,u,d,o,a,r)}else if(c.type===i.SHAPES.RREC){var Y;A=f;if((Y=1===d.alignment)||this.paintRoundedRectangle(A,u,d,o,a,r),d.visible){if(.5!==d.alignment){q=A.width,I=A.height,E=d.width*(.5-(1-d.alignment));var J=A.x-E,U=A.y-E,F=A.width+2*E,K=A.height+2*E,Q=E*(d.alignment>=1?Math.min(F/q,K/I):Math.min(q/F,I/K)),X=A.radius+Q,Z=Math.min(F,K)/2;X=X>Z?Z:X,r.beginPath(),r.moveTo(J,U+X),r.lineTo(J,U+K-X),r.quadraticCurveTo(J,U+K,J+X,U+K),r.lineTo(J+F-X,U+K),r.quadraticCurveTo(J+F,U+K,J+F,U+K-X),r.lineTo(J+F,U+X),r.quadraticCurveTo(J+F,U,J+F-X,U),r.lineTo(J+X,U),r.quadraticCurveTo(J,U,J,U+X),r.closePath()}r.globalAlpha=d.alpha*a,r.strokeStyle=l,r.stroke()}Y&&this.paintRoundedRectangle(A,u,d,o,a,r)}}},e.prototype.paintPolygonStroke=function(e,t,i,r,a,o,l){if(.5!==t.alignment){var s=t.width*(.5-(1-t.alignment)),h=n.offsetPolygon(e.points,s),v=void 0;l.beginPath(),l.moveTo(h[0],h[1]);for(var g=2;g<h.length;g+=2)l.lineTo(h[g],h[g+1]);e.closeStroke&&l.closePath();for(var p=0;p<r.length;p++){if(v=r[p].shape.points,h=n.offsetPolygon(v,s),a[p]){l.moveTo(h[0],h[1]);for(g=2;g<h.length;g+=2)l.lineTo(h[g],h[g+1])}else{l.moveTo(h[h.length-2],h[h.length-1]);for(g=h.length-4;g>=0;g-=2)l.lineTo(h[g],h[g+1])}r[p].shape.closeStroke&&l.closePath()}}l.globalAlpha=t.alpha*o,l.strokeStyle=i,l.stroke()},e.prototype.paintEllipse=function(e,t,i,r,a,n){var o=2*e.width,l=2*e.height,s=e.x-o/2,h=e.y-l/2,v=.5522848,g=o/2*v,p=l/2*v,c=s+o,f=h+l,u=s+o/2,d=h+l/2;0===i.alignment&&n.save(),n.beginPath(),n.moveTo(s,d),n.bezierCurveTo(s,d-p,u-g,h,u,h),n.bezierCurveTo(u+g,h,c,d-p,c,d),n.bezierCurveTo(c,d+p,u+g,f,u,f),n.bezierCurveTo(u-g,f,s,d+p,s,d),n.closePath(),0===i.alignment&&n.clip(),t.visible&&(n.globalAlpha=t.alpha*a,n.fillStyle=r,n.fill()),0===i.alignment&&n.restore()},e.prototype.paintRoundedRectangle=function(e,t,i,r,a,n){var o=e.x,l=e.y,s=e.width,h=e.height,v=e.radius,g=Math.min(s,h)/2;v=v>g?g:v,0===i.alignment&&n.save(),n.beginPath(),n.moveTo(o,l+v),n.lineTo(o,l+h-v),n.quadraticCurveTo(o,l+h,o+v,l+h),n.lineTo(o+s-v,l+h),n.quadraticCurveTo(o+s,l+h,o+s,l+h-v),n.lineTo(o+s,l+v),n.quadraticCurveTo(o+s,l,o+s-v,l),n.lineTo(o+v,l),n.quadraticCurveTo(o,l,o,l+v),n.closePath(),0===i.alignment&&n.clip(),t.visible&&(n.globalAlpha=t.alpha*a,n.fillStyle=r,n.fill()),0===i.alignment&&n.restore()},e.prototype.setPatternTransform=function(e,t){if(!1!==this._svgMatrix){if(!this._svgMatrix){var i=document.createElementNS("http://www.w3.org/2000/svg","svg");if(i&&i.createSVGMatrix&&(this._svgMatrix=i.createSVGMatrix()),!this._svgMatrix||!e.setTransform)return void(this._svgMatrix=!1)}this._svgMatrix.a=t.a,this._svgMatrix.b=t.b,this._svgMatrix.c=t.c,this._svgMatrix.d=t.d,this._svgMatrix.e=t.tx,this._svgMatrix.f=t.ty,e.setTransform(this._svgMatrix.inverse())}},e.prototype.destroy=function(){this.renderer=null,this._svgMatrix=null,this._tempMatrix=null},e.extension={name:"graphics",type:t.ExtensionType.CanvasRendererPlugin},e}(),l=new i.Matrix;a.Graphics.prototype.generateCanvasTexture=function(i,a){void 0===a&&(a=1);var n=this.getLocalBounds(),o=t.RenderTexture.create({width:n.width,height:n.height,scaleMode:i,resolution:a});e||(e=new r.CanvasRenderer),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(l),l.invert(),l.tx-=n.x,l.ty-=n.y,e.render(this,{renderTexture:o,clear:!0,transform:l});var s=t.Texture.from(o.baseTexture._canvasRenderTarget.canvas,{scaleMode:i});return s.baseTexture.setResolution(a),s},a.Graphics.prototype.cachedGraphicsData=[],a.Graphics.prototype._renderCanvas=function(e){!0!==this.isMask&&(this.finishPoly(),e.plugins.graphics.render(this))},exports.CanvasGraphicsRenderer=o; | ||
//# sourceMappingURL=canvas-graphics.min.js.map |
/*! | ||
* @pixi/canvas-graphics - v6.4.2 | ||
* Compiled Thu, 02 Jun 2022 15:39:26 UTC | ||
* @pixi/canvas-graphics - v6.5.0-rc | ||
* Compiled Thu, 14 Jul 2022 18:30:46 UTC | ||
* | ||
@@ -8,3 +8,3 @@ * @pixi/canvas-graphics is licensed under the MIT License. | ||
*/ | ||
import { Texture, RenderTexture } from '@pixi/core'; | ||
import { ExtensionType, Texture, RenderTexture } from '@pixi/core'; | ||
import { Matrix, SHAPES } from '@pixi/math'; | ||
@@ -558,2 +558,7 @@ import { canvasUtils, CanvasRenderer } from '@pixi/canvas-renderer'; | ||
}; | ||
/** @ignore */ | ||
CanvasGraphicsRenderer.extension = { | ||
name: 'graphics', | ||
type: ExtensionType.CanvasRendererPlugin, | ||
}; | ||
return CanvasGraphicsRenderer; | ||
@@ -560,0 +565,0 @@ }()); |
/*! | ||
* @pixi/canvas-graphics - v6.4.2 | ||
* Compiled Thu, 02 Jun 2022 15:39:26 UTC | ||
* @pixi/canvas-graphics - v6.5.0-rc | ||
* Compiled Thu, 14 Jul 2022 18:30:46 UTC | ||
* | ||
@@ -8,3 +8,3 @@ * @pixi/canvas-graphics is licensed under the MIT License. | ||
*/ | ||
import{Texture as e,RenderTexture as t}from"@pixi/core";import{Matrix as i,SHAPES as r}from"@pixi/math";import{canvasUtils as a,CanvasRenderer as o}from"@pixi/canvas-renderer";import{Graphics as l}from"@pixi/graphics";var n,s=function(){function e(){}return e.offsetPolygon=function(t,i){var r=[],a=t.length;i=e.isPolygonClockwise(t)?i:-1*i;for(var o=0;o<a;o+=2){var l=o-2;l<0&&(l+=a);var n=(o+2)%a,s=t[o]-t[l],h=t[o+1]-t[l+1],v=Math.sqrt(s*s+h*h);s/=v,h/=v;var g=-(h*=i),p=s*=i,f=[t[l]+g,t[l+1]+p],c=[t[o]+g,t[o+1]+p],u=t[n]-t[o],d=t[n+1]-t[o+1];u/=v=Math.sqrt(u*u+d*d),d/=v;var m=-(d*=i),T=u*=i,y=[t[o]+m,t[o+1]+T],x=[t[n]+m,t[n+1]+T],b=e.findIntersection(f[0],f[1],c[0],c[1],y[0],y[1],x[0],x[1]);b&&r.push.apply(r,b)}return r},e.findIntersection=function(e,t,i,r,a,o,l,n){var s=(n-o)*(i-e)-(l-a)*(r-t),h=(l-a)*(t-o)-(n-o)*(e-a);if(0===s)return 0===h&&0===(i-e)*(t-o)-(r-t)*(e-a)?[(e+i)/2,(t+r)/2]:null;var v=h/s;return[e+v*(i-e),t+v*(r-t)]},e.isPolygonClockwise=function(e){for(var t=0,i=0,r=e.length-2;i<e.length;r=i,i+=2)t+=(e[i]-e[r])*(e[i+1]+e[r+1]);return t>0},e}(),h=function(){function t(e){this._svgMatrix=null,this._tempMatrix=new i,this.renderer=e}return t.prototype._calcCanvasStyle=function(t,r){var o;return t.texture&&t.texture.baseTexture!==e.WHITE.baseTexture?t.texture.valid?(o=a.getTintedPattern(t.texture,r),this.setPatternTransform(o,t.matrix||i.IDENTITY)):o="#808080":o="#"+("00000"+(0|r).toString(16)).slice(-6),o},t.prototype.render=function(e){var t=this.renderer,i=t.context,a=e.worldAlpha,o=e.transform.worldTransform;t.setContextTransform(o),t.setBlendMode(e.blendMode);for(var l,n,s=e.geometry.graphicsData,h=(e.tint>>16&255)/255,v=(e.tint>>8&255)/255,g=(255&e.tint)/255,p=0;p<s.length;p++){var f=s[p],c=f.shape,u=f.fillStyle,d=f.lineStyle,m=0|f.fillStyle.color,T=0|f.lineStyle.color;if(f.matrix&&t.setContextTransform(o.copyTo(this._tempMatrix).append(f.matrix)),u.visible){var y=((m>>16&255)/255*h*255<<16)+((m>>8&255)/255*v*255<<8)+(255&m)/255*g*255;l=this._calcCanvasStyle(u,y)}if(d.visible){var x=((T>>16&255)/255*h*255<<16)+((T>>8&255)/255*v*255<<8)+(255&T)/255*g*255;n=this._calcCanvasStyle(d,x)}if(i.lineWidth=d.width,i.lineCap=d.cap,i.lineJoin=d.join,i.miterLimit=d.miterLimit,f.type===r.POLY){i.beginPath();var b=(A=c).points,P=f.holes,M=void 0,C=void 0,S=void 0,w=void 0,_=void 0;i.moveTo(b[0],b[1]);for(var k=2;k<b.length;k+=2)i.lineTo(b[k],b[k+1]);if(A.closeStroke&&i.closePath(),P.length>0){_=[],M=0,S=b[0],w=b[1];for(k=2;k+2<b.length;k+=2)M+=(b[k]-S)*(b[k+3]-w)-(b[k+2]-S)*(b[k+1]-w);for(var R=0;R<P.length;R++)if(b=P[R].shape.points){C=0,S=b[0],w=b[1];for(k=2;k+2<b.length;k+=2)C+=(b[k]-S)*(b[k+3]-w)-(b[k+2]-S)*(b[k+1]-w);if(C*M<0){i.moveTo(b[0],b[1]);for(k=2;k<b.length;k+=2)i.lineTo(b[k],b[k+1])}else{i.moveTo(b[b.length-2],b[b.length-1]);for(k=b.length-4;k>=0;k-=2)i.lineTo(b[k],b[k+1])}P[R].shape.closeStroke&&i.closePath(),_[R]=C*M<0}}u.visible&&(i.globalAlpha=u.alpha*a,i.fillStyle=l,i.fill()),d.visible&&this.paintPolygonStroke(A,d,n,P,_,a,i)}else if(f.type===r.RECT){var A=c;if(u.visible&&(i.globalAlpha=u.alpha*a,i.fillStyle=l,i.fillRect(A.x,A.y,A.width,A.height)),d.visible){var q=d.width*(.5-(1-d.alignment)),E=A.width+2*q,I=A.height+2*q;i.globalAlpha=d.alpha*a,i.strokeStyle=n,i.strokeRect(A.x-q,A.y-q,E,I)}}else if(f.type===r.CIRC){A=c;if(i.beginPath(),i.arc(A.x,A.y,A.radius,0,2*Math.PI),i.closePath(),u.visible&&(i.globalAlpha=u.alpha*a,i.fillStyle=l,i.fill()),d.visible){if(.5!==d.alignment){q=d.width*(.5-(1-d.alignment));i.beginPath(),i.arc(A.x,A.y,A.radius+q,0,2*Math.PI),i.closePath()}i.globalAlpha=d.alpha*a,i.strokeStyle=n,i.stroke()}}else if(f.type===r.ELIP){A=c;if((J=1===d.alignment)||this.paintEllipse(A,u,d,l,a,i),d.visible){if(.5!==d.alignment){var z=.5522848,L=(q=d.width*(.5-(1-d.alignment)),2*(A.width+q)),D=2*(A.height+q),G=A.x-L/2,B=A.y-D/2,N=L/2*z,V=D/2*z,W=G+L,Y=B+D,j=G+L/2,H=B+D/2;i.beginPath(),i.moveTo(G,H),i.bezierCurveTo(G,H-V,j-N,B,j,B),i.bezierCurveTo(j+N,B,W,H-V,W,H),i.bezierCurveTo(W,H+V,j+N,Y,j,Y),i.bezierCurveTo(j-N,Y,G,H+V,G,H),i.closePath()}i.globalAlpha=d.alpha*a,i.strokeStyle=n,i.stroke()}J&&this.paintEllipse(A,u,d,l,a,i)}else if(f.type===r.RREC){var J;A=c;if((J=1===d.alignment)||this.paintRoundedRectangle(A,u,d,l,a,i),d.visible){if(.5!==d.alignment){E=A.width,I=A.height,q=d.width*(.5-(1-d.alignment));var O=A.x-q,F=A.y-q,K=A.width+2*q,Q=A.height+2*q,U=q*(d.alignment>=1?Math.min(K/E,Q/I):Math.min(E/K,I/Q)),X=A.radius+U,Z=Math.min(K,Q)/2;X=X>Z?Z:X,i.beginPath(),i.moveTo(O,F+X),i.lineTo(O,F+Q-X),i.quadraticCurveTo(O,F+Q,O+X,F+Q),i.lineTo(O+K-X,F+Q),i.quadraticCurveTo(O+K,F+Q,O+K,F+Q-X),i.lineTo(O+K,F+X),i.quadraticCurveTo(O+K,F,O+K-X,F),i.lineTo(O+X,F),i.quadraticCurveTo(O,F,O,F+X),i.closePath()}i.globalAlpha=d.alpha*a,i.strokeStyle=n,i.stroke()}J&&this.paintRoundedRectangle(A,u,d,l,a,i)}}},t.prototype.paintPolygonStroke=function(e,t,i,r,a,o,l){if(.5!==t.alignment){var n=t.width*(.5-(1-t.alignment)),h=s.offsetPolygon(e.points,n),v=void 0;l.beginPath(),l.moveTo(h[0],h[1]);for(var g=2;g<h.length;g+=2)l.lineTo(h[g],h[g+1]);e.closeStroke&&l.closePath();for(var p=0;p<r.length;p++){if(v=r[p].shape.points,h=s.offsetPolygon(v,n),a[p]){l.moveTo(h[0],h[1]);for(g=2;g<h.length;g+=2)l.lineTo(h[g],h[g+1])}else{l.moveTo(h[h.length-2],h[h.length-1]);for(g=h.length-4;g>=0;g-=2)l.lineTo(h[g],h[g+1])}r[p].shape.closeStroke&&l.closePath()}}l.globalAlpha=t.alpha*o,l.strokeStyle=i,l.stroke()},t.prototype.paintEllipse=function(e,t,i,r,a,o){var l=2*e.width,n=2*e.height,s=e.x-l/2,h=e.y-n/2,v=.5522848,g=l/2*v,p=n/2*v,f=s+l,c=h+n,u=s+l/2,d=h+n/2;0===i.alignment&&o.save(),o.beginPath(),o.moveTo(s,d),o.bezierCurveTo(s,d-p,u-g,h,u,h),o.bezierCurveTo(u+g,h,f,d-p,f,d),o.bezierCurveTo(f,d+p,u+g,c,u,c),o.bezierCurveTo(u-g,c,s,d+p,s,d),o.closePath(),0===i.alignment&&o.clip(),t.visible&&(o.globalAlpha=t.alpha*a,o.fillStyle=r,o.fill()),0===i.alignment&&o.restore()},t.prototype.paintRoundedRectangle=function(e,t,i,r,a,o){var l=e.x,n=e.y,s=e.width,h=e.height,v=e.radius,g=Math.min(s,h)/2;v=v>g?g:v,0===i.alignment&&o.save(),o.beginPath(),o.moveTo(l,n+v),o.lineTo(l,n+h-v),o.quadraticCurveTo(l,n+h,l+v,n+h),o.lineTo(l+s-v,n+h),o.quadraticCurveTo(l+s,n+h,l+s,n+h-v),o.lineTo(l+s,n+v),o.quadraticCurveTo(l+s,n,l+s-v,n),o.lineTo(l+v,n),o.quadraticCurveTo(l,n,l,n+v),o.closePath(),0===i.alignment&&o.clip(),t.visible&&(o.globalAlpha=t.alpha*a,o.fillStyle=r,o.fill()),0===i.alignment&&o.restore()},t.prototype.setPatternTransform=function(e,t){if(!1!==this._svgMatrix){if(!this._svgMatrix){var i=document.createElementNS("http://www.w3.org/2000/svg","svg");if(i&&i.createSVGMatrix&&(this._svgMatrix=i.createSVGMatrix()),!this._svgMatrix||!e.setTransform)return void(this._svgMatrix=!1)}this._svgMatrix.a=t.a,this._svgMatrix.b=t.b,this._svgMatrix.c=t.c,this._svgMatrix.d=t.d,this._svgMatrix.e=t.tx,this._svgMatrix.f=t.ty,e.setTransform(this._svgMatrix.inverse())}},t.prototype.destroy=function(){this.renderer=null,this._svgMatrix=null,this._tempMatrix=null},t}(),v=new i;l.prototype.generateCanvasTexture=function(i,r){void 0===r&&(r=1);var a=this.getLocalBounds(),l=t.create({width:a.width,height:a.height,scaleMode:i,resolution:r});n||(n=new o),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(v),v.invert(),v.tx-=a.x,v.ty-=a.y,n.render(this,{renderTexture:l,clear:!0,transform:v});var s=e.from(l.baseTexture._canvasRenderTarget.canvas,{scaleMode:i});return s.baseTexture.setResolution(r),s},l.prototype.cachedGraphicsData=[],l.prototype._renderCanvas=function(e){!0!==this.isMask&&(this.finishPoly(),e.plugins.graphics.render(this))};export{h as CanvasGraphicsRenderer}; | ||
import{ExtensionType as e,Texture as t,RenderTexture as i}from"@pixi/core";import{Matrix as r,SHAPES as a}from"@pixi/math";import{canvasUtils as o,CanvasRenderer as n}from"@pixi/canvas-renderer";import{Graphics as l}from"@pixi/graphics";var s,h=function(){function e(){}return e.offsetPolygon=function(t,i){var r=[],a=t.length;i=e.isPolygonClockwise(t)?i:-1*i;for(var o=0;o<a;o+=2){var n=o-2;n<0&&(n+=a);var l=(o+2)%a,s=t[o]-t[n],h=t[o+1]-t[n+1],v=Math.sqrt(s*s+h*h);s/=v,h/=v;var g=-(h*=i),p=s*=i,f=[t[n]+g,t[n+1]+p],c=[t[o]+g,t[o+1]+p],u=t[l]-t[o],d=t[l+1]-t[o+1];u/=v=Math.sqrt(u*u+d*d),d/=v;var m=-(d*=i),T=u*=i,y=[t[o]+m,t[o+1]+T],x=[t[l]+m,t[l+1]+T],b=e.findIntersection(f[0],f[1],c[0],c[1],y[0],y[1],x[0],x[1]);b&&r.push.apply(r,b)}return r},e.findIntersection=function(e,t,i,r,a,o,n,l){var s=(l-o)*(i-e)-(n-a)*(r-t),h=(n-a)*(t-o)-(l-o)*(e-a);if(0===s)return 0===h&&0===(i-e)*(t-o)-(r-t)*(e-a)?[(e+i)/2,(t+r)/2]:null;var v=h/s;return[e+v*(i-e),t+v*(r-t)]},e.isPolygonClockwise=function(e){for(var t=0,i=0,r=e.length-2;i<e.length;r=i,i+=2)t+=(e[i]-e[r])*(e[i+1]+e[r+1]);return t>0},e}(),v=function(){function i(e){this._svgMatrix=null,this._tempMatrix=new r,this.renderer=e}return i.prototype._calcCanvasStyle=function(e,i){var a;return e.texture&&e.texture.baseTexture!==t.WHITE.baseTexture?e.texture.valid?(a=o.getTintedPattern(e.texture,i),this.setPatternTransform(a,e.matrix||r.IDENTITY)):a="#808080":a="#"+("00000"+(0|i).toString(16)).slice(-6),a},i.prototype.render=function(e){var t=this.renderer,i=t.context,r=e.worldAlpha,o=e.transform.worldTransform;t.setContextTransform(o),t.setBlendMode(e.blendMode);for(var n,l,s=e.geometry.graphicsData,h=(e.tint>>16&255)/255,v=(e.tint>>8&255)/255,g=(255&e.tint)/255,p=0;p<s.length;p++){var f=s[p],c=f.shape,u=f.fillStyle,d=f.lineStyle,m=0|f.fillStyle.color,T=0|f.lineStyle.color;if(f.matrix&&t.setContextTransform(o.copyTo(this._tempMatrix).append(f.matrix)),u.visible){var y=((m>>16&255)/255*h*255<<16)+((m>>8&255)/255*v*255<<8)+(255&m)/255*g*255;n=this._calcCanvasStyle(u,y)}if(d.visible){var x=((T>>16&255)/255*h*255<<16)+((T>>8&255)/255*v*255<<8)+(255&T)/255*g*255;l=this._calcCanvasStyle(d,x)}if(i.lineWidth=d.width,i.lineCap=d.cap,i.lineJoin=d.join,i.miterLimit=d.miterLimit,f.type===a.POLY){i.beginPath();var b=(A=c).points,P=f.holes,M=void 0,C=void 0,S=void 0,w=void 0,_=void 0;i.moveTo(b[0],b[1]);for(var k=2;k<b.length;k+=2)i.lineTo(b[k],b[k+1]);if(A.closeStroke&&i.closePath(),P.length>0){_=[],M=0,S=b[0],w=b[1];for(k=2;k+2<b.length;k+=2)M+=(b[k]-S)*(b[k+3]-w)-(b[k+2]-S)*(b[k+1]-w);for(var R=0;R<P.length;R++)if(b=P[R].shape.points){C=0,S=b[0],w=b[1];for(k=2;k+2<b.length;k+=2)C+=(b[k]-S)*(b[k+3]-w)-(b[k+2]-S)*(b[k+1]-w);if(C*M<0){i.moveTo(b[0],b[1]);for(k=2;k<b.length;k+=2)i.lineTo(b[k],b[k+1])}else{i.moveTo(b[b.length-2],b[b.length-1]);for(k=b.length-4;k>=0;k-=2)i.lineTo(b[k],b[k+1])}P[R].shape.closeStroke&&i.closePath(),_[R]=C*M<0}}u.visible&&(i.globalAlpha=u.alpha*r,i.fillStyle=n,i.fill()),d.visible&&this.paintPolygonStroke(A,d,l,P,_,r,i)}else if(f.type===a.RECT){var A=c;if(u.visible&&(i.globalAlpha=u.alpha*r,i.fillStyle=n,i.fillRect(A.x,A.y,A.width,A.height)),d.visible){var q=d.width*(.5-(1-d.alignment)),E=A.width+2*q,I=A.height+2*q;i.globalAlpha=d.alpha*r,i.strokeStyle=l,i.strokeRect(A.x-q,A.y-q,E,I)}}else if(f.type===a.CIRC){A=c;if(i.beginPath(),i.arc(A.x,A.y,A.radius,0,2*Math.PI),i.closePath(),u.visible&&(i.globalAlpha=u.alpha*r,i.fillStyle=n,i.fill()),d.visible){if(.5!==d.alignment){q=d.width*(.5-(1-d.alignment));i.beginPath(),i.arc(A.x,A.y,A.radius+q,0,2*Math.PI),i.closePath()}i.globalAlpha=d.alpha*r,i.strokeStyle=l,i.stroke()}}else if(f.type===a.ELIP){A=c;if((J=1===d.alignment)||this.paintEllipse(A,u,d,n,r,i),d.visible){if(.5!==d.alignment){var z=.5522848,L=(q=d.width*(.5-(1-d.alignment)),2*(A.width+q)),D=2*(A.height+q),G=A.x-L/2,B=A.y-D/2,N=L/2*z,V=D/2*z,W=G+L,Y=B+D,j=G+L/2,H=B+D/2;i.beginPath(),i.moveTo(G,H),i.bezierCurveTo(G,H-V,j-N,B,j,B),i.bezierCurveTo(j+N,B,W,H-V,W,H),i.bezierCurveTo(W,H+V,j+N,Y,j,Y),i.bezierCurveTo(j-N,Y,G,H+V,G,H),i.closePath()}i.globalAlpha=d.alpha*r,i.strokeStyle=l,i.stroke()}J&&this.paintEllipse(A,u,d,n,r,i)}else if(f.type===a.RREC){var J;A=c;if((J=1===d.alignment)||this.paintRoundedRectangle(A,u,d,n,r,i),d.visible){if(.5!==d.alignment){E=A.width,I=A.height,q=d.width*(.5-(1-d.alignment));var O=A.x-q,F=A.y-q,K=A.width+2*q,Q=A.height+2*q,U=q*(d.alignment>=1?Math.min(K/E,Q/I):Math.min(E/K,I/Q)),X=A.radius+U,Z=Math.min(K,Q)/2;X=X>Z?Z:X,i.beginPath(),i.moveTo(O,F+X),i.lineTo(O,F+Q-X),i.quadraticCurveTo(O,F+Q,O+X,F+Q),i.lineTo(O+K-X,F+Q),i.quadraticCurveTo(O+K,F+Q,O+K,F+Q-X),i.lineTo(O+K,F+X),i.quadraticCurveTo(O+K,F,O+K-X,F),i.lineTo(O+X,F),i.quadraticCurveTo(O,F,O,F+X),i.closePath()}i.globalAlpha=d.alpha*r,i.strokeStyle=l,i.stroke()}J&&this.paintRoundedRectangle(A,u,d,n,r,i)}}},i.prototype.paintPolygonStroke=function(e,t,i,r,a,o,n){if(.5!==t.alignment){var l=t.width*(.5-(1-t.alignment)),s=h.offsetPolygon(e.points,l),v=void 0;n.beginPath(),n.moveTo(s[0],s[1]);for(var g=2;g<s.length;g+=2)n.lineTo(s[g],s[g+1]);e.closeStroke&&n.closePath();for(var p=0;p<r.length;p++){if(v=r[p].shape.points,s=h.offsetPolygon(v,l),a[p]){n.moveTo(s[0],s[1]);for(g=2;g<s.length;g+=2)n.lineTo(s[g],s[g+1])}else{n.moveTo(s[s.length-2],s[s.length-1]);for(g=s.length-4;g>=0;g-=2)n.lineTo(s[g],s[g+1])}r[p].shape.closeStroke&&n.closePath()}}n.globalAlpha=t.alpha*o,n.strokeStyle=i,n.stroke()},i.prototype.paintEllipse=function(e,t,i,r,a,o){var n=2*e.width,l=2*e.height,s=e.x-n/2,h=e.y-l/2,v=.5522848,g=n/2*v,p=l/2*v,f=s+n,c=h+l,u=s+n/2,d=h+l/2;0===i.alignment&&o.save(),o.beginPath(),o.moveTo(s,d),o.bezierCurveTo(s,d-p,u-g,h,u,h),o.bezierCurveTo(u+g,h,f,d-p,f,d),o.bezierCurveTo(f,d+p,u+g,c,u,c),o.bezierCurveTo(u-g,c,s,d+p,s,d),o.closePath(),0===i.alignment&&o.clip(),t.visible&&(o.globalAlpha=t.alpha*a,o.fillStyle=r,o.fill()),0===i.alignment&&o.restore()},i.prototype.paintRoundedRectangle=function(e,t,i,r,a,o){var n=e.x,l=e.y,s=e.width,h=e.height,v=e.radius,g=Math.min(s,h)/2;v=v>g?g:v,0===i.alignment&&o.save(),o.beginPath(),o.moveTo(n,l+v),o.lineTo(n,l+h-v),o.quadraticCurveTo(n,l+h,n+v,l+h),o.lineTo(n+s-v,l+h),o.quadraticCurveTo(n+s,l+h,n+s,l+h-v),o.lineTo(n+s,l+v),o.quadraticCurveTo(n+s,l,n+s-v,l),o.lineTo(n+v,l),o.quadraticCurveTo(n,l,n,l+v),o.closePath(),0===i.alignment&&o.clip(),t.visible&&(o.globalAlpha=t.alpha*a,o.fillStyle=r,o.fill()),0===i.alignment&&o.restore()},i.prototype.setPatternTransform=function(e,t){if(!1!==this._svgMatrix){if(!this._svgMatrix){var i=document.createElementNS("http://www.w3.org/2000/svg","svg");if(i&&i.createSVGMatrix&&(this._svgMatrix=i.createSVGMatrix()),!this._svgMatrix||!e.setTransform)return void(this._svgMatrix=!1)}this._svgMatrix.a=t.a,this._svgMatrix.b=t.b,this._svgMatrix.c=t.c,this._svgMatrix.d=t.d,this._svgMatrix.e=t.tx,this._svgMatrix.f=t.ty,e.setTransform(this._svgMatrix.inverse())}},i.prototype.destroy=function(){this.renderer=null,this._svgMatrix=null,this._tempMatrix=null},i.extension={name:"graphics",type:e.CanvasRendererPlugin},i}(),g=new r;l.prototype.generateCanvasTexture=function(e,r){void 0===r&&(r=1);var a=this.getLocalBounds(),o=i.create({width:a.width,height:a.height,scaleMode:e,resolution:r});s||(s=new n),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(g),g.invert(),g.tx-=a.x,g.ty-=a.y,s.render(this,{renderTexture:o,clear:!0,transform:g});var l=t.from(o.baseTexture._canvasRenderTarget.canvas,{scaleMode:e});return l.baseTexture.setResolution(r),l},l.prototype.cachedGraphicsData=[],l.prototype._renderCanvas=function(e){!0!==this.isMask&&(this.finishPoly(),e.plugins.graphics.render(this))};export{v as CanvasGraphicsRenderer}; | ||
//# sourceMappingURL=canvas-graphics.min.js.map |
/// <reference path="./global.d.ts" /> | ||
import type { CanvasRenderer } from '@pixi/canvas-renderer'; | ||
import type { ExtensionMetadata } from '@pixi/core'; | ||
import type { Graphics } from '@pixi/graphics'; | ||
@@ -14,2 +15,4 @@ import { Matrix } from '@pixi/math'; | ||
export declare class CanvasGraphicsRenderer { | ||
/** @ignore */ | ||
static extension: ExtensionMetadata; | ||
/** A reference to the current renderer */ | ||
@@ -16,0 +19,0 @@ renderer: CanvasRenderer; |
{ | ||
"name": "@pixi/canvas-graphics", | ||
"version": "6.4.2", | ||
"version": "6.5.0-rc", | ||
"main": "dist/cjs/canvas-graphics.js", | ||
@@ -41,10 +41,10 @@ "module": "dist/esm/canvas-graphics.js", | ||
"peerDependencies": { | ||
"@pixi/canvas-display": "6.4.2", | ||
"@pixi/canvas-renderer": "6.4.2", | ||
"@pixi/constants": "6.4.2", | ||
"@pixi/core": "6.4.2", | ||
"@pixi/graphics": "6.4.2", | ||
"@pixi/math": "6.4.2" | ||
"@pixi/canvas-display": "6.5.0-rc", | ||
"@pixi/canvas-renderer": "6.5.0-rc", | ||
"@pixi/constants": "6.5.0-rc", | ||
"@pixi/core": "6.5.0-rc", | ||
"@pixi/graphics": "6.5.0-rc", | ||
"@pixi/math": "6.5.0-rc" | ||
}, | ||
"gitHead": "a87bb87036d5fb9119ee92fd9c3da23b5bb9424b" | ||
"gitHead": "16005f83e7a6d87831ce84f8a6d460606a331ef6" | ||
} |
@@ -13,5 +13,5 @@ # @pixi/canvas-graphics | ||
import { CanvasGraphicsRenderer } from '@pixi/canvas-graphics'; | ||
import { CanvasRenderer } from '@pixi/canvas-renderer'; | ||
import { extensions } from '@pixi/core'; | ||
CanvasRenderer.registerPlugin('graphics', CanvasGraphicsRenderer); | ||
extensions.add(CanvasGraphicsRenderer); | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
414028
2043
2