lam

package module
v0.0.0-...-0d7c78e Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2022 License: BSD-3-Clause Imports: 9 Imported by: 0

README

lam - lines and marbles

Uses github.com/goki/gi

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultColors = []string{"black", "red", "blue", "green", "purple", "brown", "orange"}

DefaultColors are all of the default colors for marbles and lines

View Source
var FunctionNames = []string{"f", "g", "b", "c", "d", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "u", "v", "w", "y", "z"}

FunctionNames has all of the names assigned to functions in order

Functions

func CheckIfChanges

func CheckIfChanges(expr string, functions mee.Functions) bool

CheckIfChanges checks whether a certain expression will change over time. Returns true if it changes, otherwise false

func CompileExpr

func CompileExpr(expr *mee.Expr, functions mee.Functions)

CompileExpr compiles an expression

Types

type Line

type Line struct {
	*svg.Path
	FunctionName string
	Expr         mee.Expr
	GraphIf      mee.Expr
	Bounce       mee.Expr
	Color        gist.Color
	ColorSwitch  gist.Color
	Changes      bool
}

Line contains the physical line and its data

func (*Line) CheckBlankValues

func (ln *Line) CheckBlankValues(idx int)

CheckBlankValues checks if any of the expr strings or other line values are empty, if they are sets them to their defaults

func (*Line) CheckIfChanges

func (ln *Line) CheckIfChanges(functions mee.Functions)

CheckIfChanges checks whether the line will be changed over time

func (*Line) SetFunction

func (ln *Line) SetFunction(k int, functions mee.Functions) mee.Functions

SetFunction sets the function name for a line and adds functions to reference to the function

func (*Line) SetLineParams

func (ln *Line) SetLineParams(x, t float64, h int)

SetLineParams sets x, t, a, and h for a line

type Lines

type Lines []*Line

Lines contains multiple lines

type Marble

type Marble struct {
	*svg.Circle
	Pos          Vec2
	Vel          Vec2
	PrvPos       Vec2
	TrackingInfo TrackingInfo
}

Marble contains the phyiscal marble, and its data

func (*Marble) Init

func (m *Marble) Init(wo WorldOptions, diff float64)

Init initizlies a marble

type Marbles

type Marbles []*Marble

Marbles contains multiple marbles

type TrackingInfo

type TrackingInfo struct {
	Track                 bool
	FramesSinceLastUpdate int
	PositionAtLastUpdate  Vec2
}

TrackingInfo contains the tracking info for a single marble

type Vec2

type Vec2 struct {
	X float64
	Y float64
}

Vec2 is a vector with x and y

type World

type World struct {
	*svg.SVG
	LinesSVG     *svg.Group
	MarblesSVG   *svg.Group
	TrackingSVG  *svg.Group
	AxesSVG      *svg.Group
	Lines        Lines
	Marbles      Marbles
	WorldOptions WorldOptions
	Functions    mee.Functions
	Time         float64
	Running      bool
	Error        error
}

World contains the physical svg and its groups, and the data for the lines and the marbles

func NewWorld

func NewWorld(parent ki.Ki, name string, width, height int) *World

NewWorld makes a new world and returns it

func (*World) CompileLines

func (wd *World) CompileLines()

CompileLines compiles all of the expressions in the lines and does other necessary steps needed before graphing

func (*World) Graph

func (wd *World) Graph()

Graph compiles all of the lines, graphs all of the lines of the world and resets the marbles to their starting positions

func (*World) GraphLines

func (wd *World) GraphLines()

GraphLines graphs all of the lines of the world

func (*World) HandleError

func (wd *World) HandleError(err error) bool

HandleError checks if there is an error. If there is it returns true and sets the world error to the error. Otherwise returns false

func (*World) NewLine

func (wd *World) NewLine(expr string, graphIf string, bounce string) *Line

NewLine adds a new line to the world and returns it

func (*World) ResetMarbles

func (wd *World) ResetMarbles()

ResetMarbles deletes any existing marbles and makes and graphs new ones

func (*World) Run

func (wd *World) Run()

Run runs the marbles

func (*World) Stop

func (wd *World) Stop()

Stop stops the marbles

func (*World) UpdateMarbles

func (wd *World) UpdateMarbles()

UpdateMarbles updates the marbles

type WorldOptions

type WorldOptions struct {
	NMarbles       int
	Width          float64
	StartSpeed     float64
	MarbleStartPos Vec2
	MinSize        Vec2
	MaxSize        Vec2
	GraphTimesPerX int
}

WorldOptions contains the options for the world

func (*WorldOptions) Defaults

func (wo *WorldOptions) Defaults()

Defaults sets the defaults for the world options

Jump to

Keyboard shortcuts

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