grid

package
v0.0.0-...-22e6c3c Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShoelaceArea

func ShoelaceArea(path []Point) int

Types

type ChessColor

type ChessColor int
const (
	White ChessColor = 0
	Black ChessColor = 1
)

type Direction

type Direction rune
const (
	N Direction = 'N'
	E Direction = 'E'
	S Direction = 'S'
	W Direction = 'W'
)

func (Direction) Reverse

func (d Direction) Reverse() Direction

func (Direction) TurnL

func (d Direction) TurnL() Direction

func (Direction) TurnR

func (d Direction) TurnR() Direction

type Grid

type Grid struct {
	MinPoint Point
	MaxPoint Point
	Points   map[Point]rune
}

func MakeGridFromLines

func MakeGridFromLines(lines *[]string) Grid

func (*Grid) At

func (g *Grid) At(p Point) rune

func (*Grid) Columns

func (g *Grid) Columns() []string

func (*Grid) Fill

func (g *Grid) Fill(p Point, r rune)

func (*Grid) InBounds

func (g *Grid) InBounds(p Point) bool

func (*Grid) Rows

func (g *Grid) Rows() []string

func (Grid) String

func (g Grid) String() string

type Point

type Point struct {
	X, Y int
}

func (Point) ChessColor

func (p Point) ChessColor() ChessColor

func (*Point) Distance

func (p *Point) Distance(o *Point) int

func (*Point) E

func (p *Point) E() Point

func (*Point) Move

func (p *Point) Move(direction Direction, distance int) Point

func (*Point) N

func (p *Point) N() Point

func (*Point) S

func (p *Point) S() Point

func (*Point) W

func (p *Point) W() Point

type Vector

type Vector struct {
	Point     Point
	Direction Direction
}

func (*Vector) MoveL

func (v *Vector) MoveL() Vector

func (*Vector) MoveR

func (v *Vector) MoveR() Vector

func (*Vector) Next

func (v *Vector) Next() Vector

func (*Vector) Reverse

func (v *Vector) Reverse() Vector

func (*Vector) TurnL

func (v *Vector) TurnL() Vector

func (*Vector) TurnR

func (v *Vector) TurnR() Vector

Jump to

Keyboard shortcuts

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