GetColor32() shouldn't output negative values
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- javascript
- Domain
- computer-graphics, game-dev
Research direction
Start by locating the implementations of Phaser.Display.Color.GetColor32(), ColorToRGBA(), and IntegerToRGB(), then reproduce the supplied alpha-128 example. Trace how the signed color32 value is classified and verify that the completed change preserves alpha through both conversion functions; add or run focused tests for alpha values above 127.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- JavaScript
- Stars
- 40.3k
- Forks
- 7.2k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from phaserjs/phaser
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·
-
client-controller-update ta-bot-triage team-money-movement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
MetaMask/metamask-mobile#36594 ·