Socket
Socket
Sign inDemoInstall

@pixi/color

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.2.1 to 7.2.2

12

lib/Color.d.ts

@@ -122,2 +122,14 @@ import type { HslaColor, HslColor, HsvaColor, HsvColor, RgbaColor, RgbColor } from 'colord/types';

/**
* Copy a color source internally.
* @param value - Color source
*/
private cloneSource;
/**
* Equality check for color sources.
* @param value1 - First color source
* @param value2 - Second color source
* @returns `true` if the color sources are equal, `false` otherwise.
*/
private isSourceEqual;
/**
* Convert to a RGBA color object.

@@ -124,0 +136,0 @@ * @example

39

lib/Color.js

@@ -39,3 +39,3 @@ 'use strict';

if (value instanceof _Color) {
this._value = value._value;
this._value = this.cloneSource(value._value);
this._int = value._int;

@@ -45,5 +45,5 @@ this._components.set(value._components);

throw new Error("Cannot set PIXI.Color#value to null");
} else if (this._value !== value) {
} else if (this._value === null || !this.isSourceEqual(this._value, value)) {
this.normalize(value);
this._value = value;
this._value = this.cloneSource(value);
}

@@ -54,2 +54,34 @@ }

}
cloneSource(value) {
if (typeof value === "string" || typeof value === "number" || value instanceof Number || value === null) {
return value;
} else if (Array.isArray(value) || ArrayBuffer.isView(value)) {
return value.slice(0);
} else if (typeof value === "object" && value !== null) {
return { ...value };
}
return value;
}
isSourceEqual(value1, value2) {
const type1 = typeof value1;
const type2 = typeof value2;
if (type1 !== type2) {
return false;
} else if (type1 === "number" || type1 === "string" || value1 instanceof Number) {
return value1 === value2;
} else if (Array.isArray(value1) && Array.isArray(value2) || ArrayBuffer.isView(value1) && ArrayBuffer.isView(value2)) {
if (value1.length !== value2.length) {
return false;
}
return value1.every((v, i) => v === value2[i]);
} else if (value1 !== null && value2 !== null) {
const keys1 = Object.keys(value1);
const keys2 = Object.keys(value2);
if (keys1.length !== keys2.length) {
return false;
}
return keys1.every((key) => value1[key] === value2[key]);
}
return value1 === value2;
}
toRgba() {

@@ -196,2 +228,3 @@ const [r, g, b, a] = this._components;

refreshInt() {
this._components.forEach((value, i) => this._components[i] = Math.min(Math.max(value, 0), 1));
const [r, g, b] = this._components;

@@ -198,0 +231,0 @@ this._int = (r * 255 << 16) + (g * 255 << 8) + (b * 255 | 0);

2

package.json
{
"name": "@pixi/color",
"version": "7.2.1",
"version": "7.2.2",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "module": "lib/index.mjs",

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc