Mixin: LiveScalingObjectMixin

xebra.js v1.2.5 - Documentation

LiveScalingObjectMixin

Certain live.* objects, for example live.slider and live.dial, manage their internal state using two separate but related parameters: "distance" and "value". The "distance" parameter is always a value between 0 and 1, ignoring the range and possible nonlinear scaling applied to the object. The "value" parameter is the one that the object will display, and is computed by applying the exponent and range parameters to the "distance" parameter. This mixin simply performs this calculation automatically whenever the "distance" parameter is set.

Example

// dialNode is the ObjectNode for the live.dial
dialNode.setParamValue("_parameter_range", [10, 20]);
dialNode.setParamValue("_parameter_exponent", 1);
dialNode.setParamValue("distance", 0.5);
dialNode.getParamValue("value"); // returns 15

dialNode.setParamValue("_parameter_exponent", 2);
dialNode.getParamValue("value"); // returns 12.5