mickeyjm wrote:Nixola wrote:Mickeyjm, that's exactly what I want to avoid. Canvas are fast and useful, it's not fair that some Windows users can't have them because Microsoft is dumb.
I mean get them to use love.graphcs.isSupported() then if it fails use ImageData otherwise, canvases
Appreciate where you're coming from.
Still fighting my way through ImageData.
Can't figure out how to direct drawing primitives to an image without using canvases.
We don't seem to have an equivalent for:
love.grahpics.setCanvas( canvas ) - something like love.graphics.setImage( image )
Guess that would essentially involve a canvas anyway.
But, if you are only dealing with pre-drawn (loaded from disk) images, you can get along pretty well.
Still looking for pointers (help) and examples - just to see how other people do it.
Conversions between userdata, imagedata & images are still a pain.
For those that are interested this is all the farther I've managed to get:
(note: I haven't found a way to convert an image to imagedata - just have to load an image as imagedata.)
Code: Select all
gr = love.graphics
-- load a host image
host = love.image.newImageData( 'buda.png' )
-- apply an effect to host image
host:mapPixel( effect )
-- load image to be inserted into host
insert = love.image.newImageData( 'Linux.png' )
-- insert imagedata into host
host:paste(insert,10,10,0,0,40,40)
-- create a drawing surface (canvas)
canvas = love.graphics.newCanvas( 20,20)
-- direct drawing to canvas
gr.setCanvas( canvas )
gr.setColor(255,55,255,255)
gr.circle('fill',10,10,8)
gr.setCanvas()
-- convert userdata (canvas) to imagedata
data = canvas:getImageData( )
-- add converted canvas to host imagedata
host:paste(data,30,30,0,0,20,20)
-- convert imagedata into an image
composite = gr.newImage(host)
-- now ready to draw composite
gr.setColorMode('replace')
gr.draw(composite,100,100)
Anything I missed or are using incorrectly (seems to work)?
Edit:
You can also put a image into a canvas:
Code: Select all
canvas:renderTo( function() gr.draw( image ) end )