palettes

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyColor

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

KeyColor is a color that represents the hue and chroma of a tonal palette

func NewKeyColor

func NewKeyColor(hue, requestedChroma float64) *KeyColor

NewKeyColor creates a new KeyColor with the given hue and chroma

func (*KeyColor) Create

func (k *KeyColor) Create() color.Hct

Create creates a key color from the hue and chroma The key color is the first tone, starting from T50, matching the given hue and chroma.

Returns an Hct color value

type TonalPalette

type TonalPalette struct {
	Hue      float64
	Chroma   float64
	KeyColor color.Hct
	// contains filtered or unexported fields
}

TonalPalette is a convenience type for retrieving colors that are constant in hue and chroma, but vary in tone.

Each TonalPalette is initialized with a hue and chroma, and provides a cache for efficient tone retrieval.

func FromHueAndChroma

func FromHueAndChroma(hue, chroma float64) *TonalPalette

FromHueAndChroma creates a TonalPalette from explicit hue and chroma values.

It internally generates a "key color" that best represents the given hue and chroma, and constructs a tonal palette around it.

func NewFromARGB

func NewFromARGB(c color.ARGB) *TonalPalette

NewFromARGB creates a TonalPalette from an ARGB color.

The palette’s hue and chroma will match those of the provided color, allowing tone values to vary while keeping the same hue and chroma.

func NewFromHct

func NewFromHct(hct color.Hct) *TonalPalette

NewFromHct creates a TonalPalette from a given HCT color.

The resulting palette will have the same hue and chroma as the provided HCT.

func (*TonalPalette) GetHct

func (tp *TonalPalette) GetHct(tone float64) color.Hct

GetHct returns the HCT representation of a color with the specified tone.

This provides access to hue, chroma, and tone values directly in HCT space.

func (*TonalPalette) IsBlue

func (tp *TonalPalette) IsBlue() bool

IsBlue determines if a hue is in the blue range.

func (*TonalPalette) IsCyan

func (tp *TonalPalette) IsCyan() bool

IsCyan determines if a hue is in the cyan range.

func (*TonalPalette) IsYellow

func (tp *TonalPalette) IsYellow() bool

IsYellow determines if a hue is in the yellow range.

func (*TonalPalette) Tone

func (tp *TonalPalette) Tone(tone float64) color.ARGB

Tone returns the ARGB representation of a color at a given tone (0–100).

The tone defines the perceived lightness of the color, where 0 is black and 100 is white. Results are cached for subsequent retrievals.

Jump to

Keyboard shortcuts

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