PDA

View Full Version : Colour for Transperant Pixels?



yaustar
July 11th, 2006, 19:15
Trying to do pixel perfect collision at the moment but hit a brick wall. What colour is returned using this function:

color = image:pixel(0, 0)
if the pixel is transperant? So far I have established that it isn't 0 or the colour that I set to be transperant in the image (ie (255, 0, 255) ) and I can't even get the RGB values to be printed out on the screen from the 'colour' I do get.

MasterChafed
July 12th, 2006, 00:15
is it even possible to make a transparent pixel using RGB? i know that 0,0,0 would be black and 255,255,255 is white. and all of the combos between are colors. I don't think you can make pixels transparent. Ic ould just be talking out of my bum here tho. ;)

yaustar
July 12th, 2006, 17:36
When you create a PNG/GIF file in 256 colour, you can tell the image editing program to say, "Any pixel THIS colour, will be transperant". The Luaplayer image loader will obtain this information when it parses the image.

My problem is: What 'colour value' is returned when image:pixel(x, y) is used when the pixel is transperant.

MasterChafed
July 12th, 2006, 18:23
hmm, thats a thinker. it should be 255,255,255 right? but you said it wasn't

yaustar
July 12th, 2006, 19:36
(255, 255, 255) is white. I have also tried checking against 'nil' but that doesn't work either.

It is returning something but I cant tell or access the information I need.

edit: Nevermind, I was just misunderstanding the documentation. Fixed now :).

MasterChafed
July 12th, 2006, 20:03
ok. i knew that 255 255 255 was white, and if you had set the pixel to be transparent as white, then that should have been it. just throwing out ideas. ;)

yaustar
July 12th, 2006, 20:41
I found that 'color' uses RGBA rather then RGB, so I just checked against the 'a' / alpha value.

Side note: I use bright pink for transpency ;). The least likely to be used as a real colour :P

MasterChafed
July 13th, 2006, 06:13
smart, i always use white :P glad u figured it out.