2 slab_y = function(height, shift)
3 return { -0.5, -0.5+(shift or 0), -0.5, 0.5, -0.5+height+(shift or 0), 0.5 }
5 slab_z = function(depth)
6 return { -0.5, -0.5, -0.5+depth, 0.5, 0.5, 0.5 }
8 bar_y = function(radius)
9 return { -radius, -0.5, -radius, radius, 0.5, radius }
11 cuboid = function(radius_x, radius_y, radius_z)
12 return { -radius_x, -radius_y, -radius_z, radius_x, radius_y, radius_z }
17 regular = { type = "regular" },
18 null = { type = "fixed", fixed = { 0, 0, 0, 0, 0, 0 } }
21 xdecor.pixelbox = function(size, boxes)
23 for _, box in pairs(boxes) do
24 -- `unpack` has been changed to `table.unpack` in newest Lua versions.
25 local x, y, z, w, h, l = unpack(box)
30 ((x + w) / size) - 0.5,
31 ((y + h) / size) - 0.5,
32 ((z + l) / size) - 0.5
35 return { type = "fixed", fixed = fixed }
39 mt.__index = function(table, key)
40 local ref = xdecor.box[key]
41 local ref_type = type(ref)
43 if ref_type == "function" then
45 return { type = "fixed", fixed = ref(...) }
47 elseif ref_type == "table" then
48 return { type = "fixed", fixed = ref }
49 elseif ref_type == "nil" then
50 error(key.."could not be found among nodebox presets and functions")
53 error("unexpected datatype "..tostring(type(ref)).." while looking for "..key)
56 setmetatable(xdecor.nodebox, mt)