fluid

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT, MIT Imports: 6 Imported by: 0

README

fluid

Package fluid is a viscoelastic fluid simulator ported from kotsoft/particle_based_viscoelastic_fluid. Out of fear of making a mistake, I made no effort to translate the original JavaScript into idiomatic Go.

Documentation

Index

Constants

View Source
const (
	FLUID_PADDING = 1.5
)
View Source
const (
	POSITION_FACTOR = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Fluid added in v1.3.0

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

func NewAnimation added in v1.11.0

func NewAnimation(options ...Option) *Fluid

func (*Fluid) Init added in v1.3.0

func (f *Fluid) Init(start image.Image)

func (*Fluid) Update added in v1.3.0

func (f *Fluid) Update(delta time.Duration) image.Image

type Material

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

func NewMaterial

func NewMaterial(
	name string,
	restDensity, stiffness, nearStiffness, kernelRadius number,
) Material

type Option added in v1.11.0

type Option func(*Simulator)

Option configures a Simulator.

func WithDrain added in v1.11.0

func WithDrain() Option

WithDrain adds a hole in the bottom and top boundaries at random X positions. Particles that fall through the bottom hole wrap to the top.

type Particle

type Particle struct {
	X number
	Y number
	// contains filtered or unexported fields
}

func NewParticle

func NewParticle(posX, posY, velX, velY number) Particle

type Simulator

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

func New

func New(
	width, height number,
	particles []Particle,
	options ...Option,
) *Simulator

func (*Simulator) Particles

func (s *Simulator) Particles() []Particle

func (*Simulator) Update

func (s *Simulator) Update(dt float64)

Jump to

Keyboard shortcuts

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