Ok so I know how to blit Alpha Images over top of other images but, only in rectangles.
Is there a way to just blit the image to the screen with an Alpha Mask like... it just draws an alpha value over the image only(with transparent parts).
This is so I can make just the player have a different tint instead of the rectangle of the player have the different tint.
Please any help would be much appreciated.
			
			
									
									
						Creating Masks... Alpha Value
Moderators: Shine, Insert_witty_name
- 
				my psprecious
 - Posts: 24
 - Joined: Fri Feb 17, 2006 5:08 am
 
I'm pretty sure this would be rediculously not neccessary lol
Not entirely sure that would work, but hey, worth a try.
			
			
									
									
						Code: Select all
image = Image.load("myimage.png")
grey = Color.new(127,127,127,127)
for y=1,image:width() do
 for x=1,image:height() do
  color = image:pixel(x,y)
  rgb = color:colors()
  if rgb:a() == 0 then
   image:fillRect(x,y,1,1,grey)
  end
 end
end
Well...
With a litle bit of adjustments this actually works pretty well.
Here is the function I wrote with the help of Kameku's code:
Call it like this:
AND... THANK YOU SO MUCH Kameku!!!
With this I can create lots of cool stuff.
			
			
									
									
						Here is the function I wrote with the help of Kameku's code:
Code: Select all
function Image:DrawAlpha(X, Y, MaskColour, BGColour)
  if MaskColour then
    if not X then X = 0 end
    if not Y then Y = 0 end
    imgAlpha = Image.createEmpty(self:width(), self:height())
    for YPos=0,self:width()-1 do
     for XPos=0,self:height()-1 do
      color = self:pixel(XPos,YPos)
      rgb = color:colors()
      if rgb.a == 0 then
        if BGColour then screen:fillRect(XPos,YPos,1,1,BGColour) end
      else
        imgAlpha:fillRect(XPos,YPos,1,1,MaskColour)
      end
     end
    end
    screen:blit(X, Y, imgAlpha)
  end
endCode: Select all
imgStar = Image.load("Star.PNG")
imgStar:DrawAlpha(0,0,Color.new(200,0,0,200))With this I can create lots of cool stuff.