Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
-- bbox.lua: bounding boxes (experimental).
-- This file:
-- http://angg.twu.net/LATEX/dednat6/preamble6.lua
-- http://angg.twu.net/LATEX/dednat6/preamble6.lua.html
--  (find-angg        "LATEX/dednat6/preamble6.lua")
--
-- See: (find-dn6 "preamble.lua")



-- Bounding boxes

bbmin = function (a, b) return (a and b) and min(a, b) or (a or b) end
bbmax = function (a, b) return (a and b) and max(a, b) or (a or b) end

BBox = Class {
  type    = "BBox",
  new = function (T) return BBox(T or {}):addx1y1() end,
  __tostring = function (bb) return bb:tostring() end,
  __index = {
    tostring = function (bb)
        local ntos = function (n) return n and format("%.3f", n) or "nil" end
        local str = format("BBox: [%s,%s]x[%s,%s]",
                           ntos(bb.x0), ntos(bb.x2),
                           ntos(bb.y0), ntos(bb.y2))
        if bb.x1 or bb.y1 then
          str = str..format(", center (%s,%s)", ntos(bb.x1), ntos(bb.y1))
        end
        return str
      end,
    x0x2y0y2 = function (bb) return bb.x0, bb.x2, bb.y0, bb.y2 end,
    addxy   = function (bb, x, y) return bb:addx(x):addy(y) end,
    addx1y1 = function (bb) return bb:addxy(bb.x1, bb.y1) end,
    addx = function (bb, x)
        bb.x0 = bbmin(bb.x0, x)
        bb.x2 = bbmax(bb.x2, x)
        return bb
      end,
    addy = function (bb, y)
        bb.y0 = bbmin(bb.y0, y)
        bb.y2 = bbmax(bb.y2, y)
        return bb
      end,
    enlarge = function (bb, d)
        return BBox.new {
            x0=(bb.x0 and bb.x0 - d), x2=(bb.x2 and bb.x2 + d),
            y0=(bb.y0 and bb.y0 - d), y2=(bb.y2 and bb.y2 + d),
            x1=bb.x1, y1=bb.y1,
          }
      end,
  },
}

-- TODO: center, v, toward, intinnerbox, has

--[[
 (eepitch-lua51)
 (eepitch-kill)
 (eepitch-lua51)
dofile "bbox.lua"
bb = BBox.new {x1=2, y1=3}
= bb

--]]




--[[
 (eepitch-lua51)
 (eepitch-kill)
 (eepitch-lua51)
dofile "bbox.lua"

--]]


-- Local Variables:
-- coding: utf-8-unix
-- End: