Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
RenderTarget with Alpha — Gideros Forum

RenderTarget with Alpha

antixantix Member
edited September 2015 in General questions
Hey all. I am trying to draw a shape on my RenderTarget with Alpha but it doesn;t seem to work, the shape always seems to have alpha of 1 in the end. How can I get the alpha to work?
  local canvas = RenderTarget.new(512, 512)
  local brush = Shape.new()
  local x, y, w, h = 128, 128, 256, 256
 
  brush:setFillStyle(Shape.SOLID, 0xff4422, 0.1)
  brush:setLineStyle(2, 0x113311, 0.1)
 
  brush:setBlendMode(Sprite.ALPHA)
  brush:setAlpha(0.1)
 
  brush:beginPath()
  brush:moveTo(x, y)
  brush:lineTo(x + w, y)
  brush:lineTo(x + w, y + h)
  brush:lineTo(x, y + h)
  brush:lineTo(x, y)
  brush:endPath()
 
  canvas:draw(brush)

Comments

  • tkhnomantkhnoman Member
    edited September 2015
    Did you clear your renderTarget on redraw?

    Edit:
    Wait, I think i know what you want to do.
    Do you want to create a brush, that when drawn to a canvas, it would have a certain maximum alpha?
    It would be hard to do that, not sure how.
    For me, i would prefer to create another canvas layer with controlled alpha.
  • @tkhnoman - thanks, that is correct, I want to draw my brush onto my canvas with an alpha value. I tried clearing the canvas first with an alpha of 0.25 but the end result was still an image with no alpha. It seems that shapes cannot be drawn to a Rendertarget using alpha.

    A bit dissapointing but I'm sure I can work around it.
Sign In or Register to comment.