fx

package
v0.0.0-...-20810c9 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Age in seconds
	Age = NewAttribute(1)
	// Total lifespan in seconds
	Lifespan = NewAttribute(1)

	// A value that can be randomly generated and used in initializers and modifiers.
	// Useful for generating particles on a shape with a velocity relative to the shape.
	Seed = NewAttribute(1)

	// A 2d position
	Pos2 = NewAttribute(2)
	// A 2d velocity
	Vel2 = NewAttribute(2)
	// A dampening of 2d velocity
	Vel2Dampen = NewAttribute(1)
	// A 2d acceleration
	Acc2 = NewAttribute(2)
	// A dampening of 2d acceleration
	Acc2Dampen = NewAttribute(1)

	// A 3d position
	Pos3 = NewAttribute(3)
	// A 3d velocity
	Vel3 = NewAttribute(3)
	// A dampening of 3d velocity
	Vel3Dampen = NewAttribute(1)
	// A 3d acceleration
	Acc3 = NewAttribute(3)
	// A dampening of 3d acceleration
	Acc3Dampen = NewAttribute(1)

	// A uniform size (same width & height)
	Size = NewAttribute(1)
	// A uniform size velocity
	SizeVel = NewAttribute(1)
	// A dampening of uniform size velocity
	SizeVelDampen = NewAttribute(1)
	// A uniform size acceleration
	SizeAcc = NewAttribute(1)

	// A width & height
	Size2 = NewAttribute(2)
	// A width & height velocity
	SizeVel2 = NewAttribute(2)
	// A dampening of width & height velocity
	SizeVel2Dampen = NewAttribute(2)
	// A width & height acceleration
	SizeAcc2 = NewAttribute(2)

	// A uniform scale (both width & height)
	Scale = NewAttribute(1)
	// A uniform scale velocity
	ScaleVel = NewAttribute(1)
	// A dampening of uniform scale velocity
	ScaleVelDampen = NewAttribute(1)
	// A uniform scale acceleration
	ScaleAcc = NewAttribute(1)

	// A 2d scale
	Scale2 = NewAttribute(2)
	// A 2d scale velocity
	ScaleVel2 = NewAttribute(2)
	// A dampening of 2d scale velocity
	ScaleVel2Dampen = NewAttribute(1)
	// A 2d scale acceleration
	ScaleAcc2 = NewAttribute(2)

	// An angle/rotation in radians
	Angle = NewAttribute(1)
	// Angular velocity
	AngleVel = NewAttribute(1)
	// A dampening of angular velocity
	AngleVelDampen = NewAttribute(1)
	// Angular acceleration
	AngleAcc = NewAttribute(1)

	// Rotation anchor, {0,0}=top left, {1,1}=bottom right, {.5,.5}=center
	Anchor = NewAttribute(2)

	// An RGB color
	Shade = NewAttribute(3)
	// An RGBA color
	Color = NewAttribute(4)
	// The alpha
	Alpha = NewAttribute(1)

	// Which texture defined in the system format to use.
	Texture = NewAttribute(1)
)

Functions

func Add

func Add(out, add []float32)

func Length

func Length(out []float32) float32

func LengthSq

func LengthSq(out []float32) float32

func Lerp

func Lerp(start, end []float32, delta float32, out []float32)

func Life

func Life(particle []float32, format *Format) float32

func MultiplyScalar

func MultiplyScalar(out []float32, scalar float32)

Types

type Access

type Access interface {
	Get(particle []float32, format *Format) []float32
}

type AccessConstant

type AccessConstant struct {
	Constant []float32
}

func (AccessConstant) Get

func (a AccessConstant) Get(particle []float32, format *Format) []float32

type AccessData

type AccessData struct {
	Offset int
	Size   int
}

func (AccessData) Get

func (a AccessData) Get(particle []float32, format *Format) []float32

type AccessDynamic

type AccessDynamic struct {
	Dynamic Dynamic
}

func (AccessDynamic) Get

func (a AccessDynamic) Get(particle []float32, format *Format) []float32

type AccessLerp

type AccessLerp struct {
	Data   [][]float32
	Easing ease.Easing
	// contains filtered or unexported fields
}

func (AccessLerp) Get

func (a AccessLerp) Get(particle []float32, format *Format) []float32

type Attribute

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

func NewAttribute

func NewAttribute(size int) Attribute

func (Attribute) GetInit

func (a Attribute) GetInit() Init

func (Attribute) GetModify

func (a Attribute) GetModify() Modify

func (Attribute) ID

func (a Attribute) ID() int

func (Attribute) Init

func (a Attribute) Init(init Init) Attribute

func (Attribute) Modify

func (a Attribute) Modify(modify Modify) Attribute

func (Attribute) Size

func (a Attribute) Size() int

type AttributeFormat

type AttributeFormat struct {
	Access    Access
	Attribute Attribute
}

type BurstEmitter

type BurstEmitter struct {
	Delay     float32
	Frequency Range[float32]
	Size      Range[int]
	Count     int

	Time   float32
	Next   float32
	Bursts int
}

func (BurstEmitter) Done

func (e BurstEmitter) Done() bool

func (BurstEmitter) Started

func (e BurstEmitter) Started() bool

func (*BurstEmitter) Update

func (e *BurstEmitter) Update(dt float32, rnd *rand.Rand) (size int, over float32)

type BurstEmitterType

type BurstEmitterType struct {
	Delay     Range[float32]
	Frequency Range[float32]
	Size      Range[int]
	Count     Range[int]
}

func (BurstEmitterType) Create

func (et BurstEmitterType) Create(rnd *rand.Rand) BurstEmitter

type Data

type Data struct {
	Format *Format
	Data   []float32
	Count  int
	// contains filtered or unexported fields
}

func NewData

func NewData(format *Format, capacity int) Data

func (Data) At

func (pd Data) At(index int) []float32

func (Data) Available

func (pd Data) Available() int

func (Data) Capacity

func (pd Data) Capacity() int

func (Data) Get

func (pd Data) Get(index int, attr Attribute) []float32

func (Data) Location

func (pd Data) Location(index int) int

func (Data) Move

func (pd Data) Move(from, to int)

func (Data) Swap

func (pd Data) Swap(i, j int)

type Dynamic

type Dynamic func(particle []float32, format *Format) []float32

type Emitter

type Emitter interface {
	Update(dt float32, rnd *rand.Rand) (size int, over float32)
	Done() bool
}

type EmitterType

type EmitterType interface {
	Create() Emitter
}

type Format

type Format struct {
	Size       int
	Attributes []AttributeFormat
}

func NewFormat

func NewFormat() *Format

func (Format) Access

func (pf Format) Access(attr Attribute) Access

func (*Format) Add

func (pf *Format) Add(attr AttributeFormat) *Format

func (*Format) AddConstant

func (pf *Format) AddConstant(attr Attribute, constant ...float32) *Format

func (*Format) AddData

func (pf *Format) AddData(attr Attribute) *Format

func (*Format) AddDynamic

func (pf *Format) AddDynamic(attr Attribute, dynamic Dynamic) *Format

func (*Format) AddLerp

func (pf *Format) AddLerp(attr Attribute, data [][]float32, easing ease.Easing) *Format

func (*Format) Get

func (pf *Format) Get(attr Attribute, particle []float32) []float32

func (*Format) HasData

func (pf *Format) HasData(attr Attribute) bool

type Init

type Init interface {
	Init(particle []float32, format *Format)
	Inits(attr Attribute) bool
}

type InitConstant

type InitConstant struct {
	Attribute Attribute
	Constant  []float32
}

func (InitConstant) Init

func (i InitConstant) Init(particle []float32, format *Format)

func (InitConstant) Inits

func (i InitConstant) Inits(attr Attribute) bool

type InitDynamic

type InitDynamic struct {
	Attribute Attribute
	Dynamic   Dynamic
}

func (InitDynamic) Init

func (i InitDynamic) Init(particle []float32, format *Format)

func (InitDynamic) Inits

func (i InitDynamic) Inits(attr Attribute) bool

type InitList

type InitList struct {
	List []Init
}

func (InitList) Init

func (i InitList) Init(particle []float32, format *Format)

func (InitList) Inits

func (i InitList) Inits(attr Attribute) bool

type InitNone

type InitNone struct{}

func (InitNone) Init

func (i InitNone) Init(particle []float32, format *Format)

func (InitNone) Inits

func (i InitNone) Inits(attr Attribute) bool

type InitRandom

type InitRandom struct {
	Attribute Attribute
	Start     []float32
	End       []float32
}

func (InitRandom) Init

func (i InitRandom) Init(particle []float32, format *Format)

func (InitRandom) Inits

func (i InitRandom) Inits(attr Attribute) bool

type Inits

type Inits []Init

func (Inits) Add

func (i Inits) Add(init Init) Inits

func (Inits) Constant

func (i Inits) Constant(attr Attribute, constant ...float32) Inits

func (Inits) Dynamic

func (i Inits) Dynamic(attr Attribute, dynamic Dynamic) Inits

func (Inits) Random

func (i Inits) Random(attr Attribute, start, end []float32) Inits

type Modify

type Modify interface {
	Modify(particle []float32, format *Format, dt float32)
	Modifies(attr Attribute) bool
}

type ModifyAdder

type ModifyAdder struct {
	Value Attribute
	Add   Attribute
}

func (ModifyAdder) Modifies

func (m ModifyAdder) Modifies(attr Attribute) bool

func (ModifyAdder) Modify

func (m ModifyAdder) Modify(particle []float32, format *Format, dt float32)

type ModifyAge

type ModifyAge struct {
	Age Attribute
}

func (ModifyAge) Modifies

func (m ModifyAge) Modifies(attr Attribute) bool

func (ModifyAge) Modify

func (m ModifyAge) Modify(particle []float32, format *Format, dt float32)

type ModifyLength

type ModifyLength struct {
	Value Attribute
	Add   Attribute
}

func (ModifyLength) Modifies

func (m ModifyLength) Modifies(attr Attribute) bool

func (ModifyLength) Modify

func (m ModifyLength) Modify(particle []float32, format *Format, dt float32)

type ModifyList

type ModifyList struct {
	List []Modify
}

func (ModifyList) Modifies

func (m ModifyList) Modifies(attr Attribute) bool

func (ModifyList) Modify

func (m ModifyList) Modify(particle []float32, format *Format, dt float32)

type ModifyNone

type ModifyNone struct{}

func (ModifyNone) Modifies

func (m ModifyNone) Modifies(attr Attribute) bool

func (ModifyNone) Modify

func (m ModifyNone) Modify(particle []float32, format *Format, dt float32)

type ModifyScalar

type ModifyScalar struct {
	Value  Attribute
	Scalar Attribute
}

func (ModifyScalar) Modifies

func (m ModifyScalar) Modifies(attr Attribute) bool

func (ModifyScalar) Modify

func (m ModifyScalar) Modify(particle []float32, format *Format, dt float32)

type Modifys

type Modifys []Modify

func (Modifys) Add

func (m Modifys) Add(mod Modify) Modifys

func (Modifys) Adder

func (m Modifys) Adder(attr Attribute, add Attribute) Modifys

func (Modifys) Age

func (m Modifys) Age(attr Attribute) Modifys

func (Modifys) Length

func (m Modifys) Length(attr Attribute, add Attribute) Modifys

func (Modifys) Scalar

func (m Modifys) Scalar(attr Attribute, scalar Attribute) Modifys

type Number

type Number interface {
	constraints.Integer | constraints.Float
}

type Particle2

type Particle2 struct {
	Position Point2
	Anchor   Point2
	Size     Point2
	Scale    Point2
	Angle    float32
	Tile     gfx.Tile
}

func (*Particle2) Init

func (p *Particle2) Init()

type Particle3

type Particle3 struct {
	Position Point3
	Up       Point3
	Right    Point3
	Anchor   Point2
	Size     Point2
	Scale    Point2
	Angle    float32
	Tile     gfx.Tile
}

func (*Particle3) Init

func (p *Particle3) Init()

type ParticleRenderer

type ParticleRenderer[P any] func(*P)

type Point2

type Point2 struct {
	X, Y float32
}

type Point3

type Point3 struct {
	X, Y, Z float32
}

type Range

type Range[V Number] struct {
	Min, Max V
}

func NewRange

func NewRange[V Number](min, maxExclusive V) Range[V]

func NewSingle

func NewSingle[V Number](value V) Range[V]

func (Range[V]) Get

func (r Range[V]) Get(rnd *rand.Rand) V

type Renderer

type Renderer interface {
	CreateBuffer(maxParticles int) *gfx.Buffer
	Render()
}

type System

type System struct {
	Type    *SystemType
	Random  *rand.Rand
	Data    Data
	Emitter Emitter
	Buffer  *gfx.Buffer
}

func (*System) Done

func (s *System) Done() bool

func (*System) Emit

func (s *System) Emit(update float32)

func (*System) InitAt

func (s *System) InitAt(i int)

func (*System) Render

func (s *System) Render()

func (*System) Update

func (s *System) Update(dt float32)

func (*System) UpdateAt

func (s *System) UpdateAt(i int, dt float32) bool

type SystemType

type SystemType struct {
	Format       *Format
	Initializers Inits
	Initializer  Init
	Modifiers    Modifys
	Modifier     Modify
	Emitter      EmitterType
	Random       *rand.Rand
	Renderer     Renderer
	MaxParticles int
	Trail        bool
	Spread       bool
	Ordered      bool
}

func (*SystemType) Create

func (st *SystemType) Create() System

func (*SystemType) GetInitializer

func (st *SystemType) GetInitializer() Init

func (*SystemType) GetModifier

func (st *SystemType) GetModifier() Modify

func (SystemType) Init

func (st SystemType) Init(particle []float32, format *Format)

func (SystemType) Inits

func (st SystemType) Inits(attr Attribute) bool

func (SystemType) Modifies

func (st SystemType) Modifies(attr Attribute) bool

func (SystemType) Modify

func (st SystemType) Modify(particle []float32, format *Format, dt float32)

func (*SystemType) Setup

func (st *SystemType) Setup()

type Vertex

type Vertex struct {
	X, Y, Z      float32
	TextureCoord gfx.TextureCoord
	Color        color.Color
}

Jump to

Keyboard shortcuts

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