palettegen

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2022 License: BSD-3-Clause, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const LAB_DELTA = 1e-6

Variables

This section is empty.

Functions

func FastHappyPalette

func FastHappyPalette(colorsCount int) (colors []colorful.Color)

Uses the HSV color space to generate colors with similar S,V but distributed evenly along their Hue. This is fast but not always pretty. If you've got time to spare, use LAB (the non-fast below).

func FastWarmPalette

func FastWarmPalette(colorsCount int) (colors []colorful.Color)

Uses the HSV color space to generate colors with similar S,V but distributed evenly along their Hue. This is fast but not always pretty. If you've got time to spare, use LAB (the non-fast below).

func HappyPalette

func HappyPalette(colorsCount int) ([]colorful.Color, error)

func SoftPalette

func SoftPalette(colorsCount int) ([]colorful.Color, error)

A wrapper which uses common parameters.

func SoftPaletteEx

func SoftPaletteEx(colorsCount int, settings SoftPaletteSettings) ([]colorful.Color, error)

Yeah, windows-stype Foo, FooEx, screw you golang... Uses K-means to cluster the color-space and return the means of the clusters as a new palette of distinctive colors. Falls back to K-medoid if the mean happens to fall outside of the color-space, which can only happen if you specify a CheckColor function.

func WarmPalette

func WarmPalette(colorsCount int) ([]colorful.Color, error)

Types

type SoftPaletteSettings

type SoftPaletteSettings struct {
	// A function which can be used to restrict the allowed color-space.
	CheckColor func(l, a, b float64) bool

	// The higher, the better quality but the slower. Usually two figures.
	Iterations int

	// Use up to 160000 or 8000 samples of the L*a*b* space (and thus calls to CheckColor).
	// Set this to true only if your CheckColor shapes the LAB space weirdly.
	ManySamples bool
}

Jump to

Keyboard shortcuts

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