linearToGamma method Null safety

void linearToGamma(
  1. Vector4 linearColor,
  2. Vector4 gammaColor,
  3. [double gamma = 2.2]
)

Convert linearColor from linear space into gamma color space and store the result in gammaColor. It is possible to specify a optional gamma, the default value is 2.2.

Implementation

static void linearToGamma(Vector4 linearColor, Vector4 gammaColor,
    [double gamma = 2.2]) {
  final exponent = 1.0 / gamma;

  gammaColor
    ..r = math.pow(linearColor.r, exponent).toDouble()
    ..g = math.pow(linearColor.g, exponent).toDouble()
    ..b = math.pow(linearColor.b, exponent).toDouble()
    ..a = linearColor.a;
}