Page 1 of 1

setColor simplified?

Posted: Mon Apr 28, 2014 2:30 pm
by hairy puppy
hello all,

just doing some color stuff and figured that setting colors could be done in an easier way for extreme simple settings. say between white and black, obviously has grey.
with the setColor, it would be good if you could set the color to 'setColor(255)' for white, or even black would be 'setColor(0)', and grey would be between those.
just figured it would make it quicker for just some simple setting rather than having 3 values that ultimately could be simply 1

anyhow...

Re: setColor simplified?

Posted: Mon Apr 28, 2014 3:07 pm
by Jasoco

Code: Select all

black = {0,0,0}
white = {255,255,255}
yellow = {255,255,0}
green = {0,255,0}
blue = {0,0,255}
red = {255,0,0}

love.graphics.setColor(white)

Re: setColor simplified?

Posted: Mon Apr 28, 2014 3:10 pm
by hairy puppy
that is one route, but why not just 'as is' in love itself. its not a complaint, more just a question for the future development.
but thanks for those, i think i may build up a color pallet using that that i can call up when coding ;)

Re: setColor simplified?

Posted: Mon Apr 28, 2014 4:54 pm
by Roland_Yonaba
So you want to boil down three values to a single one ?
I mean, AFAIK, you have to specify at least three values (or four, if you want alpha), respectively for red, gree and blue.
It might be possible to find a specific way to encode all those three values to a single number, and provide a new implementation of setColor that will take this number, get those three values back and feed setColor with them properly... Though I do not really see the point in doing that. :)

Alternatively, well, you can fairly implement it by yourself if this seems quite convenient to you.

Re: setColor simplified?

Posted: Mon Apr 28, 2014 5:13 pm
by hairy puppy
no, it would only be for grayscale [is that what its called?]
it was just for the simple fact of needing either white or black, or the grey inbetween. not all color [though on a technical scale white is all color ;)], just a simplified version of doing the most basic of color[s] which is white or black.
its possible in many languages, java, javascript, c, c++ etc

i just think it would be good in the long run...

Re: setColor simplified?

Posted: Mon Apr 28, 2014 7:10 pm
by Kingdaro
Only having to require one color is a bit ambiguous, and I don't think it needs to be implemented in LOVE itself. You can, however, make a simple function to generate gray colors:

Code: Select all

function gray(shade)
   return shade, shade, shade
end

function love.draw()
   love.graphics.setColor(gray(200))
   love.graphics.print("I am a nice shade of light gray.", 10, 10)
end