Page 1 of 1

Clear a canvas?

Posted: Wed May 11, 2016 4:02 pm
by Miken1
Hello!

I'm getting this weird constant drawing effect when I'm drawing something on a canvas.
Am I doing something wrong?

Code: Select all

function love.load()
  
  x, y = 0, 0
  width, height = 10, 10
  love.graphics.setBackgroundColor(80,80,80)

  canvas = love.graphics.newCanvas(200, 200)
  
end
function love.update()
  
  x, y = x + 0.1, y + 0.1

end
function love.draw()
  love.graphics.setCanvas(canvas)
  love.graphics.rectangle("fill", x, y, width, height)
  love.graphics.setCanvas()
  love.graphics.draw(canvas, 0, 0)

end

Re: Clear a canvas?

Posted: Wed May 11, 2016 4:07 pm
by Jasoco
After you setCanvas, immediately clear it before you start drawing anything.

love.graphics.clear(color)

Where color is the color to make it. Use 0,0,0,0 or 255,255,255,0 or any other color as long as zero is the fourth (alpha) number if you want it to be transparent. Or leave the alpha empty if you want it opaque.

Re: Clear a canvas?

Posted: Wed May 11, 2016 4:14 pm
by Miken1
Jasoco wrote:After you setCanvas, immediately clear it before you start drawing anything.

love.graphics.clear(color)

Where color is the color to make it. Use 0,0,0,0 or 255,255,255,0 or any other color as long as zero is the fourth (alpha) number if you want it to be transparent. Or leave the alpha empty if you want it opaque.
Oh....


Thanks alot!

Re: Clear a canvas?

Posted: Wed May 11, 2016 4:17 pm
by Nixola
Miken1 wrote:Thanks alot!
Alot is welcome.