feat(utils): add drawBorder function to utils

This commit is contained in:
Kazhnuz 2019-11-14 19:50:26 +01:00
parent ad295bf9c9
commit a83dceee80

View file

@ -75,6 +75,37 @@ function Graphics.printWithSpacing(text, spacing, align, x, y, r, sx, sy, ox, oy
end
end
-- FILTER FUNCTIONS
-- Basic filters to a drawable
function Graphics.drawShadow(drawable, x, y, r, sx, sy, ox, oy, kx, ky)
local color = love.graphics.getColor()
love.graphics.setColor(0, 0, 0, 0)
love.graphics.draw(drawable, x+1, y+1, r, sx, sy, ox, oy, kx, ky)
love.graphics.setColor(color)
love.graphics.draw(drawable, x, y, r, sx, sy, ox, oy, kx, ky)
end
function Graphics.drawBorder(drawable, border, x, y, r, sx, sy, ox, oy, kx, ky)
local color = love.graphics.getColor()
local b = border or 1
love.graphics.setColor(0, 0, 0, 0)
love.graphics.draw(drawable, x-b, y-b, limit, align, r, sx, sy, ox, oy, kx, ky)
love.graphics.draw(drawable, x , y-b, limit, align, r, sx, sy, ox, oy, kx, ky)
love.graphics.draw(drawable, x+b, y-b, limit, align, r, sx, sy, ox, oy, kx, ky)
love.graphics.draw(drawable, x+b, y , limit, align, r, sx, sy, ox, oy, kx, ky)
love.graphics.draw(drawable, x-b, y , limit, align, r, sx, sy, ox, oy, kx, ky)
love.graphics.draw(drawable, x-b, y+b, limit, align, r, sx, sy, ox, oy, kx, ky)
love.graphics.draw(drawable, x , y+b, limit, align, r, sx, sy, ox, oy, kx, ky)
love.graphics.draw(drawable, x+b, y+b, limit, align, r, sx, sy, ox, oy, kx, ky)
love.graphics.setColor(color)
love.graphics.draw(drawable, x, y, r, sx, sy, ox, oy, kx, ky)
end
-- PLACEHOLDER GRAPHICS FUNCTIONS
-- Ready-to-use placeolder and stuff