components

package
v0.0.0-...-a545287 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const BOTTOM float64 = 90
View Source
const BOTTOM_LEFT float64 = 135
View Source
const BOTTOM_RIGHT float64 = 45
View Source
const LEFT float64 = 180
View Source
const RIGHT float64 = 0
View Source
const TOP float64 = 270
View Source
const TOP_LEFT float64 = 225
View Source
const TOP_RIGHT float64 = 315

Variables

View Source
var ColorBlack color.Color = color.RGBA{R: 0x00, G: 0x00, B: 0x00, A: 0xff}
View Source
var ColorBlue color.Color = color.RGBA{R: 0x00, G: 0x00, B: 0xff, A: 0xff}
View Source
var ColorGreen color.Color = color.RGBA{R: 0x00, G: 0xff, B: 0x00, A: 0xff}
View Source
var ColorRed color.Color = color.RGBA{R: 0xff, G: 0x00, B: 0x00, A: 0xff}
View Source
var ColorViolet color.Color = color.RGBA{R: 0xff, G: 0x00, B: 0xff, A: 0xff}
View Source
var ColorWhite color.Color = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
View Source
var ColorYellow color.Color = color.RGBA{R: 0xff, G: 0xff, B: 0x00, A: 0xff}
View Source
var ImagesSuffixes = []string{".jpg", ".png", ".gif"}
View Source
var None = Origin
View Source
var Origin = Point{}
View Source
var Random = rand.New(randomSource)

Functions

func DegToRad

func DegToRad(x float64) float64

func DirectionToFloatingPoint

func DirectionToFloatingPoint(direction float64) FloatingPoint

Cartesian coordinates from angle (degrees)

func Float64Between

func Float64Between(low, high float64) float64

func FloatingPointToDirection

func FloatingPointToDirection(point FloatingPoint) float64

Angle (degrees) from cartesian coordinates

func HsvToRgb

func HsvToRgb(hue, saturation, value float64) (r, g, b int)

0 ≤ hue < 360, 0 ≤ saturation ≤ 1 and 0 ≤ value ≤ 1

func Int64Between

func Int64Between(low, high int64) int64

func OneOrMinusOne

func OneOrMinusOne() float64

func RadToDeg

func RadToDeg(x float64) float64

func RandomFile

func RandomFile(dir string, suffixes []string) (*string, error)

func ReadBeanGif

func ReadBeanGif() (*[]image.Image, *[]time.Duration, *image.Rectangle)

func ReadGif

func ReadGif(imgPath *string, targetSize Point) (*[]image.Image, *[]time.Duration, *image.Rectangle)

func ReadJpg

func ReadJpg(imgPath *string) *image.Image

func ReadPng

func ReadPng(imgPath *string) *image.Image

func Rotate

func Rotate(p, o Point, degrees float64) Point

func RotateOrigin

func RotateOrigin(fp FloatingPoint, degrees float64) FloatingPoint

func TimeToText

func TimeToText(t time.Time) string

Types

type Acceleration

type Acceleration interface {
	// Returns (dVx, dVy) in Pixels per second
	NextVelocityDelta(dtInSeconds float64) FloatingPoint
	// Direction in Degrees, reference is RIGHT
	Direction() float64
}
var Gravity Acceleration = ConstantAcceleration{/* contains filtered or unexported fields */}

type Component

type Component interface {
	Updatable
	Drawable
}

type CompositeDrawable

type CompositeDrawable struct {
	Graphic   *Graphic
	Drawables []*disablableDrawable
}

func NewCompositeDrawable

func NewCompositeDrawable(graphic *Graphic) *CompositeDrawable

func (*CompositeDrawable) AddDrawable

func (cd *CompositeDrawable) AddDrawable(drawable Drawable)

func (*CompositeDrawable) AddDrawables

func (cd *CompositeDrawable) AddDrawables(drawables ...Drawable)

func (*CompositeDrawable) DisableDrawable

func (cd *CompositeDrawable) DisableDrawable(drawable Drawable)

func (*CompositeDrawable) Draw

func (cd *CompositeDrawable) Draw(canvas canvas.Canvas) error

func (*CompositeDrawable) EnableDrawable

func (cd *CompositeDrawable) EnableDrawable(drawable Drawable)

func (*CompositeDrawable) RemoveDrawable

func (cd *CompositeDrawable) RemoveDrawable(d Drawable)

type ConstantAcceleration

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

func NewConstantAcceleration

func NewConstantAcceleration(acceleration, direction float64) *ConstantAcceleration

func (ConstantAcceleration) Direction

func (a ConstantAcceleration) Direction() float64

func (ConstantAcceleration) NextVelocityDelta

func (a ConstantAcceleration) NextVelocityDelta(dtInSeconds float64) FloatingPoint

func (ConstantAcceleration) SetAcceleration

func (a ConstantAcceleration) SetAcceleration(acceleration float64)

func (ConstantAcceleration) SetDirection

func (a ConstantAcceleration) SetDirection(direction float64)

type Drawable

type Drawable interface {
	Draw(canvas Canvas) error
}

func MaskDrawable

func MaskDrawable(mask effect.Effect, drawable Drawable) Drawable

type Graphic

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

func NewGraphic

func NewGraphic(parent *Graphic, layout *Layout) *Graphic

func NewOffsetGraphic

func NewOffsetGraphic(parent *Graphic, layout *Layout, offset Point) *Graphic

func (*Graphic) ComputedOffset

func (g *Graphic) ComputedOffset() Point

func (*Graphic) Layout

func (g *Graphic) Layout() *Layout

func (*Graphic) SetOffset

func (g *Graphic) SetOffset(offset Point)

type Layout

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

func DefaultLayout

func DefaultLayout() *Layout

func NewLayout

func NewLayout(fColor, bgColor color.Color) *Layout

func (*Layout) BackgroundColor

func (l *Layout) BackgroundColor() color.Color

func (*Layout) Color

func (l *Layout) Color() color.Color

func (*Layout) SetColor

func (l *Layout) SetColor(color color.Color)

type MaskedDrawable

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

func (MaskedDrawable) Draw

func (md MaskedDrawable) Draw(canvas Canvas) error

override Drawable.Draw method to perform indirection with effect

type Movement

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

func NewBoundedMovement

func NewBoundedMovement(initialPosition, initialVelocity FloatingPoint, accelerations *[]Acceleration, bounds *image.Rectangle) *Movement

func NewMovement

func NewMovement(initialPosition, initialVelocity FloatingPoint, accelerations *[]Acceleration) *Movement

func (*Movement) NextPosition

func (m *Movement) NextPosition(duration time.Duration) (FloatingPoint, FloatingPoint)

TODO: consider max values for accelerations Return the next position to use

func (*Movement) SetVelocity

func (m *Movement) SetVelocity(velocity FloatingPoint)

func (*Movement) Velocity

func (m *Movement) Velocity() FloatingPoint

type Physics

type Physics interface {
	// Compute and return the next position and velocity
	NextPosition(dt time.Duration) (FloatingPoint, FloatingPoint)
}

type Updatable

type Updatable interface {
	// Update is called at its own rate to avoid depending on rendering time,
	// thus we can compute speed depending on this constant rate
	Update(elapsedBetweenUpdate time.Duration) bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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