clipping
Posted: Fri Oct 11, 2024 3:56 pm
hello! i have a UI element here split into 3 parts, a background, the liquid edge, and the border, and i want to mask the red part so that it doesnt go over the edge, and stays confined to the actual image
my code currently looks like this
im trying to use a stencil for this but it literally doesnt work lol
i also tried to use a shader, but im horrible at shaders and so i didnt really understand what i was doing or what to do
can anyone help?
i tried a few methods for this with some help, but none of them workedmy code currently looks like this
Code: Select all
drawHealth = function(self, health, delta)
local healthregion = health/100*327
self.health.liquid.position = (self.health.liquid.position + (75 * delta)) % 64
love.graphics.setCanvas({self.health.bg.canvas, stencil = true})
love.graphics.clear(0,0,0,0)
love.graphics.stencil(function()
love.graphics.setColor(1,1,1,1)
love.graphics.draw(self.health.bg.texture, 0,0)
end, "replace", 1)
love.graphics.setStencilTest("greater", 0)
love.graphics.setColor(1,0,0,1)
love.graphics.rectangle("fill", 0, 0, 64, healthregion)
love.graphics.setColor(1,1,1,1)
love.graphics.draw(self.health.liquid.texture, -80 + self.health.liquid.position, healthregion - 15)
love.graphics.setStencilTest()
love.graphics.setCanvas()
love.graphics.draw(self.health.bg.canvas, 34, 34)
love.graphics.draw(self.health.gold.texture, 4,32)
end,
i also tried to use a shader, but im horrible at shaders and so i didnt really understand what i was doing or what to do
can anyone help?