-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Allow for quick-creating Colors from other Colors #23786
Comments
You can just do
or
|
Um, the first one doesn't fix anything. I want it to be a one-liner, because I often need this as a method argument. Doing it in two lines is counter-productive. As for the second one, I didn't know we can multiply colors like that. Looks like it could be enough, but still I need to define the constant each time and it's only for one alpha value. |
@KoBeWi you don't have to define the constant: var col = Color.red * Color(1,1,1, 0.5) |
What about ColorN? The first argument is the same constant name in String. var col = ColorN("red", alpha) Although a Color constructor that clones a Color and assign new alpha might be handy too. |
I added this to my PR for Now you can do this in GDScript:
Or, if you want a one-liner:
But @Naryosha's suggestion of ColorN would be better for this specific case of grabbing a preset color. |
(sorry if the title isn't clear, but I wasn't sure how to name it)
The issue is:
Godot 3.1 (or 3.0?) introduced color constants. You can now use
Color.red
for red etc. However, I sometimes need a translucent red. So I still need to useColor(1, 0, 0, 0.5)
. This is minor inconvenience of course, but since theColor.red
was introduced to avoidColor(1, 0, 0)
then why not go further?There are two "fixes" I can think of:
Color.red.with_alpha(0.5)
- it's actually longer, but I'd prefer that for whatever reason. Of course shorter version is possible (and preferred?), likeColor.red.w_a(0)
. (orColor.red.translucent(0.5)
)Or
Color.red.a = 0.5
could magically return red with 0.5 alpha`This might of course apply to other Color properties to quickly create colors from other colors, but with minor changes.
Well, this >_>
The text was updated successfully, but these errors were encountered: