Socket
Socket
Sign inDemoInstall

@pixi/canvas-renderer

Package Overview
Dependencies
Maintainers
2
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 7.1.2 to 7.2.0-beta

5

lib/CanvasContextSystem.d.ts
import { BLEND_MODES, Matrix } from '@pixi/core';
import type { ExtensionMetadata, ICanvasRenderingContext2D, ISystem } from '@pixi/core';
import type { ColorSource, ExtensionMetadata, ICanvasRenderingContext2D, ISystem } from '@pixi/core';
import type { CanvasRenderer } from './CanvasRenderer';

@@ -7,3 +7,2 @@ /**

* properties that are not included in the spec for CanvasRenderingContext2D
* @private
*/

@@ -58,3 +57,3 @@ export interface CrossPlatformCanvasRenderingContext2D extends ICanvasRenderingContext2D {

*/
clear(clearColor?: string, alpha?: number): void;
clear(clearColor?: ColorSource, alpha?: number): void;
/**

@@ -61,0 +60,0 @@ * Sets the blend mode of the renderer.

4

lib/CanvasContextSystem.js

@@ -54,7 +54,7 @@ 'use strict';

const { activeContext: context, renderer } = this;
clearColor = clearColor ?? this.renderer.background.colorString;
const fillColor = clearColor ? core.Color.shared.setValue(clearColor) : this.renderer.background.backgroundColor;
context.clearRect(0, 0, renderer.width, renderer.height);
if (clearColor) {
context.globalAlpha = alpha ?? this.renderer.background.alpha;
context.fillStyle = clearColor;
context.fillStyle = fillColor.toHex();
context.fillRect(0, 0, renderer.width, renderer.height);

@@ -61,0 +61,0 @@ context.globalAlpha = 1;

@@ -64,4 +64,4 @@ 'use strict';

if (background.alpha > 0) {
context2D.globalAlpha = background.alpha;
context2D.fillStyle = background.colorString;
context2D.globalAlpha = background.backgroundColor.alpha;
context2D.fillStyle = background.backgroundColor.toHex();
context2D.fillRect(0, 0, renderer.width, renderer.height);

@@ -73,6 +73,5 @@ context2D.globalAlpha = 1;

renderTexture._canvasRenderTarget.clear();
const clearColor = renderTexture.clearColor;
if (clearColor[3] > 0) {
context2D.globalAlpha = clearColor[3] ?? 1;
context2D.fillStyle = core.utils.hex2string(core.utils.rgb2hex(clearColor));
if (renderTexture.clear.alpha > 0) {
context2D.globalAlpha = renderTexture.clear.alpha;
context2D.fillStyle = renderTexture.clear.toHex();
context2D.fillRect(0, 0, renderTexture.realWidth, renderTexture.realHeight);

@@ -79,0 +78,0 @@ context2D.globalAlpha = 1;

import { SystemManager } from '@pixi/core';
import type { BackgroundSystem, BLEND_MODES, ExtensionMetadata, GenerateTextureSystem, ICanvas, ICanvasRenderingContext2D, IGenerateTextureOptions, IRenderableObject, IRenderer, IRendererOptions, IRendererPlugins, IRendererRenderOptions, Matrix, PluginSystem, Rectangle, RENDERER_TYPE, RenderTexture, StartupSystem, ViewSystem } from '@pixi/core';
import type { BackgroundSystem, BLEND_MODES, ColorSource, ExtensionMetadata, GenerateTextureSystem, ICanvas, ICanvasRenderingContext2D, IGenerateTextureOptions, IRenderableObject, IRenderer, IRendererOptions, IRendererPlugins, IRendererRenderOptions, Matrix, PluginSystem, Rectangle, RENDERER_TYPE, RenderTexture, StartupSystem, ViewSystem } from '@pixi/core';
import type { DisplayObject } from '@pixi/display';

@@ -36,3 +36,2 @@ import type { CanvasContextSystem, SmoothingEnabledProperties } from './CanvasContextSystem';

* | {@link PIXI.CanvasMaskSystem} | This manages masking operations. |
* | {@link PIXI.CanvasRenderSystem} | This adds the ability to render a PIXI.DisplayObject |
* | {@link PIXI.CanvasExtract} | This extracts image data from a PIXI.DisplayObject |

@@ -115,27 +114,5 @@ * | {@link PIXI.CanvasPrepare} | This prepares a PIXI.DisplayObject async for rendering |

/**
* @param {PIXI.IRendererOptions} [options] - The optional renderer parameters.
* @param {boolean} [options.autoDensity=false] -
* Whether the CSS dimensions of the renderer's view should be resized automatically.
* @param {number|string} [options.background] - Alias for `options.backgroundColor`.
* @param {number} [options.backgroundAlpha=1] -
* Transparency of the background color, value from `0` (fully transparent) to `1` (fully opaque).
* @param {number|string} [options.backgroundColor=0x000000] -
* The background color used to clear the canvas. It accepts hex numbers (e.g. `0xff0000`),
* hex strings (e.g. `'#f00'` or `'#ff0000'`) or color names (e.g. `'red'`).
* @param {boolean} [options.clearBeforeRender=true] - Whether to clear the canvas before new render passes.
* @param {PIXI.IRenderingContext} [options.context] - **WebGL Only.** User-provided WebGL rendering context object.
* @param {number} [options.height=600] - The height of the renderer's view.
* @param {boolean} [options.hello=false] - Whether to log the version and type information of renderer to console.
* @param {number} [options.resolution=PIXI.settings.RESOLUTION] -
* The resolution / device pixel ratio of the renderer.
* @param {boolean} [options.useContextAlpha=true] -
* **Deprecated since 7.0.0, use `premultipliedAlpha` and `backgroundAlpha` instead.** \
* Pass-through value for canvas' context attribute `alpha`. This option is for cases where the
* canvas needs to be opaque, possibly for performance reasons on some older devices.
* If you want to set transparency, please use `backgroundAlpha`.
* @param {PIXI.ICanvas} [options.view=null] -
* The canvas to use as the view. If omitted, a new canvas will be created.
* @param {number} [options.width=800] - The width of the renderer's view.
* @param {PIXI.IRendererOptions} [options] - See {@link PIXI.settings.RENDER_OPTIONS} for defaults.
*/
constructor(options?: IRendererOptions);
constructor(options?: Partial<IRendererOptions>);
/**

@@ -275,7 +252,7 @@ * Useful function that returns a texture of the display object that can then be used to create sprites

*/
get backgroundColor(): number;
get backgroundColor(): ColorSource;
/**
* @deprecated since 7.0.0
*/
set backgroundColor(value: number);
set backgroundColor(value: ColorSource);
/**

@@ -282,0 +259,0 @@ * The background color alpha. Setting this to 0 will make the canvas transparent.

@@ -42,20 +42,5 @@ 'use strict';

}
const startupOptions = {
hello: options.hello,
_plugin: _CanvasRenderer.__plugins,
background: {
alpha: options.backgroundAlpha,
color: options.background ?? options.backgroundColor,
clearBeforeRender: options.clearBeforeRender
},
_view: {
height: options.height,
width: options.width,
autoDensity: options.autoDensity,
resolution: options.resolution,
view: options.view
}
};
this._plugin.rendererPlugins = _CanvasRenderer.__plugins;
this.options = options;
this.startup.run(startupOptions);
this.startup.run(this.options);
}

@@ -166,3 +151,3 @@ static test() {

deprecation("7.0.0", "renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead.");
return this.background.color;
return this.background.alpha;
}

@@ -169,0 +154,0 @@ set backgroundAlpha(value) {

@@ -105,6 +105,3 @@ 'use strict';

context.restore();
const rgbValues = core.utils.hex2rgb(color);
const r = rgbValues[0];
const g = rgbValues[1];
const b = rgbValues[2];
const [r, g, b] = core.Color.shared.setValue(color).toArray();
const pixelData = context.getImageData(0, 0, crop.width, crop.height);

@@ -119,10 +116,3 @@ const pixels = pixelData.data;

},
roundColor: (color) => {
const step = canvasUtils.cacheStepsPerColorChannel;
const rgbValues = core.utils.hex2rgb(color);
rgbValues[0] = Math.min(255, rgbValues[0] / step * step);
rgbValues[1] = Math.min(255, rgbValues[1] / step * step);
rgbValues[2] = Math.min(255, rgbValues[2] / step * step);
return core.utils.rgb2hex(rgbValues);
},
roundColor: (color) => core.Color.shared.setValue(color).round(canvasUtils.cacheStepsPerColorChannel).toNumber(),
cacheStepsPerColorChannel: 8,

@@ -129,0 +119,0 @@ convertTintToImage: false,

{
"name": "@pixi/canvas-renderer",
"version": "7.1.2",
"version": "7.2.0-beta",
"main": "lib/index.js",

@@ -40,4 +40,3 @@ "module": "lib/index.mjs",

"@pixi/core"
],
"gitHead": "27e65c73bb36a06fd00d6da5bf460bbee9f6c984"
]
}

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

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