Changing the brightness of a graphics.draw object?

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
Calahagus
Prole
Posts: 6
Joined: Thu Jun 06, 2013 1:16 am

Changing the brightness of a graphics.draw object?

Post by Calahagus »

Just as the title says. Is there a function that I can use to change how bright an image I draw is, or do I have to do that outside of LOVE?
User avatar
veethree
Inner party member
Posts: 875
Joined: Sat Dec 10, 2011 7:18 pm

Re: Changing the brightness of a graphics.draw object?

Post by veethree »

To do that within love you'd need a shader i think.
nordbjerg
Prole
Posts: 12
Joined: Thu Jun 13, 2013 9:17 pm

Re: Changing the brightness of a graphics.draw object?

Post by nordbjerg »

Well, you could make a function that convert HSL into RGB.

https://love2d.org/wiki/HSL_color
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Changing the brightness of a graphics.draw object?

Post by Robin »

If you just want to darken it, you can use setColor with a gray color.
Help us help you: attach a .love.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Changing the brightness of a graphics.draw object?

Post by Boolsheet »

You can use the 'combine' color mode. See love.graphics.setColorMode and ColorMode. If I remember correctly, it does something like this.

Code: Select all

resulting color = color of texture + (color set with setColor - 128)
So setting a color of (128, 128, 128) means no change. Values above that get added, values below get subtracted.

Sadly, this function will be removed in the next version of LÖVE as we move on the the wondrous world of shaders.
Shallow indentations.
User avatar
Calahagus
Prole
Posts: 6
Joined: Thu Jun 06, 2013 1:16 am

Re: Changing the brightness of a graphics.draw object?

Post by Calahagus »

Robin wrote:If you just want to darken it, you can use setColor with a gray color.
This worked perfectly, should have thought of it myself. Thanks!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 79 guests