geometry

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package geometry computes bounded CSS boxes without fonts, images or hardware. Floats are retained until rasterization; device byte alignment belongs later.

Index

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

func ResolveAbsoluteWidth(c style.Computed, ref Reference, intrinsic Intrinsic) (Box, error)

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

func ResolveInline(c style.Computed, reference Reference) (Box, error)

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

func ResolveReplaced(c style.Computed, ref Reference, width, height float64) (Box, error)

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 ResolveWidth(c style.Computed, reference Reference, intrinsic Intrinsic) (Box, error)

func (Box) OuterHeight

func (b Box) OuterHeight() float64

func (Box) OuterWidth

func (b Box) OuterWidth() float64

func (*Box) ResolveAbsoluteHeight

func (b *Box) ResolveAbsoluteHeight(c style.Computed, natural float64) error

func (*Box) ResolveHeight

func (b *Box) ResolveHeight(c style.Computed, natural float64) error

type Edges

type Edges struct{ Top, Right, Bottom, Left float64 }

func (Edges) Horizontal

func (e Edges) Horizontal() float64

func (Edges) Vertical

func (e Edges) Vertical() float64

type Intrinsic

type Intrinsic struct{ Minimum, Preferred float64 }

func IntrinsicContribution

func IntrinsicContribution(c style.Computed, ref Reference, content Intrinsic) (Intrinsic, error)

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 BackgroundRect(area Rect, width, height float64, c style.Computed, reference Reference) (Rect, error)

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

func Tiles

func Tiles(tile, clip Rect, repeat string, budget int) ([]Rect, error)

Tiles bounds iteration before converting any floating-point index to int. Tiny positive CSS lengths cannot cause an unbounded loop or allocation.

func (Rect) Bottom

func (r Rect) Bottom() float64

func (Rect) Empty

func (r Rect) Empty() bool

func (Rect) Intersect

func (r Rect) Intersect(other Rect) Rect

func (Rect) Right

func (r Rect) Right() float64

func (Rect) Valid

func (r Rect) Valid() bool

type Reference

type Reference struct {
	Width, Height                 float64
	ViewportWidth, ViewportHeight float64
	DefiniteHeight                bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL