Ryan 84bba39187 The library
This is for the love2d engine. Works with the latest version. Look at my intro to software project for some examples on how to use this
2017-06-10 16:06:50 -04:00

20 lines
590 B
Plaintext

function gui:getTile(i,x,y,w,h)-- returns imagedata
if type(i)=="string" then
i=love.graphics.newImage(i)
elseif type(i)=="userdata" then
-- do nothing
elseif string.find(self.Type,"Image",1,true) then
local i,x,y,w,h=self.Image,i,x,y,w
else
error("getTile invalid args!!! Usage: ImageElement:getTile(x,y,w,h) or gui:getTile(imagedata,x,y,w,h)")
end
local iw,ih=i:getDimensions()
local id,_id=i:getData(),love.image.newImageData(w,h)
for _x=x,w+x-1 do
for _y=y,h+y-1 do
--
_id:setPixel(_x-x,_y-y,id:getPixel(_x,_y))
end
end
return love.graphics.newImage(_id)
end