Documentation
¶
Index ¶
- func RawTemperature(color color.Hct) float64
- type ColorMap
- type TemperatureCache
- func (t *TemperatureCache) Analogous(count, divisions int) []color.Hct
- func (t *TemperatureCache) Coldest() color.Hct
- func (t *TemperatureCache) Complement() color.Hct
- func (t *TemperatureCache) HctsByHue() []color.Hct
- func (t *TemperatureCache) HctsByTemp() []color.Hct
- func (t *TemperatureCache) InputRelativeTemperature() float64
- func (t *TemperatureCache) RelativeTemperature(hct color.Hct) float64
- func (t *TemperatureCache) TempsByHct() ColorMap
- func (t *TemperatureCache) Warmest() color.Hct
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RawTemperature ¶
RawTemperature calculates the raw temperature value of a 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 L*a*b* / 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). L*a*b* chroma is infinite. Assuming max of 130 chroma, -9.66.
- Upper bound: -0.52 + (chroma ^ 1.07 / 20). L*a*b* chroma is infinite. Assuming max of 130 chroma, 8.61.
Types ¶
type TemperatureCache ¶
type TemperatureCache struct {
// contains filtered or unexported fields
}
TemperatureCache provides design utilities using color temperature theory.
It handles analogous colors, complementary color, and uses cache to efficiently and lazily generate data for calculations when needed.
func NewTemperatureCache ¶
func NewTemperatureCache(input color.Hct) *TemperatureCache
NewTemperatureCache creates a new TemperatureCache with the given color.Hct color.
func (*TemperatureCache) Analogous ¶
func (t *TemperatureCache) Analogous(count, divisions int) []color.Hct
Analogous returns 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.
Parameters:
- count: The number of colors to return, includes the input color. Default is 5.
- divisions: The number of divisions on the color wheel. Default is 12.
func (*TemperatureCache) Coldest ¶
func (t *TemperatureCache) Coldest() color.Hct
Coldest returns the coldest color in the cache.
func (*TemperatureCache) Complement ¶
func (t *TemperatureCache) Complement() color.Hct
Complement returns 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.
func (*TemperatureCache) HctsByHue ¶
func (t *TemperatureCache) HctsByHue() []color.Hct
HctsByHue returns HCTs for all hues, with the same chroma/tone as the input. Sorted ascending, hue 0 to 360.
func (*TemperatureCache) HctsByTemp ¶
func (t *TemperatureCache) HctsByTemp() []color.Hct
HctsByTemp returns a slice of Hct colors sorted by temperature.
func (*TemperatureCache) InputRelativeTemperature ¶
func (t *TemperatureCache) InputRelativeTemperature() float64
InputRelativeTemperature returns the relative temperature of the input color.
func (*TemperatureCache) RelativeTemperature ¶
func (t *TemperatureCache) RelativeTemperature(hct color.Hct) float64
RelativeTemperature returns temperature relative to all colors with the same chroma and tone. Value on a scale from 0 to 1.
func (*TemperatureCache) TempsByHct ¶
func (t *TemperatureCache) TempsByHct() ColorMap
TempsByHct returns a map with keys of HCTs and values of raw temperature.
func (*TemperatureCache) Warmest ¶
func (t *TemperatureCache) Warmest() color.Hct
Warmest returns the warmest color in the cache.