@pixi/canvas-graphics
Advanced tools
Comparing version 6.1.0-rc.4 to 6.1.0-rc.5
/*! | ||
* @pixi/canvas-graphics - v6.1.0-rc.4 | ||
* Compiled Tue, 29 Jun 2021 17:40:45 UTC | ||
* @pixi/canvas-graphics - v6.1.0-rc.5 | ||
* Compiled Mon, 19 Jul 2021 20:32:18 UTC | ||
* | ||
@@ -140,8 +140,8 @@ * @pixi/canvas-graphics is licensed under the MIT License. | ||
/** | ||
* @param {PIXI.CanvasRenderer} renderer - The current PIXI renderer. | ||
* @param renderer - A reference to the current renderer. | ||
*/ | ||
function CanvasGraphicsRenderer(renderer) { | ||
this.renderer = renderer; | ||
this._svgMatrix = null; | ||
this._tempMatrix = new math.Matrix(); | ||
this.renderer = renderer; | ||
} | ||
@@ -152,5 +152,5 @@ /** | ||
* @private | ||
* @param {PIXI.FillStyle} style | ||
* @param {number} tint | ||
* @returns {string|CanvasPattern} | ||
* @param style - A graphics {@link PIXI.FILL_STYLE} where if `texture` is specified then a tinted CanvasPattern | ||
* will be used for the fill.stroke | ||
* @param tint - color to set the fill/stroke too. | ||
*/ | ||
@@ -176,3 +176,3 @@ CanvasGraphicsRenderer.prototype._calcCanvasStyle = function (style, tint) { | ||
* | ||
* @param {PIXI.Graphics} graphics - the actual graphics object to render | ||
* @param graphics - the actual graphics object to render | ||
*/ | ||
@@ -404,9 +404,9 @@ CanvasGraphicsRenderer.prototype.render = function (graphics) { | ||
* @private | ||
* @param {PIXI.Polygon} shape | ||
* @param {PIXI.LineStyle} lineStyle | ||
* @param {string|PIXI.CanvasPattern} contextStrokeStyle | ||
* @param {GraphicsData[]} holes | ||
* @param {boolean[]} holesDirection | ||
* @param {number} worldAlpha | ||
* @param {PIXI.CrossPlatformCanvasRenderingContext2D} context | ||
* @param shape - Shape to be drawn | ||
* @param lineStyle - Line style for the shape | ||
* @param contextStrokeStyle - The strokeStyle for the canvas context | ||
* @param holes - Holes to be added to the shape | ||
* @param holesDirection - | ||
* @param worldAlpha - The multiplied alpha of the displayObject | ||
* @param context - The canvas context | ||
*/ | ||
@@ -454,8 +454,8 @@ CanvasGraphicsRenderer.prototype.paintPolygonStroke = function (shape, lineStyle, contextStrokeStyle, holes, holesDirection, worldAlpha, context) { | ||
* @private | ||
* @param {PIXI.Ellipse} shape | ||
* @param {PIXI.FillStyle} fillStyle | ||
* @param {PIXI.LineStyle} lineStyle | ||
* @param {string|PIXI.CanvasPattern} contextFillStyle | ||
* @param {number} worldAlpha | ||
* @param {PIXI.CrossPlatformCanvasRenderingContext2D} context | ||
* @param shape - Shape to be drawn | ||
* @param fillStyle - Fill for the shape | ||
* @param lineStyle - Line style for the shape | ||
* @param contextFillStyle - The canvas context fill style | ||
* @param worldAlpha - The multiplied alpha of the displayObject | ||
* @param context - The canvas context | ||
*/ | ||
@@ -495,8 +495,8 @@ CanvasGraphicsRenderer.prototype.paintEllipse = function (shape, fillStyle, lineStyle, contextFillStyle, worldAlpha, context) { | ||
* @private | ||
* @param {PIXI.RoundedRectangle} shape | ||
* @param {PIXI.FillStyle} fillStyle | ||
* @param {PIXI.LineStyle} lineStyle | ||
* @param {string|PIXI.CanvasPattern} contextFillStyle | ||
* @param {number} worldAlpha | ||
* @param {PIXI.CrossPlatformCanvasRenderingContext2D} context | ||
* @param shape - Shape to be drawn | ||
* @param fillStyle - Fill for the shape | ||
* @param lineStyle - Line style for the shape | ||
* @param contextFillStyle - The canvas context fill style | ||
* @param worldAlpha - The multiplied alpha of the displayObject | ||
* @param context - The canvas context | ||
*/ | ||
@@ -553,6 +553,3 @@ CanvasGraphicsRenderer.prototype.paintRoundedRectangle = function (shape, fillStyle, lineStyle, contextFillStyle, worldAlpha, context) { | ||
}; | ||
/** | ||
* destroy graphics object | ||
* | ||
*/ | ||
/** destroy graphics object */ | ||
CanvasGraphicsRenderer.prototype.destroy = function () { | ||
@@ -559,0 +556,0 @@ this.renderer = null; |
/*! | ||
* @pixi/canvas-graphics - v6.1.0-rc.4 | ||
* Compiled Tue, 29 Jun 2021 17:40:45 UTC | ||
* @pixi/canvas-graphics - v6.1.0-rc.5 | ||
* Compiled Mon, 19 Jul 2021 20:32:18 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,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),y=u*=i,m=[t[n]+T,t[n+1]+y],x=[t[l]+T,t[l+1]+y],b=e.findIntersection(p[0],p[1],f[0],f[1],m[0],m[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;i<e.length-2;i+=2)t+=(e[i+2]-e[i])*(e[i+3]+e[i+1]);return t>0},e}(),l=function(){function e(e){this.renderer=e,this._svgMatrix=null,this._tempMatrix=new i.Matrix}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)).substr(-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,y=0|p.lineStyle.color;if(p.matrix&&t.setContextTransform(n.copyTo(this._tempMatrix).append(p.matrix)),u.visible){var m=((T>>16&255)/255*h*255<<16)+((T>>8&255)/255*v*255<<8)+(255&T)/255*g*255;o=this._calcCanvasStyle(u,m)}if(d.visible){var x=((y>>16&255)/255*h*255<<16)+((y>>8&255)/255*v*255<<8)+(255&y)/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((V=1===d.alignment)||this.paintEllipse(R,u,d,o,r,a),d.visible){if(.5!==d.alignment){A=d.width*(.5-(1-d.alignment));var z=2*(R.width+A),G=2*(R.height+A),X=R.x-z/2,H=R.y-G/2,L=z/2*.5522848,D=G/2*.5522848,j=X+z,B=H+G,N=X+z/2,O=H+G/2;a.beginPath(),a.moveTo(X,O),a.bezierCurveTo(X,O-D,N-L,H,N,H),a.bezierCurveTo(N+L,H,j,O-D,j,O),a.bezierCurveTo(j,O+D,N+L,B,N,B),a.bezierCurveTo(N-L,B,X,O+D,X,O),a.closePath()}a.globalAlpha=d.alpha*r,a.strokeStyle=l,a.stroke()}V&&this.paintEllipse(R,u,d,o,r,a)}else if(p.type===i.SHAPES.RREC){var V;R=f;if((V=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 W=R.x-A,Y=R.y-A,J=R.width+2*A,U=R.height+2*A,F=A*(d.alignment>=1?Math.min(J/E,U/q):Math.min(E/J,q/U)),K=R.radius+F,Q=Math.min(J,U)/2|0;K=K>Q?Q:K,a.beginPath(),a.moveTo(W,Y+K),a.lineTo(W,Y+U-K),a.quadraticCurveTo(W,Y+U,W+K,Y+U),a.lineTo(W+J-K,Y+U),a.quadraticCurveTo(W+J,Y+U,W+J,Y+U-K),a.lineTo(W+J,Y+K),a.quadraticCurveTo(W+J,Y,W+J-K,Y),a.lineTo(W+K,Y),a.quadraticCurveTo(W,Y,W,Y+K),a.closePath()}a.globalAlpha=d.alpha*r,a.strokeStyle=l,a.stroke()}V&&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=o/2*.5522848,g=l/2*.5522848,c=s+o,p=h+l,f=s+o/2,u=h+l/2;n.beginPath(),n.moveTo(s,u),n.bezierCurveTo(s,u-g,f-v,h,f,h),n.bezierCurveTo(f+v,h,c,u-g,c,u),n.bezierCurveTo(c,u+g,f+v,p,f,p),n.bezierCurveTo(f-v,p,s,u+g,s,u),n.closePath(),0===i.alignment&&n.clip(),t.visible&&(n.globalAlpha=t.alpha*r,n.fillStyle=a,n.fill())},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|0;v=v>g?g:v,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())},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(),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,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),y=u*=i,m=[t[n]+T,t[n+1]+y],x=[t[l]+T,t[l+1]+y],b=e.findIntersection(p[0],p[1],f[0],f[1],m[0],m[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;i<e.length-2;i+=2)t+=(e[i+2]-e[i])*(e[i+3]+e[i+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)).substr(-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,y=0|p.lineStyle.color;if(p.matrix&&t.setContextTransform(n.copyTo(this._tempMatrix).append(p.matrix)),u.visible){var m=((T>>16&255)/255*h*255<<16)+((T>>8&255)/255*v*255<<8)+(255&T)/255*g*255;o=this._calcCanvasStyle(u,m)}if(d.visible){var x=((y>>16&255)/255*h*255<<16)+((y>>8&255)/255*v*255<<8)+(255&y)/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((V=1===d.alignment)||this.paintEllipse(R,u,d,o,r,a),d.visible){if(.5!==d.alignment){A=d.width*(.5-(1-d.alignment));var z=2*(R.width+A),G=2*(R.height+A),X=R.x-z/2,H=R.y-G/2,L=z/2*.5522848,D=G/2*.5522848,j=X+z,B=H+G,N=X+z/2,O=H+G/2;a.beginPath(),a.moveTo(X,O),a.bezierCurveTo(X,O-D,N-L,H,N,H),a.bezierCurveTo(N+L,H,j,O-D,j,O),a.bezierCurveTo(j,O+D,N+L,B,N,B),a.bezierCurveTo(N-L,B,X,O+D,X,O),a.closePath()}a.globalAlpha=d.alpha*r,a.strokeStyle=l,a.stroke()}V&&this.paintEllipse(R,u,d,o,r,a)}else if(p.type===i.SHAPES.RREC){var V;R=f;if((V=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 W=R.x-A,Y=R.y-A,J=R.width+2*A,U=R.height+2*A,F=A*(d.alignment>=1?Math.min(J/E,U/q):Math.min(E/J,q/U)),K=R.radius+F,Q=Math.min(J,U)/2|0;K=K>Q?Q:K,a.beginPath(),a.moveTo(W,Y+K),a.lineTo(W,Y+U-K),a.quadraticCurveTo(W,Y+U,W+K,Y+U),a.lineTo(W+J-K,Y+U),a.quadraticCurveTo(W+J,Y+U,W+J,Y+U-K),a.lineTo(W+J,Y+K),a.quadraticCurveTo(W+J,Y,W+J-K,Y),a.lineTo(W+K,Y),a.quadraticCurveTo(W,Y,W,Y+K),a.closePath()}a.globalAlpha=d.alpha*r,a.strokeStyle=l,a.stroke()}V&&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=o/2*.5522848,g=l/2*.5522848,c=s+o,p=h+l,f=s+o/2,u=h+l/2;n.beginPath(),n.moveTo(s,u),n.bezierCurveTo(s,u-g,f-v,h,f,h),n.bezierCurveTo(f+v,h,c,u-g,c,u),n.bezierCurveTo(c,u+g,f+v,p,f,p),n.bezierCurveTo(f-v,p,s,u+g,s,u),n.closePath(),0===i.alignment&&n.clip(),t.visible&&(n.globalAlpha=t.alpha*r,n.fillStyle=a,n.fill())},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|0;v=v>g?g:v,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())},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(),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,e}({},PIXI,PIXI,PIXI,PIXI);Object.assign(this.PIXI,_pixi_canvas_graphics); | ||
//# sourceMappingURL=canvas-graphics.min.js.map |
/*! | ||
* @pixi/canvas-graphics - v6.1.0-rc.4 | ||
* Compiled Tue, 29 Jun 2021 17:40:45 UTC | ||
* @pixi/canvas-graphics - v6.1.0-rc.5 | ||
* Compiled Mon, 19 Jul 2021 20:32:18 UTC | ||
* | ||
@@ -145,8 +145,8 @@ * @pixi/canvas-graphics is licensed under the MIT License. | ||
/** | ||
* @param {PIXI.CanvasRenderer} renderer - The current PIXI renderer. | ||
* @param renderer - A reference to the current renderer. | ||
*/ | ||
function CanvasGraphicsRenderer(renderer) { | ||
this.renderer = renderer; | ||
this._svgMatrix = null; | ||
this._tempMatrix = new math.Matrix(); | ||
this.renderer = renderer; | ||
} | ||
@@ -157,5 +157,5 @@ /** | ||
* @private | ||
* @param {PIXI.FillStyle} style | ||
* @param {number} tint | ||
* @returns {string|CanvasPattern} | ||
* @param style - A graphics {@link PIXI.FILL_STYLE} where if `texture` is specified then a tinted CanvasPattern | ||
* will be used for the fill.stroke | ||
* @param tint - color to set the fill/stroke too. | ||
*/ | ||
@@ -181,3 +181,3 @@ CanvasGraphicsRenderer.prototype._calcCanvasStyle = function (style, tint) { | ||
* | ||
* @param {PIXI.Graphics} graphics - the actual graphics object to render | ||
* @param graphics - the actual graphics object to render | ||
*/ | ||
@@ -409,9 +409,9 @@ CanvasGraphicsRenderer.prototype.render = function (graphics) { | ||
* @private | ||
* @param {PIXI.Polygon} shape | ||
* @param {PIXI.LineStyle} lineStyle | ||
* @param {string|PIXI.CanvasPattern} contextStrokeStyle | ||
* @param {GraphicsData[]} holes | ||
* @param {boolean[]} holesDirection | ||
* @param {number} worldAlpha | ||
* @param {PIXI.CrossPlatformCanvasRenderingContext2D} context | ||
* @param shape - Shape to be drawn | ||
* @param lineStyle - Line style for the shape | ||
* @param contextStrokeStyle - The strokeStyle for the canvas context | ||
* @param holes - Holes to be added to the shape | ||
* @param holesDirection - | ||
* @param worldAlpha - The multiplied alpha of the displayObject | ||
* @param context - The canvas context | ||
*/ | ||
@@ -459,8 +459,8 @@ CanvasGraphicsRenderer.prototype.paintPolygonStroke = function (shape, lineStyle, contextStrokeStyle, holes, holesDirection, worldAlpha, context) { | ||
* @private | ||
* @param {PIXI.Ellipse} shape | ||
* @param {PIXI.FillStyle} fillStyle | ||
* @param {PIXI.LineStyle} lineStyle | ||
* @param {string|PIXI.CanvasPattern} contextFillStyle | ||
* @param {number} worldAlpha | ||
* @param {PIXI.CrossPlatformCanvasRenderingContext2D} context | ||
* @param shape - Shape to be drawn | ||
* @param fillStyle - Fill for the shape | ||
* @param lineStyle - Line style for the shape | ||
* @param contextFillStyle - The canvas context fill style | ||
* @param worldAlpha - The multiplied alpha of the displayObject | ||
* @param context - The canvas context | ||
*/ | ||
@@ -500,8 +500,8 @@ CanvasGraphicsRenderer.prototype.paintEllipse = function (shape, fillStyle, lineStyle, contextFillStyle, worldAlpha, context) { | ||
* @private | ||
* @param {PIXI.RoundedRectangle} shape | ||
* @param {PIXI.FillStyle} fillStyle | ||
* @param {PIXI.LineStyle} lineStyle | ||
* @param {string|PIXI.CanvasPattern} contextFillStyle | ||
* @param {number} worldAlpha | ||
* @param {PIXI.CrossPlatformCanvasRenderingContext2D} context | ||
* @param shape - Shape to be drawn | ||
* @param fillStyle - Fill for the shape | ||
* @param lineStyle - Line style for the shape | ||
* @param contextFillStyle - The canvas context fill style | ||
* @param worldAlpha - The multiplied alpha of the displayObject | ||
* @param context - The canvas context | ||
*/ | ||
@@ -558,6 +558,3 @@ CanvasGraphicsRenderer.prototype.paintRoundedRectangle = function (shape, fillStyle, lineStyle, contextFillStyle, worldAlpha, context) { | ||
}; | ||
/** | ||
* destroy graphics object | ||
* | ||
*/ | ||
/** destroy graphics object */ | ||
CanvasGraphicsRenderer.prototype.destroy = function () { | ||
@@ -564,0 +561,0 @@ this.renderer = null; |
/*! | ||
* @pixi/canvas-graphics - v6.1.0-rc.4 | ||
* Compiled Tue, 29 Jun 2021 17:40:45 UTC | ||
* @pixi/canvas-graphics - v6.1.0-rc.5 | ||
* Compiled Mon, 19 Jul 2021 20:32:18 UTC | ||
* | ||
@@ -8,3 +8,3 @@ * @pixi/canvas-graphics is licensed under the MIT License. | ||
*/ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var canvasRenderer,core=require("@pixi/core"),math=require("@pixi/math"),canvasRenderer$1=require("@pixi/canvas-renderer"),graphics=require("@pixi/graphics"),PolygonUtils=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 c=-(h*=i),p=s*=i,g=[t[o]+c,t[o+1]+p],f=[t[n]+c,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 m=-(d*=i),T=u*=i,x=[t[n]+m,t[n+1]+T],y=[t[l]+m,t[l+1]+T],b=e.findIntersection(g[0],g[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;i<e.length-2;i+=2)t+=(e[i+2]-e[i])*(e[i+3]+e[i+1]);return t>0},e}(),CanvasGraphicsRenderer=function(){function e(e){this.renderer=e,this._svgMatrix=null,this._tempMatrix=new math.Matrix}return e.prototype._calcCanvasStyle=function(e,t){var i;return e.texture&&e.texture.baseTexture!==core.Texture.WHITE.baseTexture?e.texture.valid?(i=canvasRenderer$1.canvasUtils.getTintedPattern(e.texture,t),this.setPatternTransform(i,e.matrix||math.Matrix.IDENTITY)):i="#808080":i="#"+("00000"+(0|t).toString(16)).substr(-6),i},e.prototype.render=function(e){var t=this.renderer,i=t.context,r=e.worldAlpha,a=e.transform.worldTransform;t.setContextTransform(a),t.setBlendMode(e.blendMode);for(var n,o,l=e.geometry.graphicsData,s=(e.tint>>16&255)/255,h=(e.tint>>8&255)/255,v=(255&e.tint)/255,c=0;c<l.length;c++){var p=l[c],g=p.shape,f=p.fillStyle,u=p.lineStyle,d=0|p.fillStyle.color,m=0|p.lineStyle.color;if(p.matrix&&t.setContextTransform(a.copyTo(this._tempMatrix).append(p.matrix)),f.visible){var T=((d>>16&255)/255*s*255<<16)+((d>>8&255)/255*h*255<<8)+(255&d)/255*v*255;n=this._calcCanvasStyle(f,T)}if(u.visible){var x=((m>>16&255)/255*s*255<<16)+((m>>8&255)/255*h*255<<8)+(255&m)/255*v*255;o=this._calcCanvasStyle(u,x)}if(i.lineWidth=u.width,i.lineCap=u.cap,i.lineJoin=u.join,i.miterLimit=u.miterLimit,p.type===math.SHAPES.POLY){i.beginPath();var y=(k=g).points,b=p.holes,M=void 0,P=void 0,S=void 0,C=void 0,w=void 0;i.moveTo(y[0],y[1]);for(var R=2;R<y.length;R+=2)i.lineTo(y[R],y[R+1]);if(k.closeStroke&&i.closePath(),b.length>0){w=[],M=0,S=y[0],C=y[1];for(R=2;R+2<y.length;R+=2)M+=(y[R]-S)*(y[R+3]-C)-(y[R+2]-S)*(y[R+1]-C);for(var _=0;_<b.length;_++)if(y=b[_].shape.points){P=0,S=y[0],C=y[1];for(R=2;R+2<y.length;R+=2)P+=(y[R]-S)*(y[R+3]-C)-(y[R+2]-S)*(y[R+1]-C);if(P*M<0){i.moveTo(y[0],y[1]);for(R=2;R<y.length;R+=2)i.lineTo(y[R],y[R+1])}else{i.moveTo(y[y.length-2],y[y.length-1]);for(R=y.length-4;R>=0;R-=2)i.lineTo(y[R],y[R+1])}b[_].shape.closeStroke&&i.closePath(),w[_]=P*M<0}}f.visible&&(i.globalAlpha=f.alpha*r,i.fillStyle=n,i.fill()),u.visible&&this.paintPolygonStroke(k,u,o,b,w,r,i)}else if(p.type===math.SHAPES.RECT){var k=g;if(f.visible&&(i.globalAlpha=f.alpha*r,i.fillStyle=n,i.fillRect(k.x,k.y,k.width,k.height)),u.visible){var A=u.width*(.5-(1-u.alignment)),q=k.width+2*A,E=k.height+2*A;i.globalAlpha=u.alpha*r,i.strokeStyle=o,i.strokeRect(k.x-A,k.y-A,q,E)}}else if(p.type===math.SHAPES.CIRC){k=g;if(i.beginPath(),i.arc(k.x,k.y,k.radius,0,2*Math.PI),i.closePath(),f.visible&&(i.globalAlpha=f.alpha*r,i.fillStyle=n,i.fill()),u.visible){if(.5!==u.alignment){A=u.width*(.5-(1-u.alignment));i.beginPath(),i.arc(k.x,k.y,k.radius+A,0,2*Math.PI),i.closePath()}i.globalAlpha=u.alpha*r,i.strokeStyle=o,i.stroke()}}else if(p.type===math.SHAPES.ELIP){k=g;if((N=1===u.alignment)||this.paintEllipse(k,f,u,n,r,i),u.visible){if(.5!==u.alignment){A=u.width*(.5-(1-u.alignment));var G=2*(k.width+A),I=2*(k.height+A),z=k.x-G/2,H=k.y-I/2,L=G/2*.5522848,U=I/2*.5522848,D=z+G,$=H+I,j=z+G/2,B=H+I/2;i.beginPath(),i.moveTo(z,B),i.bezierCurveTo(z,B-U,j-L,H,j,H),i.bezierCurveTo(j+L,H,D,B-U,D,B),i.bezierCurveTo(D,B+U,j+L,$,j,$),i.bezierCurveTo(j-L,$,z,B+U,z,B),i.closePath()}i.globalAlpha=u.alpha*r,i.strokeStyle=o,i.stroke()}N&&this.paintEllipse(k,f,u,n,r,i)}else if(p.type===math.SHAPES.RREC){var N;k=g;if((N=1===u.alignment)||this.paintRoundedRectangle(k,f,u,n,r,i),u.visible){if(.5!==u.alignment){q=k.width,E=k.height,A=u.width*(.5-(1-u.alignment));var O=k.x-A,V=k.y-A,W=k.width+2*A,Y=k.height+2*A,J=A*(u.alignment>=1?Math.min(W/q,Y/E):Math.min(q/W,E/Y)),F=k.radius+J,K=Math.min(W,Y)/2|0;F=F>K?K:F,i.beginPath(),i.moveTo(O,V+F),i.lineTo(O,V+Y-F),i.quadraticCurveTo(O,V+Y,O+F,V+Y),i.lineTo(O+W-F,V+Y),i.quadraticCurveTo(O+W,V+Y,O+W,V+Y-F),i.lineTo(O+W,V+F),i.quadraticCurveTo(O+W,V,O+W-F,V),i.lineTo(O+F,V),i.quadraticCurveTo(O,V,O,V+F),i.closePath()}i.globalAlpha=u.alpha*r,i.strokeStyle=o,i.stroke()}N&&this.paintRoundedRectangle(k,f,u,n,r,i)}}},e.prototype.paintPolygonStroke=function(e,t,i,r,a,n,o){if(.5!==t.alignment){var l=t.width*(.5-(1-t.alignment)),s=PolygonUtils.offsetPolygon(e.points,l),h=void 0;o.beginPath(),o.moveTo(s[0],s[1]);for(var v=2;v<s.length;v+=2)o.lineTo(s[v],s[v+1]);e.closeStroke&&o.closePath();for(var c=0;c<r.length;c++){if(h=r[c].shape.points,s=PolygonUtils.offsetPolygon(h,l),a[c]){o.moveTo(s[0],s[1]);for(v=2;v<s.length;v+=2)o.lineTo(s[v],s[v+1])}else{o.moveTo(s[s.length-2],s[s.length-1]);for(v=s.length-4;v>=0;v-=2)o.lineTo(s[v],s[v+1])}r[c].shape.closeStroke&&o.closePath()}}o.globalAlpha=t.alpha*n,o.strokeStyle=i,o.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=o/2*.5522848,c=l/2*.5522848,p=s+o,g=h+l,f=s+o/2,u=h+l/2;n.beginPath(),n.moveTo(s,u),n.bezierCurveTo(s,u-c,f-v,h,f,h),n.bezierCurveTo(f+v,h,p,u-c,p,u),n.bezierCurveTo(p,u+c,f+v,g,f,g),n.bezierCurveTo(f-v,g,s,u+c,s,u),n.closePath(),0===i.alignment&&n.clip(),t.visible&&(n.globalAlpha=t.alpha*a,n.fillStyle=r,n.fill())},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,c=Math.min(s,h)/2|0;v=v>c?c:v,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())},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}(),tempMatrix=new math.Matrix;graphics.Graphics.prototype.generateCanvasTexture=function(e,t){void 0===t&&(t=1);var i=this.getLocalBounds(),r=core.RenderTexture.create({width:i.width,height:i.height,scaleMode:e,resolution:t});canvasRenderer||(canvasRenderer=new canvasRenderer$1.CanvasRenderer),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(tempMatrix),tempMatrix.invert(),tempMatrix.tx-=i.x,tempMatrix.ty-=i.y,canvasRenderer.render(this,{renderTexture:r,clear:!0,transform:tempMatrix});var a=core.Texture.from(r.baseTexture._canvasRenderTarget.canvas,{scaleMode:e});return a.baseTexture.setResolution(t),a},graphics.Graphics.prototype.cachedGraphicsData=[],graphics.Graphics.prototype._renderCanvas=function(e){!0!==this.isMask&&(this.finishPoly(),e.plugins.graphics.render(this))},exports.CanvasGraphicsRenderer=CanvasGraphicsRenderer; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var canvasRenderer,core=require("@pixi/core"),math=require("@pixi/math"),canvasRenderer$1=require("@pixi/canvas-renderer"),graphics=require("@pixi/graphics"),PolygonUtils=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 c=-(h*=i),p=s*=i,g=[t[o]+c,t[o+1]+p],f=[t[n]+c,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 m=-(d*=i),T=u*=i,x=[t[n]+m,t[n+1]+T],y=[t[l]+m,t[l+1]+T],b=e.findIntersection(g[0],g[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;i<e.length-2;i+=2)t+=(e[i+2]-e[i])*(e[i+3]+e[i+1]);return t>0},e}(),CanvasGraphicsRenderer=function(){function e(e){this._svgMatrix=null,this._tempMatrix=new math.Matrix,this.renderer=e}return e.prototype._calcCanvasStyle=function(e,t){var i;return e.texture&&e.texture.baseTexture!==core.Texture.WHITE.baseTexture?e.texture.valid?(i=canvasRenderer$1.canvasUtils.getTintedPattern(e.texture,t),this.setPatternTransform(i,e.matrix||math.Matrix.IDENTITY)):i="#808080":i="#"+("00000"+(0|t).toString(16)).substr(-6),i},e.prototype.render=function(e){var t=this.renderer,i=t.context,r=e.worldAlpha,a=e.transform.worldTransform;t.setContextTransform(a),t.setBlendMode(e.blendMode);for(var n,o,l=e.geometry.graphicsData,s=(e.tint>>16&255)/255,h=(e.tint>>8&255)/255,v=(255&e.tint)/255,c=0;c<l.length;c++){var p=l[c],g=p.shape,f=p.fillStyle,u=p.lineStyle,d=0|p.fillStyle.color,m=0|p.lineStyle.color;if(p.matrix&&t.setContextTransform(a.copyTo(this._tempMatrix).append(p.matrix)),f.visible){var T=((d>>16&255)/255*s*255<<16)+((d>>8&255)/255*h*255<<8)+(255&d)/255*v*255;n=this._calcCanvasStyle(f,T)}if(u.visible){var x=((m>>16&255)/255*s*255<<16)+((m>>8&255)/255*h*255<<8)+(255&m)/255*v*255;o=this._calcCanvasStyle(u,x)}if(i.lineWidth=u.width,i.lineCap=u.cap,i.lineJoin=u.join,i.miterLimit=u.miterLimit,p.type===math.SHAPES.POLY){i.beginPath();var y=(k=g).points,b=p.holes,M=void 0,P=void 0,S=void 0,C=void 0,w=void 0;i.moveTo(y[0],y[1]);for(var R=2;R<y.length;R+=2)i.lineTo(y[R],y[R+1]);if(k.closeStroke&&i.closePath(),b.length>0){w=[],M=0,S=y[0],C=y[1];for(R=2;R+2<y.length;R+=2)M+=(y[R]-S)*(y[R+3]-C)-(y[R+2]-S)*(y[R+1]-C);for(var _=0;_<b.length;_++)if(y=b[_].shape.points){P=0,S=y[0],C=y[1];for(R=2;R+2<y.length;R+=2)P+=(y[R]-S)*(y[R+3]-C)-(y[R+2]-S)*(y[R+1]-C);if(P*M<0){i.moveTo(y[0],y[1]);for(R=2;R<y.length;R+=2)i.lineTo(y[R],y[R+1])}else{i.moveTo(y[y.length-2],y[y.length-1]);for(R=y.length-4;R>=0;R-=2)i.lineTo(y[R],y[R+1])}b[_].shape.closeStroke&&i.closePath(),w[_]=P*M<0}}f.visible&&(i.globalAlpha=f.alpha*r,i.fillStyle=n,i.fill()),u.visible&&this.paintPolygonStroke(k,u,o,b,w,r,i)}else if(p.type===math.SHAPES.RECT){var k=g;if(f.visible&&(i.globalAlpha=f.alpha*r,i.fillStyle=n,i.fillRect(k.x,k.y,k.width,k.height)),u.visible){var A=u.width*(.5-(1-u.alignment)),q=k.width+2*A,E=k.height+2*A;i.globalAlpha=u.alpha*r,i.strokeStyle=o,i.strokeRect(k.x-A,k.y-A,q,E)}}else if(p.type===math.SHAPES.CIRC){k=g;if(i.beginPath(),i.arc(k.x,k.y,k.radius,0,2*Math.PI),i.closePath(),f.visible&&(i.globalAlpha=f.alpha*r,i.fillStyle=n,i.fill()),u.visible){if(.5!==u.alignment){A=u.width*(.5-(1-u.alignment));i.beginPath(),i.arc(k.x,k.y,k.radius+A,0,2*Math.PI),i.closePath()}i.globalAlpha=u.alpha*r,i.strokeStyle=o,i.stroke()}}else if(p.type===math.SHAPES.ELIP){k=g;if((N=1===u.alignment)||this.paintEllipse(k,f,u,n,r,i),u.visible){if(.5!==u.alignment){A=u.width*(.5-(1-u.alignment));var G=2*(k.width+A),I=2*(k.height+A),z=k.x-G/2,H=k.y-I/2,L=G/2*.5522848,U=I/2*.5522848,D=z+G,$=H+I,j=z+G/2,B=H+I/2;i.beginPath(),i.moveTo(z,B),i.bezierCurveTo(z,B-U,j-L,H,j,H),i.bezierCurveTo(j+L,H,D,B-U,D,B),i.bezierCurveTo(D,B+U,j+L,$,j,$),i.bezierCurveTo(j-L,$,z,B+U,z,B),i.closePath()}i.globalAlpha=u.alpha*r,i.strokeStyle=o,i.stroke()}N&&this.paintEllipse(k,f,u,n,r,i)}else if(p.type===math.SHAPES.RREC){var N;k=g;if((N=1===u.alignment)||this.paintRoundedRectangle(k,f,u,n,r,i),u.visible){if(.5!==u.alignment){q=k.width,E=k.height,A=u.width*(.5-(1-u.alignment));var O=k.x-A,V=k.y-A,W=k.width+2*A,Y=k.height+2*A,J=A*(u.alignment>=1?Math.min(W/q,Y/E):Math.min(q/W,E/Y)),F=k.radius+J,K=Math.min(W,Y)/2|0;F=F>K?K:F,i.beginPath(),i.moveTo(O,V+F),i.lineTo(O,V+Y-F),i.quadraticCurveTo(O,V+Y,O+F,V+Y),i.lineTo(O+W-F,V+Y),i.quadraticCurveTo(O+W,V+Y,O+W,V+Y-F),i.lineTo(O+W,V+F),i.quadraticCurveTo(O+W,V,O+W-F,V),i.lineTo(O+F,V),i.quadraticCurveTo(O,V,O,V+F),i.closePath()}i.globalAlpha=u.alpha*r,i.strokeStyle=o,i.stroke()}N&&this.paintRoundedRectangle(k,f,u,n,r,i)}}},e.prototype.paintPolygonStroke=function(e,t,i,r,a,n,o){if(.5!==t.alignment){var l=t.width*(.5-(1-t.alignment)),s=PolygonUtils.offsetPolygon(e.points,l),h=void 0;o.beginPath(),o.moveTo(s[0],s[1]);for(var v=2;v<s.length;v+=2)o.lineTo(s[v],s[v+1]);e.closeStroke&&o.closePath();for(var c=0;c<r.length;c++){if(h=r[c].shape.points,s=PolygonUtils.offsetPolygon(h,l),a[c]){o.moveTo(s[0],s[1]);for(v=2;v<s.length;v+=2)o.lineTo(s[v],s[v+1])}else{o.moveTo(s[s.length-2],s[s.length-1]);for(v=s.length-4;v>=0;v-=2)o.lineTo(s[v],s[v+1])}r[c].shape.closeStroke&&o.closePath()}}o.globalAlpha=t.alpha*n,o.strokeStyle=i,o.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=o/2*.5522848,c=l/2*.5522848,p=s+o,g=h+l,f=s+o/2,u=h+l/2;n.beginPath(),n.moveTo(s,u),n.bezierCurveTo(s,u-c,f-v,h,f,h),n.bezierCurveTo(f+v,h,p,u-c,p,u),n.bezierCurveTo(p,u+c,f+v,g,f,g),n.bezierCurveTo(f-v,g,s,u+c,s,u),n.closePath(),0===i.alignment&&n.clip(),t.visible&&(n.globalAlpha=t.alpha*a,n.fillStyle=r,n.fill())},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,c=Math.min(s,h)/2|0;v=v>c?c:v,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())},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}(),tempMatrix=new math.Matrix;graphics.Graphics.prototype.generateCanvasTexture=function(e,t){void 0===t&&(t=1);var i=this.getLocalBounds(),r=core.RenderTexture.create({width:i.width,height:i.height,scaleMode:e,resolution:t});canvasRenderer||(canvasRenderer=new canvasRenderer$1.CanvasRenderer),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(tempMatrix),tempMatrix.invert(),tempMatrix.tx-=i.x,tempMatrix.ty-=i.y,canvasRenderer.render(this,{renderTexture:r,clear:!0,transform:tempMatrix});var a=core.Texture.from(r.baseTexture._canvasRenderTarget.canvas,{scaleMode:e});return a.baseTexture.setResolution(t),a},graphics.Graphics.prototype.cachedGraphicsData=[],graphics.Graphics.prototype._renderCanvas=function(e){!0!==this.isMask&&(this.finishPoly(),e.plugins.graphics.render(this))},exports.CanvasGraphicsRenderer=CanvasGraphicsRenderer; | ||
//# sourceMappingURL=canvas-graphics.min.js.map |
/*! | ||
* @pixi/canvas-graphics - v6.1.0-rc.4 | ||
* Compiled Tue, 29 Jun 2021 17:40:45 UTC | ||
* @pixi/canvas-graphics - v6.1.0-rc.5 | ||
* Compiled Mon, 19 Jul 2021 20:32:18 UTC | ||
* | ||
@@ -141,8 +141,8 @@ * @pixi/canvas-graphics is licensed under the MIT License. | ||
/** | ||
* @param {PIXI.CanvasRenderer} renderer - The current PIXI renderer. | ||
* @param renderer - A reference to the current renderer. | ||
*/ | ||
function CanvasGraphicsRenderer(renderer) { | ||
this.renderer = renderer; | ||
this._svgMatrix = null; | ||
this._tempMatrix = new Matrix(); | ||
this.renderer = renderer; | ||
} | ||
@@ -153,5 +153,5 @@ /** | ||
* @private | ||
* @param {PIXI.FillStyle} style | ||
* @param {number} tint | ||
* @returns {string|CanvasPattern} | ||
* @param style - A graphics {@link PIXI.FILL_STYLE} where if `texture` is specified then a tinted CanvasPattern | ||
* will be used for the fill.stroke | ||
* @param tint - color to set the fill/stroke too. | ||
*/ | ||
@@ -177,3 +177,3 @@ CanvasGraphicsRenderer.prototype._calcCanvasStyle = function (style, tint) { | ||
* | ||
* @param {PIXI.Graphics} graphics - the actual graphics object to render | ||
* @param graphics - the actual graphics object to render | ||
*/ | ||
@@ -405,9 +405,9 @@ CanvasGraphicsRenderer.prototype.render = function (graphics) { | ||
* @private | ||
* @param {PIXI.Polygon} shape | ||
* @param {PIXI.LineStyle} lineStyle | ||
* @param {string|PIXI.CanvasPattern} contextStrokeStyle | ||
* @param {GraphicsData[]} holes | ||
* @param {boolean[]} holesDirection | ||
* @param {number} worldAlpha | ||
* @param {PIXI.CrossPlatformCanvasRenderingContext2D} context | ||
* @param shape - Shape to be drawn | ||
* @param lineStyle - Line style for the shape | ||
* @param contextStrokeStyle - The strokeStyle for the canvas context | ||
* @param holes - Holes to be added to the shape | ||
* @param holesDirection - | ||
* @param worldAlpha - The multiplied alpha of the displayObject | ||
* @param context - The canvas context | ||
*/ | ||
@@ -455,8 +455,8 @@ CanvasGraphicsRenderer.prototype.paintPolygonStroke = function (shape, lineStyle, contextStrokeStyle, holes, holesDirection, worldAlpha, context) { | ||
* @private | ||
* @param {PIXI.Ellipse} shape | ||
* @param {PIXI.FillStyle} fillStyle | ||
* @param {PIXI.LineStyle} lineStyle | ||
* @param {string|PIXI.CanvasPattern} contextFillStyle | ||
* @param {number} worldAlpha | ||
* @param {PIXI.CrossPlatformCanvasRenderingContext2D} context | ||
* @param shape - Shape to be drawn | ||
* @param fillStyle - Fill for the shape | ||
* @param lineStyle - Line style for the shape | ||
* @param contextFillStyle - The canvas context fill style | ||
* @param worldAlpha - The multiplied alpha of the displayObject | ||
* @param context - The canvas context | ||
*/ | ||
@@ -496,8 +496,8 @@ CanvasGraphicsRenderer.prototype.paintEllipse = function (shape, fillStyle, lineStyle, contextFillStyle, worldAlpha, context) { | ||
* @private | ||
* @param {PIXI.RoundedRectangle} shape | ||
* @param {PIXI.FillStyle} fillStyle | ||
* @param {PIXI.LineStyle} lineStyle | ||
* @param {string|PIXI.CanvasPattern} contextFillStyle | ||
* @param {number} worldAlpha | ||
* @param {PIXI.CrossPlatformCanvasRenderingContext2D} context | ||
* @param shape - Shape to be drawn | ||
* @param fillStyle - Fill for the shape | ||
* @param lineStyle - Line style for the shape | ||
* @param contextFillStyle - The canvas context fill style | ||
* @param worldAlpha - The multiplied alpha of the displayObject | ||
* @param context - The canvas context | ||
*/ | ||
@@ -554,6 +554,3 @@ CanvasGraphicsRenderer.prototype.paintRoundedRectangle = function (shape, fillStyle, lineStyle, contextFillStyle, worldAlpha, context) { | ||
}; | ||
/** | ||
* destroy graphics object | ||
* | ||
*/ | ||
/** destroy graphics object */ | ||
CanvasGraphicsRenderer.prototype.destroy = function () { | ||
@@ -560,0 +557,0 @@ this.renderer = null; |
/*! | ||
* @pixi/canvas-graphics - v6.1.0-rc.4 | ||
* Compiled Tue, 29 Jun 2021 17:40:45 UTC | ||
* @pixi/canvas-graphics - v6.1.0-rc.5 | ||
* Compiled Mon, 19 Jul 2021 20:32:18 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;i<e.length-2;i+=2)t+=(e[i+2]-e[i])*(e[i+3]+e[i+1]);return t>0},e}(),h=function(){function t(e){this.renderer=e,this._svgMatrix=null,this._tempMatrix=new i}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)).substr(-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((H=1===d.alignment)||this.paintEllipse(A,u,d,l,a,i),d.visible){if(.5!==d.alignment){q=d.width*(.5-(1-d.alignment));var z=2*(A.width+q),L=2*(A.height+q),D=A.x-z/2,G=A.y-L/2,B=z/2*.5522848,N=L/2*.5522848,V=D+z,W=G+L,Y=D+z/2,j=G+L/2;i.beginPath(),i.moveTo(D,j),i.bezierCurveTo(D,j-N,Y-B,G,Y,G),i.bezierCurveTo(Y+B,G,V,j-N,V,j),i.bezierCurveTo(V,j+N,Y+B,W,Y,W),i.bezierCurveTo(Y-B,W,D,j+N,D,j),i.closePath()}i.globalAlpha=d.alpha*a,i.strokeStyle=n,i.stroke()}H&&this.paintEllipse(A,u,d,l,a,i)}else if(f.type===r.RREC){var H;A=c;if((H=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 J=A.x-q,O=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)),U=A.radius+Q,X=Math.min(F,K)/2|0;U=U>X?X:U,i.beginPath(),i.moveTo(J,O+U),i.lineTo(J,O+K-U),i.quadraticCurveTo(J,O+K,J+U,O+K),i.lineTo(J+F-U,O+K),i.quadraticCurveTo(J+F,O+K,J+F,O+K-U),i.lineTo(J+F,O+U),i.quadraticCurveTo(J+F,O,J+F-U,O),i.lineTo(J+U,O),i.quadraticCurveTo(J,O,J,O+U),i.closePath()}i.globalAlpha=d.alpha*a,i.strokeStyle=n,i.stroke()}H&&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=l/2*.5522848,g=n/2*.5522848,p=s+l,f=h+n,c=s+l/2,u=h+n/2;o.beginPath(),o.moveTo(s,u),o.bezierCurveTo(s,u-g,c-v,h,c,h),o.bezierCurveTo(c+v,h,p,u-g,p,u),o.bezierCurveTo(p,u+g,c+v,f,c,f),o.bezierCurveTo(c-v,f,s,u+g,s,u),o.closePath(),0===i.alignment&&o.clip(),t.visible&&(o.globalAlpha=t.alpha*a,o.fillStyle=r,o.fill())},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|0;v=v>g?g:v,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())},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{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;i<e.length-2;i+=2)t+=(e[i+2]-e[i])*(e[i+3]+e[i+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)).substr(-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((H=1===d.alignment)||this.paintEllipse(A,u,d,l,a,i),d.visible){if(.5!==d.alignment){q=d.width*(.5-(1-d.alignment));var z=2*(A.width+q),L=2*(A.height+q),D=A.x-z/2,G=A.y-L/2,B=z/2*.5522848,N=L/2*.5522848,V=D+z,W=G+L,Y=D+z/2,j=G+L/2;i.beginPath(),i.moveTo(D,j),i.bezierCurveTo(D,j-N,Y-B,G,Y,G),i.bezierCurveTo(Y+B,G,V,j-N,V,j),i.bezierCurveTo(V,j+N,Y+B,W,Y,W),i.bezierCurveTo(Y-B,W,D,j+N,D,j),i.closePath()}i.globalAlpha=d.alpha*a,i.strokeStyle=n,i.stroke()}H&&this.paintEllipse(A,u,d,l,a,i)}else if(f.type===r.RREC){var H;A=c;if((H=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 J=A.x-q,O=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)),U=A.radius+Q,X=Math.min(F,K)/2|0;U=U>X?X:U,i.beginPath(),i.moveTo(J,O+U),i.lineTo(J,O+K-U),i.quadraticCurveTo(J,O+K,J+U,O+K),i.lineTo(J+F-U,O+K),i.quadraticCurveTo(J+F,O+K,J+F,O+K-U),i.lineTo(J+F,O+U),i.quadraticCurveTo(J+F,O,J+F-U,O),i.lineTo(J+U,O),i.quadraticCurveTo(J,O,J,O+U),i.closePath()}i.globalAlpha=d.alpha*a,i.strokeStyle=n,i.stroke()}H&&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=l/2*.5522848,g=n/2*.5522848,p=s+l,f=h+n,c=s+l/2,u=h+n/2;o.beginPath(),o.moveTo(s,u),o.bezierCurveTo(s,u-g,c-v,h,c,h),o.bezierCurveTo(c+v,h,p,u-g,p,u),o.bezierCurveTo(p,u+g,c+v,f,c,f),o.bezierCurveTo(c-v,f,s,u+g,s,u),o.closePath(),0===i.alignment&&o.clip(),t.visible&&(o.globalAlpha=t.alpha*a,o.fillStyle=r,o.fill())},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|0;v=v>g?g:v,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())},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}; | ||
//# sourceMappingURL=canvas-graphics.min.js.map |
@@ -15,2 +15,3 @@ /// <reference path="./global.d.ts" /> | ||
export declare class CanvasGraphicsRenderer { | ||
/** A reference to the current renderer */ | ||
renderer: CanvasRenderer; | ||
@@ -20,3 +21,3 @@ private _svgMatrix; | ||
/** | ||
* @param {PIXI.CanvasRenderer} renderer - The current PIXI renderer. | ||
* @param renderer - A reference to the current renderer. | ||
*/ | ||
@@ -28,5 +29,5 @@ constructor(renderer: CanvasRenderer); | ||
* @private | ||
* @param {PIXI.FillStyle} style | ||
* @param {number} tint | ||
* @returns {string|CanvasPattern} | ||
* @param style - A graphics {@link PIXI.FILL_STYLE} where if `texture` is specified then a tinted CanvasPattern | ||
* will be used for the fill.stroke | ||
* @param tint - color to set the fill/stroke too. | ||
*/ | ||
@@ -37,3 +38,3 @@ private _calcCanvasStyle; | ||
* | ||
* @param {PIXI.Graphics} graphics - the actual graphics object to render | ||
* @param graphics - the actual graphics object to render | ||
*/ | ||
@@ -45,9 +46,9 @@ render(graphics: Graphics): void; | ||
* @private | ||
* @param {PIXI.Polygon} shape | ||
* @param {PIXI.LineStyle} lineStyle | ||
* @param {string|PIXI.CanvasPattern} contextStrokeStyle | ||
* @param {GraphicsData[]} holes | ||
* @param {boolean[]} holesDirection | ||
* @param {number} worldAlpha | ||
* @param {PIXI.CrossPlatformCanvasRenderingContext2D} context | ||
* @param shape - Shape to be drawn | ||
* @param lineStyle - Line style for the shape | ||
* @param contextStrokeStyle - The strokeStyle for the canvas context | ||
* @param holes - Holes to be added to the shape | ||
* @param holesDirection - | ||
* @param worldAlpha - The multiplied alpha of the displayObject | ||
* @param context - The canvas context | ||
*/ | ||
@@ -59,8 +60,8 @@ private paintPolygonStroke; | ||
* @private | ||
* @param {PIXI.Ellipse} shape | ||
* @param {PIXI.FillStyle} fillStyle | ||
* @param {PIXI.LineStyle} lineStyle | ||
* @param {string|PIXI.CanvasPattern} contextFillStyle | ||
* @param {number} worldAlpha | ||
* @param {PIXI.CrossPlatformCanvasRenderingContext2D} context | ||
* @param shape - Shape to be drawn | ||
* @param fillStyle - Fill for the shape | ||
* @param lineStyle - Line style for the shape | ||
* @param contextFillStyle - The canvas context fill style | ||
* @param worldAlpha - The multiplied alpha of the displayObject | ||
* @param context - The canvas context | ||
*/ | ||
@@ -72,15 +73,12 @@ private paintEllipse; | ||
* @private | ||
* @param {PIXI.RoundedRectangle} shape | ||
* @param {PIXI.FillStyle} fillStyle | ||
* @param {PIXI.LineStyle} lineStyle | ||
* @param {string|PIXI.CanvasPattern} contextFillStyle | ||
* @param {number} worldAlpha | ||
* @param {PIXI.CrossPlatformCanvasRenderingContext2D} context | ||
* @param shape - Shape to be drawn | ||
* @param fillStyle - Fill for the shape | ||
* @param lineStyle - Line style for the shape | ||
* @param contextFillStyle - The canvas context fill style | ||
* @param worldAlpha - The multiplied alpha of the displayObject | ||
* @param context - The canvas context | ||
*/ | ||
private paintRoundedRectangle; | ||
setPatternTransform(pattern: CanvasPattern, matrix: Matrix): void; | ||
/** | ||
* destroy graphics object | ||
* | ||
*/ | ||
/** destroy graphics object */ | ||
destroy(): void; | ||
@@ -87,0 +85,0 @@ } |
{ | ||
"name": "@pixi/canvas-graphics", | ||
"version": "6.1.0-rc.4", | ||
"version": "6.1.0-rc.5", | ||
"main": "dist/cjs/canvas-graphics.js", | ||
@@ -28,10 +28,10 @@ "module": "dist/esm/canvas-graphics.js", | ||
"peerDependencies": { | ||
"@pixi/canvas-display": "6.1.0-rc.4", | ||
"@pixi/canvas-renderer": "6.1.0-rc.4", | ||
"@pixi/constants": "6.1.0-rc.4", | ||
"@pixi/core": "6.1.0-rc.4", | ||
"@pixi/graphics": "6.1.0-rc.4", | ||
"@pixi/math": "6.1.0-rc.4" | ||
"@pixi/canvas-display": "6.1.0-rc.5", | ||
"@pixi/canvas-renderer": "6.1.0-rc.5", | ||
"@pixi/constants": "6.1.0-rc.5", | ||
"@pixi/core": "6.1.0-rc.5", | ||
"@pixi/graphics": "6.1.0-rc.5", | ||
"@pixi/math": "6.1.0-rc.5" | ||
}, | ||
"gitHead": "e004413841d2918bf3dffa29b1ac278589af2e6c" | ||
"gitHead": "95ea00e00e06701e990aba8c76d5c910211c2959" | ||
} |
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
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
399221
2020