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

@pixi/color - npm Package Compare versions

Comparing version 7.2.3 to 7.2.4

9

lib/Color.d.ts

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

* override the previous `value` property to be `null`.
* @param alpha - The color to multiply by.
* @param [applyToRGB=true] - Whether to premultiply RGB channels.
* @param alpha - The alpha to multiply by.
* @param {boolean} [applyToRGB=true] - Whether to premultiply RGB channels.
* @returns {PIXI.Color} - Itself.

@@ -199,6 +199,7 @@ */

* Premultiplies alpha with current color.
* @param {number} alpha - floating point alpha (0.0-1.0)
* @param {number} alpha - The alpha to multiply by.
* @param {boolean} [applyToRGB=true] - Whether to premultiply RGB channels.
* @returns {number} tint multiplied by alpha
*/
toPremultiplied(alpha: number): number;
toPremultiplied(alpha: number, applyToRGB?: boolean): number;
/**

@@ -205,0 +206,0 @@ * Convert to a hexidecimal string.

@@ -140,8 +140,8 @@ 'use strict';

}
toPremultiplied(alpha) {
toPremultiplied(alpha, applyToRGB = true) {
if (alpha === 1) {
return (alpha * 255 << 24) + this._int;
return (255 << 24) + this._int;
}
if (alpha === 0) {
return 0;
return applyToRGB ? 0 : this._int;
}

@@ -151,5 +151,7 @@ let r = this._int >> 16 & 255;

let b = this._int & 255;
r = r * alpha + 0.5 | 0;
g = g * alpha + 0.5 | 0;
b = b * alpha + 0.5 | 0;
if (applyToRGB) {
r = r * alpha + 0.5 | 0;
g = g * alpha + 0.5 | 0;
b = b * alpha + 0.5 | 0;
}
return (alpha * 255 << 24) + (r << 16) + (g << 8) + b;

@@ -189,19 +191,22 @@ }

normalize(value) {
let components;
let r;
let g;
let b;
let a;
if ((typeof value === "number" || value instanceof Number) && value >= 0 && value <= 16777215) {
const int = value;
components = [
(int >> 16 & 255) / 255,
(int >> 8 & 255) / 255,
(int & 255) / 255,
1
];
r = (int >> 16 & 255) / 255;
g = (int >> 8 & 255) / 255;
b = (int & 255) / 255;
a = 1;
} else if ((Array.isArray(value) || value instanceof Float32Array) && value.length >= 3 && value.length <= 4) {
value = this._clamp(value);
const [r, g, b, a = 1] = value;
components = [r, g, b, a];
[r, g, b, a = 1] = value;
} else if ((value instanceof Uint8Array || value instanceof Uint8ClampedArray) && value.length >= 3 && value.length <= 4) {
value = this._clamp(value, 0, 255);
const [r, g, b, a = 255] = value;
components = [r / 255, g / 255, b / 255, a / 255];
[r, g, b, a = 255] = value;
r /= 255;
g /= 255;
b /= 255;
a /= 255;
} else if (typeof value === "string" || typeof value === "object") {

@@ -216,8 +221,13 @@ if (typeof value === "string") {

if (color.isValid()) {
const { r, g, b, a } = color.rgba;
components = [r / 255, g / 255, b / 255, a];
({ r, g, b, a } = color.rgba);
r /= 255;
g /= 255;
b /= 255;
}
}
if (components) {
this._components.set(components);
if (r !== void 0) {
this._components[0] = r;
this._components[1] = g;
this._components[2] = b;
this._components[3] = a;
this.refreshInt();

@@ -224,0 +234,0 @@ } else {

{
"name": "@pixi/color",
"version": "7.2.3",
"version": "7.2.4",
"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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc