pixelutils

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: MIT Imports: 6 Imported by: 1

README

pixelutils

A collection of random things I think could be useful for those using the Pixel library.

Available Tools

Check out the wiki to see how to use these tools.

  • Sprite Packer: Runtime packer based on rectpack2D.
  • ID Generator: Thread safe integer ID generator.
  • Ticker: My attempt for an easy-to-use framerate limiter.
  • Sprite Loader: A simple sprite/picture data loader based on the Pixel example.
  • Voronoi Diagrams: A pixel-compatible interface built on Voronoi Diagrams.

Planned

Contribution

Feel free to add any tools that you've created for Pixel, I just ask that they're documented well and an usage wiki entry is added.

Documentation

Index

Constants

View Source
const (
	MAX_PREV_FPS = 500
)

Variables

This section is empty.

Functions

func LoadPictureData

func LoadPictureData(path string) (data *pixel.PictureData, err error)

Helper to load a sprite from a file and make Pixel.PictureData from it

func LoadSprite

func LoadSprite(path string) (sprite *pixel.Sprite, err error)

Helper to load a sprite from file and make a Pixel.Sprite from it

Types

type IDGen

type IDGen struct {
	sync.Mutex
	// contains filtered or unexported fields
}

IDGen is a simple, thread safe, integer id generator

func (*IDGen) Gen

func (gen *IDGen) Gen() (id int)

Gen generates the next id and returns it

type Ticker

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

func NewTicker

func NewTicker(targetFPS int64) *Ticker

NewTicker returns a new ticker with the given target fps and 500 stored previous framerates.

func NewTickerV

func NewTickerV(targetFPS, maxPrevFPS int64) *Ticker

NewTickerV returns a new ticker with the given target fps and a custom amount of stored previous framerates.

If maxPrevFPS is <= 0, don't store any previous framerates.

func (Ticker) AvgFramerate

func (ticker Ticker) AvgFramerate() float64

Return the average framerate

func (Ticker) Deltat

func (ticker Ticker) Deltat() float64

Return the last Deltat

func (Ticker) Framerate

func (ticker Ticker) Framerate() float64

Return the last framerate

func (Ticker) PrevFramerates

func (ticker Ticker) PrevFramerates() []float32

Return the list of previous framerates

func (*Ticker) Reset

func (ticker *Ticker) Reset()

Reset the ticker

func (*Ticker) SetTargetFPS

func (ticker *Ticker) SetTargetFPS(target int64)

SetTargetFPS sets the target ticker rate; will be less than or equal to target.

func (Ticker) TargetFrametime

func (ticker Ticker) TargetFrametime() time.Duration

Return the current target frametime

func (*Ticker) Tick

func (ticker *Ticker) Tick() (deltat, framerate float64)

Tick ticks the tickers and calculates the framerate and framedelta

func (*Ticker) Wait

func (ticker *Ticker) Wait()

Wait for the timer to complete its timeout

type Voronoi

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

func NewVoronoi

func NewVoronoi() (v *Voronoi)

Creates and returns a new pixel-compatible Voronoi

func (*Voronoi) Compute

func (v *Voronoi) Compute(boundingBox pixel.Rect, closeCells bool) VoronoiCellMap

Computes the voronoi diagram, constrained by the given bounding box, from the nodes inserted into the list

If closeCells == true, edges from bounding box will be included in the diagram.

func (*Voronoi) Insert

func (v *Voronoi) Insert(id interface{}, pos pixel.Vec)

Inserts the vector into the voronoi list with the given identifier

type VoronoiCell

type VoronoiCell struct {
	ID        interface{}
	Site      pixel.Vec
	Halfedges []pixel.Line
}

type VoronoiCellMap

type VoronoiCellMap map[interface{}]VoronoiCell

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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