Aego Русский

Curves in scripts

A script reads a curve field of a component and evaluates it with aego/curve:

import "aego/curve"

func Update(dt float) {
  age += dt
  fade := node.Get<Fader>().Alpha
  sr.Tint.A = curve.Eval(fade, age / curve.Duration(fade))
}
Function
Eval(c, t) float the value at t, wrapped by Before and After
EvalClamped(c, t) float the value at t clamped to the first and last key
Duration(c) float time from the first to the last key, 1 for a preset
Ease(e, t) float a preset easing at t clamped to 0..1

The constants curve.Linear, curve.OutQuad and the rest have the type curve.Easing and are the ease argument of tweens.

A Curve value is a read-only view of the field, not a copy: it sees edits made after it was read. Scripts cannot build curves or export curve fields. A view whose node or component is gone faults with AES6004.