mirror of
https://github.com/airstruck/luigi.git
synced 2025-11-18 12:25:06 +00:00
pixel alignment for lines
This commit is contained in:
@@ -32,7 +32,7 @@ function Renderer:renderOutline (widget, window)
|
||||
|
||||
love.graphics.push('all')
|
||||
love.graphics.setColor(widget.outline)
|
||||
love.graphics.rectangle('line', x1, y1, x2 - x1, y2 - y1)
|
||||
love.graphics.rectangle('line', x1 - 0.5, y1 - 0.5, x2 - x1, y2 - y1)
|
||||
love.graphics.pop()
|
||||
end
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ function Widget:getRectangle (useMargin, usePadding)
|
||||
if usePadding then
|
||||
shrink(self.padding or 0)
|
||||
end
|
||||
return x1, y1, x2, y2
|
||||
return math.floor(x1), math.floor(y1), math.floor(x2), math.floor(y2)
|
||||
end
|
||||
|
||||
function Widget:isAt (x, y)
|
||||
|
||||
@@ -22,6 +22,12 @@ function Slider:constructor(layout, data)
|
||||
local x1, y1, x2, y2 = self:getRectangle(true, true)
|
||||
local padding = self.padding or 0
|
||||
|
||||
|
||||
local sx1 = math.floor(x1 + position * (x2 - x1) - padding) - 0.5
|
||||
local sy1 = math.floor(y1 + padding) - 0.5
|
||||
local sx2 = padding * 2
|
||||
local sy2 = y2 - y1 - padding
|
||||
|
||||
love.graphics.push('all')
|
||||
|
||||
love.graphics.setColor(self.outline)
|
||||
@@ -33,21 +39,13 @@ function Slider:constructor(layout, data)
|
||||
padding
|
||||
)
|
||||
|
||||
love.graphics.rectangle('line',
|
||||
x1 + position * (x2 - x1) - padding,
|
||||
y1 + padding,
|
||||
padding * 2,
|
||||
y2 - y1 - padding
|
||||
)
|
||||
|
||||
love.graphics.setColor(self.background)
|
||||
|
||||
love.graphics.rectangle('fill',
|
||||
x1 + position * (x2 - x1) - padding,
|
||||
y1 + padding,
|
||||
padding * 2,
|
||||
y2 - y1 - padding
|
||||
)
|
||||
love.graphics.rectangle('fill', sx1, sy1, sx2, sy2)
|
||||
|
||||
love.graphics.setColor(self.outline)
|
||||
|
||||
love.graphics.rectangle('line', sx1, sy1, sx2, sy2)
|
||||
|
||||
love.graphics.pop()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user