mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#75 handle edge case on rectangle border width, renamed inner_* to offset_*
This commit is contained in:
parent
15595ca81b
commit
d3f28a6882
@ -13,8 +13,8 @@ local element = {}
|
||||
---@field parent? graphics_element
|
||||
---@field x? integer 1 if omitted
|
||||
---@field y? integer 1 if omitted
|
||||
---@field inner_x? integer 0 if omitted
|
||||
---@field inner_y? integer 0 if omitted
|
||||
---@field offset_x? integer 0 if omitted
|
||||
---@field offset_y? integer 0 if omitted
|
||||
---@field width? integer parent width if omitted
|
||||
---@field height? integer parent height if omitted
|
||||
---@field gframe? graphics_frame frame instead of x/y/width/height
|
||||
@ -66,8 +66,8 @@ function element.new(args)
|
||||
end
|
||||
|
||||
-- inner offsets
|
||||
if args.inner_x ~= nil then self.child_offset.x = args.inner_x end
|
||||
if args.inner_y ~= nil then self.child_offset.y = args.inner_y end
|
||||
if args.offset_x ~= nil then self.child_offset.x = args.offset_x end
|
||||
if args.offset_y ~= nil then self.child_offset.y = args.offset_y end
|
||||
|
||||
-- check frame
|
||||
assert(protected.frame.x >= 1, "graphics.element: frame x not >= 1")
|
||||
|
@ -19,13 +19,13 @@ local element = require("graphics.element")
|
||||
local function rectangle(args)
|
||||
-- offset children
|
||||
if args.border ~= nil then
|
||||
args.inner_x = args.border.width
|
||||
args.inner_y = args.border.width
|
||||
args.offsetx = args.border.width
|
||||
args.offsety = 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)
|
||||
args.offsety = (width_x2 // 3) + util.trinary(width_x2 % 3 > 0, 1, 0)
|
||||
end
|
||||
end
|
||||
|
||||
@ -37,7 +37,8 @@ local function rectangle(args)
|
||||
if args.border ~= nil then
|
||||
e.window.setCursorPos(1, 1)
|
||||
|
||||
local border_width = args.border.width
|
||||
local border_width = args.offsetx
|
||||
local border_height = args.offsety
|
||||
local border_blit = colors.toBlit(args.border.color)
|
||||
local width_x2 = border_width * 2
|
||||
local inner_width = e.frame.w - width_x2
|
||||
@ -73,9 +74,9 @@ local function rectangle(args)
|
||||
-- draw rectangle with borders
|
||||
for y = 1, e.frame.h do
|
||||
e.window.setCursorPos(1, y)
|
||||
if y <= border_width then
|
||||
if y <= border_height then
|
||||
-- partial pixel fill
|
||||
if args.border.even and y == border_width then
|
||||
if args.border.even and y == border_height then
|
||||
if width_x2 % 3 == 1 then
|
||||
e.window.blit(p_b, p_inv_bg, p_inv_fg)
|
||||
elseif width_x2 % 3 == 2 then
|
||||
|
Loading…
Reference in New Issue
Block a user