color

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ColorMap = map[string]string{
	"warmwhite": "#ffe9c2",
	"blue":      "#0000ff",
	"green":     "#00ff00",
	"yellow":    "#ffaf33",
	"purple":    "#af33ff",
	"red":       "#ff0000",
	"teal":      "#33ffd1",
	"pink":      "#ff08c7",
	"white":     "#ffffff",
	"black":     "#000000",
}

ColorMap is a map of named colors to hex values

Functions

func GradientColorList

func GradientColorList(gradient GradientTable, length int) []colorful.Color

GradientColorList generates a list of colors for a GradientTable length: the number of colors you want

func GradientPNG

func GradientPNG(gradient GradientTable, h int, w int) error

GradientPNG generates a gradient PNG as an example

func HexToColor

func HexToColor(s string) colorful.Color

HexToColor converts a hex string to a Color

func ToUint32

func ToUint32(color colorful.Color) uint32

ToUint32 converts a color object to a uint32 for use by the neopixel

Types

type GradientTable

type GradientTable []struct {
	Col colorful.Color
	Pos float64
}

GradientTable contains the "keypoints" of the colorgradient you want to generate. The position of each keypoint has to live in the range [0,1]

func (GradientTable) GetInterpolatedColor

func (gt GradientTable) GetInterpolatedColor(t float64) colorful.Color

GetInterpolatedColor is the meat of the gradient computation. It returns an HCL-blend between the two colors around `t`. Note: It relies heavily on the fact that the gradient keypoints are sorted.

Jump to

Keyboard shortcuts

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