Documentation
¶
Overview ¶
Package geom implements the geometry model of doc/template.md#geometry: dimensions with units, the three-decimal rounding rule, boxes, the any-two-of-three edge resolution, and content alignment.
Index ¶
- Constants
- Variables
- func AlignH(outerStart, outer, inner float64, align HAlign) float64
- func AlignV(outerStart, outer, inner float64, align VAlign) float64
- func Fits(want, have float64) bool
- func ParseDim(spec string) (float64, error)
- func Round(value float64) float64
- type Box
- type Extent
- type HAlign
- type Opt
- type PageSize
- type VAlign
Constants ¶
const Tolerance = 0.001
Tolerance is the slack allowed when comparing a length against a frame boundary, per doc/layout.md#coordinates-and-rounding. A band whose height matches the remaining space exactly fits rather than ejecting.
Variables ¶
var ErrOverSpecified = fmt.Errorf("all three of near edge, far edge and size specified")
ErrOverSpecified reports an axis with all three of near, far and size given. Templates are rejected for this at load; Resolve guards against it too.
Functions ¶
func AlignH ¶
AlignH places content of width inner inside a box at outerStart of width outer, and returns the content's start coordinate.
func AlignV ¶
AlignV places content of height inner inside a box at outerStart of height outer, and returns the content's start coordinate.
func ParseDim ¶
ParseDim parses a dimension: a bare number in PostScript points, or a number with one of the unit suffixes pt, mil, mm, cm, in.
func Round ¶
Round rounds a length to three decimal places.
The rule is normative rather than cosmetic: it decides whether a band fits, so an implementation that rounds only at output time disagrees about page breaks. Every computed coordinate and extent passes through here immediately after the computation that produces it.
Types ¶
type Box ¶
type Box struct {
Left, Top, Width, Height float64
}
Box is an absolute rectangle. Y grows downward from the top-left of the page.
type Extent ¶
Extent is one axis of a declared box: the near edge (left or top), the far edge (right or bottom, measured inward from the container's far edge), and the size. Max is the maxwidth or maxheight clamp, which is not part of the two-of-three count.
func (Extent) Resolve ¶
Resolve places the extent within a container running from start for size units, per the fill order in doc/template.md#position-and-size-any-two-of-three: missing values are filled in the order near, then far, until two of the three are known, and the third is derived.
A derived size may come out negative when the two declared edges cross; it is clamped to zero, since a printout box has non-negative extents.
type HAlign ¶
type HAlign int
HAlign is horizontal alignment of content within its box.
func ParseHAlign ¶
ParseHAlign parses a halign enumeration value.
type PageSize ¶
type PageSize struct {
Width, Height float64
}
PageSize is a page's portrait width and height in points.
func LookupPageSize ¶
LookupPageSize returns the named page size in portrait orientation.