Documentation
¶
Index ¶
Constants ¶
const ( East = 0.0 North = 90.0 West = 180.0 South = 270.0 )
Standard directions.
Variables ¶
var ( Black = color.RGBA{0, 0, 0, 255} SoftBlack = color.RGBA{10, 10, 10, 255} White = color.RGBA{255, 255, 255, 255} Red = color.RGBA{255, 0, 0, 255} Green = color.RGBA{0, 255, 0, 255} Blue = color.RGBA{0, 0, 255, 255} Cyan = color.RGBA{0, 255, 255, 255} Magenta = color.RGBA{255, 0, 255, 255} Yellow = color.RGBA{255, 255, 0, 255} // I just love this one DarkOrange = color.RGBA{150, 75, 0, 255} )
Standard colors.
Functions ¶
Types ¶
type Pen ¶
type Pen struct { Color color.Color // Line color. Size int // Line width. On bool // State of the Pen. }
A simple Pen.
type Turtle ¶
A minimal Turtle agent, moving on a cartesian plane.
type TurtleDraw ¶
type TurtleDraw struct { Turtle // Turtle agent to move around. Pen // Pen used when drawing. W *World // World to draw on. }
A drawing Turtle.
func NewTurtleDraw ¶
func NewTurtleDraw(w *World) *TurtleDraw
Create a new TurtleDraw, attached to the World w.
func (*TurtleDraw) Backward ¶
func (td *TurtleDraw) Backward(dist float64)
Move the turtle backward and draw the line if the Pen is On.
func (*TurtleDraw) Forward ¶
func (td *TurtleDraw) Forward(dist float64)
Move the turtle forward and draw the line if the Pen is On.
func (*TurtleDraw) SetPos ¶
func (td *TurtleDraw) SetPos(x, y float64)
Teleport the Turtle to (x, y) and draw the line if the Pen is On.
type World ¶
type World struct { Image *image.RGBA Width, Height int DrawLineCh chan Line // contains filtered or unexported fields }
A world to draw on.
func NewWorldWithColor ¶ added in v0.2.0
Create a new World of the requested size and background color.
func NewWorldWithImage ¶ added in v0.2.0
Create a new World attached to an image.
func (*World) Close ¶
func (w *World) Close()
Close the world channels, and stop the listen goroutine.
func (*World) ResetImage ¶ added in v0.2.0
func (w *World) ResetImage()
Reset the current image, keep the current size, default background color.
func (*World) ResetImageWithImage ¶ added in v0.2.0
Reset the current image to the provided one.
func (*World) ResetImageWithSize ¶ added in v0.2.0
Reset the current image, changing the size, default background color.
func (*World) ResetImageWithSizeColor ¶ added in v0.2.0
Reset the current image, changing the size and background color.