geom

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Area

type Area struct {
	Point
	Size
}

Area is a screen rectangle: an origin Point and a Size

func (Area) Bottom

func (a Area) Bottom() int

Bottom is the y of the bottommost cell (inclusive): Y + Height - 1

func (Area) Center

func (a Area) Center(inner Size) Point

Center returns the origin Point that centers inner within a, clamped so the origin never precedes a's own origin when inner is larger

func (Area) Contains

func (a Area) Contains(p Point) bool

Contains reports whether a Point lies inside the specified Area

func (Area) Inset

func (a Area) Inset(by Size) Area

Inset returns a shrunk toward its center by by.Width on the left and right and by.Height on the top and bottom, with the Size clamped to zero

func (Area) Intersects

func (a Area) Intersects(b Area) bool

Intersects reports whether a and b overlap in at least one cell

func (Area) Right

func (a Area) Right() int

Right is the x of the rightmost cell (inclusive): X + Width - 1

func (Area) Translate

func (a Area) Translate(d Point) Area

Translate returns a copy of Area with its origin shifted by Point

type Point

type Point struct {
	X, Y int
}

Point is a screen or document coordinate in cells

func (Point) Add

func (p Point) Add(d Point) Point

Add returns p offset by d

func (Point) Sub

func (p Point) Sub(d Point) Point

Sub returns p offset by the negation of d

type Size

type Size struct {
	Width, Height int
}

Size is a pixel or cell extent, named so a call site never has to guess the order a bare (int, int) would leave ambiguous

func (Size) Clamp

func (s Size) Clamp(p Point) Point

Clamp returns p pinned to the last valid cell of the Size, i.e. into the range [0, Width-1] x [0, Height-1]

func (Size) Contains

func (s Size) Contains(p Point) bool

Contains reports whether a Point lies inside the specified Size

func (Size) IsEmpty added in v0.3.2

func (s Size) IsEmpty() bool

IsEmpty reports whether Size has no usable cells

Jump to

Keyboard shortcuts

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