ledsgo

package module
v0.0.0-...-1580ae8 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 2 Imported by: 20

README

Color utilities for LED animations

This package is a collection of some utility functions for working with color. It is primarily intended for LED animations on microcontrollers using TinyGo, therefore it has been optimized for devices without FPU.

It is inspired by FastLED but does not implement any drivers for LED strips to keep development focused on fast animations.

Noise functions

This package contains a number of Simplex noise functions. Simplex noise is very similar to Perlin noise and produces naturally looking gradients as you might encounter in nature. It is commonly used as a building block for animations, especially in procedurally generated games.

Be warned that Simplex noise is patented (set to expire on 2022-01-18) so use at your own risk for computer graphics. This patent may or may not apply to LED animations, I don't know.

Animation demos

There is a demos subpackage which contains a number of simple animations that can be directly applied to surfaces implementing the Displayer interface.

License

This package is licensed under the MIT license, just like the FastLED library. See the LICENSE file for details. Some code has been copied from the FastLED library, this is indicated in the code.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AliceBlue            = color.RGBA{0xF0, 0xF8, 0xFF, 0xFF}
	Amethyst             = color.RGBA{0x99, 0x66, 0xCC, 0xFF}
	AntiqueWhite         = color.RGBA{0xFA, 0xEB, 0xD7, 0xFF}
	Aqua                 = color.RGBA{0x00, 0xFF, 0xFF, 0xFF}
	Aquamarine           = color.RGBA{0x7F, 0xFF, 0xD4, 0xFF}
	Azure                = color.RGBA{0xF0, 0xFF, 0xFF, 0xFF}
	Beige                = color.RGBA{0xF5, 0xF5, 0xDC, 0xFF}
	Bisque               = color.RGBA{0xFF, 0xE4, 0xC4, 0xFF}
	Black                = color.RGBA{0x00, 0x00, 0x00, 0xFF}
	BlanchedAlmond       = color.RGBA{0xFF, 0xEB, 0xCD, 0xFF}
	Blue                 = color.RGBA{0x00, 0x00, 0xFF, 0xFF}
	BlueViolet           = color.RGBA{0x8A, 0x2B, 0xE2, 0xFF}
	Brown                = color.RGBA{0xA5, 0x2A, 0x2A, 0xFF}
	BurlyWood            = color.RGBA{0xDE, 0xB8, 0x87, 0xFF}
	CadetBlue            = color.RGBA{0x5F, 0x9E, 0xA0, 0xFF}
	Chartreuse           = color.RGBA{0x7F, 0xFF, 0x00, 0xFF}
	Chocolate            = color.RGBA{0xD2, 0x69, 0x1E, 0xFF}
	Coral                = color.RGBA{0xFF, 0x7F, 0x50, 0xFF}
	CornflowerBlue       = color.RGBA{0x64, 0x95, 0xED, 0xFF}
	Cornsilk             = color.RGBA{0xFF, 0xF8, 0xDC, 0xFF}
	Crimson              = color.RGBA{0xDC, 0x14, 0x3C, 0xFF}
	Cyan                 = color.RGBA{0x00, 0xFF, 0xFF, 0xFF}
	DarkBlue             = color.RGBA{0x00, 0x00, 0x8B, 0xFF}
	DarkCyan             = color.RGBA{0x00, 0x8B, 0x8B, 0xFF}
	DarkGoldenrod        = color.RGBA{0xB8, 0x86, 0x0B, 0xFF}
	DarkGray             = color.RGBA{0xA9, 0xA9, 0xA9, 0xFF}
	DarkGrey             = color.RGBA{0xA9, 0xA9, 0xA9, 0xFF}
	DarkGreen            = color.RGBA{0x00, 0x64, 0x00, 0xFF}
	DarkKhaki            = color.RGBA{0xBD, 0xB7, 0x6B, 0xFF}
	DarkMagenta          = color.RGBA{0x8B, 0x00, 0x8B, 0xFF}
	DarkOliveGreen       = color.RGBA{0x55, 0x6B, 0x2F, 0xFF}
	DarkOrange           = color.RGBA{0xFF, 0x8C, 0x00, 0xFF}
	DarkOrchid           = color.RGBA{0x99, 0x32, 0xCC, 0xFF}
	DarkRed              = color.RGBA{0x8B, 0x00, 0x00, 0xFF}
	DarkSalmon           = color.RGBA{0xE9, 0x96, 0x7A, 0xFF}
	DarkSeaGreen         = color.RGBA{0x8F, 0xBC, 0x8F, 0xFF}
	DarkSlateBlue        = color.RGBA{0x48, 0x3D, 0x8B, 0xFF}
	DarkSlateGray        = color.RGBA{0x2F, 0x4F, 0x4F, 0xFF}
	DarkSlateGrey        = color.RGBA{0x2F, 0x4F, 0x4F, 0xFF}
	DarkTurquoise        = color.RGBA{0x00, 0xCE, 0xD1, 0xFF}
	DarkViolet           = color.RGBA{0x94, 0x00, 0xD3, 0xFF}
	DeepPink             = color.RGBA{0xFF, 0x14, 0x93, 0xFF}
	DeepSkyBlue          = color.RGBA{0x00, 0xBF, 0xFF, 0xFF}
	DimGray              = color.RGBA{0x69, 0x69, 0x69, 0xFF}
	DimGrey              = color.RGBA{0x69, 0x69, 0x69, 0xFF}
	DodgerBlue           = color.RGBA{0x1E, 0x90, 0xFF, 0xFF}
	FireBrick            = color.RGBA{0xB2, 0x22, 0x22, 0xFF}
	FloralWhite          = color.RGBA{0xFF, 0xFA, 0xF0, 0xFF}
	ForestGreen          = color.RGBA{0x22, 0x8B, 0x22, 0xFF}
	Fuchsia              = color.RGBA{0xFF, 0x00, 0xFF, 0xFF}
	Gainsboro            = color.RGBA{0xDC, 0xDC, 0xDC, 0xFF}
	GhostWhite           = color.RGBA{0xF8, 0xF8, 0xFF, 0xFF}
	Gold                 = color.RGBA{0xFF, 0xD7, 0x00, 0xFF}
	Goldenrod            = color.RGBA{0xDA, 0xA5, 0x20, 0xFF}
	Gray                 = color.RGBA{0x80, 0x80, 0x80, 0xFF}
	Grey                 = color.RGBA{0x80, 0x80, 0x80, 0xFF}
	Green                = color.RGBA{0x00, 0x80, 0x00, 0xFF}
	GreenYellow          = color.RGBA{0xAD, 0xFF, 0x2F, 0xFF}
	Honeydew             = color.RGBA{0xF0, 0xFF, 0xF0, 0xFF}
	HotPink              = color.RGBA{0xFF, 0x69, 0xB4, 0xFF}
	IndianRed            = color.RGBA{0xCD, 0x5C, 0x5C, 0xFF}
	Indigo               = color.RGBA{0x4B, 0x00, 0x82, 0xFF}
	Ivory                = color.RGBA{0xFF, 0xFF, 0xF0, 0xFF}
	Khaki                = color.RGBA{0xF0, 0xE6, 0x8C, 0xFF}
	Lavender             = color.RGBA{0xE6, 0xE6, 0xFA, 0xFF}
	LavenderBlush        = color.RGBA{0xFF, 0xF0, 0xF5, 0xFF}
	LawnGreen            = color.RGBA{0x7C, 0xFC, 0x00, 0xFF}
	LemonChiffon         = color.RGBA{0xFF, 0xFA, 0xCD, 0xFF}
	LightBlue            = color.RGBA{0xAD, 0xD8, 0xE6, 0xFF}
	LightCoral           = color.RGBA{0xF0, 0x80, 0x80, 0xFF}
	LightCyan            = color.RGBA{0xE0, 0xFF, 0xFF, 0xFF}
	LightGoldenrodYellow = color.RGBA{0xFA, 0xFA, 0xD2, 0xFF}
	LightGreen           = color.RGBA{0x90, 0xEE, 0x90, 0xFF}
	LightGrey            = color.RGBA{0xD3, 0xD3, 0xD3, 0xFF}
	LightPink            = color.RGBA{0xFF, 0xB6, 0xC1, 0xFF}
	LightSalmon          = color.RGBA{0xFF, 0xA0, 0x7A, 0xFF}
	LightSeaGreen        = color.RGBA{0x20, 0xB2, 0xAA, 0xFF}
	LightSkyBlue         = color.RGBA{0x87, 0xCE, 0xFA, 0xFF}
	LightSlateGray       = color.RGBA{0x77, 0x88, 0x99, 0xFF}
	LightSlateGrey       = color.RGBA{0x77, 0x88, 0x99, 0xFF}
	LightSteelBlue       = color.RGBA{0xB0, 0xC4, 0xDE, 0xFF}
	LightYellow          = color.RGBA{0xFF, 0xFF, 0xE0, 0xFF}
	Lime                 = color.RGBA{0x00, 0xFF, 0x00, 0xFF}
	LimeGreen            = color.RGBA{0x32, 0xCD, 0x32, 0xFF}
	Linen                = color.RGBA{0xFA, 0xF0, 0xE6, 0xFF}
	Magenta              = color.RGBA{0xFF, 0x00, 0xFF, 0xFF}
	Maroon               = color.RGBA{0x80, 0x00, 0x00, 0xFF}
	MediumAquamarine     = color.RGBA{0x66, 0xCD, 0xAA, 0xFF}
	MediumBlue           = color.RGBA{0x00, 0x00, 0xCD, 0xFF}
	MediumOrchid         = color.RGBA{0xBA, 0x55, 0xD3, 0xFF}
	MediumPurple         = color.RGBA{0x93, 0x70, 0xDB, 0xFF}
	MediumSeaGreen       = color.RGBA{0x3C, 0xB3, 0x71, 0xFF}
	MediumSlateBlue      = color.RGBA{0x7B, 0x68, 0xEE, 0xFF}
	MediumSpringGreen    = color.RGBA{0x00, 0xFA, 0x9A, 0xFF}
	MediumTurquoise      = color.RGBA{0x48, 0xD1, 0xCC, 0xFF}
	MediumVioletRed      = color.RGBA{0xC7, 0x15, 0x85, 0xFF}
	MidnightBlue         = color.RGBA{0x19, 0x19, 0x70, 0xFF}
	MintCream            = color.RGBA{0xF5, 0xFF, 0xFA, 0xFF}
	MistyRose            = color.RGBA{0xFF, 0xE4, 0xE1, 0xFF}
	Moccasin             = color.RGBA{0xFF, 0xE4, 0xB5, 0xFF}
	NavajoWhite          = color.RGBA{0xFF, 0xDE, 0xAD, 0xFF}
	Navy                 = color.RGBA{0x00, 0x00, 0x80, 0xFF}
	OldLace              = color.RGBA{0xFD, 0xF5, 0xE6, 0xFF}
	Olive                = color.RGBA{0x80, 0x80, 0x00, 0xFF}
	OliveDrab            = color.RGBA{0x6B, 0x8E, 0x23, 0xFF}
	Orange               = color.RGBA{0xFF, 0xA5, 0x00, 0xFF}
	OrangeRed            = color.RGBA{0xFF, 0x45, 0x00, 0xFF}
	Orchid               = color.RGBA{0xDA, 0x70, 0xD6, 0xFF}
	PaleGoldenrod        = color.RGBA{0xEE, 0xE8, 0xAA, 0xFF}
	PaleGreen            = color.RGBA{0x98, 0xFB, 0x98, 0xFF}
	PaleTurquoise        = color.RGBA{0xAF, 0xEE, 0xEE, 0xFF}
	PaleVioletRed        = color.RGBA{0xDB, 0x70, 0x93, 0xFF}
	PapayaWhip           = color.RGBA{0xFF, 0xEF, 0xD5, 0xFF}
	PeachPuff            = color.RGBA{0xFF, 0xDA, 0xB9, 0xFF}
	Peru                 = color.RGBA{0xCD, 0x85, 0x3F, 0xFF}
	Pink                 = color.RGBA{0xFF, 0xC0, 0xCB, 0xFF}
	Plaid                = color.RGBA{0xCC, 0x55, 0x33, 0xFF}
	Plum                 = color.RGBA{0xDD, 0xA0, 0xDD, 0xFF}
	PowderBlue           = color.RGBA{0xB0, 0xE0, 0xE6, 0xFF}
	Purple               = color.RGBA{0x80, 0x00, 0x80, 0xFF}
	Red                  = color.RGBA{0xFF, 0x00, 0x00, 0xFF}
	RosyBrown            = color.RGBA{0xBC, 0x8F, 0x8F, 0xFF}
	RoyalBlue            = color.RGBA{0x41, 0x69, 0xE1, 0xFF}
	SaddleBrown          = color.RGBA{0x8B, 0x45, 0x13, 0xFF}
	Salmon               = color.RGBA{0xFA, 0x80, 0x72, 0xFF}
	SandyBrown           = color.RGBA{0xF4, 0xA4, 0x60, 0xFF}
	SeaGreen             = color.RGBA{0x2E, 0x8B, 0x57, 0xFF}
	Seashell             = color.RGBA{0xFF, 0xF5, 0xEE, 0xFF}
	Sienna               = color.RGBA{0xA0, 0x52, 0x2D, 0xFF}
	Silver               = color.RGBA{0xC0, 0xC0, 0xC0, 0xFF}
	SkyBlue              = color.RGBA{0x87, 0xCE, 0xEB, 0xFF}
	SlateBlue            = color.RGBA{0x6A, 0x5A, 0xCD, 0xFF}
	SlateGray            = color.RGBA{0x70, 0x80, 0x90, 0xFF}
	SlateGrey            = color.RGBA{0x70, 0x80, 0x90, 0xFF}
	Snow                 = color.RGBA{0xFF, 0xFA, 0xFA, 0xFF}
	SpringGreen          = color.RGBA{0x00, 0xFF, 0x7F, 0xFF}
	SteelBlue            = color.RGBA{0x46, 0x82, 0xB4, 0xFF}
	Tan                  = color.RGBA{0xD2, 0xB4, 0x8C, 0xFF}
	Teal                 = color.RGBA{0x00, 0x80, 0x80, 0xFF}
	Thistle              = color.RGBA{0xD8, 0xBF, 0xD8, 0xFF}
	Tomato               = color.RGBA{0xFF, 0x63, 0x47, 0xFF}
	Turquoise            = color.RGBA{0x40, 0xE0, 0xD0, 0xFF}
	Violet               = color.RGBA{0xEE, 0x82, 0xEE, 0xFF}
	Wheat                = color.RGBA{0xF5, 0xDE, 0xB3, 0xFF}
	White                = color.RGBA{0xFF, 0xFF, 0xFF, 0xFF}
	WhiteSmoke           = color.RGBA{0xF5, 0xF5, 0xF5, 0xFF}
	Yellow               = color.RGBA{0xFF, 0xFF, 0x00, 0xFF}
	YellowGreen          = color.RGBA{0x9A, 0xCD, 0x32, 0xFF}
)

Colors copied from the FastLED library, originating from HTML colors. Warning: these colors are in sRGB (as used on the web), not in linear colors as used in this package. They are copied for easier porting from FastLED but please realize that the color you'll see on a screen often won't match actual LED colors.

View Source
var (
	CloudColors = Palette16{
		Blue,
		DarkBlue,
		DarkBlue,
		DarkBlue,

		DarkBlue,
		DarkBlue,
		DarkBlue,
		DarkBlue,

		Blue,
		DarkBlue,
		SkyBlue,
		SkyBlue,

		LightBlue,
		White,
		LightBlue,
		SkyBlue,
	}

	LavaColors = Palette16{
		Black,
		Maroon,
		Black,
		Maroon,

		DarkRed,
		Maroon,
		DarkRed,

		DarkRed,
		DarkRed,
		Red,
		Orange,

		White,
		Orange,
		Red,
		DarkRed,
	}

	OceanColors = Palette16{
		MidnightBlue,
		DarkBlue,
		MidnightBlue,
		Navy,

		DarkBlue,
		MediumBlue,
		SeaGreen,
		Teal,

		CadetBlue,
		Blue,
		DarkCyan,
		CornflowerBlue,

		Aquamarine,
		SeaGreen,
		Aqua,
		LightSkyBlue,
	}

	ForestColors = Palette16{
		DarkGreen,
		DarkGreen,
		DarkOliveGreen,
		DarkGreen,

		Green,
		ForestGreen,
		OliveDrab,
		Green,

		SeaGreen,
		MediumAquamarine,
		LimeGreen,
		YellowGreen,

		LightGreen,
		LawnGreen,
		MediumAquamarine,
		ForestGreen,
	}

	// HSV Rainbow
	RainbowColors = Palette16{
		color.RGBA{0xFF, 0x00, 0x00, 0xFF}, color.RGBA{0xD5, 0x2A, 0x00, 0xFF}, color.RGBA{0xAB, 0x55, 0x00, 0xFF}, color.RGBA{0xAB, 0x7F, 0x00, 0xFF},
		color.RGBA{0xAB, 0xAB, 0x00, 0xFF}, color.RGBA{0x56, 0xD5, 0x00, 0xFF}, color.RGBA{0x00, 0xFF, 0x00, 0xFF}, color.RGBA{0x00, 0xD5, 0x2A, 0xFF},
		color.RGBA{0x00, 0xAB, 0x55, 0xFF}, color.RGBA{0x00, 0x56, 0xAA, 0xFF}, color.RGBA{0x00, 0x00, 0xFF, 0xFF}, color.RGBA{0x2A, 0x00, 0xD5, 0xFF},
		color.RGBA{0x55, 0x00, 0xAB, 0xFF}, color.RGBA{0x7F, 0x00, 0x81, 0xFF}, color.RGBA{0xAB, 0x00, 0x55, 0xFF}, color.RGBA{0xD5, 0x00, 0x2B, 0xFF},
	}

	// HSV Rainbow colors with alternatating stripes of black
	RainbowStripeColors = Palette16{
		color.RGBA{0xFF, 0x00, 0x00, 0xFF}, color.RGBA{0x00, 0x00, 0x00, 0xFF}, color.RGBA{0xAB, 0x55, 0x00, 0xFF}, color.RGBA{0x00, 0x00, 0x00, 0xFF},
		color.RGBA{0xAB, 0xAB, 0x00, 0xFF}, color.RGBA{0x00, 0x00, 0x00, 0xFF}, color.RGBA{0x00, 0xFF, 0x00, 0xFF}, color.RGBA{0x00, 0x00, 0x00, 0xFF},
		color.RGBA{0x00, 0xAB, 0x55, 0xFF}, color.RGBA{0x00, 0x00, 0x00, 0xFF}, color.RGBA{0x00, 0x00, 0xFF, 0xFF}, color.RGBA{0x00, 0x00, 0x00, 0xFF},
		color.RGBA{0x55, 0x00, 0xAB, 0xFF}, color.RGBA{0x00, 0x00, 0x00, 0xFF}, color.RGBA{0xAB, 0x00, 0x55, 0xFF}, color.RGBA{0x00, 0x00, 0x00, 0xFF},
	}

	// HSV color ramp: blue purple ping red orange yellow (and back)
	// Basically, everything but the greens, which tend to make
	// people's skin look unhealthy.  This palette is good for
	// lighting at a club or party, where it'll be shining on people.
	PartyColors = Palette16{
		color.RGBA{0x55, 0x00, 0xAB, 0xFF}, color.RGBA{0x84, 0x00, 0x7C, 0xFF}, color.RGBA{0xB5, 0x00, 0x4B, 0xFF}, color.RGBA{0xE5, 0x00, 0x1B, 0xFF},
		color.RGBA{0xE8, 0x17, 0x00, 0xFF}, color.RGBA{0xB8, 0x47, 0x00, 0xFF}, color.RGBA{0xAB, 0x77, 0x00, 0xFF}, color.RGBA{0xAB, 0xAB, 0x00, 0xFF},
		color.RGBA{0xAB, 0x55, 0x00, 0xFF}, color.RGBA{0xDD, 0x22, 0x00, 0xFF}, color.RGBA{0xF2, 0x00, 0x0E, 0xFF}, color.RGBA{0xC2, 0x00, 0x3E, 0xFF},
		color.RGBA{0x8F, 0x00, 0x71, 0xFF}, color.RGBA{0x5F, 0x00, 0xA1, 0xFF}, color.RGBA{0x2F, 0x00, 0xD0, 0xFF}, color.RGBA{0x00, 0x07, 0xF9, 0xFF},
	}

	// Approximate "black body radiation" palette, akin to
	// the FastLED 'HeatColor' function.
	// Recommend that you use values 0-240 rather than
	// the usual 0-255, as the last 15 colors will be
	// 'wrapping around' from the hot end to the cold end,
	// which looks wrong.
	HeatColors = Palette16{
		color.RGBA{0x00, 0x00, 0x00, 0xFF},
		color.RGBA{0x33, 0x00, 0x00, 0xFF}, color.RGBA{0x66, 0x00, 0x00, 0xFF}, color.RGBA{0x99, 0x00, 0x00, 0xFF}, color.RGBA{0xCC, 0x00, 0x00, 0xFF}, color.RGBA{0xFF, 0x00, 0x00, 0xFF},
		color.RGBA{0xFF, 0x33, 0x00, 0xFF}, color.RGBA{0xFF, 0x66, 0x00, 0xFF}, color.RGBA{0xFF, 0x99, 0x00, 0xFF}, color.RGBA{0xFF, 0xCC, 0x00, 0xFF}, color.RGBA{0xFF, 0xFF, 0x00, 0xFF},
		color.RGBA{0xFF, 0xFF, 0x33, 0xFF}, color.RGBA{0xFF, 0xFF, 0x66, 0xFF}, color.RGBA{0xFF, 0xFF, 0x99, 0xFF}, color.RGBA{0xFF, 0xFF, 0xCC, 0xFF}, color.RGBA{0xFF, 0xFF, 0xFF, 0xFF},
	}
)

A number of palettes copied from FastLED, see: https://github.com/FastLED/FastLED/blob/master/colorpalettes.cpp

Functions

func ApplyAlpha

func ApplyAlpha(c color.RGBA, alpha uint8) color.RGBA

ApplyAlpha scales the color with the given alpha. It can be used to reduce the intensity of a given color. The color is assumed to be linear, not sRGB.

func Blend

func Blend(bottom, top color.RGBA) color.RGBA

Blend blends two colors together, assuming the colors are linear (not sRGB). The bottom alpha is assumed to be 0xff. The top alpha is used to blend the two colors together.

func Noise1

func Noise1(x uint32) uint16

1D simplex noise.

The x input is a 20.12 fixed-point value. The result covers the full range of a uint16, averaging around 32768. Only the low 20 bits of x are used.

func Noise1AVR

func Noise1AVR(x uint16) uint16

Fast 1D simplex noise for 8-bit microcontrollers (may or may not be faster on 32-bit microcontrollers). It is less precise than Noise1.

The x input is a 8.8 fixed-point value. The result covers the full range of a uint16, averaging around 32768. The output is only slightly more precise than a uint8, though.

func Noise2

func Noise2(x, y uint32) uint16

2D simplex noise.

The x and y inputs are 20.12 fixed-point value. The result covers the full range of a uint16, averaging around 32768.

func Noise3

func Noise3(x, y, z uint32) uint16

3D simplex noise.

The x, y and z inputs are 20.12 fixed-point value. The result covers the full range of a uint16, averaging around 32768.

func Noise4

func Noise4(x, y, z, w uint32) uint16

4D simplex noise.

The x, y, z and w inputs are 20.12 fixed-point value. The result covers the full range of a uint16, averaging around 32768.

func Sqrt

func Sqrt(x int) int

Sqrt is a fast integer square root function that returns a result at most one off of the intended result. It can be used in place of a floating-point square root function. Negative values are accepted and result in 0.

Types

type Color

type Color struct {
	H uint16 // hue
	S uint8  // saturation
	V uint8  // value
}

Color encodes a HSV color.

The hue is 16-bits to get better looking colors, as HSV→RGB conversions generally can use more than 8 hue bits for their conversion. Saturation and value are both just 8 bits because saturation is not that often used and value does not gain much precision with extra bits. This encoding has been chosen to have the best colors while still fitting in 32 bits.

func (Color) Rainbow

func (c Color) Rainbow() color.RGBA

Rainbow color conversion. This function was copied from the FastLED library, for details see https://github.com/FastLED/FastLED/wiki/FastLED-HSV-Colors#color-map-rainbow-vs-spectrum. The main difference is that yellow is somewhat brighter, which may look better in LEDs.

func (Color) Spectrum

func (c Color) Spectrum() color.RGBA

Return the RGB version of this color, calculated with the common HSV conversion: https://github.com/FastLED/FastLED/wiki/FastLED-HSV-Colors

type Palette16

type Palette16 [16]color.RGBA

Palette16 is a 16-color palette on a continuous scale, from which a color can be picked.

func (*Palette16) ColorAt

func (p *Palette16) ColorAt(position uint16) color.RGBA

ColorAt returns a color from the palette at the 16-bit index (0..65535) position. Colors not exactly from one position are interpolated. Colors close to the top wrap around to the bottom, so you can imagine the palette as being a custom color ring akin to a hue color ring in a HSV color picker.

This method is similar to ColorFromPalette in FastLED except that it uses a 16-bit index instead of a 8-bit index for better color accuracy.

type Strip

type Strip []color.RGBA

The LEDs of a LED strip. Colors are represented in RGB form: 0x00rrggbb.

func (Strip) FillSolid

func (s Strip) FillSolid(color color.RGBA)

FillSolid sets all colors to the given value.

func (Strip) FillSpectrum

func (s Strip) FillSpectrum(start Color, hueinc uint16)

Fill the LED strip with a color range, using the HSV spectrum conversion. The start color is the color for the first LED. All other colors have the same saturation and value but increased (and wrapped) hue.

Directories

Path Synopsis
Package patterns implements a number of animations for small LED displays.
Package patterns implements a number of animations for small LED displays.

Jump to

Keyboard shortcuts

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