position

package
v0.0.0-...-cf53f0f Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDirections

func CreateDirections[P Positioner[E], E Position](dir ...Dir) (res []E)

Types

type Collection

type Collection[P Positioner[E], E Position] [4]E
var (
	DirectionsPos8          Collection[Pos8, Pos8]   = createDirections[Pos8]()
	DirectionsPos16         Collection[Pos16, Pos16] = createDirections[Pos16]()
	DirectionsPos32         Collection[Pos32, Pos32] = createDirections[Pos32]()
	DirectionsPos           Collection[Pos, Pos]     = createDirections[Pos]()
	DirectionsDiagonalPos8  Collection[Pos8, Pos8]   = createDiagonalDirections[Pos8]()
	DirectionsDiagonalPos16 Collection[Pos16, Pos16] = createDiagonalDirections[Pos16]()
	DirectionsDiagonalPos32 Collection[Pos32, Pos32] = createDiagonalDirections[Pos32]()
	DirectionsDiagonalPos   Collection[Pos, Pos]     = createDiagonalDirections[Pos]()
)

func (Collection[P, E]) AddTo

func (c Collection[P, E]) AddTo(pos P) iter.Seq2[int, E]

type Dir

type Dir uint
const (
	Dir_Up Dir = iota
	Dir_Right
	Dir_Down
	Dir_Left
	Dir_UpLeft
	Dir_UpRight
	Dir_DownRight
	Dir_DownLeft
)

func (Dir) Pos

func (d Dir) Pos() (y, x int8)

type Pos

type Pos struct {
	Y, X int64
}

func New

func New(y, x int64) Pos

func NewNegative

func NewNegative(y, x int64) Pos

func (Pos) Add

func (p Pos) Add(b Pos) Pos

func (*Pos) AddSelf

func (p *Pos) AddSelf(o Pos)

func (Pos) Equal

func (p Pos) Equal(o Pos) bool

func (Pos) GoString

func (p Pos) GoString() string

func (Pos) IsInside

func (p Pos) IsInside(maxPos Pos) bool

func (Pos) New

func (Pos) New(y, x int) Pos

func (Pos) NewDir

func (Pos) NewDir(y, x int8) Pos

func (Pos) String

func (p Pos) String() string

func (Pos) Sub

func (p Pos) Sub(b Pos) Pos

func (*Pos) SubSelf

func (p *Pos) SubSelf(o Pos)

type Pos16

type Pos16 uint32

func New16

func New16(y, x uint16) Pos16

func New16Negative

func New16Negative(y, x int16) Pos16

func (Pos16) Add

func (p Pos16) Add(b Pos16) Pos16

func (*Pos16) AddSelf

func (p *Pos16) AddSelf(o Pos16)

func (Pos16) GoString

func (p Pos16) GoString() string

func (Pos16) IsInside

func (p Pos16) IsInside(maxPos Pos16) bool

func (Pos16) New

func (Pos16) New(y, x int) Pos16

func (Pos16) NewDir

func (Pos16) NewDir(y, x int8) Pos16

func (Pos16) String

func (p Pos16) String() string

func (Pos16) Sub

func (p Pos16) Sub(b Pos16) Pos16

func (*Pos16) SubSelf

func (p *Pos16) SubSelf(o Pos16)

func (Pos16) X

func (p Pos16) X() uint16

func (Pos16) Y

func (p Pos16) Y() uint16

type Pos32

type Pos32 uint64

func New32

func New32(y, x uint32) Pos32

func New32Negative

func New32Negative(y, x int32) Pos32

func (Pos32) Add

func (p Pos32) Add(b Pos32) Pos32

func (*Pos32) AddSelf

func (p *Pos32) AddSelf(o Pos32)

func (Pos32) GoString

func (p Pos32) GoString() string

func (Pos32) IsInside

func (p Pos32) IsInside(maxPos Pos32) bool

func (Pos32) New

func (Pos32) New(y, x int) Pos32

func (Pos32) NewDir

func (Pos32) NewDir(y, x int8) Pos32

func (Pos32) String

func (p Pos32) String() string

func (Pos32) Sub

func (p Pos32) Sub(b Pos32) Pos32

func (*Pos32) SubSelf

func (p *Pos32) SubSelf(o Pos32)

func (Pos32) X

func (p Pos32) X() uint32

func (Pos32) Y

func (p Pos32) Y() uint32

type Pos8

type Pos8 uint16

func New8

func New8(y, x uint8) Pos8

func New8Negative

func New8Negative(y, x int8) Pos8

func (Pos8) Add

func (p Pos8) Add(b Pos8) Pos8

func (*Pos8) AddSelf

func (p *Pos8) AddSelf(o Pos8)

func (Pos8) GoString

func (p Pos8) GoString() string

func (Pos8) IsInside

func (p Pos8) IsInside(maxPos Pos8) bool

func (Pos8) New

func (Pos8) New(y, x int) Pos8

func (Pos8) NewDir

func (Pos8) NewDir(y, x int8) Pos8

func (Pos8) String

func (p Pos8) String() string

func (Pos8) Sub

func (p Pos8) Sub(b Pos8) Pos8

func (*Pos8) SubSelf

func (p *Pos8) SubSelf(o Pos8)

func (Pos8) X

func (p Pos8) X() uint8

func (Pos8) Y

func (p Pos8) Y() uint8

type PosMap

type PosMap[P Position] struct {
	Map    []P
	MaxPos P
}

type Position

type Position interface {
	Pos8 | Pos16 | Pos32 | Pos
}

type Positioner

type Positioner[P Position] interface {
	Position
	IsInside(P) bool
	Add(P) P
	Sub(P) P
	NewDir(y, x int8) P
	New(x, y int) P
}

Jump to

Keyboard shortcuts

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