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: -9.66. Chroma is infinite. Assuming max of Lab chroma 130.
  • Upper bound: 8.61. Chroma is infinite. Assuming max of Lab chroma 130.

Implementation

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