rawTemperature static method

double rawTemperature(
  1. Hct color
)

Value representing cool-warm factor of a color. Values below 0 are considered cool, above, warm.

Color science has researched emotion and harmony, which art uses to select colors. Warm-cool is the foundation of analogous and complementary colors. See:

  • Li-Chen Ou's Chapter 19 in Handbook of Color Psychology (2015).
  • Josef Albers' Interaction of Color chapters 19 and 21.

Implementation of Ou, Woodcock and Wright's algorithm, which uses Lab*/LCH color space. Return value has these properties:

  • Values below 0 are cool, above 0 are warm.
  • Lower bound: -0.52 - (chroma ^ 1.07 / 20). Lab* chroma is infinite. Assuming max of 130 chroma, -9.66.
  • Upper bound: -0.52 + (chroma ^ 1.07 / 20). Lab* chroma is infinite. Assuming max of 130 chroma, 8.61.

Implementation

static double rawTemperature(Hct color) {
  final lab = ColorUtils.labFromArgb(color.toInt());
  final hue = MathUtils.sanitizeDegreesDouble(
      math.atan2(lab[2], lab[1]) * 180.0 / math.pi);
  final chroma = math.sqrt((lab[1] * lab[1]) + (lab[2] * lab[2]));
  final temperature = -0.5 +
      0.02 *
          math.pow(chroma, 1.07) *
          math.cos(
            MathUtils.sanitizeDegreesDouble(hue - 50.0) * math.pi / 180.0,
          );
  return temperature;
}