Documentation
¶
Overview ¶
Package geometry computes bounded CSS boxes without fonts, images or hardware. Floats are retained until rasterization; device byte alignment belongs later.
Index ¶
- type Box
- func ResolveAbsoluteWidth(c style.Computed, ref Reference, intrinsic Intrinsic) (Box, error)
- func ResolveInline(c style.Computed, reference Reference) (Box, error)
- func ResolveReplaced(c style.Computed, ref Reference, width, height float64) (Box, error)
- func ResolveWidth(c style.Computed, reference Reference, intrinsic Intrinsic) (Box, error)
- type Edges
- type Intrinsic
- type Rect
- func BackgroundPosition(area Rect, width, height float64, c style.Computed, reference Reference) (Rect, error)
- func BackgroundRect(area Rect, width, height float64, c style.Computed, reference Reference) (Rect, error)
- func ObjectRect(area Rect, width, height float64, c style.Computed, reference Reference) (Rect, error)
- func Tiles(tile, clip Rect, repeat string, budget int) ([]Rect, error)
- type Reference
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Box ¶
type Box struct {
ContentWidth, ContentHeight float64
Margin, Padding, Border Edges
DefiniteHeight bool
// contains filtered or unexported fields
}
func ResolveAbsoluteWidth ¶
ResolveAbsoluteWidth keeps percentage bases at the containing padding box, but auto width uses the space between insets or CSS shrink-to-fit. https://www.w3.org/TR/CSS22/visudet.html#abs-non-replaced-width
func ResolveInline ¶
ResolveInline resolves decorations, not width/height, on non-replaced inline boxes. Vertical decorations do not enlarge the line-height strut. https://www.w3.org/TR/CSS22/visudet.html#inline-non-replaced
func ResolveReplaced ¶
ResolveReplaced sizes an image before object-fit maps its pixels into the box. Width/height:auto preserves intrinsic ratio, including coupled min/max limits. https://www.w3.org/TR/CSS22/visudet.html#min-max-widths
func ResolveWidth ¶
func (Box) OuterHeight ¶
func (Box) OuterWidth ¶
func (*Box) ResolveAbsoluteHeight ¶
type Intrinsic ¶
type Intrinsic struct{ Minimum, Preferred float64 }
func IntrinsicContribution ¶
IntrinsicContribution includes fixed dimensions and box edges before an ancestor's shrink-to-fit decision. Cyclic percentage sizes behave as auto; cyclic percentage margins/padding contribute zero until final layout. https://www.w3.org/TR/css-sizing-3/#cyclic-percentage-contribution
type Rect ¶
type Rect struct{ X, Y, Width, Height float64 }
Rect is a top-left-origin logical rectangle; Width/Height never imply an allocation. Raster bounds must be intersected with the physical viewport.
func BackgroundPosition ¶
func BackgroundPosition(area Rect, width, height float64, c style.Computed, reference Reference) (Rect, error)
BackgroundPosition places an already-sized image in its fragment's padding box. Fragmented backgrounds can share an aspect-derived size across boxes.
func BackgroundRect ¶
func ObjectRect ¶
func ObjectRect(area Rect, width, height float64, c style.Computed, reference Reference) (Rect, error)
ObjectRect implements replaced-image fitting inside its already-sized CSS box. The painter must clip to that box, even for cover/none or positioned overflow. https://www.w3.org/TR/css-images-3/#the-object-fit