Documentation ¶
Overview ¶
Package colour contains some colour types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // GammaToLin converts a gamma corrected sRGB component to linear-light // form. // // The component shall be in the range 0 to 1. GammaToLin = func(val float64) float64 { if val < 0.04045 { return val / 12.92 } return math.Pow((val+0.055)/1.055, 2.4) } // LinToGamma converts a linear-light sRGB component to gamma corrected // form. // // The component shall be in the range 0 to 1. LinToGamma = func(val float64) float64 { if val > 0.0031308 { return 1.055*math.Pow(val, 1/2.4) - 0.055 } return 12.92 * val } )
https://www.w3.org/TR/css-color-4/#color-conversion-code
var NamedColours = []string{}/* 148 elements not displayed */
NamedColours is a list of the 148 possible CSS4 named colours.
Functions ¶
func IsNoSuchArcError ¶
IsNoSuchArcError is whether the argument error indicates that the specified arc does not exist.
This may happen, for example, if two LCh colours are exactly 180 degrees apart in hue and a minor or major hue arc was expected.
Types ¶
type Join ¶
type Join struct {
// contains filtered or unexported fields
}
Join LCh colour gradients into one gradient.
func (*Join) Append ¶
Append the given gradient to the join and give it the given weighting.
The weight determines the given gradient's proportion of the Join's domain: it is ultimately divided by the sum of all the join's weights.
The minimum weight is 1.
func (*Join) Colour ¶
Colour takes a parameter that varies in the range 0..1 and returns a linearly interpolated RGB colour with components clamped to the range 0..1.
type LCh ¶
type LCh struct {
// L and C represent the colour's lightness (L*) and chroma (C*) values.
//
// L* = 0 gives black and L* = 100 gives diffuse white; specular white may
// be higher.
//
// C* = 0 gives one of the true neutral grays. In practice C* does not
// exceed 230 (since the corresponding a* and b* values in Cartesian
// coordinates do not in practice exceed ±160).
L, C float64
// H represents the colour's hue (h*) value, and is the polar coordinates
// angle in the range 0..360:
//
// * yellow = 90°
//
// * green = 180°
//
// * blue = 270°
//
// * red = 360°
H float64
}
An LCh (CIELCh colour space) colour.
An LCh colour is a direct cylindrical coordinates equivalent of a Cartesian coordinates Lab colour.
The illuminant is D50 white.
In CIELCh the CIE acronym is a French title which translates as International Commission on Illumination.
func (LCh) Colour ¶
Colour is an sRGB equivalent of the receiver colour.
Note that the returned colour uses the D65 reference white whereas the receiver colour uses the D50 reference white.
type LChGrad ¶
type LChGrad struct { Δh float64 // contains filtered or unexported fields }
LChGrad is a colour gradient that linearly interpolates between two LCh colours.
func NewHueGrad ¶
NewHueGrad constructs a new LChGrad which covers the range of hue values starting from the given colour to the colour whose hue is the sum of the from and delta hues in the direction given by the sign of the delta hue.
The delta hue is measured in degrees and is clamped to the range -360..360.
func NewLChGrad ¶
NewLChGrad constructs a new LChGrad which covers the range from the given colour to the absolute L and C values and the relative hue value.
The delta hue is measured in degrees and is clamped to the range -360..360.
func NewLChMajorGrad ¶
NewLChMajorGrad constructs a new LChGrad which covers the (major arc) / (largest range) of hue values between the given colours.
func NewLChMinorGrad ¶
NewLChMinorGrad constructs a new LChGrad which covers the (minor arc) / (smallest range) of hue values between the given colours.
func (LChGrad) Colour ¶
Colour takes a parameter that varies in the range 0..1 and returns a linearly interpolated RGB colour with components clamped to the range 0..1.
func (LChGrad) Colours ¶
Colours is a slice of the receiver colour gradient between the given proportions of the interval in the range 0..1.
type Lab ¶
type Lab struct {
// L, A, and B represent the colour's L*, a*, and b* values.
//
// L* = 0 gives black and L* = 100 gives diffuse white; specular white may
// be higher.
//
// a* = positive gives a red; a* = negative gives a green.
//
// b* = positive gives a yellow; b* = negative gives a blue.
//
// a* = b* = 0 gives one of the true neutral grays. In practice the a* and
// b* values do not exceed ±160.
L, A, B float64
}
A Lab (CIELAB colour space) colour.
The illuminant is D50 white.
In CIELAB the CIE acronym is a French title which translates as International Commission on Illumination.
type MonoGrad ¶
type MonoGrad struct {
// contains filtered or unexported fields
}
MonoGrad is a constant colour gradient.
func NewMonoGrad ¶
NewMonoGrad constructs a new MonoGrad with the given constant colour.
type OkLCh ¶
type OkLCh struct {
// The lightness L is a percentage between 0 and 100. The chroma C is a
// positive number that does not exceed 0.5 in practice. The hue H is an
// angle in degrees from 0 to 360.
//
// | (b) / 90 deg / mustard yellow
// |
// |
// 180 deg / greenish cyan - - - - | - - - - (a) / 0 deg / purplish red
// |
// |
// | 270 deg / sky blue
//
// https://www.w3.org/TR/css-color-4/#funcdef-oklch
L, C, H float64
}
An OkLCh colour.
The illuminant is D65 white.
type OkLChGrad ¶
type OkLChGrad struct { Δh float64 // contains filtered or unexported fields }
OkLChGrad is a colour gradient that linearly interpolates between two OkLCh colours.
func NewOkLChGrad ¶
NewOkLChGrad constructs a new OkLChGrad which covers the range from the given colour to the absolute L and C values and the relative hue value.
The delta hue is measured in degrees and is clamped to the range -360..360.
func (OkLChGrad) Colour ¶
Colour takes a parameter that varies in the range 0..1 and returns a linearly interpolated RGB colour with components clamped to the range 0..1.
func (OkLChGrad) Colours ¶
Colours is a slice of the receiver colour gradient between the given proportions of the interval in the range 0..1.
type OkLab ¶
type OkLab struct {
// L is a percentage between 0 and 100. A and B are coordinates that do not
// exceed ±0.5 in practice.
//
// | (b) / 90 deg / mustard yellow
// |
// |
// 180 deg / greenish cyan - - - - | - - - - (a) / 0 deg / purplish red
// |
// |
// | 270 deg / sky blue
//
// https://www.w3.org/TR/css-color-4/#funcdef-oklab
L, A, B float64
}
An OkLab colour.
The illuminant is D65 white.
type RGB ¶
type RGB struct {
// The amount of the primary additive colours in the range 0..255.
R, G, B uint8
}
An RGB (sRGB colour space) colour.
The illuminant is D65 white.
func NewRGB ¶
NewRGB creates and initialises a new RGB using the argument RGB value which shall be given in ratios of 1 format, i.e each value is in the range 0..1.
func (RGB) Colour64 ¶
Colour64 returns the receiver colour in a vector format with components in the range 0..1.
func (RGB) LCh ¶
LCh returns the LCh equivalent of the receiver colour.
Note that the returned colour uses the D50 reference white whereas the receiver colour uses the D65 reference white.
func (RGB) Lab ¶
Lab returns the Lab equivalent of the receiver colour.
Note that the returned colour uses the D50 reference white whereas the receiver colour uses the D65 reference white.
type RGBA ¶
type RGBA struct { // The amount of the primary additive red colour in the range 0..255. R uint8 `json:"r"` // The amount of the primary additive green colour in the range 0..255. G uint8 `json:"g"` // The amount of the primary additive blue colour in the range 0..255. B uint8 `json:"b"` // Alpha in the range 0..1. A float64 `json:"a"` }
An RGBA colour is an RGB colour with variable opacity.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package lch contains the 148 CSS4 colour names as LCh type colours.
|
Package lch contains the 148 CSS4 colour names as LCh type colours. |
internal
Package main generates the 148 CSS4 named colour LCh type variable declarations in the lch package.
|
Package main generates the 148 CSS4 named colour LCh type variable declarations in the lch package. |
Package rgb contains the 148 CSS4 colour names as RGB type colours as well as some other colours commonly used by Mechane.
|
Package rgb contains the 148 CSS4 colour names as RGB type colours as well as some other colours commonly used by Mechane. |