particles

package
v0.0.0-...-0c3320d Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{2.0, 80.0, 1.8, "#ccccFF", true, true, true}

DefaultConfig is a default value for config

Functions

This section is empty.

Types

type Config

type Config struct {
	Speed  float64
	Area   float64
	Size   float64
	Color  string
	Bounds bool
	Bounce bool
	Move   bool
}

Config contains data for particles configuration

type Group

type Group struct {
	Max       int
	Width     int
	Height    int
	Particles Particles
}

Group represents multiple particles

func NewGroup

func NewGroup(width, height, max int, config Config) (group *Group)

NewGroup initializes a new group of particles

func (*Group) Move

func (g *Group) Move()

Move moves particles

type Particle

type Particle struct {
	Config
	ID        int
	Position  Vector
	Direction Vector
}

Particle represents a single particle

func NewParticle

func NewParticle(id int, config Config) *Particle

NewParticle initializes a new particle

func (*Particle) Bounce

func (p *Particle) Bounce(maxx, maxy float64)

Bounce bounces a particle

func (*Particle) Bounds

func (p *Particle) Bounds(maxx, maxy float64)

Bounds checks if a particle is within bounds

func (*Particle) Distance

func (p *Particle) Distance(pa *Particle) float64

Distance returns the distance between two particles

func (*Particle) Move

func (p *Particle) Move()

Move moves a particle

func (*Particle) RandomizePosition

func (p *Particle) RandomizePosition(width, height int)

RandomizePosition sets a random (within a given range) position for the particle

func (*Particle) Reverse

func (p *Particle) Reverse()

Reverse makes particles go the other way

func (*Particle) ReverseX

func (p *Particle) ReverseX()

ReverseX makes particles go the other way

func (*Particle) ReverseY

func (p *Particle) ReverseY()

ReverseY makes particles go the other way

type Particles

type Particles []*Particle

Particles is a list of particles

type Vector

type Vector [2]float64

func (Vector) Distance

func (v Vector) Distance(v2 Vector) float64

Distance returns a distance between two vectors

Jump to

Keyboard shortcuts

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