clock

package
v0.0.0-...-fd9d235 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package clock provides a clock and time functions for a sprite engine.

Index

Constants

This section is empty.

Variables

View Source
var (
	EaseIn    = CubicBezier(0.42, 0, 1, 1)
	EaseOut   = CubicBezier(0, 0, 0.58, 1)
	EaseInOut = CubicBezier(0.42, 0, 0.58, 1)
)

Standard tween functions.

Easing means a slowing near the timing boundary, as defined by a cubic bezier curve. Exact parameters match the CSS properties.

Functions

func CubicBezier

func CubicBezier(x0, y0, x1, y1 float32) func(t0, t1, t Time) float32

CubicBezier generates a tween function determined by a Cubic Bézier curve.

The parameters are cubic control parameters. The curve starts at (0,0) going toward (x0,y0), and arrives at (1,1) coming from (x1,y1).

func Linear

func Linear(t0, t1, t Time) float32

Linear computes the fraction [0,1] that t lies between [t0,t1].

Types

type Time

type Time int32

A Time represents an instant in sprite time.

The application using the sprite engine is responsible for determining sprite time.

Typically time 0 is when the app is initialized and time is quantized at the intended frame rate. For example, an app may record wall time when it is initialized

var start = time.Now()

and then compute the current instant in time for 60 FPS:

now := clock.Time(time.Since(start) * 60 / time.Second)

An application can pause or reset sprite time, but it must be aware of any stateful sprite.Arranger instances that expect time to continue.

Jump to

Keyboard shortcuts

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