pub struct TemperatureCache { /* private fields */ }Expand description
Design utilities using color temperature theory.
Analogous colors, complementary color, and cache to efficiently, lazily, generate data for calculations when needed.
Implementations§
Source§impl TemperatureCache
impl TemperatureCache
pub fn new(input: Hct) -> Self
Sourcepub fn analogous(
&mut self,
count: Option<i32>,
divisions: Option<i32>,
) -> Vec<Hct>
pub fn analogous( &mut self, count: Option<i32>, divisions: Option<i32>, ) -> Vec<Hct>
A set of colors with differing hues, equidistant in temperature.
In art, this is usually described as a set of 5 colors on a color wheel divided into 12 sections. This method allows provision of either of those values.
Behavior is undefined when count or divisions is 0.
When divisions < count, colors repeat.
count: The number of colors to return, includes the input color.divisions: The number of divisions on the color wheel.
Sourcepub fn complement(&mut self) -> Hct
pub fn complement(&mut self) -> Hct
A color that complements the input color aesthetically.
In art, this is usually described as being across the color wheel. History of this shows intent as a color that is just as cool-warm as the input color is warm-cool.
§Panics
Will panic if there is no coldest or warmest HCT
Sourcepub fn relative_temperature(&mut self, hct: &Hct) -> f64
pub fn relative_temperature(&mut self, hct: &Hct) -> f64
Temperature relative to all colors with the same chroma and tone. Value on a scale from 0 to 1.
Sourcepub fn input_relative_temperature(&mut self) -> f64
pub fn input_relative_temperature(&mut self) -> f64
Relative temperature of the input color. See relative_temperature.
Sourcepub fn hcts_by_temp(&mut self) -> &[Hct]
pub fn hcts_by_temp(&mut self) -> &[Hct]
HCTs for all hues, with the same chroma/tone as the input. Sorted from coldest first to warmest last.
Sourcepub fn temps_by_hct(&mut self) -> &Map<Hct, f64>
pub fn temps_by_hct(&mut self) -> &Map<Hct, f64>
A Map with keys of HCTs in hcts_by_temp, values of raw temperature.
Sourcepub fn hcts_by_hue(&mut self) -> Vec<Hct>
pub fn hcts_by_hue(&mut self) -> Vec<Hct>
HCTs for all hues, with the same chroma/tone as the input. Sorted ascending, hue 0 to 360.
Sourcepub fn is_between(angle: f64, a: f64, b: f64) -> bool
pub fn is_between(angle: f64, a: f64, b: f64) -> bool
Determines if an angle is between two other angles, rotating clockwise.
Sourcepub fn raw_temperature(color: Hct) -> f64
pub fn raw_temperature(color: Hct) -> f64
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.