geom

package
v0.0.0-...-c9d8584 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Point

type Point struct {
	X, Y int
}

Point is a data structure for storing integer geom coordinates.

func (Point) DiagonalNeighbours

func (p Point) DiagonalNeighbours() []Point

DiagonalNeighbours generates all Point that share a corner with self. (NE,SE,SW,NW)

func (Point) GetClosestPosition

func (p Point) GetClosestPosition(candidates []Point) Point

GetClosestPosition of all the positions in candidates, return the one closest to self.

func (Point) GetFarthestPosition

func (p Point) GetFarthestPosition(candidates []Point) Point

GetFarthestPosition of all the positions in candidates, return the one farthest from self.

func (Point) ManhattanDistanceTo

func (p Point) ManhattanDistanceTo(point Point) int

ManhattanDistanceTo returns Manhattan distance between self and target Point.

func (Point) Neighbours

func (p Point) Neighbours() []Point

Neighbours generates all Point that share a horizontal or vertical edge with this one. (N,S,E,W)

func (Point) PathLTo

func (p Point) PathLTo(point Point) []Point

PathLTo generates all positions on an L-shaped path between self and target Point.

func (Point) PositionsBresenhamTo

func (p Point) PositionsBresenhamTo(point Point) []Point

PositionsBresenhamTo generates all positions on a Bresenham algorithm line between self and other Point.

func (Point) Vector2

func (p Point) Vector2(expX, expY int) rl.Vector2

Vector2 provides the dot product of Point, used for getting Rect size for texture display.

type Rect

type Rect struct {
	// contains filtered or unexported fields
}

func NewRect

func NewRect(o Point, s Size) *Rect

func (Rect) Area

func (r Rect) Area() int

func (Rect) Center

func (r Rect) Center() (int, int)

Returns the center point of this rectangle

func (Rect) Contains

func (r Rect) Contains(other Rect) bool

Returns true if this rectangle contains all the points found in other

func (Rect) Intersect

func (r Rect) Intersect(other Rect) bool

Returns true if this rectangle intersects with another one

func (Rect) Origin

func (r Rect) Origin() Point

func (Rect) Points

func (r Rect) Points() []Point

Returns all points found within this rectangle

func (Rect) Size

func (r Rect) Size() Size

type Size

type Size struct {
	Width, Height int
}

Size is a data structure for storing width and height values.

func (Size) Area

func (s Size) Area() int

Area returns the calculates area for this Size.

Jump to

Keyboard shortcuts

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