common

package
v0.0.0-...-17ca05c Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyBool

func CopyBool(b *bool) *bool

CopyBool returns a deep copy of a *bool if its not nil Used by the Copy functions of palette providers

func CopyColor

func CopyColor(c color.Color) color.Color

CopyColor returns a deep copy of an color.Color if its not nil Used by the Copy functions of palette providers

func CopyDuration

func CopyDuration(d *time.Duration) *time.Duration

CopyDuration returns a deep copy of a *time.Duration if its not nil Used by the Copy functions of palette providers

func CopyFloat64

func CopyFloat64(f *float64) *float64

CopyFloat64 returns a deep copy of a *float64 if its not nil Used by the Copy functions of palette providers

func CopyTime

func CopyTime(t *time.Time) *time.Time

CopyTime returns a deep copy of a *time.Time if its not nil Used by the Copy functions of palette providers

Types

type Bender

type Bender interface {
	Stabilizer

	// Bend returns a value based on f
	Bend(f float64) float64

	// Copy returns a deep copy of the Bender
	Copy() Bender
}

Bender is used by Shifters to change small things over time

func CopyBender

func CopyBender(b Bender) Bender

CopyBender returns a deep copy of an Bender if its not nil Used by the Copy functions of palette providers

type Colorable

type Colorable interface {
	Colored

	// SetColor changes the color of the light
	SetColor(newColor color.Color)
}

Colorable is the interface to something which is colorable

type Colored

type Colored interface {
	// GetColor returns the color of the light
	GetColor() color.Color
}

Colored is the interface to something which is colored

type Device

type Device interface {
	// GetNodes returns all the Nodes which the device holds
	GetNodes() []Node
	// GetType returns the type
	GetType() string
	// GetID will return the ID of a device node.
	GetID() uuid.UUID

	// DispatchRender produces and dispatches Instructions
	DispatchRender(time.Time) error

	Moveable
}

Device represents a physical device with lights A device is made up of atleast a single Node

type Effect

type Effect interface {
	Spanner
	Stabilizer

	// Render will alter obj based on its information and alterability
	// obj is at least Renderable,
	// but can be any of the other interfaces in renderable.go
	Render(t time.Time, obj Renderable)
	// Priority solves rendering issues
	Priority() int

	// Set sets the start and end of a span from the provided span
	SetSpan(ss Spanner)

	// Copy returns a deep copy of a Effect
	Copy() Effect
}

Effect is a light abstraction representing patterns of colors

func CopyEffect

func CopyEffect(e Effect) Effect

CopyEffect returns a deep copy of an Effect if its not nil Used by the Copy functions of palette providers

type Indexed

type Indexed interface {
	// GetPosition returns the position and total
	// i.e. #3 of 10
	GetPosition() (int, int)
}

Indexed is the interface to something which is in an ordered set

type Locatable

type Locatable interface {

	// GetLocation returns the location of the object
	GetLocation() space.Vector
	// SetLocation changes the location of the object
	SetLocation(space.Vector)
}

Locatable is the interface to something which can be positioned in space

type Located

type Located interface {
	// GetLocation returns the location of the object
	GetLocation() space.Vector
}

Located is the interface to something which exists in space

type Moveable

type Moveable interface {
	// GetBearings returns all spacial properties of the device
	GetBearings() (location space.Vector, orientation space.Quaternion)
	// Move changes all properties of the device
	Move(location space.Vector, orientation space.Quaternion)
}

Moveable is the interface to something which is moveable in space (Should have no symmetry)

type Node

type Node interface {
	// Allocate passes Vibe into this device and its children
	// Allocate typically Stabilize the Vibe before passing it to children devices
	Allocate(Vibe)
	// Clean removes all stored resources which ended before a time
	Clean(time.Time)

	// GetChildren returns any children under the node
	GetChildren() []Node
	// Insert will insert a node underneath a parent node.
	Insert(parentID uuid.UUID, newNode Node) error
	// Delete will delete a node underneath a parent node.
	Delete(parentID, childID uuid.UUID) error

	// GetType returns the type
	GetType() string
	// GetID will return the ID of a device node.
	GetID() uuid.UUID
}

A Node is a node in the tree Nodes can reference an object which is also a Device or part of a Device Node can also be an abstraction which has a Device as a parent or child

type Orientable

type Orientable interface {
	Locatable

	// GetOrientation returns the Orientation of the object
	GetOrientation() space.Quaternion
	// SetOrientation changes the Orientation of the object
	SetOrientation(space.Quaternion)
}

Orientable is the interface to something which is orientable in space

type Oriented

type Oriented interface {
	Located

	// GetOrientation returns the Orientation of the object
	GetOrientation() space.Quaternion
}

Oriented is the interface to something which is oriented in space

type Painter

type Painter interface {
	Stabilizer

	// Paint returns a color based on t and obj
	// obj should be at least Renderable,
	// but can be any of the other interfaces specified in renderable.go
	Paint(t time.Time, obj Renderable)

	// Copy returns a deep copy of the Painter
	Copy() Painter
}

Painter is used by effects to select colors

func CopyPainter

func CopyPainter(p Painter) Painter

CopyPainter returns a deep copy of an Painter if its not nil Used by the Copy functions of palette providers

type Palette

type Palette interface {
	Seeder

	// SelectEffect returns a Effect
	SelectEffect() Effect
	// SelectPainter returns a Painter
	SelectPainter() Painter
	// SelectBender returns a Bender
	SelectBender() Bender
	// SelectShifter returns a Shifter
	SelectShifter() Shifter

	// SelectColor returns a Color
	SelectColor() color.Color
	// SelectDuration returns a Duration
	// Should generally range from 0.1s to 10s
	SelectDuration() time.Duration
	// SelectShift returns a Shift
	// Should generally range from .01 to 1
	SelectShift() float64
}

type Renderable

type Renderable interface {
	Tangible
	Colorable
}

type Seeder

type Seeder interface {
	// NextSeed returns an ever changing seed for repeatable randomization
	NextSeed() time.Time

	// Option will choose a option from a range
	// where the options is  [0, options)
	Option(options int) int

	// Chance will determine an outcome based on a percentage [0, 1]
	Chance(chance float64) bool

	// RandDuration will return a random duration [min, max]
	RandDuration(min, max time.Duration) time.Duration

	// RandShift provides a random shift [min, max] with granularity of unit
	RandShift(min, max, unit float64) float64
}

Seeder can produce changing seeds for repeatable randomization

type Shifter

type Shifter interface {
	Stabilizer

	// Shift returns a value representing some change or shift based on t and obj
	// obj should be at least Tangible,
	// but can be any of the other interfaces specified in renderable.go
	Shift(t time.Time, obj Tangible) float64

	// Copy returns a deep copy of the Shifter
	Copy() Shifter
}

Shifter is used by Painters to change small things over time

func CopyShifter

func CopyShifter(s Shifter) Shifter

CopyShifter returns a deep copy of an Shifter if its not nil Used by the Copy functions of palette providers

type Spanner

type Spanner interface {
	// Start returns the Start times
	Start() time.Time
	// SetStart sets the Start time
	SetStart(start time.Time)
	// End returns the End time
	End() time.Time
	// SetEnd sets the End time
	SetEnd(end time.Time)
}

Spanner is any object which has a beginning and end in time

type Stabilizer

type Stabilizer interface {
	// GetStabilizeFuncs returns a function for all remaining unstabilized traits
	GetStabilizeFuncs() []func(p Palette)
}

type Tangible

type Tangible interface {
	Indexed
	Orientable
}

type Vibe

type Vibe interface {
	Palette
	Stabilizer
	Spanner

	// Duplicate creates a copy of a vibe and insures that
	// the duplicated vibe will stabilize/materialize differently
	Duplicate() Vibe

	// Stabilize locks in part of the visual representation of a vibe.
	Stabilize() Vibe

	// Materialize locks all remaining unlocked visuals of a vibe
	// then returns the resulting effects
	Materialize() []Effect
}

Vibe is a heavy abstraction correlating to general feelings in music

Jump to

Keyboard shortcuts

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