package bogue

  1. Overview
  2. Docs

Animated variables

An Avar.t is a special case of dynamic variables Dynvar, where we know that the variable will be used (and thus, updated) at every iteration of the main loop.

Dependency graph

type 'a t
type direction =
  1. | No
  2. | Left
  3. | Right
  4. | Top
  5. | Bottom
  6. | TopLeft
  7. | TopRight
  8. | BottomLeft
  9. | BottomRight
  10. | Random
type callback = unit -> unit

Avar information

val progress : 'a t -> float

progress v is a float in 0,1 giving the percentage of the animation when the last v.value was computed. In case of infinite animation, this is just the elapsed Time (in ms).

Avar creation

val create : ?duration:Time.t -> ?init:callback -> ?ending:callback -> ?finished:bool -> ?update:('a t -> float -> 'a) -> 'a -> 'a t

Generic Avar creation. If finished = true, the var never gets updated, ie behaves like a normal Var. Otherwise, the update parameter is compulsory. update is a function v -> t -> 'a which gives the new value of the variable given the old value v, where t is the current timing of the animation as described in progress.

val fromto : ?duration:int -> ?ending:callback -> int -> int -> int t

fromto x1 x2 creates a integer Avar.t with initial value x1 and, as time elapses, moves continuously to x2, with a final slowdown.

OCaml

Innovation. Community. Security.