colorutil

package
v1.7.35 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2019 License: MIT Imports: 7 Imported by: 4

Documentation

Overview

Utilities for parsing and manipulating colors.

Index

Constants

View Source
const (
	Invalid lmodel = iota
	HSI
	HSL
	HSV
)

Variables

This section is empty.

Functions

func Equals

func Equals(first interface{}, second interface{}) bool

Return whether two colors are equivalent in the 24-bit RGB (RGB255) color space.

func HslToRgb

func HslToRgb(hue float64, saturation float64, lightness float64) (uint8, uint8, uint8)

Given HSL values (where hue is given in degrees (out of 360°), saturation and lightness are [0, 1]), return the corresponding RGB values (where each value is [0, 255]).

func HsvToRgb

func HsvToRgb(hue float64, saturation float64, value float64) (uint8, uint8, uint8)

Given HSL values (where hue is given in degrees (out of 360°), saturation and value are [0, 1]), return the corresponding RGB values (where each value is [0, 255]).

func RgbToHsl

func RgbToHsl(r float64, g float64, b float64) (float64, float64, float64)

Given RGB values (where each value is [0, 255]), return the hue (in degrees), saturation, and lightness (where each is [0, 1]).

Types

type Color

type Color struct {
	// contains filtered or unexported fields
}

func AdjustHue

func AdjustHue(in interface{}, degrees float64) (Color, error)

Adjust the hue of the given color by the specified number of degrees.

func Darken

func Darken(in interface{}, percent int) (Color, error)

Darken the given color by a certain percent. Consistent with the results of the Sass darken() function.

func Lighten

func Lighten(in interface{}, percent int) (Color, error)

Lighten the given color by a certain percent. Consistent with the results of the Sass lighten() function.

func MustParse

func MustParse(value interface{}) Color

Parse the given value into a Color or panic.

func Parse

func Parse(value interface{}) (Color, error)

Parse the given value into a Color or return an error.

func (Color) Equals

func (self Color) Equals(other interface{}) bool

Return whether the given color is equal to this one in the 24-bit RGB (RGB255) color space

func (Color) HSI

func (self Color) HSI() (float64, float64, float64)

Return the current color as hue (out of 360°), saturation [0, 1], and intensity [0, 1].

func (Color) HSL

func (self Color) HSL() (float64, float64, float64)

Return the current color as hue (out of 360°), saturation [0, 1], and lightness [0, 1].

func (Color) HSV

func (self Color) HSV() (float64, float64, float64)

Return the current color as hue (out of 360°), saturation [0, 1], and value [0, 1].

func (Color) RGBA

func (self Color) RGBA() (uint32, uint32, uint32, uint32)

Return the current color as a 32-bit uint quad, implementing the color.Color interface.

func (Color) RGBA255

func (self Color) RGBA255() (uint8, uint8, uint8, uint8)

Return the current color as 4x 8-bit RGB values, each [0, 255].

func (Color) String

func (self Color) String() string

func (Color) StringHSLA

func (self Color) StringHSLA() string

func (Color) StringRGBA

func (self Color) StringRGBA() string

Jump to

Keyboard shortcuts

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