Opacity

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Sparx
Party member
Posts: 125
Joined: Thu Apr 02, 2009 9:54 am
Location: Aachen, Germany

Opacity

Post by Sparx »

Hi there,

is tehre a way to set or change the opacity of an image?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Opacity

Post 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)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Opacity

Post 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.)
Help us help you: attach a .love.
User avatar
Sparx
Party member
Posts: 125
Joined: Thu Apr 02, 2009 9:54 am
Location: Aachen, Germany

Re: Opacity

Post by Sparx »

I mean there ust be the possibility changing the overal opacity of a loaded image.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Opacity

Post by bartbes »

Compositing isn't possible (yet), but what I posted should work.
User avatar
mike
Administrator
Posts: 364
Joined: Mon Feb 04, 2008 5:24 pm

Re: Opacity

Post 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.
Now posting IN STEREO (where available)
User avatar
mikembley
Citizen
Posts: 72
Joined: Wed Dec 17, 2008 5:30 pm
Location: Blackburn, UK
Contact:

Re: Opacity

Post 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!
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Opacity

Post by bartbes »

And this wasn't the same I said?
User avatar
Sparx
Party member
Posts: 125
Joined: Thu Apr 02, 2009 9:54 am
Location: Aachen, Germany

Re: Opacity

Post 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?
User avatar
Gerrit
Prole
Posts: 46
Joined: Wed Mar 25, 2009 7:40 pm

Re: Opacity

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

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 51 guests