Check if pixel is transparent
Moderators: Shine, Insert_witty_name
Check if pixel is transparent
Is there a way to check if a pixel in an image is transparent? When I use the img:pixel, the transparent pixels register as white for me. thanks.
"There is no spoone"
-The Matricks
-The Matricks
You can use "pixel" to get the color and "colors" to get the color components of a color object:
Code: Select all
image = Image.createEmpty(1, 1)
color = image:pixel(0, 0)
colors = color:colors()
assert(colors.r == 0)
assert(colors.g == 0)
assert(colors.b == 0)
assert(colors.a == 0)
Yes, I think 8888 should be the new pixelmode mode for Lua Player, because this makes things a lot easier and you have alpha blending and true color. The drawback is less speed, but you can use the Timer class for smooth animations, so you don't need 60 fps.
Not relying on a fixed fps rate, but using the Timer class, has another advantage: a port to the PC version would be much easier and it would run on PC smooth, too and on other consoles. And if someone wants to implement a caching algorithm for images in VRAM, it would be faster than the current Lua Player, even in true color :-)
Not relying on a fixed fps rate, but using the Timer class, has another advantage: a port to the PC version would be much easier and it would run on PC smooth, too and on other consoles. And if someone wants to implement a caching algorithm for images in VRAM, it would be faster than the current Lua Player, even in true color :-)