Documentation
¶
Index ¶
- Constants
- Variables
- type Collection
- type Color
- func DecodeHexRGB(s string) (Color, error)
- func HSLAFromInts(ints ...int) (Color, error)
- func HSLFromInts(ints ...int) (Color, error)
- func HSVAFromInts(ints ...int) (Color, error)
- func HSVFromInts(ints ...int) (Color, error)
- func RGBAFromInts(ints ...int) (Color, error)
- func RGBFromInts(ints ...int) (Color, error)
- func WithName(name string, c Color) Color
- type HSLAColor
- func (c HSLAColor) HSL() Color
- func (c HSLAColor) HSV() Color
- func (HSLAColor) HasName(string) bool
- func (c HSLAColor) Ints() []int
- func (HSLAColor) Name() string
- func (HSLAColor) Names() []string
- func (c HSLAColor) Opaque() Color
- func (c HSLAColor) RGB() Color
- func (c HSLAColor) Translucent() Color
- func (HSLAColor) Type() Type
- type HSLColor
- type HSVAColor
- func (c HSVAColor) HSL() Color
- func (c HSVAColor) HSV() Color
- func (HSVAColor) HasName(string) bool
- func (c HSVAColor) Ints() []int
- func (HSVAColor) Name() string
- func (HSVAColor) Names() []string
- func (c HSVAColor) Opaque() Color
- func (c HSVAColor) RGB() Color
- func (c HSVAColor) Translucent() Color
- func (HSVAColor) Type() Type
- type HSVColor
- type Named
- type RGBAColor
- func (c RGBAColor) HSL() Color
- func (c RGBAColor) HSV() Color
- func (RGBAColor) HasName(string) bool
- func (c RGBAColor) Ints() []int
- func (RGBAColor) Name() string
- func (RGBAColor) Names() []string
- func (c RGBAColor) Opaque() Color
- func (c RGBAColor) RGB() Color
- func (c RGBAColor) String() string
- func (c RGBAColor) Translucent() Color
- func (RGBAColor) Type() Type
- type RGBColor
- type Scheme
- type Type
Constants ¶
const HSLAOpaque = byte(100)
const HSVAOpaque = byte(100)
const RGBAOpaque = byte(255)
Variables ¶
var ( NotYetImplementedErr = errors.New("not yet implemented") UnknownColorTypeErr = errors.New("unknown color type") UnparsableColorStringErr = errors.New("could not parse color string") NotEnoughIntsErr = errors.New("not enough values") TooManyIntsErr = errors.New("too many values") ColorComponentOutOfRangeErr = errors.New("color component out of range") UnnamedColorErr = errors.New("unnamed color") UnknownColorNameErr = errors.New("unknown color name") UnknownColorSchemeNameErr = errors.New("unknown colorscheme name") )
var HSLAIntLimits = intLimits{ // contains filtered or unexported fields }
var HSVAIntLimits = intLimits{ // contains filtered or unexported fields }
var RGBAIntLimits = intLimits{ // contains filtered or unexported fields }
var Schemes = &Collection{ Schemes: []*Scheme{}, Scheme: map[string]*Scheme{}, }
Functions ¶
This section is empty.
Types ¶
type Collection ¶
func (*Collection) Add ¶
func (c *Collection) Add(s *Scheme, ids ...string)
func (*Collection) ColorWithName ¶
func (c *Collection) ColorWithName(name string) (Color, error)
parse a color name of the form [/[scheme]/]name
- all comparisons are case-insensitive - if no scheme name is provided, all schemes will be scanned in order
type Color ¶
type Color interface { HasName(string) bool // will mostly be false Name() string // will mostly be "" Names() []string // will mostly be [] Type() Type // type of color (RGB, HSL or HSV) Ints() []int // type-dependent component values, guaranteed to be in the expected order and ranges (rgb[a] or hsl[a]) Opaque() Color // returns a color in it's original format, without opacity (i.e. 3 ints) Translucent() Color // returns a color in it's original format, with opacity (i.e. 4 ints) RGB() Color // returns an RGB/RGBA representation of the color HSL() Color // returns an HSL/HSLA representation of the color HSV() Color // returns an HSL/HSLA representation of the color }
func DecodeHexRGB ¶
TODO: 2024-12-29 refactor this somehow
func HSLAFromInts ¶
HSLAFromInts returns a Color constructed from 3 or 4 HSL(A) components
The first value will be folded to the range [0,359] All other values must be between 0 and 100 (percent)
func HSLFromInts ¶
HSLFromInts creates an HSL value from 3 ints in the order red, green, blue.
If a 4th int is provided, it is assumed to be an opacity value and an HSLA value will be returned instead.
All values must be in the range between 0 and 255 inclusively.
func HSVAFromInts ¶
HSVAFromInts returns a Color constructed from 3 or 4 HSV(A) components
The first value will be folded to the range [0,359] All other values must be between 0 and 100 (percent)
func HSVFromInts ¶
HSVFromInts creates an HSV value from 3 ints in the order hue, saturation, value (brightness)
If a 4th int is provided, it is assumed to be an opacity value and a HSVA value will be returned instead.
All values must be in the range between 0 and 255 inclusively.
func RGBAFromInts ¶
RGBAFromInts creates an RGBA value from 4 ints in the order red, green, blue and alpha (opacity).
If only 3 values are provided, an RGB color will be returned instead.
All values must be in the range between 0 and 255 inclusively.
func RGBFromInts ¶
RGBFromInts creates an RGB value from 3 ints in the order red, green, blue.
If a 4th int is provided, it is assumed to be an opacity value and an RGBA value will be returned instead.
All values must be in the range between 0 and 255 inclusively.
type HSLAColor ¶
type HSLAColor struct { H int16 // hue: 0 .. 360 degrees (too big for a byte) S byte // saturation: 0 .. 100 (%) L byte // lightness: 0 .. 100 (%) A byte // opacity: 0 .. 100 (%) }
HSLAColor represents a color specified by four integer values for hue (0 .. 359: 0: red, 120: green, 240: blue) saturation (0 .. 100: 0: no color 100: fully saturated) luminence (0 .. 100: 0: dark 100: light) and opacity (0 .. 100: 0: transparent 100: opaque)
func (HSLAColor) Translucent ¶
type HSLColor ¶
type HSLColor struct {
HSLAColor
}
HSLColor is just an HSLColor with foll opacity
func (HSLColor) Translucent ¶
type HSVAColor ¶
type HSVAColor struct { H int16 // hue: 0 .. 360 degrees (too big for a byte) S byte // saturation: 0 .. 100 (%) V byte // lightness: 0 .. 100 (%) A byte // opacity: 0 .. 100 (%) }
HSVAColor represents a color specified by four integer values for hue (0 .. 359: 0: red, 120: green, 240: blue) saturation (0 .. 100: 0: no color 100: fully saturated) value (brighness) (0 .. 100: 0: dark 100: bright) and opacity (0 .. 100: 0: transparent 100: opaque)
func (HSVAColor) Translucent ¶
type HSVColor ¶
type HSVColor struct {
HSVAColor
}
HSVColor is just an HSVColor with foll opacity
func (HSVColor) Translucent ¶
type RGBAColor ¶
type RGBAColor struct { R byte // red: 0 .. 255 G byte // green: 0 .. 255 B byte // blue: 0 .. 255 A byte // opacity: 0 .. 255 }
RGBAColor represents a color specified by four integer values for red, green, blue and opacity (0: transparent, 255: opaque), ranging between 0 and 255
func (RGBAColor) Translucent ¶
type RGBColor ¶
type RGBColor struct {
RGBAColor
}
RGBColor is just an RGBAColor with full opacity Note: even without the opacity value, both structs would be 32 bits in size