convert static method

dynamic convert(
  1. dynamic color,
  2. dynamic sourceColorSpace,
  3. dynamic targetColorSpace
)

Implementation

static convert( color, sourceColorSpace, targetColorSpace ) {

	if ( legacyMode || sourceColorSpace == targetColorSpace || ! sourceColorSpace || ! targetColorSpace ) {

		return color;

	}

	if ( FN[ sourceColorSpace ] != null && FN[ sourceColorSpace ]![ targetColorSpace ] != null ) {

		var fn = FN[ sourceColorSpace ]![ targetColorSpace ]!;

		color.r = fn( color.r );
		color.g = fn( color.g );
		color.b = fn( color.b );

		return color;

	}

	throw( 'Unsupported color space conversion.' );

}