godotengine / godotengine/godot
Color wrapper for alpha values does not work
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Reproducible in 4.1.1 and 4.3
### System information
Godot v4.3.stable - Windows 10.0.22631 - GLES3 (Compatibility) - NVIDIA GeForce RTX 4070 Ti (NVIDIA; 32.0.15.6109) - AMD Ryzen 9 7950X 16-Core Processor (32 Threads)
### Issue description
On the docs for Color, there are wrappers for RGBA to use 0-255 instead of 0-1 values.
https://docs.godotengine.org/en/stable/classes/class_color.html#class-color-property-a
However, the wrapper for alpha (a) value does not work.
The docs should explain this or the engine should give a warning if values outside the expected range are used.
(Alternatively--the wrapper should behave as expected.)
Instead of using the wrapper, Color8 can also be used to strictly specify the 0-255 range.
### Steps to reproduce
Open the MRP below.
Run the root scene and observe the color behavior.
The lines are generated from left to right, from i=0 to i=num_lines.
We expect the first two lines to have the same color, but they do not:
line.default_color = Color(1, 1, 1, 51.0/255.0)
line.default_color = Color(255, 255, 255, 51)
The third and fourth lines show the expected behavior, demonstrated using Color8 (both lines should be the same color.)
line.default_color = Color(1, 1, 1, 51.0/255.0)
line.default_color = Color8(255, 255, 255, 51)
### Minimal reproduction project (MRP)
[color_test.zip](https://github.com/user-attachments/files/17104957/color_test.zip)
Contributor guide
Assessment
This issue has not been assessed yet.