setColor simplified?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
hairy puppy
Prole
Posts: 29
Joined: Tue Apr 22, 2014 3:34 pm

setColor simplified?

Post 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...
lewis lepton
------
http://smokingbunny.net
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: setColor simplified?

Post 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)
User avatar
hairy puppy
Prole
Posts: 29
Joined: Tue Apr 22, 2014 3:34 pm

Re: setColor simplified?

Post 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 ;)
lewis lepton
------
http://smokingbunny.net
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: setColor simplified?

Post 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.
User avatar
hairy puppy
Prole
Posts: 29
Joined: Tue Apr 22, 2014 3:34 pm

Re: setColor simplified?

Post 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...
lewis lepton
------
http://smokingbunny.net
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: setColor simplified?

Post 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
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot] and 2 guests