garden/window.lua

30 lines
672 B
Lua

-- primitive of drawing objects
local w = {}
function w.draw(f)
return function(self)
love.graphics.push()
love.graphics.translate(self.x, self.y)
f(self)
love.graphics.pop()
end
end
function w.mousepressed(f)
return function(self, x, y, button)
local x, y = x - self.x, y - self.y
if 0 <= x and x <= self.width and 0 <= y and y <= self.height then
f(self, x, y, button)
end
end
end
function w.draw_border(width, height)
love.graphics.push('all')
love.graphics.setLineWidth(5)
love.graphics.rectangle('line', 0, 0, width, height, 5)
love.graphics.pop()
end
return w