********************* Users who are 'canvas challenged' need read no further. **************************
I have found the syntax used to deal with canvases somewhat clunky and have come up with a slightly different one.
Was wonder if this might be of interest for future releases of Love.
Currently:
Code: Select all
canvas = love.graphics.newCanvas( width, height )
love.graphics.setCanvas( canvas )
love.graphics.draw( image )
love.graphics.setColor( { 255, 0, 0, 255 } )
love.graphics.circle( 'line', 45, 45, 20 )
love.graphics.setColor( { 255, 255, 255, 255 } )
love.graphics.setFont( gr.newFont( 16 ) )
love.graphics.print( 'message', 5, 75 )
love.graphics.rectangle( 'fill', 35, 35, 20, 20 )
love.graphics.setColor( {0, 0, 0, 255} )
love.graphics.print( '2', 40, 35 )
love.graphics.setCanvas()
Code: Select all
love.graphics.draw( canvas, 100,100, angle,1,1,45,45 )
Code: Select all
can3 = newCanvas( image )
can3:Color( 255, 0, 0, 255 )
can3:circle( 'line', 45, 45, 20 )
can3:Color( 255, 255, 255, 255 )
can3:fontsize( 16 )
can3:text( 'message', 5, 75 )
can3:box( 'fill', 35, 35, 20, 20 )
can3:Color( 0, 0, 0, 255 )
can3:text( '2', 40, 35 )
Code: Select all
can3:draw( 100, 100, angle, 1, 1, can3.canvas:getWidth()/2, can3.canvas:getHeight()/2)
I just find it easier to read code later especially when I didn't use 'canvas' for a name but something more descriptive.
No speed advantage (or penalty) and could be extended to use fake canvases.
Of any merit or better to leave well enough alone?
Your opinion?
Edit: Canvas.lua library updated with more love.graphics features.
Canvas:line() now permits any number of line segments to be handled in one call. Points can be individually listed or put in a table and Canvas:trianglestrip() added.
Other Canvas functions now pass all the usual love.graphics settings straight through.