normalize static method

double normalize(
  1. num value,
  2. TypedData array
)

Normalizes the given value according to the given typed array.

@param {number} value - The float value in the range [0,1] to normalize. @param {TypedArray} array - The typed array that defines the data type of the value. @return {number} The normalize value.

Implementation

static double normalize( num value, TypedData array ) {
  switch ( array.runtimeType ) {
    case Float32List:
      return value.toDouble();
    case Uint32List:
      return ( value * 4294967295.0 ).roundToDouble();
    case Uint16List:
      return ( value * 65535.0 ).roundToDouble();
    case Uint8List:
      return ( value * 255.0 ).roundToDouble();
    case Int32List:
      return ( value * 2147483647.0 ).roundToDouble();
    case Int16List:
      return ( value * 32767.0 ).roundToDouble();
    case Int8List:
      return ( value * 127.0 ).roundToDouble();
    default:
      throw( 'Invalid component type.' );
  }
}