Color masking possible?

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
ecliptic
Prole
Posts: 10
Joined: Wed Jul 01, 2009 12:34 pm

Color masking possible?

Post by ecliptic »

Hello. I'm thinking about doing a puzzle game, but one of the key things I need to make the presentation correct is allow color masking on all drawn objects, to simulate the user putting red goggles, green goggles, blue goggles, etc. thus giving everything a tint of the proper color when the proper glasses are being worn.

I checked through the documentation but couldn't seem to find anything to do that, unless one of the blending modes could help me, but the documentation regarding that functionality is somewhat sparse. If there's a way to do it at the rendered screen level too, that's fine, but again I didn't see anything indicating post-processing of this sort is doable at this point.

Thanks for your help!
User avatar
Almost
Prole
Posts: 42
Joined: Fri Aug 21, 2009 8:04 pm
Location: Canada
Contact:

Re: Color masking possible?

Post by Almost »

love.graphics.setColorMode(love.color_modulate) --see http://love2d.org/docs/Constants.html for the values of things like colormode

love.graphics.setColor(255,200,200) --slightly red color
love.graphics.draw(image,100,100) --image will now be drawn with a red tint (rather, the green and blue values of the image will be lessened)


That allows for tinting when drawing images, you still have to set colors before you draw stuff to make it the right color. The alternate solution is, of course, to just draw a massive transparent rectangle in front of everything.

love.graphics.setColor(255,0,0,32) --transparent red
love.graphics.rectangle(love.draw_fill,0,0,love.graphics.getWidth(),love.graphics.getHeight())
ecliptic
Prole
Posts: 10
Joined: Wed Jul 01, 2009 12:34 pm

Re: Color masking possible?

Post by ecliptic »

Perfect! Thank you so much! :)
Post Reply

Who is online

Users browsing this forum: No registered users and 80 guests