From a83dceee80465f667f351276d88111365562fa0b Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Thu, 14 Nov 2019 19:50:26 +0100 Subject: [PATCH] feat(utils): add drawBorder function to utils --- gamecore/utils/graphics.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/gamecore/utils/graphics.lua b/gamecore/utils/graphics.lua index 925ddbe..4aaac79 100644 --- a/gamecore/utils/graphics.lua +++ b/gamecore/utils/graphics.lua @@ -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