basiccolor

package
v0.0.0-...-df1f0a2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: BSD-2-Clause, BSD-2-Clause Imports: 4 Imported by: 0

README

Resources

Color Picker: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Colors/Color_picker_tool

Human Colors: https://vasilis.nl/nerd/code/human-colours/tests/hue-en-gb.php

License

Licensed under a BSD 2-Clause license. The code in hsl.go was originally licensed under an MIT License. See license information in the file.

Documentation

Overview

Package basiccolor provides functions to determine the closest basic color (e.g., red, white, orange) to a given color.

Index

Constants

This section is empty.

Variables

View Source
var HSLModel = color.ModelFunc(func(c color.Color) color.Color {
	if _, ok := c.(HSL); ok {
		return c
	}
	nrgba := color.NRGBAModel.Convert(c).(color.NRGBA)
	h, s, l := nrgbToHSL(nrgba.R, nrgba.G, nrgba.B)
	return HSL{h, s, l, nrgba.A}
})

HSLModel is the color.Model for the HSL type.

Functions

This section is empty.

Types

type Color

type Color int

Color represents a basic color.

const (
	Red Color = iota
	Orange
	Brown
	Yellow
	Green
	Blue
	Violet
	Pink
	Black
	Gray
	White
)

func Closest

func Closest(c color.Color) Color

Closest returns the closest basic color to c.

func (Color) String

func (i Color) String() string

type HSL

type HSL struct {
	H, S, L float64
	A       uint8
}

HSL represents the HSL value for a color.

func (HSL) RGBA

func (c HSL) RGBA() (uint32, uint32, uint32, uint32)

Jump to

Keyboard shortcuts

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