chroma

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2021 License: MIT Imports: 1 Imported by: 0

README

chroma Go Reference GitHub tag license Go Report Card codecov

Find names of ~2800 colors from a Go package.

Inspiration and color data have been sourced from ayushoriginal/Optimized-RGB-To-ColorName


Usage:

// Pick a color close to IBM Blue
blue := color.RGBA{84, 138, 196, 255}

// Find the nearest color
nearest := chroma.NearestColor(blue)

// Print what we got
fmt.Printf("%+v\n", nearest)
&{Color:{Color:{R:90 G:135 B:197 A:255} Names:[IBM Blue]} RGBDistance:{R:6 G:-3 B:1}}

Todo

  • Use faster algorithm for NearestColor()
  • Optimize data structures.

Contributing

Issues/PRs are much appreciated!

Feature requests/improvements welcome.

License

This project is licensed under the MIT License.

Documentation

Overview

Package chroma provides a way of finding names of ~2800 colors.

These colors have been sourced from: https://github.com/ayushoriginal/Optimized-RGB-To-ColorName

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Color

type Color struct {
	color.Color
	Names []string
}

Color embeds a color.Color interface and a slice of associated names.

type Nearest

type Nearest struct {
	Color       Color
	RGBDistance RGBDistance
}

Nearest contains a Color, and distance from another color.

func NearestColor

func NearestColor(c color.Color) *Nearest

NearestColor returns the nearest color, and distance from the given color.

Example
// Pick a color close to IBM Blue
blue := color.RGBA{84, 138, 196, 255}

// Find the nearest color
nearest := NearestColor(blue)

// Print what we got
fmt.Printf("%+v\n", nearest)
Output:

&{Color:{Color:{R:90 G:135 B:197 A:255} Names:[IBM Blue]} RGBDistance:{R:6 G:-3 B:1}}

type Palette

type Palette []Color

Palette is a palette of colors.

func (Palette) Load

func (p Palette) Load()

Load will replace the current palette data with the palette specified.

type RGBDistance

type RGBDistance struct {
	R, G, B int16
}

RGBDistance holds a signed distance of 8-bit RGB values to get from one color to another. Range: -255 through 255.

Jump to

Keyboard shortcuts

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