jigsaw

package
v0.0.0-...-07010e4 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Image = `` /* 9321-byte string literal not displayed */
View Source
var ImageTest = `` /* 609-byte string literal not displayed */
View Source
var Monster = `
Tile 666:
..................#.
#....##....##....###
.#..#..#..#..#..#...
`

Functions

func AlignTiles

func AlignTiles(ts []Tile) ([][]*Tile, error)

func AlignTilesNaiv

func AlignTilesNaiv(ts []Tile) ([][]Tile, error)

func ArrangeEdge

func ArrangeEdge(dim int, tiles []Tile)

func FindMonster

func FindMonster(img string)

func FindTilesWithNoMatches

func FindTilesWithNoMatches(tiles []Tile)

func TileIDs

func TileIDs(tiles []Tile) []int

Types

type LinkedTile

type LinkedTile struct {
	Tile                     Tile
	Left, Top, Right, Bottom *LinkedTile
}
func (lt *LinkedTile) TryLink(t Tile) (*LinkedTile, bool)

type MatchPosition

type MatchPosition string
const (
	MatchNone   MatchPosition = "none"
	MatchLeft   MatchPosition = "left"
	MatchTop    MatchPosition = "top"
	MatchRight  MatchPosition = "right"
	MatchBottom MatchPosition = "bottom"
)

func AllValidMatchPositions

func AllValidMatchPositions() []MatchPosition

type RotateDir

type RotateDir string
const (
	Clockwise        RotateDir = "clockwise"
	CounterClockwise RotateDir = "counter-clockwise"
)

type Tile

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

func FindEdgeTiles

func FindEdgeTiles(ts []Tile) []Tile

func ParseTile

func ParseTile(sl []string, dimRows int, dimCols int) (Tile, error)

func (Tile) Col

func (t Tile) Col(ci int) []int

func (Tile) FirstCol

func (t Tile) FirstCol() []int

func (Tile) FirstRow

func (t Tile) FirstRow() []int

func (Tile) FlippedColumns

func (t Tile) FlippedColumns() Tile

func (Tile) FlippedRows

func (t Tile) FlippedRows() Tile

func (Tile) ID

func (t Tile) ID() int

func (Tile) LastCol

func (t Tile) LastCol() []int

func (Tile) LastRow

func (t Tile) LastRow() []int

func (Tile) Match

func (t Tile) Match(ot Tile, exclude []MatchPosition) []MatchPosition

func (Tile) MatchAt

func (t Tile) MatchAt(pos MatchPosition, ot Tile) bool

func (*Tile) MatchBottom

func (t *Tile) MatchBottom(ot Tile) bool

func (*Tile) MatchLeft

func (t *Tile) MatchLeft(ot Tile) bool

func (*Tile) MatchRight

func (t *Tile) MatchRight(ot Tile) bool

func (*Tile) MatchTop

func (t *Tile) MatchTop(ot Tile) bool

func (Tile) Rotated

func (t Tile) Rotated(dir RotateDir, rcnt int) Tile

func (Tile) Row

func (t Tile) Row(ri int) []int

func (Tile) String

func (t Tile) String() string

func (Tile) Transformed

func (t Tile) Transformed(trans Transform) Tile

type Transform

type Transform string
const (
	TransformNone      Transform = "none"
	TransformRotate90  Transform = "rotate-90"
	TransformRotate180 Transform = "rotate-180"
	TransformRotate270 Transform = "rotate-270"
	TransformFlipRows  Transform = "flip-rows"
	TransformFlipCols  Transform = "flip-cols"

	TransformFlipRowsRotate90  Transform = "flip-rows-rotate-90"
	TransformFlipRowsRotate180 Transform = "flip-rows-rotate-180"
	TransformFlipRowsRotate270 Transform = "flip-rows-rotate-270"

	TransformFlipColsRotate90  Transform = "flip-cols-rotate-90"
	TransformFlipColsRotate180 Transform = "flip-cols-rotate-180"
	TransformFlipColsRotate270 Transform = "flip-cols-rotate-270"
)

func AllTransforms

func AllTransforms() []Transform

Jump to

Keyboard shortcuts

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