How to use the @pixi/utils.hex2rgb 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.js / packages / graphics / src / GraphicsRenderer.js View on Github external
this.updateGraphics(graphics);

            webGL = graphics._webGL[this.CONTEXT_UID];
        }

        // This  could be speeded up for sure!
        const shader = this.primitiveShader;

        renderer.state.setBlendMode(graphics.blendMode);

        for (let i = 0, n = webGL.data.length; i < n; i++)
        {
            webGLData = webGL.data[i];

            shader.uniforms.translationMatrix = graphics.transform.worldTransform.toArray(true);
            shader.uniforms.tint = hex2rgb(graphics.tint);
            shader.uniforms.alpha = graphics.worldAlpha;

            renderer.shader.bind(shader);
            renderer.geometry.bind(webGLData.geometry);

            if (webGLData.nativeLines)
            {
                renderer.geometry.draw(gl.LINES, webGLData.indices.length / 6);
            }
            else
            {
                renderer.geometry.draw(gl.TRIANGLE_STRIP, webGLData.indices.length);
            }
        }
    }
github pixijs / pixi.js / packages / graphics / src / utils / buildRoundedRectangle.js View on Github external
const radius = rrectData.radius;

    const recPoints = [];

    recPoints.push(x, y + radius);
    quadraticBezierCurve(x, y + height - radius, x, y + height, x + radius, y + height, recPoints);
    quadraticBezierCurve(x + width - radius, y + height, x + width, y + height, x + width, y + height - radius, recPoints);
    quadraticBezierCurve(x + width, y + radius, x + width, y, x + width - radius, y, recPoints);
    quadraticBezierCurve(x + radius, y, x, y, x, y + radius + 0.0000000001, recPoints);

    // this tiny number deals with the issue that occurs when points overlap and earcut fails to triangulate the item.
    // TODO - fix this properly, this is not very elegant.. but it works for now.

    if (graphicsData.fill)
    {
        const color = hex2rgb(graphicsData.fillColor);
        const alpha = graphicsData.fillAlpha;

        const r = color[0] * alpha;
        const g = color[1] * alpha;
        const b = color[2] * alpha;

        const verts = webGLData.points;
        const indices = webGLData.indices;

        const vecPos = verts.length / 6;

        const triangles = earcut(recPoints, null, 2);

        for (let i = 0, j = triangles.length; i < j; i += 3)
        {
            indices.push(triangles[i] + vecPos);
github pixijs / pixi-filters / filters / outline / src / OutlineFilter.js View on Github external
set color(value) {
        hex2rgb(value, this.uniforms.outlineColor);
    }
}
github pixijs / pixi.js / packages / graphics / src / Graphics.js View on Github external
this._spriteRect = new Sprite(new Texture(Texture.WHITE));
        }

        const sprite = this._spriteRect;
        const fillColor = this.graphicsData[0].fillColor;

        if (this.tint === 0xffffff)
        {
            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;
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 / bevel / src / BevelFilter.js View on Github external
set lightColor(value) {
        hex2rgb(value, this.uniforms.lightColor);
    }
github pixijs / pixi-filters / filters / glow / src / GlowFilter.js View on Github external
set color(value) {
        hex2rgb(value, this.uniforms.glowColor);
    }