2021-08-08 18:13:52 -04:00
|
|
|
local geom = require 'geom'
|
2021-08-08 15:58:53 -04:00
|
|
|
local format = require 'format'
|
2022-07-17 18:40:24 -04:00
|
|
|
local color = require 'color'
|
2021-07-29 22:37:30 -04:00
|
|
|
local dial = require 'dial'
|
|
|
|
local rect = require 'rect'
|
2021-08-08 18:19:37 -04:00
|
|
|
local fill_rect = require 'fill_rect'
|
|
|
|
local compound_dial = require 'compound_dial'
|
2021-07-29 22:37:30 -04:00
|
|
|
local arc = require 'arc'
|
2021-08-06 23:41:17 -04:00
|
|
|
local circle = require 'circle'
|
2021-07-29 22:37:30 -04:00
|
|
|
local text = require 'text'
|
2021-08-08 18:19:37 -04:00
|
|
|
local tbl = require 'text_table'
|
|
|
|
local compound_bar = require 'compound_bar'
|
|
|
|
local text_threshold = require 'text_threshold'
|
|
|
|
local text_column = require 'text_column'
|
2021-07-29 22:37:30 -04:00
|
|
|
local line = require 'line'
|
|
|
|
local timeseries = require 'timeseries'
|
2021-08-08 18:19:37 -04:00
|
|
|
local scaled_timeseries = require 'scaled_timeseries'
|
2021-07-30 23:05:36 -04:00
|
|
|
local style = require 'style'
|
|
|
|
local source = require 'source'
|
2021-11-10 12:37:23 -05:00
|
|
|
local pure = require 'pure'
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local compile_patterns
|
|
|
|
|
2022-07-19 00:54:46 -04:00
|
|
|
-- TODO move to color module
|
2022-07-17 18:40:24 -04:00
|
|
|
compile_patterns = function(patterns)
|
|
|
|
local r = {}
|
|
|
|
for k, v in pairs(patterns) do
|
|
|
|
if type(v) == "number" then
|
|
|
|
r[k] = color.rgb(v)
|
|
|
|
elseif v.color ~= nil then
|
|
|
|
r[k] = color.rgba(v.color, v.alpha)
|
|
|
|
elseif v.gradient ~= nil then
|
|
|
|
local p = {}
|
|
|
|
local g = v.gradient
|
|
|
|
for i = 1, #g do
|
|
|
|
local _g = g[i]
|
|
|
|
p[_g.stop] = _g.color
|
|
|
|
end
|
|
|
|
r[k] = color.gradient_rgb(p)
|
|
|
|
elseif v.gradient_alpha ~= nil then
|
|
|
|
local p = {}
|
|
|
|
local g = v.gradient_alpha
|
|
|
|
for i = 1, #g do
|
|
|
|
local _g = g[i]
|
|
|
|
p[_g.stop] = {_g.color, _g.alpha}
|
|
|
|
end
|
|
|
|
r[k] = color.gradient_rgba(p)
|
|
|
|
else
|
|
|
|
r[k] = compile_patterns(v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return r
|
|
|
|
end
|
|
|
|
|
|
|
|
return function(config)
|
|
|
|
local M = {}
|
2021-07-11 21:11:38 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local patterns = compile_patterns(config.theme.patterns)
|
2022-07-18 00:36:44 -04:00
|
|
|
local font = config.theme.font
|
|
|
|
local font_sizes = font.sizes
|
|
|
|
local font_family = font.family
|
2022-07-19 00:54:46 -04:00
|
|
|
local geometry = config.theme.geometry
|
2021-07-11 21:11:38 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- constants
|
2021-07-11 21:11:38 -04:00
|
|
|
|
2022-07-19 00:54:46 -04:00
|
|
|
local CAP_ROUND = CAIRO_LINE_CAP_ROUND
|
|
|
|
local CAP_BUTT = CAIRO_LINE_CAP_BUTT
|
|
|
|
local JOIN_MITER = CAIRO_LINE_JOIN_MITER
|
|
|
|
|
|
|
|
local FONT_BOLD = CAIRO_FONT_WEIGHT_BOLD
|
|
|
|
local FONT_NORMAL = CAIRO_FONT_WEIGHT_NORMAL
|
|
|
|
|
|
|
|
local HEADER_UNDERLINE_CAP = CAP_ROUND
|
2022-07-17 18:40:24 -04:00
|
|
|
local HEADER_UNDERLINE_THICKNESS = 3
|
2021-07-11 21:11:38 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local SEPARATOR_THICKNESS = 1
|
|
|
|
local TABLE_LINE_THICKNESS = 1
|
2021-07-11 21:11:38 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local ARC_WIDTH = 2
|
2021-08-06 23:41:17 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local DIAL_THETA0 = 90
|
|
|
|
local DIAL_THETA1 = 360
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- line helper functions
|
|
|
|
|
|
|
|
local _make_horizontal_line = function(x, y, w)
|
2022-07-19 00:54:46 -04:00
|
|
|
return geom.make_line(geom.make_point(x, y), geom.make_point(x + w, y))
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-08-06 23:41:17 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- text helper functions
|
2021-07-11 21:11:38 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local make_font_spec = function(f, size, bold)
|
2022-07-19 00:54:46 -04:00
|
|
|
return {
|
|
|
|
family = f,
|
|
|
|
size = size,
|
|
|
|
weight = bold and FONT_BOLD or FONT_NORMAL,
|
|
|
|
slant = FONT_NORMAL,
|
|
|
|
}
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-06 00:11:00 -04:00
|
|
|
|
2022-07-18 00:36:44 -04:00
|
|
|
local normal_font_spec = make_font_spec(font_family, font_sizes.normal, false)
|
|
|
|
local label_font_spec = make_font_spec(font_family, font_sizes.plot_label, false)
|
2021-07-06 00:11:00 -04:00
|
|
|
|
2022-07-19 00:54:46 -04:00
|
|
|
local _text_row_style = function(x_align, _color)
|
|
|
|
return text.config(normal_font_spec, _color, x_align, 'center')
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-10 17:13:17 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local _left_text_style = _text_row_style('left', patterns.text.inactive)
|
|
|
|
local _right_text_style = _text_row_style('right', patterns.text.active)
|
2021-07-10 17:13:17 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local _bare_text = function(pt, _text, _style)
|
2022-07-19 00:54:46 -04:00
|
|
|
return text.make_plain(pt, _text, _style)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-10 17:13:17 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local _left_text = function(pt, _text)
|
2022-07-19 00:54:46 -04:00
|
|
|
return _bare_text(pt, _text, _left_text_style)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-10 17:13:17 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local _right_text = function(pt, _text)
|
2022-07-19 00:54:46 -04:00
|
|
|
return _bare_text(pt, _text, _right_text_style)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-30 22:46:20 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- timeseries helper functions
|
2021-07-30 22:46:20 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local _default_grid_config = timeseries.grid_config(
|
2022-07-19 00:54:46 -04:00
|
|
|
geometry.plot.ticks[1],
|
|
|
|
geometry.plot.ticks[2],
|
|
|
|
patterns.plot.grid
|
2022-07-17 18:40:24 -04:00
|
|
|
)
|
2021-07-30 22:46:20 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local _default_plot_config = timeseries.config(
|
2022-07-19 00:54:46 -04:00
|
|
|
geometry.plot.seconds,
|
|
|
|
patterns.plot.outline,
|
|
|
|
patterns.plot.data.border,
|
|
|
|
patterns.plot.data.fill,
|
|
|
|
_default_grid_config
|
2022-07-17 18:40:24 -04:00
|
|
|
)
|
2021-07-30 22:46:20 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local _format_percent_label = function(_)
|
2022-07-19 00:54:46 -04:00
|
|
|
return function(z) return string.format('%i%%', math.floor(z * 100)) end
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-30 22:46:20 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local _format_percent_maybe = function(z)
|
2022-07-19 00:54:46 -04:00
|
|
|
if z == -1 then return 'N/A' else return string.format('%s%%', z) end
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-30 22:46:20 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local _percent_label_config = timeseries.label_config(
|
2022-07-19 00:54:46 -04:00
|
|
|
patterns.text.inactive,
|
|
|
|
label_font_spec,
|
|
|
|
_format_percent_label
|
2022-07-17 18:40:24 -04:00
|
|
|
)
|
2021-07-30 22:46:20 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local _make_timeseries = function(x, y, w, h, label_config, update_freq)
|
2022-07-19 00:54:46 -04:00
|
|
|
return timeseries.make(
|
|
|
|
geom.make_box(x, y, w, h),
|
|
|
|
update_freq,
|
|
|
|
_default_plot_config,
|
|
|
|
label_config
|
|
|
|
)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-30 22:46:20 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local _make_tagged_percent_timeseries = function(x, y, w, h, spacing, label, update_freq, _format)
|
2022-07-19 00:54:46 -04:00
|
|
|
return {
|
|
|
|
label = _left_text(geom.make_point(x, y), label),
|
|
|
|
value = text_threshold.make_formatted(
|
|
|
|
geom.make_point(x + w, y),
|
|
|
|
nil,
|
|
|
|
_right_text_style,
|
|
|
|
_format,
|
|
|
|
text_threshold.config(patterns.text.critical, 80, false)
|
|
|
|
),
|
|
|
|
plot = M.make_percent_timeseries(
|
|
|
|
x,
|
|
|
|
y + spacing,
|
|
|
|
w,
|
|
|
|
h,
|
|
|
|
update_freq
|
|
|
|
),
|
|
|
|
}
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-30 22:46:20 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- scaled timeseries helper functions
|
2021-07-30 22:46:20 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local _base_2_scale_data = function(m)
|
2022-07-19 00:54:46 -04:00
|
|
|
return scaled_timeseries.scaling_parameters(2, m, 0.9)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-30 22:46:20 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local _make_scaled_timeseries = function(x, y, w, h, f, min_domain, update_freq)
|
2022-07-19 00:54:46 -04:00
|
|
|
return scaled_timeseries.make(
|
|
|
|
geom.make_box(x, y, w, h),
|
|
|
|
update_freq,
|
|
|
|
_default_plot_config,
|
|
|
|
timeseries.label_config(patterns.text.inactive, label_font_spec, f),
|
|
|
|
_base_2_scale_data(min_domain)
|
|
|
|
)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-10 17:13:17 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- header
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.make_header = function(x, y, w, _text)
|
2022-07-19 00:54:46 -04:00
|
|
|
local underline_y = y + geometry.header.underline_offset
|
|
|
|
local bottom_y = underline_y + geometry.header.padding
|
|
|
|
return {
|
|
|
|
text = text.make_plain(
|
|
|
|
geom.make_point(x, y),
|
|
|
|
_text,
|
|
|
|
text.config(
|
2022-07-18 00:36:44 -04:00
|
|
|
make_font_spec(font_family, font_sizes.header, true),
|
2022-07-17 18:40:24 -04:00
|
|
|
patterns.header,
|
|
|
|
'left',
|
|
|
|
'top'
|
2022-07-19 00:54:46 -04:00
|
|
|
)
|
|
|
|
),
|
|
|
|
bottom_y = bottom_y,
|
|
|
|
underline = line.make(
|
|
|
|
_make_horizontal_line(x, underline_y, w),
|
|
|
|
line.config(
|
2022-07-17 18:40:24 -04:00
|
|
|
style.line(HEADER_UNDERLINE_THICKNESS, HEADER_UNDERLINE_CAP),
|
|
|
|
patterns.header,
|
|
|
|
true
|
2022-07-19 00:54:46 -04:00
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.draw_header = function(cr, header)
|
2022-07-19 00:54:46 -04:00
|
|
|
text.draw(header.text, cr)
|
|
|
|
line.draw(header.underline, cr)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- percent timeseries
|
2021-07-11 14:48:51 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.make_percent_timeseries = function(x, y, w, h, update_freq)
|
2022-07-19 00:54:46 -04:00
|
|
|
return _make_timeseries(x, y, w, h, _percent_label_config, update_freq)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- tagged percent timeseries
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.make_tagged_percent_timeseries = function(x, y, w, h, spacing, label, update_freq)
|
2022-07-19 00:54:46 -04:00
|
|
|
return _make_tagged_percent_timeseries(
|
|
|
|
x, y, w, h, spacing, label, update_freq, '%s%%'
|
|
|
|
)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.make_tagged_maybe_percent_timeseries = function(x, y, w, h, spacing, label, update_freq)
|
2022-07-19 00:54:46 -04:00
|
|
|
return _make_tagged_percent_timeseries(
|
|
|
|
x, y, w, h, spacing, label, update_freq, _format_percent_maybe
|
|
|
|
)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-13 00:14:04 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.tagged_percent_timeseries_draw_static = function(pp, cr)
|
2022-07-19 00:54:46 -04:00
|
|
|
text.draw(pp.label, cr)
|
|
|
|
timeseries.draw_static(pp.plot, cr)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.tagged_percent_timeseries_draw_dynamic = function(obj, cr)
|
2022-07-19 00:54:46 -04:00
|
|
|
text_threshold.draw(obj.value, cr)
|
|
|
|
timeseries.draw_dynamic(obj.plot, cr)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-30 22:46:20 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.tagged_percent_timeseries_set = function(obj, percent)
|
2022-07-19 00:54:46 -04:00
|
|
|
local _percent = pure.round_percent(percent)
|
|
|
|
text.set(obj.value, _percent)
|
|
|
|
timeseries.update(obj.plot, _percent / 100)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.tagged_maybe_percent_timeseries_set = function(obj, percent)
|
2022-07-19 00:54:46 -04:00
|
|
|
if percent == false then
|
|
|
|
text.set(obj.value, -1)
|
|
|
|
timeseries.update(obj.plot, 0)
|
|
|
|
else
|
|
|
|
M.tagged_percent_timeseries_set(obj, percent)
|
|
|
|
end
|
2021-07-13 00:14:04 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- scaled plot
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-- Generate a format string for labels on y axis of plots. If the max of the
|
|
|
|
-- plot if numerically less than the number of grid lines, this means that
|
|
|
|
-- some number of decimal places are necessary to accurately display the number.
|
|
|
|
-- Note that this for now only works when the number of y grid lines if 4, as
|
|
|
|
-- it gives enough resolution for 1, 0.75, 0.5, and 0.25 but no more
|
|
|
|
M.y_label_format_string = function(plot_max, unit)
|
2022-07-19 00:54:46 -04:00
|
|
|
local num_fmt
|
|
|
|
if plot_max < 2 then
|
|
|
|
num_fmt = '%.2f'
|
|
|
|
elseif plot_max < 4 then
|
|
|
|
num_fmt = '%.1f'
|
|
|
|
else
|
|
|
|
num_fmt = '%.0f'
|
|
|
|
end
|
|
|
|
return string.format('%s %s', num_fmt, unit)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-18 19:18:14 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.converted_y_label_format_generator = function(unit)
|
2022-07-19 00:54:46 -04:00
|
|
|
return function(plot_max)
|
|
|
|
local new_prefix, new_max = format.convert_data_val(plot_max)
|
|
|
|
local conversion_factor = plot_max / new_max
|
|
|
|
local fmt = M.y_label_format_string(new_max, new_prefix..unit..'/s')
|
|
|
|
return function(bytes)
|
|
|
|
return string.format(fmt, bytes / conversion_factor)
|
|
|
|
end
|
|
|
|
end
|
2021-07-18 19:18:14 -04:00
|
|
|
end
|
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- tagged scaled plot
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.make_tagged_scaled_timeseries = function(x, y, w, h, format_fun, label_fun,
|
2022-07-19 00:54:46 -04:00
|
|
|
spacing, label, min_domain,
|
|
|
|
update_freq)
|
|
|
|
return {
|
|
|
|
label = _left_text(geom.make_point(x, y), label),
|
|
|
|
value = text.make_formatted(
|
|
|
|
geom.make_point(x + w, y),
|
|
|
|
0,
|
|
|
|
_right_text_style,
|
|
|
|
format_fun
|
|
|
|
),
|
|
|
|
plot = _make_scaled_timeseries(
|
|
|
|
x,
|
|
|
|
y + spacing,
|
|
|
|
w,
|
|
|
|
h,
|
|
|
|
label_fun,
|
|
|
|
min_domain,
|
|
|
|
update_freq
|
|
|
|
),
|
|
|
|
}
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.tagged_scaled_timeseries_draw_static = function(asp, cr)
|
2022-07-19 00:54:46 -04:00
|
|
|
text.draw(asp.label, cr)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.tagged_scaled_timeseries_draw_dynamic = function(asp, cr)
|
2022-07-19 00:54:46 -04:00
|
|
|
text.draw(asp.value, cr)
|
|
|
|
scaled_timeseries.draw_dynamic(asp.plot, cr)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.tagged_scaled_timeseries_set = function(asp, value)
|
2022-07-19 00:54:46 -04:00
|
|
|
text.set(asp.value, value)
|
|
|
|
scaled_timeseries.update(asp.plot, value)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- rate timecourse plots
|
2021-07-19 23:58:58 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local make_differential = function(update_frequency)
|
2022-07-19 00:54:46 -04:00
|
|
|
return function(x0, x1)
|
|
|
|
-- mask overflow
|
|
|
|
if x1 > x0 then
|
|
|
|
return (x1 - x0) * update_frequency
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
2021-07-19 23:58:58 -04:00
|
|
|
end
|
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.make_rate_timeseries = function(x, y, w, h, format_fun, label_fun, spacing,
|
2022-07-19 00:54:46 -04:00
|
|
|
label, min_domain, update_freq, init)
|
|
|
|
return {
|
|
|
|
label = _left_text(geom.make_point(x, y), label),
|
|
|
|
value = text.make_formatted(
|
|
|
|
geom.make_point(x + w, y),
|
|
|
|
0,
|
|
|
|
_right_text_style,
|
|
|
|
format_fun
|
|
|
|
),
|
|
|
|
plot = _make_scaled_timeseries(
|
|
|
|
x,
|
|
|
|
y + spacing,
|
|
|
|
w,
|
|
|
|
h,
|
|
|
|
label_fun,
|
|
|
|
min_domain,
|
|
|
|
update_freq
|
|
|
|
),
|
|
|
|
prev_value = init,
|
|
|
|
derive = make_differential(update_freq),
|
|
|
|
}
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-19 23:58:58 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.update_rate_timeseries = function(obj, value)
|
2022-07-19 00:54:46 -04:00
|
|
|
local rate = obj.derive(obj.prev_value, value)
|
|
|
|
text.set(obj.value, rate)
|
|
|
|
scaled_timeseries.update(obj.plot, rate)
|
|
|
|
obj.prev_value = value
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-19 23:58:58 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- circle
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.make_circle = function(x, y, r)
|
2022-07-19 00:54:46 -04:00
|
|
|
return circle.make(
|
|
|
|
geom.make_circle(x, y, r),
|
|
|
|
circle.config(style.line(ARC_WIDTH, CAP_BUTT), patterns.border)
|
|
|
|
)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- ring with text data in the center
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.make_text_circle = function(x, y, r, fmt, threshhold, pre_function)
|
2022-07-19 00:54:46 -04:00
|
|
|
return {
|
|
|
|
ring = M.make_circle(x, y, r),
|
|
|
|
value = text_threshold.make_formatted(
|
|
|
|
geom.make_point(x, y),
|
|
|
|
0,
|
|
|
|
text.config(normal_font_spec, patterns.text.active, 'center', 'center'),
|
|
|
|
fmt,
|
|
|
|
text_threshold.config(patterns.text.critical, threshhold, pre_function)
|
|
|
|
),
|
|
|
|
}
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.text_circle_draw_static = function(tr, cr)
|
2022-07-19 00:54:46 -04:00
|
|
|
arc.draw(tr.ring, cr)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.text_circle_draw_dynamic = function(tr, cr)
|
2022-07-19 00:54:46 -04:00
|
|
|
text_threshold.draw(tr.value, cr)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.text_circle_set = function(tr, value)
|
2022-07-19 00:54:46 -04:00
|
|
|
text_threshold.set(tr.value, value)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- dial
|
2021-07-11 23:02:45 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local threshold_indicator = function(threshold)
|
2022-07-19 00:54:46 -04:00
|
|
|
return source.threshold_config(
|
|
|
|
patterns.indicator.fg.active,
|
|
|
|
patterns.indicator.fg.critical,
|
|
|
|
threshold
|
|
|
|
)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-11 23:57:56 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.make_dial = function(x, y, radius, thickness, threshold, _format, pre_function)
|
2022-07-19 00:54:46 -04:00
|
|
|
return {
|
|
|
|
dial = dial.make(
|
|
|
|
geom.make_arc(x, y, radius, DIAL_THETA0, DIAL_THETA1),
|
|
|
|
arc.config(style.line(thickness, CAP_BUTT), patterns.indicator.bg),
|
|
|
|
threshold_indicator(threshold)
|
|
|
|
),
|
|
|
|
text_circle = M.make_text_circle(x, y, radius - thickness / 2 - 2, _format, threshold, pre_function),
|
|
|
|
}
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-19 21:14:38 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.dial_set = function(dl, value)
|
2022-07-19 00:54:46 -04:00
|
|
|
dial.set(dl.dial, value)
|
|
|
|
M.text_circle_set(dl.text_circle, value)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-19 21:14:38 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.dial_draw_static = function(dl, cr)
|
2022-07-19 00:54:46 -04:00
|
|
|
dial.draw_static(dl.dial, cr)
|
|
|
|
M.text_circle_draw_static(dl.text_circle, cr)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-19 21:14:38 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.dial_draw_dynamic = function(dl, cr)
|
2022-07-19 00:54:46 -04:00
|
|
|
dial.draw_dynamic(dl.dial, cr)
|
|
|
|
M.text_circle_draw_dynamic(dl.text_circle, cr)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- compound dial
|
2021-07-11 23:10:35 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.make_compound_dial = function(x, y, outer_radius, inner_radius, thickness,
|
2022-07-19 00:54:46 -04:00
|
|
|
threshold, num_dials)
|
|
|
|
return compound_dial.make(
|
|
|
|
geom.make_arc(x, y, outer_radius, DIAL_THETA0, DIAL_THETA1),
|
|
|
|
arc.config(style.line(thickness, CAP_BUTT), patterns.indicator.bg),
|
|
|
|
threshold_indicator(threshold),
|
|
|
|
inner_radius,
|
|
|
|
num_dials
|
|
|
|
)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-11 23:10:35 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- annotated compound bar
|
2021-07-11 23:57:56 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.make_compound_bar = function(x, y, w, pad, labels, spacing, thickness, threshold)
|
2022-07-19 00:54:46 -04:00
|
|
|
return {
|
|
|
|
labels = text_column.make(
|
|
|
|
geom.make_point(x, y),
|
|
|
|
labels,
|
|
|
|
_left_text_style,
|
|
|
|
nil,
|
|
|
|
spacing
|
|
|
|
),
|
|
|
|
bars = compound_bar.make(
|
|
|
|
geom.make_point(x + pad, y),
|
|
|
|
w - pad,
|
|
|
|
line.config(
|
|
|
|
style.line(thickness, CAP_BUTT),
|
2022-07-17 18:40:24 -04:00
|
|
|
patterns.indicator.bg,
|
|
|
|
true
|
2022-07-19 00:54:46 -04:00
|
|
|
),
|
|
|
|
threshold_indicator(threshold),
|
|
|
|
spacing,
|
|
|
|
#labels,
|
|
|
|
false
|
|
|
|
)
|
|
|
|
}
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-11 23:57:56 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.compound_bar_draw_static = function(cb, cr)
|
2022-07-19 00:54:46 -04:00
|
|
|
text_column.draw(cb.labels, cr)
|
|
|
|
compound_bar.draw_static(cb.bars, cr)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-11 23:57:56 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.compound_bar_draw_dynamic = function(cb, cr)
|
2022-07-19 00:54:46 -04:00
|
|
|
compound_bar.draw_dynamic(cb.bars, cr)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-11 23:57:56 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.compound_bar_set = function(cb, i, value)
|
2022-07-19 00:54:46 -04:00
|
|
|
compound_bar.set(cb.bars, i, value)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-11 23:57:56 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- separator (eg a horizontal line)
|
2021-07-11 21:11:38 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.make_separator = function(x, y, w)
|
2022-07-19 00:54:46 -04:00
|
|
|
return line.make(
|
|
|
|
_make_horizontal_line(x, y, w),
|
|
|
|
line.config(
|
|
|
|
style.line(SEPARATOR_THICKNESS, CAP_BUTT),
|
|
|
|
patterns.border,
|
|
|
|
true
|
|
|
|
)
|
|
|
|
)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- text row (label with a value, aligned as far apart as possible)
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.make_text_row = function(x, y, w, label)
|
2022-07-19 00:54:46 -04:00
|
|
|
return {
|
|
|
|
label = _left_text(geom.make_point(x, y), label),
|
|
|
|
value = _right_text(geom.make_point(x + w, y), nil),
|
|
|
|
}
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.text_row_draw_static = function(row, cr)
|
2022-07-19 00:54:46 -04:00
|
|
|
text.draw(row.label, cr)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.text_row_draw_dynamic = function(row, cr)
|
2022-07-19 00:54:46 -04:00
|
|
|
text.draw(row.value, cr)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.text_row_set = function(row, value)
|
2022-07-19 00:54:46 -04:00
|
|
|
text.set(row.value, value)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- text row with critical indicator
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.make_threshold_text_row = function(x, y, w, label, append_end, limit)
|
2022-07-19 00:54:46 -04:00
|
|
|
return{
|
|
|
|
label = _left_text(geom.make_point(x, y), label),
|
|
|
|
value = text_threshold.make_formatted(
|
|
|
|
geom.make_point(x + w, y),
|
|
|
|
nil,
|
|
|
|
_right_text_style,
|
|
|
|
append_end,
|
|
|
|
text_threshold.config(patterns.text.critical, limit, false)
|
|
|
|
)
|
|
|
|
}
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.threshold_text_row_draw_static = M.text_row_draw_static
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.threshold_text_row_draw_dynamic = function(row, cr)
|
2022-07-19 00:54:46 -04:00
|
|
|
text_threshold.draw(row.value, cr)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.threshold_text_row_set = function(row, value)
|
2022-07-19 00:54:46 -04:00
|
|
|
text_threshold.set(row.value, value)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- multiple text row separated by spacing
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-19 00:54:46 -04:00
|
|
|
M.make_text_rows_formatted = function(x, y, w, spacing, labels, _format)
|
|
|
|
return {
|
|
|
|
labels = text_column.make(
|
|
|
|
geom.make_point(x, y),
|
|
|
|
labels,
|
|
|
|
_left_text_style,
|
|
|
|
nil,
|
|
|
|
spacing
|
|
|
|
),
|
|
|
|
values = text_column.make_n(
|
|
|
|
geom.make_point(x + w, y),
|
|
|
|
#labels,
|
|
|
|
_right_text_style,
|
|
|
|
_format,
|
|
|
|
spacing,
|
|
|
|
0
|
|
|
|
)
|
|
|
|
}
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.make_text_rows = function(x, y, w, spacing, labels)
|
2022-07-19 00:54:46 -04:00
|
|
|
return M.make_text_rows_formatted(
|
|
|
|
x,
|
|
|
|
y,
|
|
|
|
w,
|
|
|
|
spacing,
|
|
|
|
labels,
|
|
|
|
nil
|
|
|
|
)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-11 23:57:56 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.text_rows_draw_static = function(rows, cr)
|
2022-07-19 00:54:46 -04:00
|
|
|
text_column.draw(rows.labels, cr)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.text_rows_draw_dynamic = function(rows, cr)
|
2022-07-19 00:54:46 -04:00
|
|
|
text_column.draw(rows.values, cr)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.text_rows_set = function(rows, i, value)
|
2022-07-19 00:54:46 -04:00
|
|
|
text_column.set(rows.values, i, value)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- table
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-19 00:54:46 -04:00
|
|
|
local gtable = geometry.table
|
|
|
|
local padding = gtable.padding
|
|
|
|
local xpad = padding[1]
|
|
|
|
local ypad = padding[2]
|
|
|
|
|
2022-07-18 00:36:44 -04:00
|
|
|
local default_table_font_spec = make_font_spec(font_family, font_sizes.table, false)
|
2021-07-11 16:53:25 -04:00
|
|
|
|
2022-07-19 00:54:46 -04:00
|
|
|
local col_fmt = gtable.name_chars > 0 and gtable.name_chars
|
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
local default_table_config = function(label)
|
2022-07-19 00:54:46 -04:00
|
|
|
return tbl.config(
|
|
|
|
rect.config(
|
|
|
|
style.closed_poly(TABLE_LINE_THICKNESS, JOIN_MITER),
|
|
|
|
patterns.border
|
|
|
|
),
|
|
|
|
line.config(
|
|
|
|
style.line(TABLE_LINE_THICKNESS, CAP_BUTT),
|
|
|
|
patterns.border,
|
|
|
|
true
|
|
|
|
),
|
|
|
|
tbl.header_config(
|
|
|
|
default_table_font_spec,
|
|
|
|
patterns.text.active,
|
|
|
|
gtable.header_padding
|
|
|
|
),
|
|
|
|
tbl.body_config(
|
|
|
|
default_table_font_spec,
|
|
|
|
patterns.text.inactive,
|
|
|
|
{
|
|
|
|
tbl.column_config('Name', col_fmt),
|
2022-07-17 18:40:24 -04:00
|
|
|
tbl.column_config('PID', false),
|
|
|
|
tbl.column_config(label, false),
|
2022-07-19 00:54:46 -04:00
|
|
|
}
|
|
|
|
),
|
|
|
|
tbl.padding(xpad, ypad, xpad, ypad)
|
|
|
|
)
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-11 16:53:25 -04:00
|
|
|
|
2022-07-19 00:54:46 -04:00
|
|
|
M.table_height = function(n)
|
|
|
|
return ypad * 2 + gtable.header_padding + gtable.row_spacing * n
|
2022-07-17 18:40:24 -04:00
|
|
|
end
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-19 00:54:46 -04:00
|
|
|
M.make_text_table = function(x, y, w, n, label)
|
|
|
|
local h = M.table_height(n)
|
|
|
|
return tbl.make(
|
|
|
|
geom.make_box(x, y, w, h),
|
|
|
|
n,
|
|
|
|
default_table_config(label)
|
|
|
|
)
|
2022-07-18 00:36:44 -04:00
|
|
|
end
|
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- panel
|
2021-07-05 23:27:43 -04:00
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
M.make_panel = function(x, y, w, h, thickness)
|
2022-07-19 00:54:46 -04:00
|
|
|
return fill_rect.make(
|
|
|
|
geom.make_box(x, y, w, h),
|
|
|
|
rect.config(
|
|
|
|
style.closed_poly(thickness, JOIN_MITER),
|
|
|
|
patterns.border
|
|
|
|
),
|
|
|
|
patterns.panel.bg
|
|
|
|
)
|
2022-07-16 23:48:01 -04:00
|
|
|
end
|
2022-07-12 01:23:59 -04:00
|
|
|
|
2022-07-17 18:54:23 -04:00
|
|
|
----------------------------------------------------------------------------
|
|
|
|
-- compile individual module
|
|
|
|
|
|
|
|
local _combine_blocks = function(acc, new)
|
|
|
|
if new.active == true then
|
|
|
|
local n = new.f(acc.next_y)
|
|
|
|
table.insert(acc.objs, n.obj)
|
|
|
|
acc.w = math.max(acc.w, n.w)
|
|
|
|
acc.final_y = acc.next_y + n.h
|
|
|
|
acc.next_y = acc.final_y + new.offset
|
|
|
|
end
|
|
|
|
return acc
|
|
|
|
end
|
|
|
|
|
|
|
|
local non_false = function(xs)
|
|
|
|
return pure.filter(function(x) return x ~= false end, xs)
|
|
|
|
end
|
|
|
|
|
|
|
|
local mk_block = function(f, active, offset)
|
|
|
|
return {f = f, active = active, offset = offset}
|
|
|
|
end
|
|
|
|
|
|
|
|
local active_blocks = function(blockspecs)
|
|
|
|
local bs = pure.filter(function(b) return b[2] end, blockspecs)
|
|
|
|
return pure.map(function(b) return mk_block(table.unpack(b)) end, bs)
|
|
|
|
end
|
|
|
|
|
2022-07-17 19:18:52 -04:00
|
|
|
local mk_separator = function(width, x, y)
|
|
|
|
local separator = M.make_separator(x, y, width)
|
|
|
|
return M.mk_acc_static(width, 0, pure.partial(line.draw, separator))
|
|
|
|
end
|
|
|
|
|
|
|
|
local flatten_sections = function(point, width, top, ...)
|
2022-07-17 18:54:23 -04:00
|
|
|
local f = function(acc, new)
|
|
|
|
if #new.blocks == 0 then
|
|
|
|
return acc
|
|
|
|
elseif #acc == 0 then
|
|
|
|
return new.blocks
|
|
|
|
else
|
|
|
|
return pure.flatten(
|
2022-07-17 19:18:52 -04:00
|
|
|
{
|
|
|
|
acc,
|
|
|
|
{mk_block(pure.partial(mk_separator, width, point.x), true, new.top)},
|
|
|
|
new.blocks
|
|
|
|
}
|
2022-07-17 18:54:23 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return pure.reduce(f, active_blocks(top), {...})
|
|
|
|
end
|
|
|
|
|
2022-07-17 19:18:52 -04:00
|
|
|
M.mk_section = function(top, ...)
|
2022-07-17 18:54:23 -04:00
|
|
|
return {
|
|
|
|
top = top,
|
|
|
|
blocks = active_blocks({...})
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
M.mk_acc = function(w, h, u, s, d)
|
|
|
|
return {w = w, h = h, obj = {u, s, d}}
|
|
|
|
end
|
|
|
|
|
|
|
|
M.mk_acc_static = function(w, h, s)
|
|
|
|
return M.mk_acc(w, h, false, s, false)
|
|
|
|
end
|
|
|
|
|
|
|
|
M.compile_module = function(header, point, width, top_blocks, ...)
|
|
|
|
local mk_header = function(y)
|
|
|
|
local obj = M.make_header(point.x, y, width, header)
|
|
|
|
return M.mk_acc_static(
|
|
|
|
width,
|
|
|
|
obj.bottom_y - y,
|
|
|
|
function(cr) M.draw_header(cr, obj) end
|
|
|
|
)
|
|
|
|
end
|
2022-07-17 19:18:52 -04:00
|
|
|
local blocks = flatten_sections(point, width, top_blocks, ...)
|
2022-07-17 18:54:23 -04:00
|
|
|
local r = pure.reduce(
|
|
|
|
_combine_blocks,
|
|
|
|
{w = 0, next_y = point.y, final_y = point.y, objs = {}},
|
|
|
|
{mk_block(mk_header, true, 0), table.unpack(blocks)}
|
|
|
|
)
|
|
|
|
local us, ss, ds = table.unpack(pure.unzip(r.objs))
|
|
|
|
return {
|
|
|
|
next_x = point.x + r.w,
|
|
|
|
next_y = r.final_y,
|
|
|
|
update = pure.sequence(table.unpack(non_false(us))),
|
|
|
|
static = pure.sequence(table.unpack(ss)),
|
|
|
|
dynamic = pure.sequence(table.unpack(non_false(ds)))
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2022-07-17 18:40:24 -04:00
|
|
|
return M
|
2022-07-16 23:48:01 -04:00
|
|
|
end
|