garrysmod icon indicating copy to clipboard operation
garrysmod copied to clipboard

Default the color creation to white when no arguments are provided

Open dvdvideo1234 opened this issue 4 years ago • 10 comments
trafficstars

dvdvideo1234 avatar Oct 31 '21 10:10 dvdvideo1234

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

dvdvideo1234 avatar Oct 31 '21 17:10 dvdvideo1234

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 avatar Nov 01 '21 00:11 Kefta

@Kefta

What should the 2-nd, 3-rd and 4-th option return then ?

dvdvideo1234 avatar Nov 01 '21 16:11 dvdvideo1234

The 4th already defaults to 255, the 1st thru 3rd should not be optional.

Kefta avatar Nov 01 '21 16:11 Kefta

Can we just have a separate function for this? Color is already the most callable function

GitSparTV avatar Nov 01 '21 17:11 GitSparTV

@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.

dvdvideo1234 avatar Nov 03 '21 16:11 dvdvideo1234

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 avatar Nov 04 '21 00:11 Kefta

@Kefta Will wait for the other patch implementation then. Will be nice to have Color() ;)

dvdvideo1234 avatar Nov 04 '21 07:11 dvdvideo1234

color_white >:v

thegrb93 avatar Nov 04 '21 07:11 thegrb93

racist

ExtReMLapin avatar Nov 15 '21 12:11 ExtReMLapin

Well, using Color(rgba) is the way to go to create one and use it for whatever

dvdvideo1234 avatar Jan 13 '23 15:01 dvdvideo1234