getRelativeTemperature method

double getRelativeTemperature(
  1. Hct hct
)

Temperature relative to all colors with the same chroma and tone.

Returns a value on a scale from 0 to 1.

Implementation

double getRelativeTemperature(Hct hct) {
  final range = _tempsByHct[_warmest]! - _tempsByHct[_coldest]!;
  final differenceFromColdest = _tempsByHct[hct]! - _tempsByHct[_coldest]!;
  // Handle when there's no difference in temperature between warmest and
  // coldest: for example, at T100, only one color is available, white.
  return range == 0.0 ? 0.5 : differenceFromColdest / range;
}