linearToSrgb static method

double linearToSrgb(
  1. double linear
)

One linear channel encoded for display: the inverse of srgbToLinear, for a caller writing a colour out where a person reads it.

Implementation

static double linearToSrgb(double linear) {
  final magnitude = linear.abs();
  final encoded = magnitude <= 0.0031308
      ? magnitude * 12.92
      : 1.055 * math.pow(magnitude, 1 / 2.4).toDouble() - 0.055;
  return linear < 0 ? -encoded : encoded;
}