1 Reply Latest reply on Aug 3, 2006 1:48 PM by Newsgroup_User

    How to draw with alpha?

    WrongAgain Level 1
      I want to draw some lines and shape with alpha. Or to say, I want to erase some area in an image and let it become transparent. How can I write the code? Can I use draw() or fill()?

      For example, this code:

      c = member("TransparentImage").image.getPixel(nX, nY, #integer)

      If the place (nX,nY) is transparent(png image),the variable c will get color containing alpha. Now I want to do this :

      member("TransparentImage").image.draw(x1, y1, x2, y2, #integer:c)

      Of course, Director will say there is error in "#integer:c". But I want to draw a transparent square (to erase something) and I don't know how to write this sentence.

      How should I do?
        • 1. Re: How to draw with alpha?
          Level 7
          It's not clear whether by "erase" you are wanting to fill an area with a
          solid colour OR to draw into the image's alpha channel to make it
          transparent. Assuming the latter:
          i = duplicate(member("TransparentImage").image)
          a = i.extractAlpha()
          OK = a.draw(x1, y1, x2, y2, color(255, 255, 255))
          -- put "draw:", OK
          OK = i.setAlpha(a)
          -- put "setAlpha:", OK
          i.useAlpha = 1
          member("TransparentImage").image = i