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 double a = astar;
  final double b = bstar;
  final double m = math.sqrt(a * a + b * b);
  final double M = (math.exp(m * 0.0228) - 1.0) / 0.0228;
  final double c = M / viewingConditions.fLRoot;
  double h = math.atan2(b, a) * (180.0 / math.pi);
  if (h < 0.0) {
    h += 360.0;
  }
  final double j = jstar / (1 - (jstar - 100) * 0.007);

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