terrapin

package module
v0.0.0-...-9909c0d Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2014 License: MIT Imports: 3 Imported by: 6

README

Terrapin

Turtle graphics for Golang using image.RGBA

Usage

i := image.NewRGBA(image.Rect(0, 0, 300, 300))
t := terrapin.NewTerrapin(i, terrapin.Position{150.0, 150.0})

t.Forward(100)
t.Right(math.Pi * 1 / 2)
t.Forward(100)
t.Right(math.Pi * 3 / 4)
t.Forward(math.Hypot(100, 100))

png.Encode(writer, i)

Examples

To see a couple of little examples:

go get github.com/holizz/terrapin
go run $GOPATH/src/github.com/holizz/terrapin/example/main.go

License

MIT (see LICENSE.txt)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Position

type Position struct {
	X, Y float64
}

type Terrapin

type Terrapin struct {
	Image       *image.RGBA
	Pos         Position
	Orientation float64
	Color       color.Color
	Pen         bool
}

func NewTerrapin

func NewTerrapin(i *image.RGBA, starting Position) (t *Terrapin)

func (*Terrapin) Backward

func (t *Terrapin) Backward(dist float64)

func (*Terrapin) Forward

func (t *Terrapin) Forward(dist float64)

func (*Terrapin) Left

func (t *Terrapin) Left(radians float64)

func (*Terrapin) PenDown

func (t *Terrapin) PenDown()

func (*Terrapin) PenUp

func (t *Terrapin) PenUp()

func (*Terrapin) Right

func (t *Terrapin) Right(radians float64)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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