Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pixi/canvas-graphics

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/canvas-graphics - npm Package Compare versions

Comparing version 5.4.0-rc.2 to 5.4.0-rc.3

8

dist/browser/canvas-graphics.js
/*!
* @pixi/canvas-graphics - v5.4.0-rc.2
* Compiled Tue, 17 Nov 2020 01:47:11 UTC
* @pixi/canvas-graphics - v5.4.0-rc.3
* Compiled Thu, 10 Dec 2020 03:22:17 UTC
*

@@ -9,3 +9,3 @@ * @pixi/canvas-graphics is licensed under the MIT License.

this.PIXI = this.PIXI || {};
var _pixi_canvas_graphics = (function (exports, math, canvasRenderer$1, graphics, core) {
var _pixi_canvas_graphics = (function (exports, core, math, canvasRenderer$1, graphics) {
'use strict';

@@ -50,3 +50,3 @@

var res;
if (style.texture) {
if (style.texture && style.texture.baseTexture !== core.Texture.WHITE.baseTexture) {
if (style.texture.valid) {

@@ -53,0 +53,0 @@ res = canvasRenderer$1.canvasUtils.getTintedPattern(style.texture, tint);

/*!
* @pixi/canvas-graphics - v5.4.0-rc.2
* Compiled Tue, 17 Nov 2020 01:47:11 UTC
* @pixi/canvas-graphics - v5.4.0-rc.3
* Compiled Thu, 10 Dec 2020 03:22:17 UTC
*

@@ -8,3 +8,3 @@ * @pixi/canvas-graphics is licensed under the MIT License.

*/
this.PIXI=this.PIXI||{};var _pixi_canvas_graphics=function(t,e,i,a,r){"use strict";var l,s=function(){function t(t){this.renderer=t,this._svgMatrix=null,this._tempMatrix=new e.Matrix}return t.prototype._calcCanvasStyle=function(t,a){var r;return t.texture?t.texture.valid?(r=i.canvasUtils.getTintedPattern(t.texture,a),this.setPatternTransform(r,t.matrix||e.Matrix.IDENTITY)):r="#808080":r="#"+("00000"+(0|a).toString(16)).substr(-6),r},t.prototype.render=function(t){var i=this.renderer,a=i.context,r=t.worldAlpha,l=t.transform.worldTransform;i.setContextTransform(l),i.setBlendMode(t.blendMode);for(var s,o,n=t.geometry.graphicsData,h=(t.tint>>16&255)/255,v=(t.tint>>8&255)/255,p=(255&t.tint)/255,c=0;c<n.length;c++){var g=n[c],f=g.shape,d=g.fillStyle,u=g.lineStyle,x=0|g.fillStyle.color,y=0|g.lineStyle.color;if(g.matrix&&i.setContextTransform(l.copyTo(this._tempMatrix).append(g.matrix)),d.visible){var T=((x>>16&255)/255*h*255<<16)+((x>>8&255)/255*v*255<<8)+(255&x)/255*p*255;s=this._calcCanvasStyle(d,T)}if(u.visible){var b=((y>>16&255)/255*h*255<<16)+((y>>8&255)/255*v*255<<8)+(255&y)/255*p*255;o=this._calcCanvasStyle(u,b)}if(a.lineWidth=u.width,a.lineCap=u.cap,a.lineJoin=u.join,a.miterLimit=u.miterLimit,g.type===e.SHAPES.POLY){a.beginPath();var S=(A=f).points,m=g.holes,M=void 0,P=void 0,_=void 0,C=void 0;a.moveTo(S[0],S[1]);for(var I=2;I<S.length;I+=2)a.lineTo(S[I],S[I+1]);if(A.closeStroke&&a.closePath(),m.length>0){M=0,_=S[0],C=S[1];for(I=2;I+2<S.length;I+=2)M+=(S[I]-_)*(S[I+3]-C)-(S[I+2]-_)*(S[I+1]-C);for(var w=0;w<m.length;w++)if(S=m[w].shape.points){P=0,_=S[0],C=S[1];for(I=2;I+2<S.length;I+=2)P+=(S[I]-_)*(S[I+3]-C)-(S[I+2]-_)*(S[I+1]-C);if(P*M<0){a.moveTo(S[0],S[1]);for(I=2;I<S.length;I+=2)a.lineTo(S[I],S[I+1])}else{a.moveTo(S[S.length-2],S[S.length-1]);for(I=S.length-4;I>=0;I-=2)a.lineTo(S[I],S[I+1])}m[w].shape.closeStroke&&a.closePath()}}d.visible&&(a.globalAlpha=d.alpha*r,a.fillStyle=s,a.fill()),u.visible&&(a.globalAlpha=u.alpha*r,a.strokeStyle=o,a.stroke())}else if(g.type===e.SHAPES.RECT){var A=f;d.visible&&(a.globalAlpha=d.alpha*r,a.fillStyle=s,a.fillRect(A.x,A.y,A.width,A.height)),u.visible&&(a.globalAlpha=u.alpha*r,a.strokeStyle=o,a.strokeRect(A.x,A.y,A.width,A.height))}else if(g.type===e.SHAPES.CIRC){A=f;a.beginPath(),a.arc(A.x,A.y,A.radius,0,2*Math.PI),a.closePath(),d.visible&&(a.globalAlpha=d.alpha*r,a.fillStyle=s,a.fill()),u.visible&&(a.globalAlpha=u.alpha*r,a.strokeStyle=o,a.stroke())}else if(g.type===e.SHAPES.ELIP){var k=2*(A=f).width,R=2*A.height,E=A.x-k/2,G=A.y-R/2;a.beginPath();var X=k/2*.5522848,L=R/2*.5522848,H=E+k,q=G+R,z=E+k/2,D=G+R/2;a.moveTo(E,D),a.bezierCurveTo(E,D-L,z-X,G,z,G),a.bezierCurveTo(z+X,G,H,D-L,H,D),a.bezierCurveTo(H,D+L,z+X,q,z,q),a.bezierCurveTo(z-X,q,E,D+L,E,D),a.closePath(),d.visible&&(a.globalAlpha=d.alpha*r,a.fillStyle=s,a.fill()),u.visible&&(a.globalAlpha=u.alpha*r,a.strokeStyle=o,a.stroke())}else if(g.type===e.SHAPES.RREC){var j=(A=f).x,B=A.y,N=A.width,O=A.height,V=A.radius,Y=Math.min(N,O)/2|0;V=V>Y?Y:V,a.beginPath(),a.moveTo(j,B+V),a.lineTo(j,B+O-V),a.quadraticCurveTo(j,B+O,j+V,B+O),a.lineTo(j+N-V,B+O),a.quadraticCurveTo(j+N,B+O,j+N,B+O-V),a.lineTo(j+N,B+V),a.quadraticCurveTo(j+N,B,j+N-V,B),a.lineTo(j+V,B),a.quadraticCurveTo(j,B,j,B+V),a.closePath(),d.visible&&(a.globalAlpha=d.alpha*r,a.fillStyle=s,a.fill()),u.visible&&(a.globalAlpha=u.alpha*r,a.strokeStyle=o,a.stroke())}}},t.prototype.setPatternTransform=function(t,e){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||!t.setTransform)return void(this._svgMatrix=!1)}this._svgMatrix.a=e.a,this._svgMatrix.b=e.b,this._svgMatrix.c=e.c,this._svgMatrix.d=e.d,this._svgMatrix.e=e.tx,this._svgMatrix.f=e.ty,t.setTransform(this._svgMatrix.inverse())}},t.prototype.destroy=function(){this.renderer=null,this._svgMatrix=null,this._tempMatrix=null},t}(),o=new e.Matrix;return a.Graphics.prototype.generateCanvasTexture=function(t,e){void 0===e&&(e=1);var a=this.getLocalBounds(),s=r.RenderTexture.create({width:a.width,height:a.height,scaleMode:t,resolution:e});l||(l=new i.CanvasRenderer),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(o),o.invert(),o.tx-=a.x,o.ty-=a.y,l.render(this,s,!0,o);var n=r.Texture.from(s.baseTexture._canvasRenderTarget.canvas,{scaleMode:t});return n.baseTexture.setResolution(e),n},a.Graphics.prototype.cachedGraphicsData=[],a.Graphics.prototype._renderCanvas=function(t){!0!==this.isMask&&(this.finishPoly(),t.plugins.graphics.render(this))},t.CanvasGraphicsRenderer=s,t}({},PIXI,PIXI,PIXI,PIXI);Object.assign(this.PIXI,_pixi_canvas_graphics);
this.PIXI=this.PIXI||{};var _pixi_canvas_graphics=function(e,t,i,r,a){"use strict";var l,s=function(){function e(e){this.renderer=e,this._svgMatrix=null,this._tempMatrix=new i.Matrix}return e.prototype._calcCanvasStyle=function(e,a){var l;return e.texture&&e.texture.baseTexture!==t.Texture.WHITE.baseTexture?e.texture.valid?(l=r.canvasUtils.getTintedPattern(e.texture,a),this.setPatternTransform(l,e.matrix||i.Matrix.IDENTITY)):l="#808080":l="#"+("00000"+(0|a).toString(16)).substr(-6),l},e.prototype.render=function(e){var t=this.renderer,r=t.context,a=e.worldAlpha,l=e.transform.worldTransform;t.setContextTransform(l),t.setBlendMode(e.blendMode);for(var s,o,n=e.geometry.graphicsData,h=(e.tint>>16&255)/255,v=(e.tint>>8&255)/255,p=(255&e.tint)/255,c=0;c<n.length;c++){var g=n[c],f=g.shape,u=g.fillStyle,x=g.lineStyle,d=0|g.fillStyle.color,T=0|g.lineStyle.color;if(g.matrix&&t.setContextTransform(l.copyTo(this._tempMatrix).append(g.matrix)),u.visible){var y=((d>>16&255)/255*h*255<<16)+((d>>8&255)/255*v*255<<8)+(255&d)/255*p*255;s=this._calcCanvasStyle(u,y)}if(x.visible){var b=((T>>16&255)/255*h*255<<16)+((T>>8&255)/255*v*255<<8)+(255&T)/255*p*255;o=this._calcCanvasStyle(x,b)}if(r.lineWidth=x.width,r.lineCap=x.cap,r.lineJoin=x.join,r.miterLimit=x.miterLimit,g.type===i.SHAPES.POLY){r.beginPath();var S=(A=f).points,m=g.holes,M=void 0,P=void 0,_=void 0,C=void 0;r.moveTo(S[0],S[1]);for(var I=2;I<S.length;I+=2)r.lineTo(S[I],S[I+1]);if(A.closeStroke&&r.closePath(),m.length>0){M=0,_=S[0],C=S[1];for(I=2;I+2<S.length;I+=2)M+=(S[I]-_)*(S[I+3]-C)-(S[I+2]-_)*(S[I+1]-C);for(var w=0;w<m.length;w++)if(S=m[w].shape.points){P=0,_=S[0],C=S[1];for(I=2;I+2<S.length;I+=2)P+=(S[I]-_)*(S[I+3]-C)-(S[I+2]-_)*(S[I+1]-C);if(P*M<0){r.moveTo(S[0],S[1]);for(I=2;I<S.length;I+=2)r.lineTo(S[I],S[I+1])}else{r.moveTo(S[S.length-2],S[S.length-1]);for(I=S.length-4;I>=0;I-=2)r.lineTo(S[I],S[I+1])}m[w].shape.closeStroke&&r.closePath()}}u.visible&&(r.globalAlpha=u.alpha*a,r.fillStyle=s,r.fill()),x.visible&&(r.globalAlpha=x.alpha*a,r.strokeStyle=o,r.stroke())}else if(g.type===i.SHAPES.RECT){var A=f;u.visible&&(r.globalAlpha=u.alpha*a,r.fillStyle=s,r.fillRect(A.x,A.y,A.width,A.height)),x.visible&&(r.globalAlpha=x.alpha*a,r.strokeStyle=o,r.strokeRect(A.x,A.y,A.width,A.height))}else if(g.type===i.SHAPES.CIRC){A=f;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=s,r.fill()),x.visible&&(r.globalAlpha=x.alpha*a,r.strokeStyle=o,r.stroke())}else if(g.type===i.SHAPES.ELIP){var k=2*(A=f).width,E=2*A.height,R=A.x-k/2,G=A.y-E/2;r.beginPath();var X=k/2*.5522848,H=E/2*.5522848,L=R+k,q=G+E,z=R+k/2,D=G+E/2;r.moveTo(R,D),r.bezierCurveTo(R,D-H,z-X,G,z,G),r.bezierCurveTo(z+X,G,L,D-H,L,D),r.bezierCurveTo(L,D+H,z+X,q,z,q),r.bezierCurveTo(z-X,q,R,D+H,R,D),r.closePath(),u.visible&&(r.globalAlpha=u.alpha*a,r.fillStyle=s,r.fill()),x.visible&&(r.globalAlpha=x.alpha*a,r.strokeStyle=o,r.stroke())}else if(g.type===i.SHAPES.RREC){var j=(A=f).x,B=A.y,N=A.width,O=A.height,V=A.radius,W=Math.min(N,O)/2|0;V=V>W?W:V,r.beginPath(),r.moveTo(j,B+V),r.lineTo(j,B+O-V),r.quadraticCurveTo(j,B+O,j+V,B+O),r.lineTo(j+N-V,B+O),r.quadraticCurveTo(j+N,B+O,j+N,B+O-V),r.lineTo(j+N,B+V),r.quadraticCurveTo(j+N,B,j+N-V,B),r.lineTo(j+V,B),r.quadraticCurveTo(j,B,j,B+V),r.closePath(),u.visible&&(r.globalAlpha=u.alpha*a,r.fillStyle=s,r.fill()),x.visible&&(r.globalAlpha=x.alpha*a,r.strokeStyle=o,r.stroke())}}},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}(),o=new i.Matrix;return a.Graphics.prototype.generateCanvasTexture=function(e,i){void 0===i&&(i=1);var a=this.getLocalBounds(),s=t.RenderTexture.create({width:a.width,height:a.height,scaleMode:e,resolution:i});l||(l=new r.CanvasRenderer),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(o),o.invert(),o.tx-=a.x,o.ty-=a.y,l.render(this,s,!0,o);var n=t.Texture.from(s.baseTexture._canvasRenderTarget.canvas,{scaleMode:e});return n.baseTexture.setResolution(i),n},a.Graphics.prototype.cachedGraphicsData=[],a.Graphics.prototype._renderCanvas=function(e){!0!==this.isMask&&(this.finishPoly(),e.plugins.graphics.render(this))},e.CanvasGraphicsRenderer=s,e}({},PIXI,PIXI,PIXI,PIXI);Object.assign(this.PIXI,_pixi_canvas_graphics);
//# sourceMappingURL=canvas-graphics.min.js.map
/*!
* @pixi/canvas-graphics - v5.4.0-rc.2
* Compiled Tue, 17 Nov 2020 01:47:11 UTC
* @pixi/canvas-graphics - v5.4.0-rc.3
* Compiled Thu, 10 Dec 2020 03:22:17 UTC
*

@@ -12,6 +12,6 @@ * @pixi/canvas-graphics is licensed under the MIT License.

var core = require('@pixi/core');
var math = require('@pixi/math');
var canvasRenderer$1 = require('@pixi/canvas-renderer');
var graphics = require('@pixi/graphics');
var core = require('@pixi/core');

@@ -55,3 +55,3 @@ /*

var res;
if (style.texture) {
if (style.texture && style.texture.baseTexture !== core.Texture.WHITE.baseTexture) {
if (style.texture.valid) {

@@ -58,0 +58,0 @@ res = canvasRenderer$1.canvasUtils.getTintedPattern(style.texture, tint);

/*!
* @pixi/canvas-graphics - v5.4.0-rc.2
* Compiled Tue, 17 Nov 2020 01:47:11 UTC
* @pixi/canvas-graphics - v5.4.0-rc.3
* Compiled Thu, 10 Dec 2020 03:22:17 UTC
*

@@ -8,3 +8,3 @@ * @pixi/canvas-graphics is licensed under the MIT License.

*/
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var canvasRenderer,math=require("@pixi/math"),canvasRenderer$1=require("@pixi/canvas-renderer"),graphics=require("@pixi/graphics"),core=require("@pixi/core"),CanvasGraphicsRenderer=function(){function e(e){this.renderer=e,this._svgMatrix=null,this._tempMatrix=new math.Matrix}return e.prototype._calcCanvasStyle=function(e,t){var r;return e.texture?e.texture.valid?(r=canvasRenderer$1.canvasUtils.getTintedPattern(e.texture,t),this.setPatternTransform(r,e.matrix||math.Matrix.IDENTITY)):r="#808080":r="#"+("00000"+(0|t).toString(16)).substr(-6),r},e.prototype.render=function(e){var t=this.renderer,r=t.context,a=e.worldAlpha,i=e.transform.worldTransform;t.setContextTransform(i),t.setBlendMode(e.blendMode);for(var s,l,o=e.geometry.graphicsData,n=(e.tint>>16&255)/255,h=(e.tint>>8&255)/255,v=(255&e.tint)/255,p=0;p<o.length;p++){var c=o[p],d=c.shape,g=c.fillStyle,f=c.lineStyle,x=0|c.fillStyle.color,u=0|c.lineStyle.color;if(c.matrix&&t.setContextTransform(i.copyTo(this._tempMatrix).append(c.matrix)),g.visible){var m=((x>>16&255)/255*n*255<<16)+((x>>8&255)/255*h*255<<8)+(255&x)/255*v*255;s=this._calcCanvasStyle(g,m)}if(f.visible){var y=((u>>16&255)/255*n*255<<16)+((u>>8&255)/255*h*255<<8)+(255&u)/255*v*255;l=this._calcCanvasStyle(f,y)}if(r.lineWidth=f.width,r.lineCap=f.cap,r.lineJoin=f.join,r.miterLimit=f.miterLimit,c.type===math.SHAPES.POLY){r.beginPath();var T=(w=d).points,b=c.holes,M=void 0,S=void 0,C=void 0,_=void 0;r.moveTo(T[0],T[1]);for(var P=2;P<T.length;P+=2)r.lineTo(T[P],T[P+1]);if(w.closeStroke&&r.closePath(),b.length>0){M=0,C=T[0],_=T[1];for(P=2;P+2<T.length;P+=2)M+=(T[P]-C)*(T[P+3]-_)-(T[P+2]-C)*(T[P+1]-_);for(var R=0;R<b.length;R++)if(T=b[R].shape.points){S=0,C=T[0],_=T[1];for(P=2;P+2<T.length;P+=2)S+=(T[P]-C)*(T[P+3]-_)-(T[P+2]-C)*(T[P+1]-_);if(S*M<0){r.moveTo(T[0],T[1]);for(P=2;P<T.length;P+=2)r.lineTo(T[P],T[P+1])}else{r.moveTo(T[T.length-2],T[T.length-1]);for(P=T.length-4;P>=0;P-=2)r.lineTo(T[P],T[P+1])}b[R].shape.closeStroke&&r.closePath()}}g.visible&&(r.globalAlpha=g.alpha*a,r.fillStyle=s,r.fill()),f.visible&&(r.globalAlpha=f.alpha*a,r.strokeStyle=l,r.stroke())}else if(c.type===math.SHAPES.RECT){var w=d;g.visible&&(r.globalAlpha=g.alpha*a,r.fillStyle=s,r.fillRect(w.x,w.y,w.width,w.height)),f.visible&&(r.globalAlpha=f.alpha*a,r.strokeStyle=l,r.strokeRect(w.x,w.y,w.width,w.height))}else if(c.type===math.SHAPES.CIRC){w=d;r.beginPath(),r.arc(w.x,w.y,w.radius,0,2*Math.PI),r.closePath(),g.visible&&(r.globalAlpha=g.alpha*a,r.fillStyle=s,r.fill()),f.visible&&(r.globalAlpha=f.alpha*a,r.strokeStyle=l,r.stroke())}else if(c.type===math.SHAPES.ELIP){var A=2*(w=d).width,k=2*w.height,E=w.x-A/2,G=w.y-k/2;r.beginPath();var q=A/2*.5522848,L=k/2*.5522848,H=E+A,I=G+k,z=E+A/2,D=G+k/2;r.moveTo(E,D),r.bezierCurveTo(E,D-L,z-q,G,z,G),r.bezierCurveTo(z+q,G,H,D-L,H,D),r.bezierCurveTo(H,D+L,z+q,I,z,I),r.bezierCurveTo(z-q,I,E,D+L,E,D),r.closePath(),g.visible&&(r.globalAlpha=g.alpha*a,r.fillStyle=s,r.fill()),f.visible&&(r.globalAlpha=f.alpha*a,r.strokeStyle=l,r.stroke())}else if(c.type===math.SHAPES.RREC){var $=(w=d).x,j=w.y,B=w.width,N=w.height,O=w.radius,V=Math.min(B,N)/2|0;O=O>V?V:O,r.beginPath(),r.moveTo($,j+O),r.lineTo($,j+N-O),r.quadraticCurveTo($,j+N,$+O,j+N),r.lineTo($+B-O,j+N),r.quadraticCurveTo($+B,j+N,$+B,j+N-O),r.lineTo($+B,j+O),r.quadraticCurveTo($+B,j,$+B-O,j),r.lineTo($+O,j),r.quadraticCurveTo($,j,$,j+O),r.closePath(),g.visible&&(r.globalAlpha=g.alpha*a,r.fillStyle=s,r.fill()),f.visible&&(r.globalAlpha=f.alpha*a,r.strokeStyle=l,r.stroke())}}},e.prototype.setPatternTransform=function(e,t){if(!1!==this._svgMatrix){if(!this._svgMatrix){var r=document.createElementNS("http://www.w3.org/2000/svg","svg");if(r&&r.createSVGMatrix&&(this._svgMatrix=r.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 r=this.getLocalBounds(),a=core.RenderTexture.create({width:r.width,height:r.height,scaleMode:e,resolution:t});canvasRenderer||(canvasRenderer=new canvasRenderer$1.CanvasRenderer),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(tempMatrix),tempMatrix.invert(),tempMatrix.tx-=r.x,tempMatrix.ty-=r.y,canvasRenderer.render(this,a,!0,tempMatrix);var i=core.Texture.from(a.baseTexture._canvasRenderTarget.canvas,{scaleMode:e});return i.baseTexture.setResolution(t),i},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"),CanvasGraphicsRenderer=function(){function e(e){this.renderer=e,this._svgMatrix=null,this._tempMatrix=new math.Matrix}return e.prototype._calcCanvasStyle=function(e,t){var r;return e.texture&&e.texture.baseTexture!==core.Texture.WHITE.baseTexture?e.texture.valid?(r=canvasRenderer$1.canvasUtils.getTintedPattern(e.texture,t),this.setPatternTransform(r,e.matrix||math.Matrix.IDENTITY)):r="#808080":r="#"+("00000"+(0|t).toString(16)).substr(-6),r},e.prototype.render=function(e){var t=this.renderer,r=t.context,a=e.worldAlpha,i=e.transform.worldTransform;t.setContextTransform(i),t.setBlendMode(e.blendMode);for(var s,l,o=e.geometry.graphicsData,n=(e.tint>>16&255)/255,h=(e.tint>>8&255)/255,v=(255&e.tint)/255,p=0;p<o.length;p++){var c=o[p],d=c.shape,g=c.fillStyle,x=c.lineStyle,f=0|c.fillStyle.color,u=0|c.lineStyle.color;if(c.matrix&&t.setContextTransform(i.copyTo(this._tempMatrix).append(c.matrix)),g.visible){var m=((f>>16&255)/255*n*255<<16)+((f>>8&255)/255*h*255<<8)+(255&f)/255*v*255;s=this._calcCanvasStyle(g,m)}if(x.visible){var T=((u>>16&255)/255*n*255<<16)+((u>>8&255)/255*h*255<<8)+(255&u)/255*v*255;l=this._calcCanvasStyle(x,T)}if(r.lineWidth=x.width,r.lineCap=x.cap,r.lineJoin=x.join,r.miterLimit=x.miterLimit,c.type===math.SHAPES.POLY){r.beginPath();var y=(w=d).points,b=c.holes,M=void 0,S=void 0,C=void 0,_=void 0;r.moveTo(y[0],y[1]);for(var P=2;P<y.length;P+=2)r.lineTo(y[P],y[P+1]);if(w.closeStroke&&r.closePath(),b.length>0){M=0,C=y[0],_=y[1];for(P=2;P+2<y.length;P+=2)M+=(y[P]-C)*(y[P+3]-_)-(y[P+2]-C)*(y[P+1]-_);for(var R=0;R<b.length;R++)if(y=b[R].shape.points){S=0,C=y[0],_=y[1];for(P=2;P+2<y.length;P+=2)S+=(y[P]-C)*(y[P+3]-_)-(y[P+2]-C)*(y[P+1]-_);if(S*M<0){r.moveTo(y[0],y[1]);for(P=2;P<y.length;P+=2)r.lineTo(y[P],y[P+1])}else{r.moveTo(y[y.length-2],y[y.length-1]);for(P=y.length-4;P>=0;P-=2)r.lineTo(y[P],y[P+1])}b[R].shape.closeStroke&&r.closePath()}}g.visible&&(r.globalAlpha=g.alpha*a,r.fillStyle=s,r.fill()),x.visible&&(r.globalAlpha=x.alpha*a,r.strokeStyle=l,r.stroke())}else if(c.type===math.SHAPES.RECT){var w=d;g.visible&&(r.globalAlpha=g.alpha*a,r.fillStyle=s,r.fillRect(w.x,w.y,w.width,w.height)),x.visible&&(r.globalAlpha=x.alpha*a,r.strokeStyle=l,r.strokeRect(w.x,w.y,w.width,w.height))}else if(c.type===math.SHAPES.CIRC){w=d;r.beginPath(),r.arc(w.x,w.y,w.radius,0,2*Math.PI),r.closePath(),g.visible&&(r.globalAlpha=g.alpha*a,r.fillStyle=s,r.fill()),x.visible&&(r.globalAlpha=x.alpha*a,r.strokeStyle=l,r.stroke())}else if(c.type===math.SHAPES.ELIP){var A=2*(w=d).width,k=2*w.height,E=w.x-A/2,G=w.y-k/2;r.beginPath();var q=A/2*.5522848,H=k/2*.5522848,I=E+A,L=G+k,z=E+A/2,D=G+k/2;r.moveTo(E,D),r.bezierCurveTo(E,D-H,z-q,G,z,G),r.bezierCurveTo(z+q,G,I,D-H,I,D),r.bezierCurveTo(I,D+H,z+q,L,z,L),r.bezierCurveTo(z-q,L,E,D+H,E,D),r.closePath(),g.visible&&(r.globalAlpha=g.alpha*a,r.fillStyle=s,r.fill()),x.visible&&(r.globalAlpha=x.alpha*a,r.strokeStyle=l,r.stroke())}else if(c.type===math.SHAPES.RREC){var $=(w=d).x,j=w.y,B=w.width,N=w.height,O=w.radius,V=Math.min(B,N)/2|0;O=O>V?V:O,r.beginPath(),r.moveTo($,j+O),r.lineTo($,j+N-O),r.quadraticCurveTo($,j+N,$+O,j+N),r.lineTo($+B-O,j+N),r.quadraticCurveTo($+B,j+N,$+B,j+N-O),r.lineTo($+B,j+O),r.quadraticCurveTo($+B,j,$+B-O,j),r.lineTo($+O,j),r.quadraticCurveTo($,j,$,j+O),r.closePath(),g.visible&&(r.globalAlpha=g.alpha*a,r.fillStyle=s,r.fill()),x.visible&&(r.globalAlpha=x.alpha*a,r.strokeStyle=l,r.stroke())}}},e.prototype.setPatternTransform=function(e,t){if(!1!==this._svgMatrix){if(!this._svgMatrix){var r=document.createElementNS("http://www.w3.org/2000/svg","svg");if(r&&r.createSVGMatrix&&(this._svgMatrix=r.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 r=this.getLocalBounds(),a=core.RenderTexture.create({width:r.width,height:r.height,scaleMode:e,resolution:t});canvasRenderer||(canvasRenderer=new canvasRenderer$1.CanvasRenderer),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(tempMatrix),tempMatrix.invert(),tempMatrix.tx-=r.x,tempMatrix.ty-=r.y,canvasRenderer.render(this,a,!0,tempMatrix);var i=core.Texture.from(a.baseTexture._canvasRenderTarget.canvas,{scaleMode:e});return i.baseTexture.setResolution(t),i},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 - v5.4.0-rc.2
* Compiled Tue, 17 Nov 2020 01:47:11 UTC
* @pixi/canvas-graphics - v5.4.0-rc.3
* Compiled Thu, 10 Dec 2020 03:22:17 UTC
*

@@ -8,6 +8,6 @@ * @pixi/canvas-graphics is licensed under the MIT License.

*/
import { Texture, RenderTexture } from '@pixi/core';
import { Matrix, SHAPES } from '@pixi/math';
import { canvasUtils, CanvasRenderer } from '@pixi/canvas-renderer';
import { Graphics } from '@pixi/graphics';
import { RenderTexture, Texture } from '@pixi/core';

@@ -51,3 +51,3 @@ /*

var res;
if (style.texture) {
if (style.texture && style.texture.baseTexture !== Texture.WHITE.baseTexture) {
if (style.texture.valid) {

@@ -54,0 +54,0 @@ res = canvasUtils.getTintedPattern(style.texture, tint);

/*!
* @pixi/canvas-graphics - v5.4.0-rc.2
* Compiled Tue, 17 Nov 2020 01:47:11 UTC
* @pixi/canvas-graphics - v5.4.0-rc.3
* Compiled Thu, 10 Dec 2020 03:22:17 UTC
*

@@ -8,3 +8,3 @@ * @pixi/canvas-graphics is licensed under the MIT License.

*/
import{Matrix as t,SHAPES as e}from"@pixi/math";import{canvasUtils as i,CanvasRenderer as r}from"@pixi/canvas-renderer";import{Graphics as a}from"@pixi/graphics";import{RenderTexture as l,Texture as o}from"@pixi/core";var s,n=function(){function r(e){this.renderer=e,this._svgMatrix=null,this._tempMatrix=new t}return r.prototype._calcCanvasStyle=function(e,r){var a;return e.texture?e.texture.valid?(a=i.getTintedPattern(e.texture,r),this.setPatternTransform(a,e.matrix||t.IDENTITY)):a="#808080":a="#"+("00000"+(0|r).toString(16)).substr(-6),a},r.prototype.render=function(t){var i=this.renderer,r=i.context,a=t.worldAlpha,l=t.transform.worldTransform;i.setContextTransform(l),i.setBlendMode(t.blendMode);for(var o,s,n=t.geometry.graphicsData,h=(t.tint>>16&255)/255,v=(t.tint>>8&255)/255,p=(255&t.tint)/255,f=0;f<n.length;f++){var g=n[f],c=g.shape,d=g.fillStyle,x=g.lineStyle,u=0|g.fillStyle.color,y=0|g.lineStyle.color;if(g.matrix&&i.setContextTransform(l.copyTo(this._tempMatrix).append(g.matrix)),d.visible){var m=((u>>16&255)/255*h*255<<16)+((u>>8&255)/255*v*255<<8)+(255&u)/255*p*255;o=this._calcCanvasStyle(d,m)}if(x.visible){var T=((y>>16&255)/255*h*255<<16)+((y>>8&255)/255*v*255<<8)+(255&y)/255*p*255;s=this._calcCanvasStyle(x,T)}if(r.lineWidth=x.width,r.lineCap=x.cap,r.lineJoin=x.join,r.miterLimit=x.miterLimit,g.type===e.POLY){r.beginPath();var b=(A=c).points,M=g.holes,S=void 0,_=void 0,C=void 0,w=void 0;r.moveTo(b[0],b[1]);for(var P=2;P<b.length;P+=2)r.lineTo(b[P],b[P+1]);if(A.closeStroke&&r.closePath(),M.length>0){S=0,C=b[0],w=b[1];for(P=2;P+2<b.length;P+=2)S+=(b[P]-C)*(b[P+3]-w)-(b[P+2]-C)*(b[P+1]-w);for(var k=0;k<M.length;k++)if(b=M[k].shape.points){_=0,C=b[0],w=b[1];for(P=2;P+2<b.length;P+=2)_+=(b[P]-C)*(b[P+3]-w)-(b[P+2]-C)*(b[P+1]-w);if(_*S<0){r.moveTo(b[0],b[1]);for(P=2;P<b.length;P+=2)r.lineTo(b[P],b[P+1])}else{r.moveTo(b[b.length-2],b[b.length-1]);for(P=b.length-4;P>=0;P-=2)r.lineTo(b[P],b[P+1])}M[k].shape.closeStroke&&r.closePath()}}d.visible&&(r.globalAlpha=d.alpha*a,r.fillStyle=o,r.fill()),x.visible&&(r.globalAlpha=x.alpha*a,r.strokeStyle=s,r.stroke())}else if(g.type===e.RECT){var A=c;d.visible&&(r.globalAlpha=d.alpha*a,r.fillStyle=o,r.fillRect(A.x,A.y,A.width,A.height)),x.visible&&(r.globalAlpha=x.alpha*a,r.strokeStyle=s,r.strokeRect(A.x,A.y,A.width,A.height))}else if(g.type===e.CIRC){A=c;r.beginPath(),r.arc(A.x,A.y,A.radius,0,2*Math.PI),r.closePath(),d.visible&&(r.globalAlpha=d.alpha*a,r.fillStyle=o,r.fill()),x.visible&&(r.globalAlpha=x.alpha*a,r.strokeStyle=s,r.stroke())}else if(g.type===e.ELIP){var R=2*(A=c).width,L=2*A.height,E=A.x-R/2,I=A.y-L/2;r.beginPath();var q=R/2*.5522848,z=L/2*.5522848,D=E+R,G=I+L,B=E+R/2,N=I+L/2;r.moveTo(E,N),r.bezierCurveTo(E,N-z,B-q,I,B,I),r.bezierCurveTo(B+q,I,D,N-z,D,N),r.bezierCurveTo(D,N+z,B+q,G,B,G),r.bezierCurveTo(B-q,G,E,N+z,E,N),r.closePath(),d.visible&&(r.globalAlpha=d.alpha*a,r.fillStyle=o,r.fill()),x.visible&&(r.globalAlpha=x.alpha*a,r.strokeStyle=s,r.stroke())}else if(g.type===e.RREC){var V=(A=c).x,Y=A.y,j=A.width,J=A.height,O=A.radius,W=Math.min(j,J)/2|0;O=O>W?W:O,r.beginPath(),r.moveTo(V,Y+O),r.lineTo(V,Y+J-O),r.quadraticCurveTo(V,Y+J,V+O,Y+J),r.lineTo(V+j-O,Y+J),r.quadraticCurveTo(V+j,Y+J,V+j,Y+J-O),r.lineTo(V+j,Y+O),r.quadraticCurveTo(V+j,Y,V+j-O,Y),r.lineTo(V+O,Y),r.quadraticCurveTo(V,Y,V,Y+O),r.closePath(),d.visible&&(r.globalAlpha=d.alpha*a,r.fillStyle=o,r.fill()),x.visible&&(r.globalAlpha=x.alpha*a,r.strokeStyle=s,r.stroke())}}},r.prototype.setPatternTransform=function(t,e){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||!t.setTransform)return void(this._svgMatrix=!1)}this._svgMatrix.a=e.a,this._svgMatrix.b=e.b,this._svgMatrix.c=e.c,this._svgMatrix.d=e.d,this._svgMatrix.e=e.tx,this._svgMatrix.f=e.ty,t.setTransform(this._svgMatrix.inverse())}},r.prototype.destroy=function(){this.renderer=null,this._svgMatrix=null,this._tempMatrix=null},r}(),h=new t;a.prototype.generateCanvasTexture=function(t,e){void 0===e&&(e=1);var i=this.getLocalBounds(),a=l.create({width:i.width,height:i.height,scaleMode:t,resolution:e});s||(s=new r),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(h),h.invert(),h.tx-=i.x,h.ty-=i.y,s.render(this,a,!0,h);var n=o.from(a.baseTexture._canvasRenderTarget.canvas,{scaleMode:t});return n.baseTexture.setResolution(e),n},a.prototype.cachedGraphicsData=[],a.prototype._renderCanvas=function(t){!0!==this.isMask&&(this.finishPoly(),t.plugins.graphics.render(this))};export{n 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 l}from"@pixi/canvas-renderer";import{Graphics as o}from"@pixi/graphics";var s,n=function(){function t(e){this.renderer=e,this._svgMatrix=null,this._tempMatrix=new i}return t.prototype._calcCanvasStyle=function(t,r){var l;return t.texture&&t.texture.baseTexture!==e.WHITE.baseTexture?t.texture.valid?(l=a.getTintedPattern(t.texture,r),this.setPatternTransform(l,t.matrix||i.IDENTITY)):l="#808080":l="#"+("00000"+(0|r).toString(16)).substr(-6),l},t.prototype.render=function(e){var t=this.renderer,i=t.context,a=e.worldAlpha,l=e.transform.worldTransform;t.setContextTransform(l),t.setBlendMode(e.blendMode);for(var o,s,n=e.geometry.graphicsData,h=(e.tint>>16&255)/255,v=(e.tint>>8&255)/255,p=(255&e.tint)/255,f=0;f<n.length;f++){var g=n[f],c=g.shape,d=g.fillStyle,x=g.lineStyle,u=0|g.fillStyle.color,y=0|g.lineStyle.color;if(g.matrix&&t.setContextTransform(l.copyTo(this._tempMatrix).append(g.matrix)),d.visible){var T=((u>>16&255)/255*h*255<<16)+((u>>8&255)/255*v*255<<8)+(255&u)/255*p*255;o=this._calcCanvasStyle(d,T)}if(x.visible){var m=((y>>16&255)/255*h*255<<16)+((y>>8&255)/255*v*255<<8)+(255&y)/255*p*255;s=this._calcCanvasStyle(x,m)}if(i.lineWidth=x.width,i.lineCap=x.cap,i.lineJoin=x.join,i.miterLimit=x.miterLimit,g.type===r.POLY){i.beginPath();var b=(A=c).points,M=g.holes,S=void 0,_=void 0,C=void 0,w=void 0;i.moveTo(b[0],b[1]);for(var P=2;P<b.length;P+=2)i.lineTo(b[P],b[P+1]);if(A.closeStroke&&i.closePath(),M.length>0){S=0,C=b[0],w=b[1];for(P=2;P+2<b.length;P+=2)S+=(b[P]-C)*(b[P+3]-w)-(b[P+2]-C)*(b[P+1]-w);for(var k=0;k<M.length;k++)if(b=M[k].shape.points){_=0,C=b[0],w=b[1];for(P=2;P+2<b.length;P+=2)_+=(b[P]-C)*(b[P+3]-w)-(b[P+2]-C)*(b[P+1]-w);if(_*S<0){i.moveTo(b[0],b[1]);for(P=2;P<b.length;P+=2)i.lineTo(b[P],b[P+1])}else{i.moveTo(b[b.length-2],b[b.length-1]);for(P=b.length-4;P>=0;P-=2)i.lineTo(b[P],b[P+1])}M[k].shape.closeStroke&&i.closePath()}}d.visible&&(i.globalAlpha=d.alpha*a,i.fillStyle=o,i.fill()),x.visible&&(i.globalAlpha=x.alpha*a,i.strokeStyle=s,i.stroke())}else if(g.type===r.RECT){var A=c;d.visible&&(i.globalAlpha=d.alpha*a,i.fillStyle=o,i.fillRect(A.x,A.y,A.width,A.height)),x.visible&&(i.globalAlpha=x.alpha*a,i.strokeStyle=s,i.strokeRect(A.x,A.y,A.width,A.height))}else if(g.type===r.CIRC){A=c;i.beginPath(),i.arc(A.x,A.y,A.radius,0,2*Math.PI),i.closePath(),d.visible&&(i.globalAlpha=d.alpha*a,i.fillStyle=o,i.fill()),x.visible&&(i.globalAlpha=x.alpha*a,i.strokeStyle=s,i.stroke())}else if(g.type===r.ELIP){var R=2*(A=c).width,E=2*A.height,I=A.x-R/2,L=A.y-E/2;i.beginPath();var q=R/2*.5522848,z=E/2*.5522848,D=I+R,G=L+E,B=I+R/2,N=L+E/2;i.moveTo(I,N),i.bezierCurveTo(I,N-z,B-q,L,B,L),i.bezierCurveTo(B+q,L,D,N-z,D,N),i.bezierCurveTo(D,N+z,B+q,G,B,G),i.bezierCurveTo(B-q,G,I,N+z,I,N),i.closePath(),d.visible&&(i.globalAlpha=d.alpha*a,i.fillStyle=o,i.fill()),x.visible&&(i.globalAlpha=x.alpha*a,i.strokeStyle=s,i.stroke())}else if(g.type===r.RREC){var V=(A=c).x,W=A.y,Y=A.width,j=A.height,H=A.radius,J=Math.min(Y,j)/2|0;H=H>J?J:H,i.beginPath(),i.moveTo(V,W+H),i.lineTo(V,W+j-H),i.quadraticCurveTo(V,W+j,V+H,W+j),i.lineTo(V+Y-H,W+j),i.quadraticCurveTo(V+Y,W+j,V+Y,W+j-H),i.lineTo(V+Y,W+H),i.quadraticCurveTo(V+Y,W,V+Y-H,W),i.lineTo(V+H,W),i.quadraticCurveTo(V,W,V,W+H),i.closePath(),d.visible&&(i.globalAlpha=d.alpha*a,i.fillStyle=o,i.fill()),x.visible&&(i.globalAlpha=x.alpha*a,i.strokeStyle=s,i.stroke())}}},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}(),h=new i;o.prototype.generateCanvasTexture=function(i,r){void 0===r&&(r=1);var a=this.getLocalBounds(),o=t.create({width:a.width,height:a.height,scaleMode:i,resolution:r});s||(s=new l),this.transform.updateLocalTransform(),this.transform.localTransform.copyTo(h),h.invert(),h.tx-=a.x,h.ty-=a.y,s.render(this,o,!0,h);var n=e.from(o.baseTexture._canvasRenderTarget.canvas,{scaleMode:i});return n.baseTexture.setResolution(r),n},o.prototype.cachedGraphicsData=[],o.prototype._renderCanvas=function(e){!0!==this.isMask&&(this.finishPoly(),e.plugins.graphics.render(this))};export{n as CanvasGraphicsRenderer};
//# sourceMappingURL=canvas-graphics.min.js.map
{
"name": "@pixi/canvas-graphics",
"version": "5.4.0-rc.2",
"version": "5.4.0-rc.3",
"main": "dist/cjs/canvas-graphics.js",

@@ -28,10 +28,10 @@ "module": "dist/esm/canvas-graphics.js",

"dependencies": {
"@pixi/canvas-display": "5.4.0-rc.2",
"@pixi/canvas-renderer": "5.4.0-rc.2",
"@pixi/constants": "5.4.0-rc.2",
"@pixi/core": "5.4.0-rc.2",
"@pixi/graphics": "5.4.0-rc.2",
"@pixi/math": "5.4.0-rc.2"
"@pixi/canvas-display": "5.4.0-rc.3",
"@pixi/canvas-renderer": "5.4.0-rc.3",
"@pixi/constants": "5.4.0-rc.3",
"@pixi/core": "5.4.0-rc.3",
"@pixi/graphics": "5.4.0-rc.3",
"@pixi/math": "5.4.0-rc.3"
},
"gitHead": "fc4ca303a8f03eee754e12e0e769c263d8b19465"
"gitHead": "0c48db94f0521d85cc226fc4b15f69c30d53c765"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc