I was experimenting with the canvas. In the test when you click a green dot is placed at your cursor position, but the green dots are only visible for a short time after you click.
function love.load()
dots = love.graphics.newCanvas(800, 600)
love.mouse.setVisible(false)
end
function love.mousepressed(x, y, button)
if button == "l" then
love.graphics.setCanvas(dots)
love.graphics.setColor(0, 255, 0, 255)
love.graphics.circle("fill", x, y, 10, 16)
love.graphics.setCanvas()
end
end
function love.draw()
love.graphics.setBlendMode('premultiplied')
love.graphics.draw(dots)
local x, y = love.mouse.getPosition()
love.graphics.setColor(255, 0, 0)
love.graphics.circle("fill", x, y, 20, 16)
end
Yeah, it's one of the problems with the love.graphics API model of setting global state for something that is usually only intended to affect the few lines directly below it.
Suggestions for how to improve the situation are welcome.
slime wrote:Suggestions for how to improve the situation are welcome.
How about additional 'color' parameter in primitive drawing functions?
SDL_draw and SDL_gfx libraries uses this approach.
And soon after, the need for a "blendmode" parameter comes, then another, then another...
And finally, we can all stop worrying
about lg.draw(drawable,x,y,z,r,sx,sy,ox,oy,color,blendmode,mesh,source,scissors,vbo,u,v) et. al.
affecting any state at all
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.