field

package
v0.0.0-...-dd13743 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BodyStats

type BodyStats struct {
	Position     vect.Vect
	Velocity     vect.Vect
	Acceleration vect.Vect
}

BodyStats holds statistics for a body on the field

type Field

type Field struct {
	ShowTrails bool
	ViewFinder *viewfinder.ViewFinder
	// contains filtered or unexported fields
}

Field represents a gravity simulation field

func New

func New(name string, x, y float64) *Field

New creates a gravity simulation field

func (*Field) Add

func (f *Field) Add(position vect.Vect, r float32, m vect.Float, velocity vect.Vect, color color.Color, manual bool)

Add adds a new body to the field

func (*Field) ClearObjects

func (f *Field) ClearObjects()

ClearObjects removes all manually added bodies from the field

func (Field) Draw

func (f Field) Draw(win pixel.Target)

Draw draws the bodies on the specified Target

func (*Field) MakeCanvas

func (f *Field) MakeCanvas()

MakeCanvas creates a pixelgl canvas on which to draw the field

func (Field) Stats

func (f Field) Stats() (output []BodyStats)

Stats generates BodyStats for each body on the field

func (*Field) Step

func (f *Field) Step()

Step performs one step of the simulation

func (*Field) Steps

func (f *Field) Steps(n int)

Steps performs a number of steps of the simulation

func (*Field) ToggleShowTrails

func (f *Field) ToggleShowTrails()

ToggleShowTrails toggles the ShowTrails setting

Jump to

Keyboard shortcuts

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