Skip to content

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

@teebarjunk

Description

@teebarjunk

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;
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions