2 slab_y = function(height, shift)
8 -0.5 + height + (shift or 0),
12 slab_z = function(depth)
13 return {-0.5, -0.5, -0.5 + depth, 0.5, 0.5, 0.5}
15 bar_y = function(radius)
16 return {-radius, -0.5, -radius, radius, 0.5, radius}
18 cuboid = function(radius_x, radius_y, radius_z)
19 return {-radius_x, -radius_y, -radius_z, radius_x, radius_y, radius_z}
24 regular = {type = "regular"},
26 type = "fixed", fixed = {0,0,0,0,0,0}
30 xdecor.pixelbox = function(size, boxes)
32 for _, box in ipairs(boxes) do
33 -- `unpack` has been changed to `table.unpack` in newest Lua versions.
34 local x, y, z, w, h, l = unpack(box)
39 ((x + w) / size) - 0.5,
40 ((y + h) / size) - 0.5,
41 ((z + l) / size) - 0.5
45 return {type = "fixed", fixed = fixed}
50 mt.__index = function(table, key)
51 local ref = xdecor.box[key]
52 local ref_type = type(ref)
54 if ref_type == "function" then
56 return {type = "fixed", fixed = ref(...)}
58 elseif ref_type == "table" then
59 return {type = "fixed", fixed = ref}
60 elseif ref_type == "nil" then
61 error(key .. "could not be found among nodebox presets and functions")
64 error("unexpected datatype " .. tostring(type(ref)) .. " while looking for " .. key)
67 setmetatable(xdecor.nodebox, mt)