Unfortunately, I have a problem. Whatever color I set when drawing to canvas, this is not kept when drawing cached canvas from the main loop.
I can individually set canvas drawing color in the loop, e.g. when color is set to red in love.draw, drawing canvas is red.
I am using 'alpha', 'premultiplied' as recommended.
Is canvas two colors only (black and white) or can you draw to canvas multiple colors?
code example:
Code: Select all
mapvars.finalstate=love.graphics.newCanvas(mapvars.width, mapvars.height)
love.graphics.setCanvas(mapvars.finalstate)
love.graphics.setColor(color) -- different colors based on structure type (red, blue, gray etc.)
love.graphics.line(mapvars.offset.x+structures[i].coords[o].x, mapvars.offset.y+structures[i].coords[o].y, mapvars.offset.x+structures[i].coords[o+1].x, mapvars.offset.y+structures[i].coords[o+1].y)
-- store ImageData object for later use
love.graphics.setCanvas()
Code: Select all
love.graphics.setBlendMode('alpha', 'premultiplied')
love.graphics.draw(mapvars.finalstate)
-- everything is white background, [b]black lines only[/b]