ca

package
v0.0.0-...-454c9f3 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = Config{
	Cells:       50,
	Generations: 50,
	Format:      "txt",
	Random:      false,
	Rule:        30,
	Size:        5,
}

Functions

func Register

func Register(key string, np NewPrinter)

Types

type Config

type Config struct {
	Cells       int
	Generations int
	Format      string
	Random      bool
	Rule        int
	Size        int
}

func (Config) Print

func (c Config) Print(w io.Writer) error

type DrawPrinter

type DrawPrinter struct {
	Drawer
	// contains filtered or unexported fields
}

func (*DrawPrinter) Close

func (d *DrawPrinter) Close() error

func (*DrawPrinter) Print

func (d *DrawPrinter) Print(v []bool)

type Drawer

type Drawer interface {
	Draw(x0, y0, x1, y1 int, b bool)
	Close() error
}

The Drawer interface is an abstraction for drawing binary automata cells to an x/y grid.

type ImageDrawer

type ImageDrawer struct {
	io.Writer
	*image.Gray
	// contains filtered or unexported fields
}

An ImageDrawer is a drawer which draws to a grayscale gif.

func (*ImageDrawer) Close

func (p *ImageDrawer) Close() error

func (*ImageDrawer) Draw

func (p *ImageDrawer) Draw(x0, y0, x1, y1 int, b bool)

type JsonPrinter

type JsonPrinter struct {
	io.Writer
	// contains filtered or unexported fields
}

func (*JsonPrinter) Close

func (p *JsonPrinter) Close() error

func (*JsonPrinter) Print

func (p *JsonPrinter) Print(v []bool)

type NewPrinter

type NewPrinter func(cells, generations, size int, out io.Writer) Printer

TODO doc

type Printer

type Printer interface {
	Print(v []bool)
	Close() error
}

A Printer prints automata generations.

func NewImagePrinter

func NewImagePrinter(cells, generations, size int, out io.Writer, onClose func(*ImageDrawer) error) Printer

The newImagePrinter function returns a new image printer which writes to out.

func NewJsonPrinter

func NewJsonPrinter(w io.Writer) Printer

func NewLogPrinter

func NewLogPrinter(cells, generations, size int, out io.Writer) Printer

func NewSvgPrinter

func NewSvgPrinter(cells, generations, size int, out io.Writer) Printer

type SvgDrawer

type SvgDrawer struct {
	*svg.SVG
}

An SvgDrawer is a drawer

func (*SvgDrawer) Close

func (s *SvgDrawer) Close() error

func (*SvgDrawer) Draw

func (s *SvgDrawer) Draw(x0, y0, x1, y1 int, b bool)

Jump to

Keyboard shortcuts

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