temperature

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RawTemperature

func RawTemperature(c color.Hct) float64

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 Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache 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 NewCache

func NewCache(input color.Hct) *Cache

NewCache creates a new TemperatureCache with the given color.Hct color.

func (*Cache) Analogous

func (t *Cache) 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 (*Cache) Coldest

func (t *Cache) Coldest() color.Hct

Coldest returns the coldest color in the cache.

func (*Cache) Complement

func (t *Cache) 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 (*Cache) HctsByHue

func (t *Cache) HctsByHue() []color.Hct

HctsByHue returns HCTs for all hues, with the same chroma/tone as the input. Sorted ascending, hue 0 to 360.

func (*Cache) HctsByTemp

func (t *Cache) HctsByTemp() []color.Hct

HctsByTemp returns a slice of Hct colors sorted by temperature.

func (*Cache) InputRelativeTemperature

func (t *Cache) InputRelativeTemperature() float64

InputRelativeTemperature returns the relative temperature of the input color.

func (*Cache) RelativeTemperature

func (t *Cache) 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 (*Cache) TempsByHct

func (t *Cache) TempsByHct() HctMap

TempsByHct returns a map with keys of HCTs and values of raw temperature.

func (*Cache) Warmest

func (t *Cache) Warmest() color.Hct

Warmest returns the warmest color in the cache.

type HctMap

type HctMap map[[3]int64]float64

HctMap is map containing Hct hash as key and temperature as value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL