genlsystem

package
v0.0.0-...-ce97658 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

README

Note

This code is heavlily influenced by the amazing lindenturtle package by "der-antikeks". See: https://github.com/der-antikeks/lindenturtle/

I have added a crude 3d turtle for generating simple wavefront OBJ files, which was in part inspired by: https://github.com/yalue/l_system_3d

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinTree

func BinTree(n int) image.Image

func ExportToPNG

func ExportToPNG(filePath string, m image.Image)

func Hilbert

func Hilbert(n int) image.Image

func Hilbert3d

func Hilbert3d(fname string, n int) error

func Lindenmayer

func Lindenmayer(start []string, rules map[string][]string, n int) []string

Lindenmayer iterative function. See: http://en.wikipedia.org/wiki/L-system

func Plant

func Plant(n int) image.Image

func Plant3d

func Plant3d(fname string, n int) error

func Pyramid3d

func Pyramid3d(fname string, n int) error

func Tree

func Tree(n int) image.Image

Types

type Bounds

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

func (*Bounds) AddPoint

func (a *Bounds) AddPoint(x, y float64)

func (*Bounds) Size

func (a *Bounds) Size() (width, height float64)

type Bounds3d

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

func (*Bounds3d) AddPoint

func (a *Bounds3d) AddPoint(x, y, z float64)

func (*Bounds3d) Size

func (a *Bounds3d) Size() (width, height, depth float64)

type Turtle

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

Turtle implements a turtle-esque drawing system.

func NewTurtle

func NewTurtle(rules map[string]func(*Turtle)) *Turtle

NewTurtle returns a new Turtle struct.

func (*Turtle) Angle

func (t *Turtle) Angle() (degree float64)

get angle

func (*Turtle) Cleanup

func (t *Turtle) Cleanup()

func (*Turtle) Color

func (t *Turtle) Color() color.Color

get color

func (*Turtle) Draw

func (t *Turtle) Draw(f, r float64)

draw line forward

func (*Turtle) Go

func (t *Turtle) Go(path []string) image.Image

UNLEASH THE TURTLE!

func (*Turtle) Move

func (t *Turtle) Move(f, r float64)

move forward without drawing

func (*Turtle) Position

func (t *Turtle) Position() (x, y float64)

get position

func (*Turtle) Restore

func (t *Turtle) Restore()

restore position and angle

func (*Turtle) Save

func (t *Turtle) Save()

save position and angle

func (*Turtle) SetColor

func (t *Turtle) SetColor(c color.Color)

set color

func (*Turtle) SetWidth

func (t *Turtle) SetWidth(w float64)

set width

func (*Turtle) Turn

func (t *Turtle) Turn(degree float64)

add rotation

func (*Turtle) Width

func (t *Turtle) Width() float64

get width

type Turtle3d

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

Turtle3d implements a turtle-esque drawing system IN 3D! This code is partially inspired by: https://github.com/yalue/l_system_3d and: https://github.com/recp/cglm/blob/master/include/cglm/vec3.h

func NewTurtle3d

func NewTurtle3d(rules map[string]func(*Turtle3d)) *Turtle3d

NewTurtle3d returns a new Turtle3d struct.

func (*Turtle3d) Cleanup

func (t *Turtle3d) Cleanup()

func (*Turtle3d) Draw

func (t *Turtle3d) Draw(f float64)

Draw draws a line forward.

func (*Turtle3d) GetColor

func (t *Turtle3d) GetColor() color.Color

GetColor gets the current color.

func (*Turtle3d) GetForward

func (t *Turtle3d) GetForward() vectors.Vec3

GetForward gets the current forward vector

func (*Turtle3d) GetPosition

func (t *Turtle3d) GetPosition() (x, y, z float64)

GetPosition gets the current position.

func (*Turtle3d) GetWidth

func (t *Turtle3d) GetWidth() float64

GetWidth gets the current width.

func (*Turtle3d) Go

func (t *Turtle3d) Go(fname string, path []string) error

UNLEASH THE TURTLE!

func (*Turtle3d) Move

func (t *Turtle3d) Move(f float64)

Move moves forward without drawing.

func (*Turtle3d) Pitch

func (t *Turtle3d) Pitch(angle float64)

func (*Turtle3d) Restore

func (t *Turtle3d) Restore()

restore position and angle

func (*Turtle3d) Roll

func (t *Turtle3d) Roll(angle float64)

func (*Turtle3d) Rotate

func (t *Turtle3d) Rotate(angle float64)

Rotate is the same as Yaw.

func (*Turtle3d) Save

func (t *Turtle3d) Save()

save position and angle

func (*Turtle3d) SetColor

func (t *Turtle3d) SetColor(c color.Color)

SetColor sets the current color.

func (*Turtle3d) SetWidth

func (t *Turtle3d) SetWidth(w float64)

SetWidth sets the current width.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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