Socket
Socket
Sign inDemoInstall

@pixi/canvas-renderer

Package Overview
Dependencies
Maintainers
3
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/canvas-renderer - npm Package Compare versions

Comparing version 5.1.5 to 5.2.0

71

dist/canvas-renderer.js
/*!
* @pixi/canvas-renderer - v5.1.5
* Compiled Tue, 24 Sep 2019 04:07:05 UTC
* @pixi/canvas-renderer - v5.2.0
* Compiled Wed, 06 Nov 2019 02:32:43 UTC
*

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

*
* @param {object} maskData - the maskData that will be pushed
* @param {PIXI.MaskData | PIXI.Graphics} maskData - the maskData that will be pushed
*/

@@ -34,7 +34,8 @@ CanvasMaskManager.prototype.pushMask = function pushMask (maskData)

var renderer = this.renderer;
var maskObject = maskData.isMaskData ? maskData.maskObject : maskData;
renderer.context.save();
var cacheAlpha = maskData.alpha;
var transform = maskData.transform.worldTransform;
var cacheAlpha = maskObject.alpha;
var transform = maskObject.transform.worldTransform;
var resolution = renderer.resolution;

@@ -53,5 +54,5 @@

// lots of effort required. If demand is great enough..
if (!maskData._texture)
if (!maskObject._texture)
{
this.renderGraphicsShape(maskData);
this.renderGraphicsShape(maskObject);
renderer.context.clip();

@@ -313,2 +314,3 @@ }

array[constants.BLEND_MODES.DST_ATOP] = 'destination-atop';
array[constants.BLEND_MODES.XOR] = 'xor';

@@ -490,8 +492,11 @@ // SUBTRACT from flash, does not exist in canvas

transform.copyTo(tempWt);
// lets not forget to flag the parent transform as dirty...
this._tempDisplayObjectParent.transform._worldID = -1;
// Canvas Renderer doesn't use "context.translate"
// nor does it store current translation in projectionSystem
// we re-calculate all matrices,
// its not like CanvasRenderer can survive more than 1000 elements
displayObject.transform._parentID = -1;
}
else
{
// in this case matrix cache in displayObject works like expected
tempWt.identity();

@@ -504,2 +509,8 @@ }

displayObject.parent = cacheParent;
if (transform)
{
// Clear the matrix cache one more time,
// we dont have our computations to affect standard "transform=null" case
displayObject.transform._parentID = -1;
}
// displayObject.hitArea = //TODO add a temp hit area

@@ -681,10 +692,10 @@ }

*
* @class
* @namespace PIXI.canvasUtils
* @memberof PIXI
*/
var CanvasTinter = {
var canvasUtils = {
/**
* Basically this method just needs a sprite and a color and tints the sprite with the given color.
*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @param {PIXI.Sprite} sprite - the sprite to tint

@@ -697,3 +708,3 @@ * @param {number} color - the color to use to tint the sprite with

color = CanvasTinter.roundColor(color);
color = canvasUtils.roundColor(color);

@@ -719,10 +730,10 @@ var stringColor = "#" + ((("00000" + ((color | 0).toString(16)))).substr(-6));

{
canvas = CanvasTinter.canvas || document.createElement('canvas');
canvas = canvasUtils.canvas || document.createElement('canvas');
}
CanvasTinter.tintMethod(texture, color, canvas);
canvasUtils.tintMethod(texture, color, canvas);
canvas.tintId = texture._updateID;
if (CanvasTinter.convertTintToImage)
if (canvasUtils.convertTintToImage)
{

@@ -740,3 +751,3 @@ // is this better?

// if we are not converting the texture to an image then we need to lose the reference to the canvas
CanvasTinter.canvas = null;
canvasUtils.canvas = null;
}

@@ -750,3 +761,3 @@

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @param {PIXI.Texture} texture - the texture to tint

@@ -809,3 +820,3 @@ * @param {number} color - the color to use to tint the sprite with

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @param {PIXI.Texture} texture - the texture to tint

@@ -854,3 +865,3 @@ * @param {number} color - the color to use to tint the sprite with

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @param {PIXI.Texture} texture - the texture to tint

@@ -908,5 +919,5 @@ * @param {number} color - the color to use to tint the sprite with

/**
* Rounds the specified color according to the CanvasTinter.cacheStepsPerColorChannel.
* Rounds the specified color according to the canvasUtils.cacheStepsPerColorChannel.
*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @param {number} color - the color to round, should be a hex color

@@ -916,3 +927,3 @@ * @return {number} The rounded color.

roundColor: function (color) {
var step = CanvasTinter.cacheStepsPerColorChannel;
var step = canvasUtils.cacheStepsPerColorChannel;

@@ -931,3 +942,3 @@ var rgbValues = utils.hex2rgb(color);

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @type {number}

@@ -940,3 +951,3 @@ */

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @type {boolean}

@@ -949,3 +960,3 @@ */

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @type {boolean}

@@ -958,3 +969,3 @@ */

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @type {Function}

@@ -967,3 +978,3 @@ */

CanvasTinter.tintMethod = CanvasTinter.canUseMultiply ? CanvasTinter.tintWithMultiply : CanvasTinter.tintWithPerPixel;
canvasUtils.tintMethod = canvasUtils.canUseMultiply ? canvasUtils.tintWithMultiply : canvasUtils.tintWithPerPixel;

@@ -1012,4 +1023,4 @@ // Reference to Renderer.create static function

exports.CanvasRenderer = CanvasRenderer;
exports.CanvasTinter = CanvasTinter;
exports.canUseNewCanvasBlendModes = canUseNewCanvasBlendModes;
exports.canvasUtils = canvasUtils;

@@ -1016,0 +1027,0 @@ return exports;

/*!
* @pixi/canvas-renderer - v5.1.5
* Compiled Tue, 24 Sep 2019 04:07:05 UTC
* @pixi/canvas-renderer - v5.2.0
* Compiled Wed, 06 Nov 2019 02:32:43 UTC
*

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

*/
this.PIXI=this.PIXI||{};var _pixi_canvas_renderer=function(t,e,o,r,i,n){"use strict";var a=function(t){this.renderer=t};function s(t){var e=document.createElement("canvas");e.width=6,e.height=1;var o=e.getContext("2d");return o.fillStyle=t,o.fillRect(0,0,6,1),e}function h(){if("undefined"==typeof document)return!1;var t=s("#ff00ff"),e=s("#ffff00"),o=document.createElement("canvas");o.width=6,o.height=1;var r=o.getContext("2d");r.globalCompositeOperation="multiply",r.drawImage(t,0,0),r.drawImage(e,2,0);var i=r.getImageData(2,0,1,1);if(!i)return!1;var n=i.data;return 255===n[0]&&0===n[1]&&0===n[2]}a.prototype.pushMask=function(t){var e=this.renderer;e.context.save();var o=t.alpha,r=t.transform.worldTransform,i=e.resolution;e.context.setTransform(r.a*i,r.b*i,r.c*i,r.d*i,r.tx*i,r.ty*i),t._texture||(this.renderGraphicsShape(t),e.context.clip()),t.worldAlpha=o},a.prototype.renderGraphicsShape=function(t){var e=this.renderer.context,o=t.geometry.graphicsData,i=o.length;if(0!==i){e.beginPath();for(var n=0;n<i;n++){var a=o[n],s=a.shape;if(a.type===r.SHAPES.POLY){var h=s.points;e.moveTo(h[0],h[1]);for(var l=1;l<h.length/2;l++)e.lineTo(h[2*l],h[2*l+1]);h[0]===h[h.length-2]&&h[1]===h[h.length-1]&&e.closePath()}else if(a.type===r.SHAPES.RECT)e.rect(s.x,s.y,s.width,s.height),e.closePath();else if(a.type===r.SHAPES.CIRC)e.arc(s.x,s.y,s.radius,0,2*Math.PI),e.closePath();else if(a.type===r.SHAPES.ELIP){var c=2*s.width,E=2*s.height,d=s.x-c/2,D=s.y-E/2,u=c/2*.5522848,g=E/2*.5522848,p=d+c,S=D+E,_=d+c/2,O=D+E/2;e.moveTo(d,O),e.bezierCurveTo(d,O-g,_-u,D,_,D),e.bezierCurveTo(_+u,D,p,O-g,p,O),e.bezierCurveTo(p,O+g,_+u,S,_,S),e.bezierCurveTo(_-u,S,d,O+g,d,O),e.closePath()}else if(a.type===r.SHAPES.RREC){var v=s.x,M=s.y,m=s.width,N=s.height,L=s.radius,C=Math.min(m,N)/2|0;L=L>C?C:L,e.moveTo(v,M+L),e.lineTo(v,M+N-L),e.quadraticCurveTo(v,M+N,v+L,M+N),e.lineTo(v+m-L,M+N),e.quadraticCurveTo(v+m,M+N,v+m,M+N-L),e.lineTo(v+m,M+L),e.quadraticCurveTo(v+m,M,v+m-L,M),e.lineTo(v+L,M),e.quadraticCurveTo(v,M,v,M+L),e.closePath()}}}},a.prototype.popMask=function(t){t.context.restore(),t.invalidateBlendMode()},a.prototype.destroy=function(){};var l=function(t){function r(e,n,s){var l;t.call(this,"Canvas",e,n,s),this.type=i.RENDERER_TYPE.CANVAS,this.rootContext=this.view.getContext("2d",{alpha:this.transparent}),this.context=this.rootContext,this.refresh=!0,this.maskManager=new a(this),this.smoothProperty="imageSmoothingEnabled",this.rootContext.imageSmoothingEnabled||(this.rootContext.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":this.rootContext.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":this.rootContext.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":this.rootContext.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")),this.initPlugins(r.__plugins),this.blendModes=(void 0===l&&(l=[]),h()?(l[i.BLEND_MODES.NORMAL]="source-over",l[i.BLEND_MODES.ADD]="lighter",l[i.BLEND_MODES.MULTIPLY]="multiply",l[i.BLEND_MODES.SCREEN]="screen",l[i.BLEND_MODES.OVERLAY]="overlay",l[i.BLEND_MODES.DARKEN]="darken",l[i.BLEND_MODES.LIGHTEN]="lighten",l[i.BLEND_MODES.COLOR_DODGE]="color-dodge",l[i.BLEND_MODES.COLOR_BURN]="color-burn",l[i.BLEND_MODES.HARD_LIGHT]="hard-light",l[i.BLEND_MODES.SOFT_LIGHT]="soft-light",l[i.BLEND_MODES.DIFFERENCE]="difference",l[i.BLEND_MODES.EXCLUSION]="exclusion",l[i.BLEND_MODES.HUE]="hue",l[i.BLEND_MODES.SATURATION]="saturate",l[i.BLEND_MODES.COLOR]="color",l[i.BLEND_MODES.LUMINOSITY]="luminosity"):(l[i.BLEND_MODES.NORMAL]="source-over",l[i.BLEND_MODES.ADD]="lighter",l[i.BLEND_MODES.MULTIPLY]="source-over",l[i.BLEND_MODES.SCREEN]="source-over",l[i.BLEND_MODES.OVERLAY]="source-over",l[i.BLEND_MODES.DARKEN]="source-over",l[i.BLEND_MODES.LIGHTEN]="source-over",l[i.BLEND_MODES.COLOR_DODGE]="source-over",l[i.BLEND_MODES.COLOR_BURN]="source-over",l[i.BLEND_MODES.HARD_LIGHT]="source-over",l[i.BLEND_MODES.SOFT_LIGHT]="source-over",l[i.BLEND_MODES.DIFFERENCE]="source-over",l[i.BLEND_MODES.EXCLUSION]="source-over",l[i.BLEND_MODES.HUE]="source-over",l[i.BLEND_MODES.SATURATION]="source-over",l[i.BLEND_MODES.COLOR]="source-over",l[i.BLEND_MODES.LUMINOSITY]="source-over"),l[i.BLEND_MODES.NORMAL_NPM]=l[i.BLEND_MODES.NORMAL],l[i.BLEND_MODES.ADD_NPM]=l[i.BLEND_MODES.ADD],l[i.BLEND_MODES.SCREEN_NPM]=l[i.BLEND_MODES.SCREEN],l[i.BLEND_MODES.SRC_IN]="source-in",l[i.BLEND_MODES.SRC_OUT]="source-out",l[i.BLEND_MODES.SRC_ATOP]="source-atop",l[i.BLEND_MODES.DST_OVER]="destination-over",l[i.BLEND_MODES.DST_IN]="destination-in",l[i.BLEND_MODES.DST_OUT]="destination-out",l[i.BLEND_MODES.DST_ATOP]="destination-atop",l[i.BLEND_MODES.SUBTRACT]="source-over",l),this._activeBlendMode=null,this._outerBlend=!1,this.renderingToScreen=!1,o.sayHello("Canvas"),this.resize(this.options.width,this.options.height)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.render=function(t,r,n,a,s){if(this.view){this.renderingToScreen=!r,this.emit("prerender");var h=this.resolution;r?((r=r.baseTexture||r)._canvasRenderTarget||(r._canvasRenderTarget=new o.CanvasRenderTarget(r.width,r.height,r.resolution),r.resource=new e.resources.CanvasResource(r._canvasRenderTarget.canvas),r.valid=!0),this.context=r._canvasRenderTarget.context,this.resolution=r._canvasRenderTarget.resolution):this.context=this.rootContext;var l=this.context;if(r||(this._lastObjectRendered=t),!s){var c=t.parent,E=this._tempDisplayObjectParent.transform.worldTransform;a?(a.copyTo(E),this._tempDisplayObjectParent.transform._worldID=-1):E.identity(),t.parent=this._tempDisplayObjectParent,t.updateTransform(),t.parent=c}l.save(),l.setTransform(1,0,0,1,0,0),l.globalAlpha=1,this._activeBlendMode=i.BLEND_MODES.NORMAL,this._outerBlend=!1,l.globalCompositeOperation=this.blendModes[i.BLEND_MODES.NORMAL],(void 0!==n?n:this.clearBeforeRender)&&this.renderingToScreen&&(this.transparent?l.clearRect(0,0,this.width,this.height):(l.fillStyle=this._backgroundColorString,l.fillRect(0,0,this.width,this.height)));var d=this.context;this.context=l,t.renderCanvas(this),this.context=d,l.restore(),this.resolution=h,this.emit("postrender")}},r.prototype.clear=function(t){var e=this.context;t=t||this._backgroundColorString,!this.transparent&&t?(e.fillStyle=t,e.fillRect(0,0,this.width,this.height)):e.clearRect(0,0,this.width,this.height)},r.prototype.setBlendMode=function(t,e){var o=t===i.BLEND_MODES.SRC_IN||t===i.BLEND_MODES.SRC_OUT||t===i.BLEND_MODES.DST_IN||t===i.BLEND_MODES.DST_ATOP;!e&&o&&(t=i.BLEND_MODES.NORMAL),this._activeBlendMode!==t&&(this._activeBlendMode=t,this._outerBlend=o,this.context.globalCompositeOperation=this.blendModes[t])},r.prototype.destroy=function(e){t.prototype.destroy.call(this,e),this.context=null,this.refresh=!0,this.maskManager.destroy(),this.maskManager=null,this.smoothProperty=null},r.prototype.resize=function(e,o){t.prototype.resize.call(this,e,o),this.smoothProperty&&(this.rootContext[this.smoothProperty]=n.settings.SCALE_MODE===i.SCALE_MODES.LINEAR)},r.prototype.invalidateBlendMode=function(){this._activeBlendMode=this.blendModes.indexOf(this.context.globalCompositeOperation)},r.registerPlugin=function(t,e){r.__plugins=r.__plugins||{},r.__plugins[t]=e},r}(e.AbstractRenderer),c={getTintedCanvas:function(t,e){var o=t.texture,r="#"+("00000"+(0|(e=c.roundColor(e))).toString(16)).substr(-6);o.tintCache=o.tintCache||{};var i,n=o.tintCache[r];if(n){if(n.tintId===o._updateID)return o.tintCache[r];i=o.tintCache[r]}else i=c.canvas||document.createElement("canvas");if(c.tintMethod(o,e,i),i.tintId=o._updateID,c.convertTintToImage){var a=new Image;a.src=i.toDataURL(),o.tintCache[r]=a}else o.tintCache[r]=i,c.canvas=null;return i},tintWithMultiply:function(t,e,o){var r=o.getContext("2d"),i=t._frame.clone(),n=t.baseTexture.resolution;i.x*=n,i.y*=n,i.width*=n,i.height*=n,o.width=Math.ceil(i.width),o.height=Math.ceil(i.height),r.save(),r.fillStyle="#"+("00000"+(0|e).toString(16)).substr(-6),r.fillRect(0,0,i.width,i.height),r.globalCompositeOperation="multiply";var a=t.baseTexture.getDrawableSource();r.drawImage(a,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.globalCompositeOperation="destination-atop",r.drawImage(a,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.restore()},tintWithOverlay:function(t,e,o){var r=o.getContext("2d"),i=t._frame.clone(),n=t.baseTexture.resolution;i.x*=n,i.y*=n,i.width*=n,i.height*=n,o.width=Math.ceil(i.width),o.height=Math.ceil(i.height),r.save(),r.globalCompositeOperation="copy",r.fillStyle="#"+("00000"+(0|e).toString(16)).substr(-6),r.fillRect(0,0,i.width,i.height),r.globalCompositeOperation="destination-atop",r.drawImage(t.baseTexture.getDrawableSource(),i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.restore()},tintWithPerPixel:function(t,e,r){var i=r.getContext("2d"),n=t._frame.clone(),a=t.baseTexture.resolution;n.x*=a,n.y*=a,n.width*=a,n.height*=a,r.width=Math.ceil(n.width),r.height=Math.ceil(n.height),i.save(),i.globalCompositeOperation="copy",i.drawImage(t.baseTexture.getDrawableSource(),n.x,n.y,n.width,n.height,0,0,n.width,n.height),i.restore();for(var s=o.hex2rgb(e),h=s[0],l=s[1],c=s[2],E=i.getImageData(0,0,n.width,n.height),d=E.data,D=0;D<d.length;D+=4)d[D+0]*=h,d[D+1]*=l,d[D+2]*=c;i.putImageData(E,0,0)},roundColor:function(t){var e=c.cacheStepsPerColorChannel,r=o.hex2rgb(t);return r[0]=Math.min(255,r[0]/e*e),r[1]=Math.min(255,r[1]/e*e),r[2]=Math.min(255,r[2]/e*e),o.rgb2hex(r)},cacheStepsPerColorChannel:8,convertTintToImage:!1,canUseMultiply:h(),tintMethod:function(){}};c.tintMethod=c.canUseMultiply?c.tintWithMultiply:c.tintWithPerPixel;var E=e.Renderer.create;return e.Renderer.create=function(t){if(!(t&&t.forceCanvas))try{return E(t)}catch(t){}return new l(t)},e.BaseTexture.prototype.getDrawableSource=function(){var t=this.resource;return t?t.bitmap||t.source:this.source},t.CanvasRenderer=l,t.CanvasTinter=c,t.canUseNewCanvasBlendModes=h,t}({},PIXI,PIXI.utils,PIXI,PIXI,PIXI);Object.assign(this.PIXI,_pixi_canvas_renderer);
this.PIXI=this.PIXI||{};var _pixi_canvas_renderer=function(t,e,o,r,i,n){"use strict";var a=function(t){this.renderer=t};function s(t){var e=document.createElement("canvas");e.width=6,e.height=1;var o=e.getContext("2d");return o.fillStyle=t,o.fillRect(0,0,6,1),e}function h(){if("undefined"==typeof document)return!1;var t=s("#ff00ff"),e=s("#ffff00"),o=document.createElement("canvas");o.width=6,o.height=1;var r=o.getContext("2d");r.globalCompositeOperation="multiply",r.drawImage(t,0,0),r.drawImage(e,2,0);var i=r.getImageData(2,0,1,1);if(!i)return!1;var n=i.data;return 255===n[0]&&0===n[1]&&0===n[2]}a.prototype.pushMask=function(t){var e=this.renderer,o=t.isMaskData?t.maskObject:t;e.context.save();var r=o.alpha,i=o.transform.worldTransform,n=e.resolution;e.context.setTransform(i.a*n,i.b*n,i.c*n,i.d*n,i.tx*n,i.ty*n),o._texture||(this.renderGraphicsShape(o),e.context.clip()),t.worldAlpha=r},a.prototype.renderGraphicsShape=function(t){var e=this.renderer.context,o=t.geometry.graphicsData,i=o.length;if(0!==i){e.beginPath();for(var n=0;n<i;n++){var a=o[n],s=a.shape;if(a.type===r.SHAPES.POLY){var h=s.points;e.moveTo(h[0],h[1]);for(var l=1;l<h.length/2;l++)e.lineTo(h[2*l],h[2*l+1]);h[0]===h[h.length-2]&&h[1]===h[h.length-1]&&e.closePath()}else if(a.type===r.SHAPES.RECT)e.rect(s.x,s.y,s.width,s.height),e.closePath();else if(a.type===r.SHAPES.CIRC)e.arc(s.x,s.y,s.radius,0,2*Math.PI),e.closePath();else if(a.type===r.SHAPES.ELIP){var c=2*s.width,E=2*s.height,d=s.x-c/2,D=s.y-E/2,u=c/2*.5522848,g=E/2*.5522848,S=d+c,_=D+E,p=d+c/2,O=D+E/2;e.moveTo(d,O),e.bezierCurveTo(d,O-g,p-u,D,p,D),e.bezierCurveTo(p+u,D,S,O-g,S,O),e.bezierCurveTo(S,O+g,p+u,_,p,_),e.bezierCurveTo(p-u,_,d,O+g,d,O),e.closePath()}else if(a.type===r.SHAPES.RREC){var v=s.x,M=s.y,m=s.width,N=s.height,L=s.radius,C=Math.min(m,N)/2|0;L=L>C?C:L,e.moveTo(v,M+L),e.lineTo(v,M+N-L),e.quadraticCurveTo(v,M+N,v+L,M+N),e.lineTo(v+m-L,M+N),e.quadraticCurveTo(v+m,M+N,v+m,M+N-L),e.lineTo(v+m,M+L),e.quadraticCurveTo(v+m,M,v+m-L,M),e.lineTo(v+L,M),e.quadraticCurveTo(v,M,v,M+L),e.closePath()}}}},a.prototype.popMask=function(t){t.context.restore(),t.invalidateBlendMode()},a.prototype.destroy=function(){};var l=function(t){function r(e,n,s){var l;t.call(this,"Canvas",e,n,s),this.type=i.RENDERER_TYPE.CANVAS,this.rootContext=this.view.getContext("2d",{alpha:this.transparent}),this.context=this.rootContext,this.refresh=!0,this.maskManager=new a(this),this.smoothProperty="imageSmoothingEnabled",this.rootContext.imageSmoothingEnabled||(this.rootContext.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":this.rootContext.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":this.rootContext.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":this.rootContext.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")),this.initPlugins(r.__plugins),this.blendModes=(void 0===l&&(l=[]),h()?(l[i.BLEND_MODES.NORMAL]="source-over",l[i.BLEND_MODES.ADD]="lighter",l[i.BLEND_MODES.MULTIPLY]="multiply",l[i.BLEND_MODES.SCREEN]="screen",l[i.BLEND_MODES.OVERLAY]="overlay",l[i.BLEND_MODES.DARKEN]="darken",l[i.BLEND_MODES.LIGHTEN]="lighten",l[i.BLEND_MODES.COLOR_DODGE]="color-dodge",l[i.BLEND_MODES.COLOR_BURN]="color-burn",l[i.BLEND_MODES.HARD_LIGHT]="hard-light",l[i.BLEND_MODES.SOFT_LIGHT]="soft-light",l[i.BLEND_MODES.DIFFERENCE]="difference",l[i.BLEND_MODES.EXCLUSION]="exclusion",l[i.BLEND_MODES.HUE]="hue",l[i.BLEND_MODES.SATURATION]="saturate",l[i.BLEND_MODES.COLOR]="color",l[i.BLEND_MODES.LUMINOSITY]="luminosity"):(l[i.BLEND_MODES.NORMAL]="source-over",l[i.BLEND_MODES.ADD]="lighter",l[i.BLEND_MODES.MULTIPLY]="source-over",l[i.BLEND_MODES.SCREEN]="source-over",l[i.BLEND_MODES.OVERLAY]="source-over",l[i.BLEND_MODES.DARKEN]="source-over",l[i.BLEND_MODES.LIGHTEN]="source-over",l[i.BLEND_MODES.COLOR_DODGE]="source-over",l[i.BLEND_MODES.COLOR_BURN]="source-over",l[i.BLEND_MODES.HARD_LIGHT]="source-over",l[i.BLEND_MODES.SOFT_LIGHT]="source-over",l[i.BLEND_MODES.DIFFERENCE]="source-over",l[i.BLEND_MODES.EXCLUSION]="source-over",l[i.BLEND_MODES.HUE]="source-over",l[i.BLEND_MODES.SATURATION]="source-over",l[i.BLEND_MODES.COLOR]="source-over",l[i.BLEND_MODES.LUMINOSITY]="source-over"),l[i.BLEND_MODES.NORMAL_NPM]=l[i.BLEND_MODES.NORMAL],l[i.BLEND_MODES.ADD_NPM]=l[i.BLEND_MODES.ADD],l[i.BLEND_MODES.SCREEN_NPM]=l[i.BLEND_MODES.SCREEN],l[i.BLEND_MODES.SRC_IN]="source-in",l[i.BLEND_MODES.SRC_OUT]="source-out",l[i.BLEND_MODES.SRC_ATOP]="source-atop",l[i.BLEND_MODES.DST_OVER]="destination-over",l[i.BLEND_MODES.DST_IN]="destination-in",l[i.BLEND_MODES.DST_OUT]="destination-out",l[i.BLEND_MODES.DST_ATOP]="destination-atop",l[i.BLEND_MODES.XOR]="xor",l[i.BLEND_MODES.SUBTRACT]="source-over",l),this._activeBlendMode=null,this._outerBlend=!1,this.renderingToScreen=!1,o.sayHello("Canvas"),this.resize(this.options.width,this.options.height)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.render=function(t,r,n,a,s){if(this.view){this.renderingToScreen=!r,this.emit("prerender");var h=this.resolution;r?((r=r.baseTexture||r)._canvasRenderTarget||(r._canvasRenderTarget=new o.CanvasRenderTarget(r.width,r.height,r.resolution),r.resource=new e.resources.CanvasResource(r._canvasRenderTarget.canvas),r.valid=!0),this.context=r._canvasRenderTarget.context,this.resolution=r._canvasRenderTarget.resolution):this.context=this.rootContext;var l=this.context;if(r||(this._lastObjectRendered=t),!s){var c=t.parent,E=this._tempDisplayObjectParent.transform.worldTransform;a?(a.copyTo(E),t.transform._parentID=-1):E.identity(),t.parent=this._tempDisplayObjectParent,t.updateTransform(),t.parent=c,a&&(t.transform._parentID=-1)}l.save(),l.setTransform(1,0,0,1,0,0),l.globalAlpha=1,this._activeBlendMode=i.BLEND_MODES.NORMAL,this._outerBlend=!1,l.globalCompositeOperation=this.blendModes[i.BLEND_MODES.NORMAL],(void 0!==n?n:this.clearBeforeRender)&&this.renderingToScreen&&(this.transparent?l.clearRect(0,0,this.width,this.height):(l.fillStyle=this._backgroundColorString,l.fillRect(0,0,this.width,this.height)));var d=this.context;this.context=l,t.renderCanvas(this),this.context=d,l.restore(),this.resolution=h,this.emit("postrender")}},r.prototype.clear=function(t){var e=this.context;t=t||this._backgroundColorString,!this.transparent&&t?(e.fillStyle=t,e.fillRect(0,0,this.width,this.height)):e.clearRect(0,0,this.width,this.height)},r.prototype.setBlendMode=function(t,e){var o=t===i.BLEND_MODES.SRC_IN||t===i.BLEND_MODES.SRC_OUT||t===i.BLEND_MODES.DST_IN||t===i.BLEND_MODES.DST_ATOP;!e&&o&&(t=i.BLEND_MODES.NORMAL),this._activeBlendMode!==t&&(this._activeBlendMode=t,this._outerBlend=o,this.context.globalCompositeOperation=this.blendModes[t])},r.prototype.destroy=function(e){t.prototype.destroy.call(this,e),this.context=null,this.refresh=!0,this.maskManager.destroy(),this.maskManager=null,this.smoothProperty=null},r.prototype.resize=function(e,o){t.prototype.resize.call(this,e,o),this.smoothProperty&&(this.rootContext[this.smoothProperty]=n.settings.SCALE_MODE===i.SCALE_MODES.LINEAR)},r.prototype.invalidateBlendMode=function(){this._activeBlendMode=this.blendModes.indexOf(this.context.globalCompositeOperation)},r.registerPlugin=function(t,e){r.__plugins=r.__plugins||{},r.__plugins[t]=e},r}(e.AbstractRenderer),c={getTintedCanvas:function(t,e){var o=t.texture,r="#"+("00000"+(0|(e=c.roundColor(e))).toString(16)).substr(-6);o.tintCache=o.tintCache||{};var i,n=o.tintCache[r];if(n){if(n.tintId===o._updateID)return o.tintCache[r];i=o.tintCache[r]}else i=c.canvas||document.createElement("canvas");if(c.tintMethod(o,e,i),i.tintId=o._updateID,c.convertTintToImage){var a=new Image;a.src=i.toDataURL(),o.tintCache[r]=a}else o.tintCache[r]=i,c.canvas=null;return i},tintWithMultiply:function(t,e,o){var r=o.getContext("2d"),i=t._frame.clone(),n=t.baseTexture.resolution;i.x*=n,i.y*=n,i.width*=n,i.height*=n,o.width=Math.ceil(i.width),o.height=Math.ceil(i.height),r.save(),r.fillStyle="#"+("00000"+(0|e).toString(16)).substr(-6),r.fillRect(0,0,i.width,i.height),r.globalCompositeOperation="multiply";var a=t.baseTexture.getDrawableSource();r.drawImage(a,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.globalCompositeOperation="destination-atop",r.drawImage(a,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.restore()},tintWithOverlay:function(t,e,o){var r=o.getContext("2d"),i=t._frame.clone(),n=t.baseTexture.resolution;i.x*=n,i.y*=n,i.width*=n,i.height*=n,o.width=Math.ceil(i.width),o.height=Math.ceil(i.height),r.save(),r.globalCompositeOperation="copy",r.fillStyle="#"+("00000"+(0|e).toString(16)).substr(-6),r.fillRect(0,0,i.width,i.height),r.globalCompositeOperation="destination-atop",r.drawImage(t.baseTexture.getDrawableSource(),i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.restore()},tintWithPerPixel:function(t,e,r){var i=r.getContext("2d"),n=t._frame.clone(),a=t.baseTexture.resolution;n.x*=a,n.y*=a,n.width*=a,n.height*=a,r.width=Math.ceil(n.width),r.height=Math.ceil(n.height),i.save(),i.globalCompositeOperation="copy",i.drawImage(t.baseTexture.getDrawableSource(),n.x,n.y,n.width,n.height,0,0,n.width,n.height),i.restore();for(var s=o.hex2rgb(e),h=s[0],l=s[1],c=s[2],E=i.getImageData(0,0,n.width,n.height),d=E.data,D=0;D<d.length;D+=4)d[D+0]*=h,d[D+1]*=l,d[D+2]*=c;i.putImageData(E,0,0)},roundColor:function(t){var e=c.cacheStepsPerColorChannel,r=o.hex2rgb(t);return r[0]=Math.min(255,r[0]/e*e),r[1]=Math.min(255,r[1]/e*e),r[2]=Math.min(255,r[2]/e*e),o.rgb2hex(r)},cacheStepsPerColorChannel:8,convertTintToImage:!1,canUseMultiply:h(),tintMethod:function(){}};c.tintMethod=c.canUseMultiply?c.tintWithMultiply:c.tintWithPerPixel;var E=e.Renderer.create;return e.Renderer.create=function(t){if(!(t&&t.forceCanvas))try{return E(t)}catch(t){}return new l(t)},e.BaseTexture.prototype.getDrawableSource=function(){var t=this.resource;return t?t.bitmap||t.source:this.source},t.CanvasRenderer=l,t.canUseNewCanvasBlendModes=h,t.canvasUtils=c,t}({},PIXI,PIXI.utils,PIXI,PIXI,PIXI);Object.assign(this.PIXI,_pixi_canvas_renderer);
//# sourceMappingURL=canvas-renderer.min.js.map
/*!
* @pixi/canvas-renderer - v5.1.5
* Compiled Tue, 24 Sep 2019 04:07:05 UTC
* @pixi/canvas-renderer - v5.2.0
* Compiled Wed, 06 Nov 2019 02:32:43 UTC
*

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

*
* @param {object} maskData - the maskData that will be pushed
* @param {PIXI.MaskData | PIXI.Graphics} maskData - the maskData that will be pushed
*/

@@ -36,7 +36,8 @@ CanvasMaskManager.prototype.pushMask = function pushMask (maskData)

var renderer = this.renderer;
var maskObject = maskData.isMaskData ? maskData.maskObject : maskData;
renderer.context.save();
var cacheAlpha = maskData.alpha;
var transform = maskData.transform.worldTransform;
var cacheAlpha = maskObject.alpha;
var transform = maskObject.transform.worldTransform;
var resolution = renderer.resolution;

@@ -55,5 +56,5 @@

// lots of effort required. If demand is great enough..
if (!maskData._texture)
if (!maskObject._texture)
{
this.renderGraphicsShape(maskData);
this.renderGraphicsShape(maskObject);
renderer.context.clip();

@@ -315,2 +316,3 @@ }

array[BLEND_MODES.DST_ATOP] = 'destination-atop';
array[BLEND_MODES.XOR] = 'xor';

@@ -492,8 +494,11 @@ // SUBTRACT from flash, does not exist in canvas

transform.copyTo(tempWt);
// lets not forget to flag the parent transform as dirty...
this._tempDisplayObjectParent.transform._worldID = -1;
// Canvas Renderer doesn't use "context.translate"
// nor does it store current translation in projectionSystem
// we re-calculate all matrices,
// its not like CanvasRenderer can survive more than 1000 elements
displayObject.transform._parentID = -1;
}
else
{
// in this case matrix cache in displayObject works like expected
tempWt.identity();

@@ -506,2 +511,8 @@ }

displayObject.parent = cacheParent;
if (transform)
{
// Clear the matrix cache one more time,
// we dont have our computations to affect standard "transform=null" case
displayObject.transform._parentID = -1;
}
// displayObject.hitArea = //TODO add a temp hit area

@@ -683,10 +694,10 @@ }

*
* @class
* @namespace PIXI.canvasUtils
* @memberof PIXI
*/
var CanvasTinter = {
var canvasUtils = {
/**
* Basically this method just needs a sprite and a color and tints the sprite with the given color.
*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @param {PIXI.Sprite} sprite - the sprite to tint

@@ -699,3 +710,3 @@ * @param {number} color - the color to use to tint the sprite with

color = CanvasTinter.roundColor(color);
color = canvasUtils.roundColor(color);

@@ -721,10 +732,10 @@ var stringColor = "#" + ((("00000" + ((color | 0).toString(16)))).substr(-6));

{
canvas = CanvasTinter.canvas || document.createElement('canvas');
canvas = canvasUtils.canvas || document.createElement('canvas');
}
CanvasTinter.tintMethod(texture, color, canvas);
canvasUtils.tintMethod(texture, color, canvas);
canvas.tintId = texture._updateID;
if (CanvasTinter.convertTintToImage)
if (canvasUtils.convertTintToImage)
{

@@ -742,3 +753,3 @@ // is this better?

// if we are not converting the texture to an image then we need to lose the reference to the canvas
CanvasTinter.canvas = null;
canvasUtils.canvas = null;
}

@@ -752,3 +763,3 @@

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @param {PIXI.Texture} texture - the texture to tint

@@ -811,3 +822,3 @@ * @param {number} color - the color to use to tint the sprite with

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @param {PIXI.Texture} texture - the texture to tint

@@ -856,3 +867,3 @@ * @param {number} color - the color to use to tint the sprite with

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @param {PIXI.Texture} texture - the texture to tint

@@ -910,5 +921,5 @@ * @param {number} color - the color to use to tint the sprite with

/**
* Rounds the specified color according to the CanvasTinter.cacheStepsPerColorChannel.
* Rounds the specified color according to the canvasUtils.cacheStepsPerColorChannel.
*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @param {number} color - the color to round, should be a hex color

@@ -918,3 +929,3 @@ * @return {number} The rounded color.

roundColor: function (color) {
var step = CanvasTinter.cacheStepsPerColorChannel;
var step = canvasUtils.cacheStepsPerColorChannel;

@@ -933,3 +944,3 @@ var rgbValues = hex2rgb(color);

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @type {number}

@@ -942,3 +953,3 @@ */

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @type {boolean}

@@ -951,3 +962,3 @@ */

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @type {boolean}

@@ -960,3 +971,3 @@ */

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @type {Function}

@@ -969,3 +980,3 @@ */

CanvasTinter.tintMethod = CanvasTinter.canUseMultiply ? CanvasTinter.tintWithMultiply : CanvasTinter.tintWithPerPixel;
canvasUtils.tintMethod = canvasUtils.canUseMultiply ? canvasUtils.tintWithMultiply : canvasUtils.tintWithPerPixel;

@@ -1013,3 +1024,3 @@ // Reference to Renderer.create static function

export { CanvasRenderer, CanvasTinter, canUseNewCanvasBlendModes };
export { CanvasRenderer, canUseNewCanvasBlendModes, canvasUtils };
//# sourceMappingURL=canvas-renderer.es.js.map
/*!
* @pixi/canvas-renderer - v5.1.5
* Compiled Tue, 24 Sep 2019 04:07:05 UTC
* @pixi/canvas-renderer - v5.2.0
* Compiled Wed, 06 Nov 2019 02:32:43 UTC
*

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

*
* @param {object} maskData - the maskData that will be pushed
* @param {PIXI.MaskData | PIXI.Graphics} maskData - the maskData that will be pushed
*/

@@ -40,7 +40,8 @@ CanvasMaskManager.prototype.pushMask = function pushMask (maskData)

var renderer = this.renderer;
var maskObject = maskData.isMaskData ? maskData.maskObject : maskData;
renderer.context.save();
var cacheAlpha = maskData.alpha;
var transform = maskData.transform.worldTransform;
var cacheAlpha = maskObject.alpha;
var transform = maskObject.transform.worldTransform;
var resolution = renderer.resolution;

@@ -59,5 +60,5 @@

// lots of effort required. If demand is great enough..
if (!maskData._texture)
if (!maskObject._texture)
{
this.renderGraphicsShape(maskData);
this.renderGraphicsShape(maskObject);
renderer.context.clip();

@@ -319,2 +320,3 @@ }

array[constants.BLEND_MODES.DST_ATOP] = 'destination-atop';
array[constants.BLEND_MODES.XOR] = 'xor';

@@ -496,8 +498,11 @@ // SUBTRACT from flash, does not exist in canvas

transform.copyTo(tempWt);
// lets not forget to flag the parent transform as dirty...
this._tempDisplayObjectParent.transform._worldID = -1;
// Canvas Renderer doesn't use "context.translate"
// nor does it store current translation in projectionSystem
// we re-calculate all matrices,
// its not like CanvasRenderer can survive more than 1000 elements
displayObject.transform._parentID = -1;
}
else
{
// in this case matrix cache in displayObject works like expected
tempWt.identity();

@@ -510,2 +515,8 @@ }

displayObject.parent = cacheParent;
if (transform)
{
// Clear the matrix cache one more time,
// we dont have our computations to affect standard "transform=null" case
displayObject.transform._parentID = -1;
}
// displayObject.hitArea = //TODO add a temp hit area

@@ -687,10 +698,10 @@ }

*
* @class
* @namespace PIXI.canvasUtils
* @memberof PIXI
*/
var CanvasTinter = {
var canvasUtils = {
/**
* Basically this method just needs a sprite and a color and tints the sprite with the given color.
*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @param {PIXI.Sprite} sprite - the sprite to tint

@@ -703,3 +714,3 @@ * @param {number} color - the color to use to tint the sprite with

color = CanvasTinter.roundColor(color);
color = canvasUtils.roundColor(color);

@@ -725,10 +736,10 @@ var stringColor = "#" + ((("00000" + ((color | 0).toString(16)))).substr(-6));

{
canvas = CanvasTinter.canvas || document.createElement('canvas');
canvas = canvasUtils.canvas || document.createElement('canvas');
}
CanvasTinter.tintMethod(texture, color, canvas);
canvasUtils.tintMethod(texture, color, canvas);
canvas.tintId = texture._updateID;
if (CanvasTinter.convertTintToImage)
if (canvasUtils.convertTintToImage)
{

@@ -746,3 +757,3 @@ // is this better?

// if we are not converting the texture to an image then we need to lose the reference to the canvas
CanvasTinter.canvas = null;
canvasUtils.canvas = null;
}

@@ -756,3 +767,3 @@

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @param {PIXI.Texture} texture - the texture to tint

@@ -815,3 +826,3 @@ * @param {number} color - the color to use to tint the sprite with

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @param {PIXI.Texture} texture - the texture to tint

@@ -860,3 +871,3 @@ * @param {number} color - the color to use to tint the sprite with

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @param {PIXI.Texture} texture - the texture to tint

@@ -914,5 +925,5 @@ * @param {number} color - the color to use to tint the sprite with

/**
* Rounds the specified color according to the CanvasTinter.cacheStepsPerColorChannel.
* Rounds the specified color according to the canvasUtils.cacheStepsPerColorChannel.
*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @param {number} color - the color to round, should be a hex color

@@ -922,3 +933,3 @@ * @return {number} The rounded color.

roundColor: function (color) {
var step = CanvasTinter.cacheStepsPerColorChannel;
var step = canvasUtils.cacheStepsPerColorChannel;

@@ -937,3 +948,3 @@ var rgbValues = utils.hex2rgb(color);

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @type {number}

@@ -946,3 +957,3 @@ */

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @type {boolean}

@@ -955,3 +966,3 @@ */

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @type {boolean}

@@ -964,3 +975,3 @@ */

*
* @memberof PIXI.CanvasTinter
* @memberof PIXI.canvasUtils
* @type {Function}

@@ -973,3 +984,3 @@ */

CanvasTinter.tintMethod = CanvasTinter.canUseMultiply ? CanvasTinter.tintWithMultiply : CanvasTinter.tintWithPerPixel;
canvasUtils.tintMethod = canvasUtils.canUseMultiply ? canvasUtils.tintWithMultiply : canvasUtils.tintWithPerPixel;

@@ -1018,4 +1029,4 @@ // Reference to Renderer.create static function

exports.CanvasRenderer = CanvasRenderer;
exports.CanvasTinter = CanvasTinter;
exports.canUseNewCanvasBlendModes = canUseNewCanvasBlendModes;
exports.canvasUtils = canvasUtils;
//# sourceMappingURL=canvas-renderer.js.map
{
"name": "@pixi/canvas-renderer",
"version": "5.1.5",
"version": "5.2.0",
"main": "lib/canvas-renderer.js",

@@ -27,9 +27,12 @@ "module": "lib/canvas-renderer.es.js",

"dependencies": {
"@pixi/constants": "^5.1.0",
"@pixi/core": "^5.1.5",
"@pixi/math": "^5.1.0",
"@pixi/settings": "^5.1.3",
"@pixi/utils": "^5.1.3"
"@pixi/constants": "^5.2.0",
"@pixi/core": "^5.2.0",
"@pixi/math": "^5.2.0",
"@pixi/settings": "^5.2.0",
"@pixi/utils": "^5.2.0"
},
"gitHead": "8cf3db88d06355cbabea64150cdb0774191e502c"
"devDependencies": {
"@pixi/display": "^5.2.0"
},
"gitHead": "aaf96b460582b83a1fa73037ef2dd69dd9e84415"
}

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