turtle

package
v0.0.0-...-20d9937 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *Turtle, width, height int, delay time.Duration)

Run runs the simulation with the given turtle

func ShowDocs

func ShowDocs()

ShowDocs prints out usage documentation

Types

type GradientTable

type GradientTable []struct {
	Col colorful.Color
	Pos float64
}

GradientTable contains the "keypoints" of the colorgradient you want to generate. The position of each keypoint has to live in the range [0,256]

func NewPalette

func NewPalette() GradientTable

NewPalette returns the gradient color palette

func (GradientTable) GetInterpolatedColorFor

func (gt GradientTable) GetInterpolatedColorFor(t float64) colorful.Color

GetInterpolatedColorFor returns a HCL-blend between the two colors around `t`. Note: It relies heavily on the fact that the gradient keypoints are sorted.

type Point

type Point struct {
	X, Y float64
}

Point is a point on a 2D plane

func NewPoint

func NewPoint(x, y float64) Point

NewPoint returns a new point

type State

type State struct {
	Position  Point
	Direction float64 // in degrees
	StepSize  float64
	BrushSize float64
	Angle     float64 // Sets the number of turns that make up a complete circle to n. (Each turn will be by 360°/n.)
	Color     int
	Left      float64 // 1 or -1
}

State is the turtle state

type Turtle

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

Turtle allows drawing on a canvas

func NewTurtle

func NewTurtle(lsystem *l.System, state State, rotate float64, palette GradientTable) *Turtle

NewTurtle returns a new turtle centered at pos rotate controls rotation of the entire drawing by n°. Positive values rotate counterclockwise, negative values rotate clockwise. With the default of 0, the turtle begins pointing up. For example, to start with the turtle pointing to the right, use rotate 90.

func (*Turtle) Draw

func (t *Turtle) Draw(cv *canvas.Canvas, w, h float64, zoom float64, xoffset, yoffset float64)

Draw makes the turtle draw on the canvas based on the state in the system

func (*Turtle) State

func (t *Turtle) State() *State

State returns the pointer to the current state attached to the turtle

func (*Turtle) Step

func (t *Turtle) Step(n int, delay time.Duration)

Step makes the turtle take n steps

func (*Turtle) System

func (t *Turtle) System() *l.System

System returns the system attached to the turtle

Jump to

Keyboard shortcuts

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