chessboard

package module
v0.0.0-...-c647508 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 21 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnoType

type AnnoType int8
const (
	NoAnno AnnoType = iota
	RectAnno
	CircleAnno
	CrossAnno
	ArrowAnno
)

type Annotation

type Annotation struct {
	Type  AnnoType
	Start chess.Square
	End   chess.Square // only for arrows
	Color color.NRGBA
	Width union.Size
	// contains filtered or unexported fields
}

func (*Annotation) Copy

func (a *Annotation) Copy() Annotation

func (*Annotation) Draw

func (a *Annotation) Draw(gtx layout.Context, squareOrigins []union.Point, squareSize union.Size, redraw bool)

func (*Annotation) Equal

func (a *Annotation) Equal(b *Annotation) bool

func (*Annotation) Scale

func (a *Annotation) Scale(factor float32)

type Colors

type Colors struct {
	Empty     color.NRGBA
	Hint      color.NRGBA
	Highlight color.NRGBA
	LastMove  color.NRGBA
	Primary   color.NRGBA
	Info      color.NRGBA
	Warning   color.NRGBA
	Danger    color.NRGBA
}

type Config

type Config struct {
	ShowHints      bool
	ShowLastMove   bool
	Colors         Colors
	AnimationSpeed time.Duration
	Coordinates    Coordinates
	BoardTexture   Texture
	PieceTextures  []Texture
}

func NewConfig

func NewConfig(board Texture, pieces []Texture, colors Colors) (c *Config)

type Coordinates

type Coordinates int8
const (
	NoCoordinates Coordinates = iota
	InsideCoordinates
	OutsideCoordinates
	EachSquare
)

type CoordinatesStyle

type CoordinatesStyle struct {
	Type     Coordinates
	Theme    *material.Theme
	FontSize float32
	Flipped  bool
	Board    layout.Widget
}

func (CoordinatesStyle) Layout

type Promotion

type Promotion struct {
	Position         union.Point
	SquareSize       union.Size
	Color            chess.Color
	Background       color.NRGBA
	PieceTextures    []Texture
	HoveredCandidate chess.Piece
	Flipped          bool
}

func (Promotion) Layout

func (p Promotion) Layout(gtx layout.Context) layout.Dimensions

type Texture

type Texture struct {
	Image *image.NRGBA
	Size  union.Size
}

func LoadTexture

func LoadTexture(file io.Reader) (t Texture, err error)

type Widget

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

func NewWidget

func NewWidget(th *material.Theme, config *Config) *Widget

func (*Widget) Flip

func (w *Widget) Flip()

func (*Widget) Game

func (w *Widget) Game() *chess.Game

func (*Widget) Layout

func (w *Widget) Layout(gtx layout.Context) layout.Dimensions

func (*Widget) MoveBackward

func (w *Widget) MoveBackward()

func (*Widget) PositionChanged

func (w *Widget) PositionChanged() bool

func (*Widget) Reset

func (w *Widget) Reset()

func (*Widget) SetGame

func (w *Widget) SetGame(game *chess.Game)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳