Socket
Socket
Sign inDemoInstall

@pixi/utils

Package Overview
Dependencies
6
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.0.4 to 7.0.5

4

lib/browser/hello.js

@@ -5,5 +5,9 @@ 'use strict';

var deprecation = require('../logging/deprecation.js');
function skipHello() {
deprecation.deprecation("7.0.0", "skipHello is deprecated, please use PIXI.settings.RENDER_OPTIONS.hello");
}
function sayHello() {
deprecation.deprecation("7.0.0", `sayHello is deprecated, please use Renderer's "hello" option`);
}

@@ -10,0 +14,0 @@

79

lib/media/trimCanvas.js

@@ -5,5 +5,19 @@ 'use strict';

function checkRow(data, width, y) {
for (let x = 0, index = 4 * y * width; x < width; ++x, index += 4) {
if (data[index + 3] !== 0)
return false;
}
return true;
}
function checkColumn(data, width, x, top, bottom) {
const stride = 4 * width;
for (let y = top, index = top * stride + 4 * x; y <= bottom; ++y, index += stride) {
if (data[index + 3] !== 0)
return false;
}
return true;
}
function trimCanvas(canvas) {
let width = canvas.width;
let height = canvas.height;
let { width, height } = canvas;
const context = canvas.getContext("2d", {

@@ -13,47 +27,24 @@ willReadFrequently: true

const imageData = context.getImageData(0, 0, width, height);
const pixels = imageData.data;
const len = pixels.length;
const bound = {
top: null,
left: null,
right: null,
bottom: null
};
let data = null;
let i;
let x;
let y;
for (i = 0; i < len; i += 4) {
if (pixels[i + 3] !== 0) {
x = i / 4 % width;
y = ~~(i / 4 / width);
if (bound.top === null) {
bound.top = y;
}
if (bound.left === null) {
bound.left = x;
} else if (x < bound.left) {
bound.left = x;
}
if (bound.right === null) {
bound.right = x + 1;
} else if (bound.right < x) {
bound.right = x + 1;
}
if (bound.bottom === null) {
bound.bottom = y;
} else if (bound.bottom < y) {
bound.bottom = y;
}
}
const data = imageData.data;
let top = 0;
let bottom = height - 1;
let left = 0;
let right = width - 1;
while (top < height && checkRow(data, width, top))
++top;
if (top === height) {
return { width: 0, height: 0, data: null };
}
if (bound.top !== null) {
width = bound.right - bound.left;
height = bound.bottom - bound.top + 1;
data = context.getImageData(bound.left, bound.top, width, height);
}
while (checkRow(data, width, bottom))
--bottom;
while (checkColumn(data, width, left, top, bottom))
++left;
while (checkColumn(data, width, right, top, bottom))
--right;
width = right - left + 1;
height = bottom - top + 1;
return {
width,
height,
width,
data
data: context.getImageData(left, top, width, height)
};

@@ -60,0 +51,0 @@ }

{
"name": "@pixi/utils",
"version": "7.0.4",
"version": "7.0.5",
"main": "lib/index.js",

@@ -25,7 +25,7 @@ "module": "lib/index.mjs",

"homepage": "http://pixijs.com/",
"bugs": "https://github.com/pixijs/pixi.js/issues",
"bugs": "https://github.com/pixijs/pixijs/issues",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/pixijs/pixi.js.git"
"url": "https://github.com/pixijs/pixijs.git"
},

@@ -40,4 +40,4 @@ "publishConfig": {

"dependencies": {
"@pixi/constants": "7.0.4",
"@pixi/settings": "7.0.4",
"@pixi/constants": "7.0.5",
"@pixi/settings": "7.0.5",
"@types/earcut": "^2.1.0",

@@ -51,3 +51,3 @@ "earcut": "^2.2.4",

},
"gitHead": "1d0f4da7abd7238a440f78b3661e40ced1a27614"
"gitHead": "8a89713515f9dbe298484120429202534ac1f9f7"
}

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc