Page 1 of 2
Transparency
Posted: Mon Apr 04, 2011 9:37 pm
by Iskai
Hi there. What's the recommended way of handling transparency with LOVE? I have a spritesheet in which my sprites are drawn on a magenta background (I previously used this with an SDL version of the same app) but I can't seem to figure out how to draw them without the magenta background.
Using setColor and setBackgroundColor just stops everything from being displayed - most frustrating.
It's my first time with LOVE and i'm....um... loving it.
Re: Transparency
Posted: Mon Apr 04, 2011 9:44 pm
by Robin
You can use transparency in a decent image editor, LÖVE will use that. Use the eraser, or the color-to-alpha function like the gimp has.
Re: Transparency
Posted: Mon Apr 04, 2011 9:50 pm
by Iskai
I was kind of thinking that yes, perhaps I could use a file format that supports transparency. I was more wondering if using existing assets (such as my spritesheet) was possible or must I modify it specially to work with LOVE?
Re: Transparency
Posted: Mon Apr 04, 2011 10:22 pm
by Taehl
Using alpha channels isn't a Love-specific thing, it's standard for EVERYTHING. The only reason that "magic magenta"/"garish green" thing ever caught on was due to .gif being popular before .png came around and did everything better.
Re: Transparency
Posted: Tue Apr 05, 2011 12:57 am
by Jasoco
I remember my DOOM hacking days. So much magenta. Soooo much magentaaaaa...
Use PNG. Or GIF. And don't use Paint.exe. Use Gimp or Photoshop or one of the hundreds of better free and paid image editors out there fore Windows, Linux or Mac.
Re: Transparency
Posted: Tue Apr 05, 2011 1:37 am
by Ensayia
It sort of amazes me that the paint program provided with the most recent Windows doesn't support layers or any sort of transparency whatsoever. Microsoft even upgraded the calculator! Poor paint gets forgotten...
Re: Transparency
Posted: Tue Apr 05, 2011 2:11 am
by Jasoco
But it has the Ribbon! Also known as the dividing line between two groups of people in an argument over whether the ribbon is awesome or the ribbon sucks. I'm in the "The ribbon is confusing as hell and they should just stick with menus and toolbars" camp actually.
Paint has everything BUT layers now. While IE9 is going the simplistic route, the rest of Windows is going the "complicate the interface to the point of confusion" route.
- NBoF5.png (427.91 KiB) Viewed 645 times
Windows doesn't even have a native PDF support that OS X has had since 2000.
Re: Transparency
Posted: Tue Apr 05, 2011 3:13 am
by sharpobject
Code: Select all
#!/usr/bin/python
from PIL import Image
import _imaging
import sys
for arg in sys.argv:
img = None
try:
img = Image.open(arg)
except:
continue
img = img.convert("RGBA")
datas = img.getdata()
newData = []
for r,g,b,a in datas:
if r == 255 and g == 0 and b == 255:
newData.append((255, 255, 255, 0))
else:
newData.append((r,g,b,a))
img.putdata(newData)
img.save(arg+".png")
Code: Select all
dripping:demo robert$ ls
image_0.bmp image_1.bmp maketransparent.py
dripping:demo robert$ ./maketransparent.py *
dripping:demo robert$ ls
image_0.bmp image_1.bmp maketransparent.py
image_0.bmp.png image_1.bmp.png
Re: Transparency
Posted: Tue Apr 05, 2011 6:18 am
by Iskai
I'm not saying that the whole magenta transparency thing is better or anything - I was just wondering if I'd missed something as there didn't seem to be an obvious way to define that colour as transparency. Based on your replies though, I'll simply use a PNG with transparency.
Jasoco wrote:
And don't use Paint.exe. Use Gimp or Photoshop or one of the hundreds of better free and paid image editors out there fore Windows, Linux or Mac.
I actually made my images with
http://www.aseprite.org/ - thankfully it supports those image formats as well. I wouldn't use MSPaint when there are much better, free alternatives available.
Thanks for the help!
Re: Transparency
Posted: Tue Apr 05, 2011 4:34 pm
by TechnoCat
Iskai wrote:I'm not saying that the whole magenta transparency thing is better or anything - I was just wondering if I'd missed something as there didn't seem to be an obvious way to define that colour as transparency.
Thanks for the help!
there is an obvious way to do it. I'm not sure why everyone else is sidetracking the question. However, the HUGE disadvantage to using magenta is the lack of alphas between 0 and 255.
imageFile -> ImageData
ImageData->
mapPixel()
return a=0 if magenta
imageData -> image