You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@pixi/color

Package Overview
Dependencies
Maintainers
2
Versions
21
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

to
7.2.3

13

lib/Color.d.ts

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

* Rounds the specified color according to the step. This action is destructive, and will
* override the previous `value` property to be `null`.
* @param step - Number of steps which will be used as a cap when rounding colors
* override the previous `value` property to be `null`. The alpha component is not rounded.
* @param steps - Number of steps which will be used as a cap when rounding colors
*/
round(step: number): this;
round(steps: number): this;
/**

@@ -244,2 +244,9 @@ * Convert to an [R, G, B, A] array of normalized floats (numbers from 0.0 to 1.0).

private refreshInt;
/**
* Clamps values to a range. Will override original values
* @param value - Value(s) to clamp
* @param min - Minimum value
* @param max - Maximum value
*/
private _clamp;
}

@@ -165,12 +165,10 @@ 'use strict';

setAlpha(alpha) {
this._components[3] = alpha;
this._components[3] = this._clamp(alpha);
return this;
}
round(step) {
round(steps) {
const [r, g, b] = this._components;
this._components.set([
Math.min(255, r / step * step),
Math.min(255, g / step * step),
Math.min(255, b / step * step)
]);
this._components[0] = Math.round(r * steps) / steps;
this._components[1] = Math.round(g * steps) / steps;
this._components[2] = Math.round(b * steps) / steps;
this.refreshInt();

@@ -199,6 +197,8 @@ this._value = null;

];
} else if ((Array.isArray(value) || value instanceof Float32Array) && value.length >= 3 && value.length <= 4 && value.every((v) => v <= 1 && v >= 0)) {
} 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];
} 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;

@@ -227,6 +227,15 @@ components = [r / 255, g / 255, b / 255, a / 255];

refreshInt() {
this._components.forEach((value, i) => this._components[i] = Math.min(Math.max(value, 0), 1));
this._clamp(this._components);
const [r, g, b] = this._components;
this._int = (r * 255 << 16) + (g * 255 << 8) + (b * 255 | 0);
}
_clamp(value, min = 0, max = 1) {
if (typeof value === "number") {
return Math.min(Math.max(value, min), max);
}
value.forEach((v, i) => {
value[i] = Math.min(Math.max(v, min), max);
});
return value;
}
};

@@ -233,0 +242,0 @@ let Color = _Color;

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