Documentation
¶
Overview ¶
Package render provides a small, framework-neutral drawing protocol over display.Box.
Walk streams visible path and rule commands without copying transformed path geometry. The path template in each command borrows storage from the box and is valid only for the duration of its callback invocation. ResolvePath is the explicit allocating escape hatch for hosts that need standalone geometry.
Fit computes a uniform transform that places all certified box bounds, including overflow, inside a host viewport.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidViewport reports a nil, non-finite, or non-positive viewport. ErrInvalidViewport = errors.New("render: invalid viewport") // ErrInvalidFitOptions reports invalid padding or alignment. ErrInvalidFitOptions = errors.New("render: invalid fit options") )
var ( // ErrInvalidBox reports malformed input needed by the drawing protocol. ErrInvalidBox = errors.New("render: invalid box") // ErrInvalidCallback reports a nil Walk callback. ErrInvalidCallback = errors.New("render: invalid callback") // ErrInvalidCommand reports a command that cannot be resolved as a path. ErrInvalidCommand = errors.New("render: invalid command") )
Functions ¶
func ResolvePath ¶
ResolvePath materializes one path command in box coordinates.
ResolvePath allocates a new geometry.Path. Hosts that can draw directly from segments should use Walk and transform points to box coordinates themselves. ResolvePath does not mutate the borrowed template.
Types ¶
type Command ¶
type Command struct {
Kind CommandKind
Paint display.Paint
Bound geometry.Rect
Path display.PathTemplate
At geometry.Point
Em float32
Rect geometry.Rect
}
Command is one visible drawing operation in box coordinates.
Path aliases Box.Paths storage. Callers must not mutate Path or retain it after the Walk callback returns. Rule commands use Rect and leave Path empty.
type CommandKind ¶
type CommandKind uint8
CommandKind identifies one visible drawing operation.
const ( // CommandPath fills a shared path template placed by At and Em. CommandPath CommandKind = iota // CommandRule fills Rect. CommandRule )
type FitOptions ¶
FitOptions controls placement inside a viewport. Padding is applied equally on every side. The box is always centered vertically.
type Transform ¶
Transform maps box coordinates into viewport coordinates as offset + point*scale.
func Fit ¶
Fit returns a uniform transform that tightly fits Box.Bounds(), including certified overflow, inside viewport after padding.
Fit may enlarge small boxes. A box with zero width and height uses scale 1. The viewport must have finite positive dimensions, and padding must leave a finite positive content area.