garrysmod
garrysmod copied to clipboard
Default the color creation to white when no arguments are provided
These will produce the same result in range [0-255]:
Color(1,2,3,4)
Color(Color(1,2,3,4))
Color({1,2,3,4})
Color({r=1,g=2,b=3,a=4})
I do not see the convinence of the default args, especially with an already-present color_white const, and the constructor additions have been done more efficiently and cohesively here: https://github.com/Facepunch/garrysmod/pull/1312
@Kefta
What should the 2-nd, 3-rd and 4-th option return then ?
The 4th already defaults to 255, the 1st thru 3rd should not be optional.
Can we just have a separate function for this? Color is already the most callable function
@GitSparTV The idea is to be able to be called like Vector() and defaulting to 255 will not change anything as right now everyone calls it with Color(0,0,0) for example by providing at least 3 arguments.
Vector() works as a single constructor because it's a C func which can handle multiple Lua types. Adding this same functionality to Color in Lua is going to significantly slow the func down.
@Kefta Will wait for the other patch implementation then. Will be nice to have Color() ;)
color_white >:v
racist
Well, using Color(rgba) is the way to go to create one and use it for whatever