canvas

package
v0.0.0-...-ccddcae Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Canvas

type Canvas interface {
	// Clear ensures a given rectangle on the canvas is empty,
	// ready for drawing to.
	Clear(rect image.Rectangle) error

	// Draw draws a line between two points on the canvas.
	// The points should be provided in grid space.
	Draw(a, b Point) error

	// WaitForQuit blocks until the canvas has exited.
	WaitForQuit()
}

type PaperCanvas

type PaperCanvas struct {
	Canvas
}

func NewPaperCanvas

func NewPaperCanvas(gridWidth, gridHeight int) (sc PaperCanvas)

TODO: Implement me!

func (*PaperCanvas) Clear

func (sc *PaperCanvas) Clear(rect image.Rectangle) error

TODO: Implement me! Block until complete.

func (*PaperCanvas) Draw

func (sc *PaperCanvas) Draw(a, b Point) error

TODO: Implement me! Block until complete.

func (*PaperCanvas) WaitForQuit

func (sc *PaperCanvas) WaitForQuit()

TODO: Implement me!

type Point

type Point struct {
	X, Y float64
}

func Pt

func Pt(x, y float64) Point

Pt is shorthand for Point{X, Y}.

func (Point) Add

func (p Point) Add(q Point) Point

Add returns the vector p+q.

func (Point) Div

func (p Point) Div(k float64) Point

Div returns the vector p/k.

func (Point) Mul

func (p Point) Mul(k float64) Point

Mul returns the vector p*k.

func (Point) Sub

func (p Point) Sub(q Point) Point

Sub returns the vector p-q.

type ScreenCanvas

type ScreenCanvas struct {
	Canvas
	// contains filtered or unexported fields
}

func NewScreenCanvas

func NewScreenCanvas(gridWidth, gridHeight int) (sc ScreenCanvas)

NewScreenCanvas creates a new ScreenCanvas.

func (*ScreenCanvas) Clear

func (sc *ScreenCanvas) Clear(rect image.Rectangle) error

Clear overwrites the entire canvas with a white background. The rectangle to clear is ignored, but an error is returned if the rectangle is larger than the drawable area.

func (*ScreenCanvas) Draw

func (sc *ScreenCanvas) Draw(a, b Point) error

Draw draws a line between two points in grid space on the canvas. The points are converted from grid space to canvas space.

func (*ScreenCanvas) WaitForQuit

func (sc *ScreenCanvas) WaitForQuit()

Jump to

Keyboard shortcuts

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