Skip to content

GetColor32() shouldn't output negative values #7305

@samme

Description

@samme

Version

  • Phaser Version: 4.1.0

Description

Phaser.Display.Color.GetColor32() can output negative numbers (for 127 < alpha ≤ 255), but Phaser.Display.Color.ColorToRGBA() and Phaser.Display.Color.IntegerToRGB() treat input ≤ 0xffffff as 24-bit, ignoring alpha.

Example Test Code

const alpha = 128;
const color32 = Phaser.Display.Color.GetColor32(0, 0, 0, alpha);
const rgb = Phaser.Display.Color.IntegerToRGB(color32);
const rgba = Phaser.Display.Color.ColorToRGBA(color32);

console.assert(rgb.a === alpha, `rgb.a should be ${alpha} not ${rgb.a}`);
// "Assertion failed: rgb.a should be 128 not 255"

console.assert(rgba.a === alpha, `rgba.a should be ${alpha} not ${rgba.a}`);
// "Assertion failed: rgba.a should be 128 not 255"

Additional Information

Can be "fixed" with GetColor32() >>> 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions