score

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GoogleBlue color.ARGB = 0xff4285f4 // #4285f4

GoogleBlue is Google's Blue color as ARGB

Functions

func Score

func Score(
	colorsToPopulation map[color.ARGB]int,
	options ...Option,
) []color.ARGB

Score ranks colors based on suitability for being used for a UI theme.

colorsToPopulation: map with keys of colors and values of how often the color appears, usually from a source image. options: optional parameters for customizing scoring behavior.

Returns Colors sorted by suitability for a UI theme. The most suitable color is the first item, the least suitable is the last. There will always be at least one color returned. If all the input colors were not suitable for a theme, a default fallback color will be provided, Google Blue.

Types

type Option

type Option func(*options)

Option is a function that modifies the underlying options

func WithFallback

func WithFallback(c color.ARGB) Option

WithFallback sets a fallback color if no color has been found

func WithFilter

func WithFilter() Option

WithFilter sets if the resulting colors should be filtered to not include hues that are not used often enough, and colors that are effectively grayscale.

func WithLimit

func WithLimit(limit int) Option

WithLimit sets the limit for number of desired color

Jump to

Keyboard shortcuts

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