#75 offset children of rectangles with borders

This commit is contained in:
Mikayla Fischler
2022-06-19 11:20:09 -04:00
parent 5a3897572d
commit 15595ca81b
2 changed files with 35 additions and 1 deletions

View File

@@ -17,6 +17,18 @@ local element = require("graphics.element")
-- new rectangle
---@param args rectangle_args
local function rectangle(args)
-- offset children
if args.border ~= nil then
args.inner_x = args.border.width
args.inner_y = args.border.width
-- slightly different y offset if the border is set to even
if args.border.even then
local width_x2 = (2 * args.border.width)
args.inner_y = (width_x2 // 3) + util.trinary(width_x2 % 3 > 0, 1, 0)
end
end
-- create new graphics element base object
local e = element.new(args)