Skip to main content

TemperatureCache

Struct TemperatureCache 

Source
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

Source

pub fn warmest(&mut self) -> Hct

§Panics

Will panic if there is no warmest HCT

Source

pub fn coldest(&mut self) -> Hct

§Panics

Will panic if there is no coldest HCT

Source

pub fn new(input: Hct) -> Self

Source

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.
Source

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

Source

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.

Source

pub fn input_relative_temperature(&mut self) -> f64

Relative temperature of the input color. See relative_temperature.

Source

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.

Source

pub fn temps_by_hct(&mut self) -> &Map<Hct, f64>

A Map with keys of HCTs in hcts_by_temp, values of raw temperature.

Source

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.

Source

pub fn is_between(angle: f64, a: f64, b: f64) -> bool

Determines if an angle is between two other angles, rotating clockwise.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.