Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamicBitmapText displayCallback seems to reverse red and blue channel. #5225

Closed
teebarjunk opened this issue Jul 16, 2020 · 1 comment
Closed

Comments

@teebarjunk
Copy link

Version

  • Phaser Version: 3.24.1
  • Operating system: Kubuntu (Linux)
  • Browser: Firefox

Description

For DynamicBitmapText.setDisplayCallback, when setting the characters color, the red and blue channels seem to be reversed.
It works fine when setting the DynamicBitmapText's tint color. Just not individual characters.

I think the problem lines are 236-239 in: DynamicBitmapTextWebGLRenderer.js
Where it calls: Utils.getTintAppendFloatAlpha

Example Test Code

this.text = this.add.dynamicBitmapText(16, 16, "font", "This should be red.");
this.text.setDisplayCallback((data) => {
	data.color = 0xff0000;
	return data;
});

Additional Information

I got it to work by swapping the r and b:

this.text = this.add.dynamicBitmapText(16, 16, "font", "This should be red.");
this.text.setDisplayCallback((data) => {
	data.color = 0xff0000;
	var b = data.color & 255;
	var g = (data.color >> 8) & 255;
	var r = (data.color >> 16) & 255;
	data.color = (1 << 24) + (b << 16) + (g << 8) + r;
	return data;
});
@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

Zachpocalypse pushed a commit to Zachpocalypse/phaser that referenced this issue Sep 16, 2020
…k` would inverse the red and blue channels if the color was not properly encoded for WebGL. It is now encoded automatically, meaning you can pass normal hex values as the colors in the display callback. Fix phaserjs#5225
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants