fromUcsInViewingConditions static method

Cam16 fromUcsInViewingConditions(
  1. double jstar,
  2. double astar,
  3. double bstar,
  4. ViewingConditions viewingConditions,
)

Create a CAM16 color from CAM16-UCS coordinates jstar, astar, bstar. in viewingConditions.

Implementation

static Cam16 fromUcsInViewingConditions(double jstar, double astar,
    double bstar, ViewingConditions viewingConditions) {
  final a = astar;
  final b = bstar;
  final m = math.sqrt(a * a + b * b);
  final M = (math.exp(m * 0.0228) - 1.0) / 0.0228;
  final c = M / viewingConditions.fLRoot;
  var h = math.atan2(b, a) * (180.0 / math.pi);
  if (h < 0.0) {
    h += 360.0;
  }
  final j = jstar / (1 - (jstar - 100) * 0.007);

  return Cam16.fromJchInViewingConditions(j, c, h, viewingConditions);
}