diff options
author | xgoff <antipotroast@gmail.com> | 2012-08-04 02:17:29 -0500 |
---|---|---|
committer | xgoff <antipotroast@gmail.com> | 2012-08-04 02:17:29 -0500 |
commit | 0913693cde5fb74db76b2d283787ffb6a4d794ec (patch) | |
tree | 6f180d8d6967702bcb3993527b25f129738acfae /fakecanvas.lua | |
parent | 6de633350db152d47b53ae8ede75d0199bc22b7b (diff) | |
download | love2d-fakecanvas-0913693cde5fb74db76b2d283787ffb6a4d794ec.tar.gz love2d-fakecanvas-0913693cde5fb74db76b2d283787ffb6a4d794ec.tar.bz2 love2d-fakecanvas-0913693cde5fb74db76b2d283787ffb6a4d794ec.tar.xz love2d-fakecanvas-0913693cde5fb74db76b2d283787ffb6a4d794ec.zip |
zero-argument version of canvas:clear() is much faster now
Diffstat (limited to 'fakecanvas.lua')
-rw-r--r-- | fakecanvas.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fakecanvas.lua b/fakecanvas.lua index c311b7e..863dca7 100644 --- a/fakecanvas.lua +++ b/fakecanvas.lua @@ -50,11 +50,13 @@ local options = { vflip = true, } +local blank function canvas:clear (...) -- other option is chucking out the imagedata and creating a new one, but i'd probably end up using mapPixel anyway local nargs = select("#", ...) if nargs == 0 then - canvases[self]._imagedata:mapPixel(function () return 0, 0, 0, 0 end) + local id = canvases[self]._imagedata + id:paste(blank, 0, 0, 0, 0, id:getWidth(), id:getHeight()) elseif nargs == 1 and type(...) == "table" then local t = ... local r, g, b, a = tonumber(t[1]) or 0, tonumber(t[2]) or 0, tonumber(t[3]) or 0, tonumber(t[4]) or 255 @@ -318,6 +320,8 @@ function M.getOption (name) return options[name] end +blank = love.image.newImageData(M.getMaxCanvasSize()) + M.enable() return M
\ No newline at end of file |