Seeking comments regarding canvas syntax

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
qaisjp
Party member
Posts: 490
Joined: Tue Sep 04, 2012 10:49 am
Location: United Kingdom
Contact:

Re: Seeking comments regarding canvas syntax

Post by qaisjp »

Ref wrote:Replaced drawi and drawc with a single draw.
Thanks for the suggestion!
What is drawi? drawc seems to be "draw canvas", but what does drawi stand for?
what is this licensed under? mit? creative commons zero? public domain? same license as love?

fake canvas would be helpful ;P

you're welcome.
Lua is not an acronym.
User avatar
Xgoff
Party member
Posts: 211
Joined: Fri Nov 19, 2010 4:20 am

Re: Seeking comments regarding canvas syntax

Post by Xgoff »

qaisjp wrote:
Ref wrote:Replaced drawi and drawc with a single draw.
Thanks for the suggestion!
What is drawi? drawc seems to be "draw canvas", but what does drawi stand for?
"image" presumably
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Seeking comments regarding canvas syntax

Post by Ref »

'drawc' and 'drawi' have been depreciated.
They were originally a clumsy way to enable drawing a canvas (drawc)and drawing an image (drawi).
Newer version(see attachment) eliminates both, replacing it with a simgle draw for both canvases and images.
However, this introduces another complication.
In order to use any of the canvas functions, the object calling the action must have a metatable attached ( via object = newCanvas( item ) where item is an image, filename or width & height for a new canvas.
So to draw an image, you have to do imagecanvas=newCanvas( image_filename) and then imagecanvas:draw( ... ).
(Don't know what garbagecollection will do with all the extraneous canvases - help!)

As far as license goes, feel free to say what ever you want - talk is cheap.
I wasn't intending this to be useable code but to see if the developers of LOVE would think that this might be something to consider (if there was any interest) for future releases.

The code is very primitive and some of the more senior members of the community (after they stop laughing) could improve on it (corrections and comments saught). Documentaion is non-existing so code is only of interest to the more adventuresome.
Use, modify, correct, enhanse as you see fit and please don't blame me for my limited programming skills - still just learning.
Attachments
Modified_Canvas_Demo2.love
lates & greatest
(26.07 KiB) Downloaded 68 times
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Seeking comments regarding canvas syntax

Post by Ref »

Fun for the feable minded.
Tried to simulate above syntax for non-canvas systems.
Obviously not the way to go to fake canvases.
Constantly recreating images just too slow.
Demo takes ~16 seconds to create the simulated canvases though subsiquent display runs at same frame rate as the canvas demo.
Alternate approach to simulated canvas (Xgoff) superior!
Attachments
Non-canvas Demo.love
Bad example!
(25.87 KiB) Downloaded 65 times
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Seeking comments regarding canvas syntax

Post by Ref »

OK! Dead horse for lack of interest.
Just for completeness before ending topic.
For those wanting a simple way to simulate canvas on machines lacking this capability, try my simcanvas.lua.
Syntax follows love.graphics.
To use, put at head of script:

Code: Select all

simcan = require 'simcanvas'
replace normal love.graphics function:

Code: Select all

canvas = love.graphics.newCanvas( width, height )
with:

Code: Select all

canvas = simcan.newCanvas( width, height )
and replace:

Code: Select all

love.graphics.setCanvas(  canvas )
with:

Code: Select all

simcan.setCanvas(canvas )
and replace

Code: Select all

love.graphics.setCanvas()
with (this is the only real change):

Code: Select all

canvas = simcan.setCanvas()
That's it.
Still a little slow but probably close to the best we can do now.
EOT
Attachments
simcanvas.love
canvas free using only slightly changed syntax
(25.61 KiB) Downloaded 53 times
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests