Minor cleanup

This commit is contained in:
2023-08-26 17:55:11 -07:00
parent 079bef1e52
commit 7a34cbe48d
2 changed files with 6 additions and 139 deletions

View File

@ -33,23 +33,23 @@ function dotgrid:new()
end
function dots:draw(context, cr, width, height)
local col_size = (height - self.spacing * (self.rows-1)) // self.rows
local row_size = (width - self.spacing * (self.cols-1)) // self.cols
local col_size = math.floor((height - self.spacing * (self.rows-1)) / self.rows)
local row_size = math.floor((width - self.spacing * (self.cols-1)) / self.cols)
-- Compute rounding offsets for better centering
local xoffset = (
local xoffset = math.floor((
width - (
(col_size * self.cols) +
(self.spacing * (self.cols - 1))
)
) // 2
) / 2)
local yoffset = (
local yoffset = math.floor((
height - (
(row_size * self.rows) +
(self.spacing * (self.rows - 1))
)
) // 2
) / 2)
-- How many dots should be on
local on = math.floor((self.value / self.max) * (self.rows * self.cols))