Morph Support Functions in MRlib
© 2012, Martin Rinehart
Note: these functions are used by the morph functions (see the Morph Functions page). They should not be called directly, except to add additional morph functions.
morph_from_change()
morph_spec = morph_from_change( change_spec, num_frames )
Given a change_spec
and number of frames, returns a morph_spec
.
A change_spec
is a string with start and stop values separated by a semicolor: "100px;200px"
. A morph_spec
is an array of values, one per output frame: [ '100px', '102px', ..., '200px']
.
Works for numbers (opacity), pixels, percent ('%' suffix), colors ('#rrggbb') and "two-px" values (borderRadius: '10px 20px'
).
morph_steps()
morph_steps( start, end, nsteps, round )
Converts 3, 9, 4 into [3, 5, 7, 9].
The optional last argument, if true, rounds steps to the nearest integer.
morph_styles()
morph_styles( element, morph_specs, millis_morph, millis_delay )
Morph styles contained in a morph_specs
object.
A morph_specs
object contains one property per style to morph. The name of the property is the name of the style. The value is the series of style values. Example:
var morph_specs = { top: ['100px', '102px', ... ], backgroundColor: ['#f0f0ff', '#efefff', ... ], ... };
spread_colors()
color_morph_array = spread_colors( start_color, end_color, ncolors )
Given start/end colors ('#rrggbb' form) returns a morphing array ([ '#f0f0ff', '#efefff', ... ]
.
Feedback: MartinRinehart at gmail dot com
# # #