potty

package
v0.0.0-...-80b3781 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

potty is a little pixel library and set of toilet effects for pixelslinger

Index

Constants

View Source
const (
	CSpeed    = 0.004 // How fast they go up
	CSpeedVar = 0.004 // Speed variation each time a circle starts over
	CLifeSpan = 0.75

	CircleButton = config.BLINK_CIRCLE_PAD
)
View Source
const (
	DrainingComplete = 4.0                             // seconds
	RefillStarting   = 8.0                             // seconds
	RefillComplete   = 16.0                            // seconds
	RefillDuration   = RefillComplete - RefillStarting // seconds

	// Size of falling water streams when draining
	FlushStreamerSize = 0.15

	FlushControlPad = config.FLUSH_PAD
)
View Source
const BSpeed = 0.008 // How fast they go up
View Source
const BSpeedVar = 0.004 // Speed variation each time a bubble starts over
View Source
const BSpread = 9 // How spread out the buubbles are (aka few can you see)

Variables

View Source
var (
	White = colorful.LinearRgb(1, 1, 1)
	Black = colorful.LinearRgb(0, 0, 0)
)
View Source
var (
	LightCyan  = colorful.LinearRgb(0.6, 0.7, 0.8)
	DarkCyan   = colorful.LinearRgb(0.1, 0.4, 0.8)
	Aquamarine = colorful.LinearRgb(0.1, 0.25, 0.75)
	Teal       = colorful.LinearRgb(0.4, 0.7, 0.55)
)
View Source
var RandGen = rand.New(rand.NewSource(9))

make persistant random values

Functions

func Clamp

func Clamp(s float64) float64

func ColorFromBytes

func ColorFromBytes(r, g, b byte) colorful.Color

func FloatToByte

func FloatToByte(x byte) float64

func MakeEffectFaderPattern

func MakeEffectFaderPattern(locations []float64) func(bytesIn chan []byte, bytesOut chan []byte, midiState *midi.MidiState)

func MakeWaterPattern

func MakeWaterPattern(locations []float64) func(bytesIn chan []byte, bytesOut chan []byte, midiState *midi.MidiState)

func NextColorPicker

func NextColorPicker() colorPicker

func RandBlue

func RandBlue() colorful.Color

func RandGreen

func RandGreen() colorful.Color

func RandRed

func RandRed() colorful.Color

func RandVal

func RandVal(low, high float64) float64

Types

type Bubble

type Bubble struct {
	Speed float64
	Z     float64
}

func NewBubble

func NewBubble() *Bubble

func (*Bubble) Move

func (b *Bubble) Move()

func (*Bubble) Strength

func (b *Bubble) Strength(pZ float64) float64

type BubbleEffect

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

func NewBubbleEffect

func NewBubbleEffect(space *PixelSpace) *BubbleEffect

func (*BubbleEffect) Render

func (b *BubbleEffect) Render(midiState *midi.MidiState, t float64)

type Circle

type Circle struct {
	Pixel
	Speed    float64
	Strength float64
	EndTime  float64
	Dead     bool
	// contains filtered or unexported fields
}

func NewCircle

func NewCircle(space *PixelSpace, t float64) *Circle

func (*Circle) Blend

func (c *Circle) Blend(pixel *Pixel) colorful.Color

func (*Circle) ID

func (c *Circle) ID() float64

func (*Circle) Move

func (c *Circle) Move(t float64)

type ColorDanceEffect

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

func NewColorDanceEffect

func NewColorDanceEffect(space *PixelSpace) *ColorDanceEffect

func (*ColorDanceEffect) Render

func (e *ColorDanceEffect) Render(midiState *midi.MidiState, t float64)

type FlushEffect

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

func NewFlushEffect

func NewFlushEffect(space *PixelSpace) *FlushEffect

func (*FlushEffect) Render

func (f *FlushEffect) Render(midiState *midi.MidiState, t float64)

func (*FlushEffect) SetFlushState

func (f *FlushEffect) SetFlushState(midiState *midi.MidiState, t float64)

type Pixel

type Pixel struct {
	Color colorful.Color

	X float64
	Y float64
	Z float64

	XFlat float64 // Y dimension flattened into X
}

func NewPixel

func NewPixel(x, y, z float64) *Pixel

func (*Pixel) ToBytes

func (p *Pixel) ToBytes() (r, g, b byte)

type PixelSpace

type PixelSpace struct {
	Pixels []*Pixel   // Pixels all in a row
	Strips [][]*Pixel // Same Pixels organized by strips

	Len int // Total number of pixels

	// Bounding Box
	MaxX float64
	MaxY float64
	MaxZ float64
	MinX float64
	MinY float64
	MinZ float64

	MaxXFlat float64
	MinXFlat float64
}

func NewPixelSpace

func NewPixelSpace(locations []float64) *PixelSpace

NewPixelSpace takes a slice of xyz coordinates and returns a slice of pixels in a bounding box.

func (*PixelSpace) NormalDistance

func (b *PixelSpace) NormalDistance(p1, p2 *Pixel) float64

Distance between two pixels in [0,1] space

func (*PixelSpace) RandomPixel

func (b *PixelSpace) RandomPixel() *Pixel

Z coord for pixel in [0,1] space

func (*PixelSpace) SetFromBytes

func (b *PixelSpace) SetFromBytes(bytes []byte)

func (*PixelSpace) ToBytes

func (b *PixelSpace) ToBytes(bytes []byte) []byte

ToBytes writes the Pixel to the output buffer

func (*PixelSpace) XFlatNormal

func (b *PixelSpace) XFlatNormal(pixel *Pixel) float64

XFlat coord for pixel in [0,1] space

func (*PixelSpace) XNormal

func (b *PixelSpace) XNormal(pixel *Pixel) float64

X coord for pixel in [0,1] space

func (*PixelSpace) ZNormal

func (b *PixelSpace) ZNormal(pixel *Pixel) float64

Z coord for pixel in [0,1] space

type Renderer

type Renderer interface {
	Render(midiState *midi.MidiState, t float64)
}

type WaterEffect

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

func NewWaterEffect

func NewWaterEffect(space *PixelSpace) *WaterEffect

func (*WaterEffect) Render

func (w *WaterEffect) Render(midiState *midi.MidiState, t float64)

Jump to

Keyboard shortcuts

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