Socket
Socket
Sign inDemoInstall

@pixi/utils

Package Overview
Dependencies
Maintainers
2
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/utils - npm Package Compare versions

Comparing version 7.1.2 to 7.2.0-beta

27

lib/color/hex.d.ts
/**
* Converts a hexadecimal color number to an [R, G, B] array of normalized floats (numbers from 0.0 to 1.0).
* @example
* import { utils } from 'pixi.js';
* utils.hex2rgb(0xffffff); // returns [1, 1, 1]
* @memberof PIXI.utils
* @function hex2rgb
* @see PIXI.Color.toRgbArray
* @deprecated since 7.2.0
* @param {number} hex - The hexadecimal number to convert

@@ -15,5 +14,4 @@ * @param {number[]} [out=[]] - If supplied, this array will be used rather than returning a new one

* Converts a hexadecimal color number to a string.
* @example
* import { utils } from 'pixi.js';
* utils.hex2string(0xffffff); // returns "#ffffff"
* @see PIXI.Color.toHex
* @deprecated since 7.2.0
* @memberof PIXI.utils

@@ -27,12 +25,4 @@ * @function hex2string

* Converts a string to a hexadecimal color number.
* It can handle:
* - hex strings starting with #: "#ffffff"
* - hex strings starting with 0x: "0xffffff"
* - hex strings without prefix: "ffffff"
* - hex strings (3 characters) with #: "#fff"
* - hex strings (3 characters) without prefix: "fff"
* - css colors: "black"
* @example
* import { utils } from 'pixi.js';
* utils.string2hex("#ffffff"); // returns 0xffffff, which is 16777215 as an integer
* @deprecated since 7.2.0
* @see PIXI.Color.toNumber
* @memberof PIXI.utils

@@ -46,5 +36,4 @@ * @function string2hex

* Converts a color as an [R, G, B] array of normalized floats to a hexadecimal number.
* @example
* import { utils } from 'pixi.js';
* utils.rgb2hex([1, 1, 1]); // returns 0xffffff, which is 16777215 as an integer
* @deprecated since 7.2.0
* @see PIXI.Color.toNumber
* @memberof PIXI.utils

@@ -51,0 +40,0 @@ * @function rgb2hex

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

var cssColorNames = require('./../external/css-color-names/css-color-names.js');
var color = require('@pixi/color');
var deprecation = require('../logging/deprecation.js');
function hex2rgb(hex, out = []) {
out[0] = (hex >> 16 & 255) / 255;
out[1] = (hex >> 8 & 255) / 255;
out[2] = (hex & 255) / 255;
return out;
deprecation.deprecation("7.2.0", "utils.hex2rgb is deprecated, use Color#toRgbArray instead");
return color.Color.shared.setValue(hex).toRgbArray(out);
}
function hex2string(hex) {
let hexString = hex.toString(16);
hexString = "000000".substring(0, 6 - hexString.length) + hexString;
return `#${hexString}`;
deprecation.deprecation("7.2.0", "utils.hex2string is deprecated, use Color#toHex instead");
return color.Color.shared.setValue(hex).toHex();
}
function string2hex(string) {
if (typeof string === "string") {
string = cssColorNames["default"][string.toLowerCase()] || string;
if (string[0] === "#") {
string = string.slice(1);
}
if (string.length === 3) {
const [r, g, b] = string;
string = r + r + g + g + b + b;
}
}
return parseInt(string, 16);
deprecation.deprecation("7.2.0", "utils.string2hex is deprecated, use Color#toNumber instead");
return color.Color.shared.setValue(string).toNumber();
}
function rgb2hex(rgb) {
return (rgb[0] * 255 << 16) + (rgb[1] * 255 << 8) + (rgb[2] * 255 | 0);
deprecation.deprecation("7.2.0", "utils.rgb2hex is deprecated, use Color#toNumber instead");
return color.Color.shared.setValue(rgb).toNumber();
}

@@ -35,0 +25,0 @@

@@ -17,31 +17,31 @@ /**

/**
* combines rgb and alpha to out array
* @memberof PIXI.utils
* @function premultiplyRgba
* @param {Float32Array|number[]} rgb - input rgb
* @param {number} alpha - alpha param
* @param {Float32Array} [out] - output
* @param {boolean} [premultiply=true] - do premultiply it
* @returns {Float32Array} vec4 rgba
* @deprecated since 7.2.0
* @see PIXI.Color.premultiply
* @param {Float32Array|number[]} rgb -
* @param {number} alpha -
* @param {Float32Array} [out] -
* @param {boolean} [premultiply=true] -
*/
export declare function premultiplyRgba(rgb: Float32Array | number[], alpha: number, out?: Float32Array, premultiply?: boolean): Float32Array;
/**
* premultiplies tint
* @memberof PIXI.utils
* @function premultiplyTint
* @param {number} tint - integer RGB
* @param {number} alpha - floating point alpha (0.0-1.0)
* @returns {number} tint multiplied by alpha
* @deprecated since 7.2.0
* @see PIXI.Color.toPremultiplied
* @param {number} tint -
* @param {number} alpha -
*/
export declare function premultiplyTint(tint: number, alpha: number): number;
/**
* converts integer tint and float alpha to vec4 form, premultiplies by default
* @memberof PIXI.utils
* @function premultiplyTintToRgba
* @param {number} tint - input tint
* @param {number} alpha - alpha param
* @param {Float32Array} [out] - output
* @param {boolean} [premultiply=true] - do premultiply it
* @returns {Float32Array} vec4 rgba
* @deprecated since 7.2.0
* @see PIXI.Color.premultiply
* @param {number} tint -
* @param {number} alpha -
* @param {Float32Array} [out] -
* @param {boolean} [premultiply=true] -
*/
export declare function premultiplyTintToRgba(tint: number, alpha: number, out: Float32Array, premultiply?: boolean): Float32Array;
export declare function premultiplyTintToRgba(tint: number, alpha: number, out?: Float32Array, premultiply?: boolean): Float32Array;

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

var color = require('@pixi/color');
var constants = require('@pixi/constants');
var deprecation = require('../logging/deprecation.js');

@@ -30,43 +32,13 @@ function mapPremultipliedBlendModes() {

}
function premultiplyRgba(rgb, alpha, out, premultiply) {
out = out || new Float32Array(4);
if (premultiply || premultiply === void 0) {
out[0] = rgb[0] * alpha;
out[1] = rgb[1] * alpha;
out[2] = rgb[2] * alpha;
} else {
out[0] = rgb[0];
out[1] = rgb[1];
out[2] = rgb[2];
}
out[3] = alpha;
return out;
function premultiplyRgba(rgb, alpha, out, premultiply = true) {
deprecation.deprecation("7.2.0", `utils.premultiplyRgba has moved to Color.premultiply`);
return color.Color.shared.setValue(rgb).premultiply(alpha, premultiply).toArray(out ?? new Float32Array(4));
}
function premultiplyTint(tint, alpha) {
if (alpha === 1) {
return (alpha * 255 << 24) + tint;
}
if (alpha === 0) {
return 0;
}
let R = tint >> 16 & 255;
let G = tint >> 8 & 255;
let B = tint & 255;
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;
deprecation.deprecation("7.2.0", `utils.premultiplyTint has moved to Color.toPremultiplied`);
return color.Color.shared.setValue(tint).toPremultiplied(alpha);
}
function premultiplyTintToRgba(tint, alpha, out, premultiply) {
out = out || new Float32Array(4);
out[0] = (tint >> 16 & 255) / 255;
out[1] = (tint >> 8 & 255) / 255;
out[2] = (tint & 255) / 255;
if (premultiply || premultiply === void 0) {
out[0] *= alpha;
out[1] *= alpha;
out[2] *= alpha;
}
out[3] = alpha;
return out;
function premultiplyTintToRgba(tint, alpha, out, premultiply = true) {
deprecation.deprecation("7.2.0", `utils.premultiplyTintToRgba has moved to Color.premultiply`);
return color.Color.shared.setValue(tint).premultiply(alpha, premultiply).toArray(out ?? new Float32Array(4));
}

@@ -73,0 +45,0 @@

@@ -15,5 +15,2 @@ /**

* console.log(utils.isMobile);
*
* // Convert hex color to string
* console.log(utils.hex2string(0xff00ff)); // returns: "#ff00ff"
* @namespace PIXI.utils

@@ -20,0 +17,0 @@ */

@@ -28,4 +28,7 @@ /**

isEmpty(): boolean;
/** An empty BoundingBox. */
/**
* An empty BoundingBox.
* @type {PIXI.utils.BoundingBox}
*/
static readonly EMPTY: BoundingBox;
}

@@ -7,3 +7,3 @@ import type { BaseTexture, Program, Texture } from '@pixi/core';

* @memberof PIXI.utils
* @type {object}
* @type {Record<string, Program>}
*/

@@ -18,3 +18,3 @@ export declare const ProgramCache: {

* @memberof PIXI.utils
* @type {object}
* @type {Record<string, Texture>}
*/

@@ -29,3 +29,3 @@ export declare const TextureCache: {

* @memberof PIXI.utils
* @type {object}
* @type {Record<string, BaseTexture>}
*/

@@ -32,0 +32,0 @@ export declare const BaseTextureCache: {

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

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

"dependencies": {
"@pixi/constants": "7.1.2",
"@pixi/settings": "7.1.2",
"@pixi/color": "7.2.0-beta",
"@pixi/constants": "7.2.0-beta",
"@pixi/settings": "7.2.0-beta",
"@types/earcut": "^2.1.0",

@@ -46,7 +47,3 @@ "earcut": "^2.2.4",

"url": "^0.11.0"
},
"devDependencies": {
"css-color-names": "^1.0.1"
},
"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

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