2022-06-06 19:42:39 +00:00
|
|
|
local core = {}
|
|
|
|
|
|
|
|
local events = {}
|
|
|
|
|
|
|
|
---@class monitor_touch
|
|
|
|
---@field monitor string
|
|
|
|
---@field x integer
|
|
|
|
---@field y integer
|
|
|
|
|
2022-06-08 17:08:48 +00:00
|
|
|
-- create a new touch event definition
|
2022-06-06 19:42:39 +00:00
|
|
|
---@param monitor string
|
|
|
|
---@param x integer
|
|
|
|
---@param y integer
|
|
|
|
---@return monitor_touch
|
|
|
|
function events.touch(monitor, x, y)
|
|
|
|
return {
|
|
|
|
monitor = monitor,
|
|
|
|
x = x,
|
|
|
|
y = y
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
core.events = events
|
|
|
|
|
|
|
|
local graphics = {}
|
|
|
|
|
|
|
|
---@alias TEXT_ALIGN integer
|
|
|
|
graphics.TEXT_ALIGN = {
|
|
|
|
LEFT = 1,
|
|
|
|
CENTER = 2,
|
|
|
|
RIGHT = 3
|
|
|
|
}
|
|
|
|
|
2022-06-08 16:27:28 +00:00
|
|
|
---@class graphics_border
|
|
|
|
---@field width integer
|
|
|
|
---@field color color
|
2022-06-08 17:08:48 +00:00
|
|
|
---@field even boolean
|
2022-06-08 16:27:28 +00:00
|
|
|
|
2022-06-08 17:08:48 +00:00
|
|
|
-- create a new border definition
|
|
|
|
---@param width integer border width
|
|
|
|
---@param color color border color
|
|
|
|
---@param even boolean whether to pad width extra to account for rectangular pixels
|
2022-06-08 16:27:28 +00:00
|
|
|
---@return graphics_border
|
2022-06-08 17:08:48 +00:00
|
|
|
function graphics.border(width, color, even)
|
2022-06-08 16:27:28 +00:00
|
|
|
return {
|
|
|
|
width = width,
|
2022-06-08 17:08:48 +00:00
|
|
|
color = color,
|
|
|
|
even = even
|
2022-06-08 16:27:28 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2022-06-06 19:42:39 +00:00
|
|
|
---@class graphics_frame
|
|
|
|
---@field x integer
|
|
|
|
---@field y integer
|
|
|
|
---@field w integer
|
|
|
|
---@field h integer
|
|
|
|
|
2022-06-08 17:08:48 +00:00
|
|
|
-- create a new graphics frame definition
|
2022-06-06 19:42:39 +00:00
|
|
|
---@param x integer
|
|
|
|
---@param y integer
|
|
|
|
---@param w integer
|
|
|
|
---@param h integer
|
|
|
|
---@return graphics_frame
|
|
|
|
function graphics.gframe(x, y, w, h)
|
|
|
|
return {
|
|
|
|
x = x,
|
|
|
|
y = y,
|
|
|
|
w = w,
|
|
|
|
h = h
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
---@class cpair
|
2022-06-08 17:08:48 +00:00
|
|
|
---@field color_a color
|
|
|
|
---@field color_b color
|
|
|
|
---@field blit_a string
|
|
|
|
---@field blit_b string
|
2022-06-06 19:42:39 +00:00
|
|
|
---@field fgd color
|
|
|
|
---@field bkg color
|
|
|
|
---@field blit_fgd string
|
|
|
|
---@field blit_bkg string
|
|
|
|
|
2022-06-08 17:08:48 +00:00
|
|
|
-- create a new color pair definition
|
|
|
|
---@param a color
|
|
|
|
---@param b color
|
2022-06-06 19:42:39 +00:00
|
|
|
---@return cpair
|
2022-06-08 17:08:48 +00:00
|
|
|
function graphics.cpair(a, b)
|
2022-06-06 19:42:39 +00:00
|
|
|
return {
|
2022-06-08 17:08:48 +00:00
|
|
|
-- color pairs
|
|
|
|
color_a = a,
|
|
|
|
color_b = b,
|
|
|
|
blit_a = a,
|
|
|
|
blit_b = b,
|
|
|
|
-- aliases
|
|
|
|
fgd = a,
|
|
|
|
bkg = b,
|
|
|
|
blit_fgd = colors.toBlit(a),
|
|
|
|
blit_bkg = colors.toBlit(b)
|
2022-06-06 19:42:39 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
core.graphics = graphics
|
|
|
|
|
|
|
|
return core
|