Page 1 of 1

Opacity

Posted: Thu Apr 02, 2009 1:21 pm
by Sparx
Hi there,

is tehre a way to set or change the opacity of an image?

Re: Opacity

Posted: Thu Apr 02, 2009 2:38 pm
by bartbes
I don't know for sure, but I guess when you set love.color_modulate you can just use setColor. (if you don't understand this I'd suggest reading the docs)

Re: Opacity

Posted: Thu Apr 02, 2009 2:47 pm
by Robin
I don't know if it's possible to change opacity with LÖVE. I just set the opacity in the .png-images that I load. (For example as with http://love2d.org/forum/viewtopic.php?f ... t=10#p5797.)

Re: Opacity

Posted: Thu Apr 02, 2009 10:49 pm
by Sparx
I mean there ust be the possibility changing the overal opacity of a loaded image.

Re: Opacity

Posted: Fri Apr 03, 2009 6:00 am
by bartbes
Compositing isn't possible (yet), but what I posted should work.

Re: Opacity

Posted: Fri Apr 03, 2009 5:14 pm
by mike
Sparx wrote:I mean there ust be the possibility changing the overal opacity of a loaded image.
Use color modulation:

Code: Select all

image = love.graphics.newImage("banana.jpg")
love.graphics.setColorMode(love.color_modulate)
love.graphics.setColor(255, 255, 255, 50) -- red, green, blue, opacity (this would be white with 20% opacity)
love.graphics.draw(image, 400, 300)
You can modulate the image to be any color, but if you set the color to white you can control the opacity while keeping the original colors.

Re: Opacity

Posted: Fri Apr 03, 2009 5:51 pm
by mikembley
Thanks for the solution Mike, I was scratching my head for ages trying to work this one out.. Im slightly bald in one spot now!

Re: Opacity

Posted: Fri Apr 03, 2009 6:21 pm
by bartbes
And this wasn't the same I said?

Re: Opacity

Posted: Sat Apr 04, 2009 12:22 pm
by Sparx
It definatley is. But a Problem is that in this specific solution i need to set these opacity settings each time I draw an image. Is there a way of saving the once modulated image to a new Image?

Re: Opacity

Posted: Sat Apr 04, 2009 12:44 pm
by Gerrit
Sparx wrote:It definatley is. But a Problem is that in this specific solution i need to set these opacity settings each time I draw an image. Is there a way of saving the once modulated image to a new Image?
Not yet but you can still make a function out of the above to call it each time you're drawing.