Morphr
Morphr
is a tiny and lightweight javascript class for morphing numerical values of
arbitrary, mostly plain javascript objects in a given time interval dt
along a given range dval
.
Most often you will want to use it for animation. So it works excellently in combination with Html canvas.
Example
(animated gif)
see example
Morphr Example
Sequential morphing is easily achieved via multiple Morphr
objects. DOM element attributes are morphable as well.
see sequential
Here is a more complex canvas based Crank-Rocker animation using a g2 command queue for vector graphics.
Maybe you want to learn a bit more about Crank-Rockers.
API Reference
Morphr
is a tiny class for simultaneously morphing numerical object values in a given time interval.
Use case is most often parameter animation of plain javascript objects. So it works excellently with
canvas. Morphr
depends on requestAnimationFrame
.
Do not use new Morphr()
, call Morphr.create()
instead for creating instances.
- Morphr
- static
- .create([dt], [t0], [fn]) ⇒
object
- .create([dt], [t0], [fn]) ⇒
- instance
- .register(hdl) ⇒
object
- .start() ⇒
object
- .register(hdl) ⇒
- static
object
Morphr.create([dt], [t0], [fn]) ⇒ Create a Morphr
instance by start time, duration and timing function for morphing. A couple of predefined
timing functions are available [s. VDI2143]:
linear
quadratic
sinoid
poly5
Kind: static method of Morphr
Returns: object
- Morphr
instance.
Param | Type | Default | Description |
---|---|---|---|
[dt] | float |
2 |
Duration in [s]. |
[t0] | float |
0 |
Start time in [s] relative to first time call of start method. |
[fn] | function | string |
"linear" |
Timing function as function object or name of predefined function. |
object
morphr.register(hdl) ⇒ Register morphing handler function.
Kind: instance method of Morphr
Returns: object
- this.
Param | Type | Description |
---|---|---|
hdl | function |
Callback function hdl(q){} , where q is the - via fn - normalized time or the boolean value false to reset for a new start. |
object
morphr.start() ⇒ Start morphing process.
Kind: instance method of Morphr
Returns: object
- this.
Change Log
All notable changes to this project will be documented here. This project adheres to Semantic Versioning.