Documentation ¶
Overview ¶
Package canvas contains the logic to draw the game
Index ¶
- type Canvas
- func (c *Canvas) GameStatus(s game.Status)
- func (c *Canvas) InitDom(ctx context.Context, wg *sync.WaitGroup)
- func (c *Canvas) MoveCursor(pp pixelPosition)
- func (c *Canvas) MoveEnd(pp pixelPosition)
- func (c *Canvas) MoveStart(pp pixelPosition)
- func (c Canvas) NumCols() int
- func (c Canvas) NumRows() int
- func (c *Canvas) Redraw()
- func (c *Canvas) StartSwap()
- func (c *Canvas) UpdateSize()
- type Config
- type Context
- type Socket
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Canvas ¶
type Canvas struct { Socket Socket // contains filtered or unexported fields }
Canvas is the object which draws the game
func (*Canvas) GameStatus ¶
GameStatus sets the gameStatus for the canvas. The canvas is redrawn afterwards to clean up drawing artifacts
func (*Canvas) MoveCursor ¶
func (c *Canvas) MoveCursor(pp pixelPosition)
MoveCursor should be called whenever the cursor moves, regardless of if a move is being made.
func (*Canvas) MoveEnd ¶
func (c *Canvas) MoveEnd(pp pixelPosition)
MoveEnd should be called when a move is done being made at the specified coordinates.
func (*Canvas) MoveStart ¶
func (c *Canvas) MoveStart(pp pixelPosition)
MoveStart should be called when a move is started to be made at the specified coordinates.
func (*Canvas) UpdateSize ¶
func (c *Canvas) UpdateSize()
UpdateSize sets the draw properties of the canvas for it's current size in the window. TODO: allow tileLength to be changed
type Config ¶
type Config struct {
TileLength int
}
Config contains the parameters to create a Canvas
type Context ¶
type Context interface { SetFont(name string) SetLineWidth(width float64) SetFillColor(name string) SetStrokeColor(name string) FillText(text string, x, y int) ClearRect(x, y, width, height int) FillRect(x, y, width, height int) StrokeRect(x, y, width, height int) }
Context handles the drawing of the canvas