What?! What a f%ck?
Im sorry. So, if having some calm down obviously r, g and b just had squared, cuz for example 65025 / 255 = 255, logically.
But why it happened? I swear I do not change them... and they are constants at all.
All going as it should and have obvious solution or it's some issue that should appear in GitHub repository of Godot?
WTF: Color parameters was squared, color parameters are broken
Color values range from 0.0 to 1.0. It's good to check the documentation if you are confused.
https://docs.godotengine.org/en/stable/classes/class_color.html
You can use int values in the range 0..255, but that requires using the Color properties r8, g8 and b8, or manually converting from 0..255 to 0.0..1.0.
- Edited
Oh... ok, interfaces again tricked on me like in rotation case(degrees and radians). Thank's you, guys.
Fixed by that for now, not so elegant, so I think I should use 0-1 rgb or use built-in presets of colors, well, it's does not matter.
P.S. In place of "/ 255" should be "/ 255.0" either it's will be integer division and we always will have 0 or 1
Hi,
I don't know which version of Godot you are using, but in latest stable Godot version in color picker you can change display to give you exactly what you need to paste to your script. Just click the hash sign '#' and then it should display color in script format instead of hex.
- Edited
Color(70 / 255, 120 / 255, 255 / 255)
That won't have the desired result, since it uses integer division. It needs to use floating point division: Color(70.0 / 255.0, 120.0 / 255.0, 255.0 / 255.0)
The quoted post has been corrected, so this comment no longer applies.
@DaveTheCoder said:
Color(70 / 255, 120 / 255, 255 / 255)
That won't have the desired result, since it uses integer division. It needs to use floating point division: Color(70.0 / 255.0, 120.0 / 255.0, 255.0 / 255.0)
Rightly, how did I miss it... Just a second, I'll fix the post
- Edited
You do not need to use division to specify colors in the 0-255 range. Use the Color8()
constructor instead:
Color8(255, 0, 255, 128) # 50% opaque magenta.
Thanks, Calinou, I overlooked that one. I see that it's documented in the GDScript section, rather than the Color class section. https://docs.godotengine.org/en/stable/classes/class_@gdscript.html?highlight=color8#class-gdscript-method-color8
Color8 is also mentioned in the Color class description: https://docs.godotengine.org/en/stable/classes/class_color.html#class-color