How to use the @pixi/utils.rgb2hex function in @pixi/utils

To help you get started, we’ve selected a few @pixi/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pixijs / pixi-filters / filters / multi-color-replace / src / MultiColorReplaceFilter.js View on Github external
throw `Length of replacements (${colorCount}) exceeds the maximum colors length (${this._maxColors})`;
        }

        // Fill with negative values
        originals[colorCount * 3] = -1;

        for (let i = 0; i < colorCount; i++) {
            const pair = replacements[i];

            // for original colors
            let color = pair[0];
            if (typeof color === 'number') {
                color = hex2rgb(color);
            }
            else {
                pair[0] = rgb2hex(color);
            }

            originals[i * 3] = color[0];
            originals[(i * 3) + 1] = color[1];
            originals[(i * 3) + 2] = color[2];

            // for target colors
            let targetColor = pair[1];
            if (typeof targetColor === 'number') {
                targetColor = hex2rgb(targetColor);
            }
            else {
                pair[1] = rgb2hex(targetColor);
            }

            targets[i * 3] = targetColor[0];
github pixijs / pixi.js / packages / canvas / canvas-renderer / src / CanvasTinter.js View on Github external
roundColor: (color) =>
    {
        const step = CanvasTinter.cacheStepsPerColorChannel;

        const rgbValues = hex2rgb(color);

        rgbValues[0] = Math.min(255, (rgbValues[0] / step) * step);
        rgbValues[1] = Math.min(255, (rgbValues[1] / step) * step);
        rgbValues[2] = Math.min(255, (rgbValues[2] / step) * step);

        return rgb2hex(rgbValues);
    },
github pixijs / pixi.js / packages / graphics / src / Graphics.js View on Github external
{
            sprite.tint = fillColor;
        }
        else if (this.tint !== this._prevRectTint || fillColor !== this._prevRectFillColor)
        {
            const t1 = tempColor1;
            const t2 = tempColor2;

            hex2rgb(fillColor, t1);
            hex2rgb(this.tint, t2);

            t1[0] *= t2[0];
            t1[1] *= t2[1];
            t1[2] *= t2[2];

            sprite.tint = rgb2hex(t1);

            this._prevRectTint = this.tint;
            this._prevRectFillColor = fillColor;
        }

        sprite.alpha = this.graphicsData[0].fillAlpha;
        sprite.worldAlpha = this.worldAlpha * sprite.alpha;
        sprite.blendMode = this.blendMode;

        sprite._texture._frame.width = rect.width;
        sprite._texture._frame.height = rect.height;

        sprite.transform.worldTransform = this.transform.worldTransform;

        sprite.anchor.set(-rect.x / rect.width, -rect.y / rect.height);
        sprite._onAnchorUpdate();
github pixijs / pixi-filters / filters / simple-lightmap / src / SimpleLightmapFilter.js View on Github external
set color(value) {
        const arr = this.uniforms.ambientColor;
        if (typeof value === 'number') {
            hex2rgb(value, arr);
            this._color = value;
        }
        else {
            arr[0] = value[0];
            arr[1] = value[1];
            arr[2] = value[2];
            arr[3] = value[3];
            this._color = rgb2hex(arr);
        }
    }
    get color() {
github pixijs / pixi-filters / filters / color-replace / src / ColorReplaceFilter.js View on Github external
set newColor(value) {
        let arr = this.uniforms.newColor;
        if (typeof value === 'number') {
            hex2rgb(value, arr);
            this._newColor = value;
        }
        else {
            arr[0] = value[0];
            arr[1] = value[1];
            arr[2] = value[2];
            this._newColor = rgb2hex(arr);
        }
    }
    get newColor() {
github pixijs / pixi-filters / filters / drop-shadow / src / DropShadowFilter.js View on Github external
get color() {
        return rgb2hex(this._tintFilter.uniforms.color);
    }
    set color(value) {
github pixijs / pixi-filters / filters / bevel / src / BevelFilter.js View on Github external
get lightColor() {
        return rgb2hex(this.uniforms.lightColor);
    }
    set lightColor(value) {
github pixijs / pixi-filters / filters / outline / src / OutlineFilter.js View on Github external
get color() {
        return rgb2hex(this.uniforms.outlineColor);
    }
    set color(value) {
github pixijs / pixi-filters / filters / color-replace / src / ColorReplaceFilter.js View on Github external
set originalColor(value) {
        let arr = this.uniforms.originalColor;
        if (typeof value === 'number') {
            hex2rgb(value, arr);
            this._originalColor = value;
        }
        else {
            arr[0] = value[0];
            arr[1] = value[1];
            arr[2] = value[2];
            this._originalColor = rgb2hex(arr);
        }
    }
    get originalColor() {