colormap

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: BSD-3-Clause Imports: 5 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AvailableMaps = map[string]*Map{}

AvailableMaps is the list of all available color maps

View Source
var StandardMaps = map[string]*Map{
	"ColdHot": {
		Name:    "ColdHot",
		NoColor: colors.FromRGB(200, 200, 200),
		Colors: []color.RGBA{
			{0, 255, 255, 255},
			{0, 0, 255, 255},
			{127, 127, 127, 255},
			{255, 0, 0, 255},
			{255, 255, 0, 255},
		},
	},
	"Jet": {
		Name:    "Jet",
		NoColor: color.RGBA{200, 200, 200, 255},
		Colors: []color.RGBA{
			{0, 0, 127, 255},
			{0, 0, 255, 255},
			{0, 127, 255, 255},
			{0, 255, 255, 255},
			{127, 255, 127, 255},
			{255, 255, 0, 255},
			{255, 127, 0, 255},
			{255, 0, 0, 255},
			{127, 0, 0, 255},
		},
	},
	"JetMuted": {
		Name:    "JetMuted",
		NoColor: color.RGBA{200, 200, 200, 255},
		Colors: []color.RGBA{
			{25, 25, 153, 255},
			{25, 102, 230, 255},
			{0, 230, 230, 255},
			{0, 179, 0, 255},
			{230, 230, 0, 255},
			{230, 102, 25, 255},
			{153, 25, 25, 255},
		},
	},
	"Viridis": {
		Name:    "Viridis",
		NoColor: color.RGBA{200, 200, 200, 255},
		Colors: []color.RGBA{
			{72, 33, 114, 255},
			{67, 62, 133, 255},
			{56, 87, 140, 255},
			{45, 111, 142, 255},
			{36, 133, 142, 255},
			{30, 155, 138, 255},
			{42, 176, 127, 255},
			{81, 197, 105, 255},
			{134, 212, 73, 255},
			{194, 223, 35, 255},
			{253, 231, 37, 255},
		},
	},
	"Plasma": {
		Name:    "Plasma",
		NoColor: color.RGBA{200, 200, 200, 255},
		Colors: []color.RGBA{
			{61, 4, 155, 255},
			{99, 0, 167, 255},
			{133, 6, 166, 255},
			{166, 32, 152, 255},
			{192, 58, 131, 255},
			{213, 84, 110, 255},
			{231, 111, 90, 255},
			{246, 141, 69, 255},
			{253, 174, 50, 255},
			{252, 210, 36, 255},
			{240, 248, 33, 255},
		},
	},
	"Inferno": {
		Name:    "Inferno",
		NoColor: color.RGBA{200, 200, 200, 255},
		Colors: []color.RGBA{
			{37, 12, 3, 255},
			{19, 11, 52, 255},
			{57, 9, 99, 255},
			{95, 19, 110, 255},
			{133, 33, 107, 255},
			{169, 46, 94, 255},
			{203, 65, 73, 255},
			{230, 93, 47, 255},
			{247, 131, 17, 255},
			{252, 174, 19, 255},
			{245, 219, 76, 255},
			{252, 254, 164, 255},
		},
	},
	"BlueRed": {
		Name:    "BlueRed",
		NoColor: color.RGBA{200, 200, 200, 255},
		Colors: []color.RGBA{
			{0, 0, 255, 255},
			{255, 0, 0, 255},
		},
	},
	"BlueBlackRed": {
		Name:    "BlueBlackRed",
		NoColor: color.RGBA{200, 200, 200, 255},
		Colors: []color.RGBA{
			{0, 0, 255, 255},
			{76, 76, 76, 255},
			{255, 0, 0, 255},
		},
	},
	"BlueGreyRed": {
		Name:    "BlueGreyRed",
		NoColor: color.RGBA{200, 200, 200, 255},
		Colors: []color.RGBA{
			{0, 0, 255, 255},
			{127, 127, 127, 255},
			{255, 0, 0, 255},
		},
	},
	"BlueWhiteRed": {
		Name:    "BlueWhiteRed",
		NoColor: color.RGBA{200, 200, 200, 255},
		Colors: []color.RGBA{
			{0, 0, 255, 255},
			{230, 230, 230, 255},
			{255, 0, 0, 255},
		},
	},
	"BlueGreenRed": {
		Name:    "BlueGreenRed",
		NoColor: color.RGBA{200, 200, 200, 255},
		Colors: []color.RGBA{
			{0, 0, 255, 255},
			{0, 230, 0, 255},
			{255, 0, 0, 255},
		},
	},
	"Rainbow": {
		Name:    "Rainbow",
		NoColor: color.RGBA{200, 200, 200, 255},
		Colors: []color.RGBA{
			{255, 0, 255, 255},
			{0, 0, 255, 255},
			{0, 255, 0, 255},
			{255, 255, 0, 255},
			{255, 0, 0, 255},
		},
	},
	"ROYGBIV": {
		Name:    "ROYGBIV",
		NoColor: color.RGBA{200, 200, 200, 255},
		Colors: []color.RGBA{
			{255, 0, 255, 255},
			{0, 0, 127, 255},
			{0, 0, 255, 255},
			{0, 255, 0, 255},
			{255, 255, 0, 255},
			{255, 0, 0, 255},
		},
	},
	"DarkLight": {
		Name:    "DarkLight",
		NoColor: color.RGBA{200, 200, 200, 255},
		Colors: []color.RGBA{
			{0, 0, 0, 255},
			{250, 250, 250, 255},
		},
	},
	"DarkLightDark": {
		Name:    "DarkLightDark",
		NoColor: color.RGBA{200, 200, 200, 255},
		Colors: []color.RGBA{
			{0, 0, 0, 255},
			{250, 250, 250, 255},
			{0, 0, 0, 255},
		},
	},
	"LightDarkLight": {
		Name:    "DarkLightDark",
		NoColor: color.RGBA{200, 200, 200, 255},
		Colors: []color.RGBA{
			{250, 250, 250, 255},
			{0, 0, 0, 255},
			{250, 250, 250, 255},
		},
	},
}

StandardMaps is a list of standard color maps

Functions

func AvailableMapsList added in v0.0.10

func AvailableMapsList() []string

AvailableMapsList returns a sorted list of color map names, e.g., for choosers

Types

type Map

type Map struct {
	// Name is the name of the color map
	Name string

	// if true, this map should be used as an indexed list instead of interpolating a normalized floating point value: requires caller to check this flag and pass int indexes instead of normalized values to MapIndex
	Indexed bool

	// the colorspace algorithm to use for blending colors
	Blend colors.BlendTypes

	// color to display for invalid numbers (e.g., NaN)
	NoColor color.RGBA

	// list of colors to interpolate between
	Colors []color.RGBA
}

Map maps a value onto a color by interpolating between a list of colors defining a spectrum, or optionally as an indexed list of colors.

func (*Map) Map

func (cm *Map) Map(val float32) color.RGBA

Map returns color for normalized value in range 0-1. NaN returns NoColor which can be used to indicate missing values.

func (*Map) MapIndex

func (cm *Map) MapIndex(val int) color.RGBA

MapIndex returns color for given index, for scale in Indexed mode. NoColor is returned for values out of range of available colors. It is responsibility of the caller to use this method instead of Map based on the Indexed flag.

func (*Map) String

func (cm *Map) String() string

Jump to

Keyboard shortcuts

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