Documentation ¶
Index ¶
- func Blend(pct float32, x, y color.Color) color.RGBA
- func InCyclicOrder(a, b, c float32) bool
- func InverseChromaticAdapt(adapted float32) float32
- func LMSToOps(l, m, s float32, vw *View) (redVgreen, yellowVblue, grey, greyNorm float32)
- func LMSToXYZ(l, m, s float32) (x, y, z float32)
- func LuminanceAdapt(l, m, s float32, vw *View) (lA, mA, sA float32)
- func LuminanceAdaptComp(v, d, fl float32) float32
- func SanitizeDegrees(deg float32) float32
- func SanitizeRadians(angle float32) float32
- func XYZToLMS(x, y, z float32) (l, m, s float32)
- type CAM
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Blend ¶
Blend returns a color that is the given percent blend between the first and second color; 10 = 10% of the first and 90% of the second, etc; blending is done directly on non-premultiplied CAM16-UCS values, and a correctly premultiplied color is returned.
func InCyclicOrder ¶
InCyclicOrder returns true a, b, c are in order around a circle
func InverseChromaticAdapt ¶
func LMSToOps ¶
LMSToOps converts Long, Medium, Short cone-based values to opponent redVgreen (a) and yellowVblue (b), and grey (achromatic) values, that more closely reflect neural responses. greyNorm is a normalizing grey factor used in the CAM16 model. l, m, s values must be in 100-base units. Uses the CIECAM16 color appearance model.
func LMSToXYZ ¶
LMSToXYZ converts Long, Medium, Short cone-based responses to XYZ using the CAT16 transform from CIECAM16 color appearance model (LiLiWangEtAl17)
func LuminanceAdapt ¶
LuminanceAdapt performs luminance adaptation and response compression according to the CAM16 model, on given r,g,b components, using equations from HuntLiLuo03 and parameters on given viewing conditions
func LuminanceAdaptComp ¶
LuminanceAdaptComp performs luminance adaptation and response compression according to the CAM16 model, on one component, using equations from HuntLiLuo03 d = discount factor fl = luminance adaptation factor
func SanitizeDegrees ¶ added in v0.0.7
SanitizeDegrees ensures that degrees is in [0-360) range
func SanitizeRadians ¶
SanitizeRadians sanitizes a small enough angle in radians. Takes an angle in radians; must not deviate too much from 0, and returns a coterminal angle between 0 and 2pi.
Types ¶
type CAM ¶
type CAM struct { // hue (h) is the spectral identity of the color (red, green, blue etc) in degrees (0-360) Hue float32 // chroma (C) is the colorfulness or saturation of the color -- greyscale colors have no chroma, and fully saturated ones have high chroma Chroma float32 // colorfulness (M) is the absolute chromatic intensity Colorfulness float32 // saturation (s) is the colorfulness relative to brightness Saturation float32 // brightness (Q) is the apparent amount of light from the color, which is not a simple function of actual light energy emitted Brightness float32 // lightness (J) is the brightness relative to a reference white, which varies as a function of chroma and hue Lightness float32 }
CAM represents a point in the cam16 color model along 6 dimensions representing the perceived hue, colorfulness, and brightness, similar to HSL but much more well-calibrated to actual human subjective judgments.
func FromJCH ¶
FromJCH returns CAM values from the given lightness (j), chroma (c), and hue (h) values under standard viewing condition
func FromJCHView ¶
FromJCHView returns CAM values from the given lightness (j), chroma (c), and hue (h) values under the given viewing conditions
func FromSRGB ¶
FromSRGB returns CAM values from given SRGB color coordinates, under standard viewing conditions. The RGB value range is 0-1, and RGB values have gamma correction.
func FromUCS ¶
FromUCS returns CAM values from the given CAM16-UCS coordinates (jstar, astar, and bstar), under standard viewing conditions
func FromUCSView ¶
FromUCS returns CAM values from the given CAM16-UCS coordinates (jstar, astar, and bstar), using the given viewing conditions
func FromXYZ ¶
FromXYZ returns CAM values from given XYZ color coordinate, under standard viewing conditions
func FromXYZView ¶
FromXYZView returns CAM values from given XYZ color coordinate, under given viewing conditions. Requires 100-base XYZ coordinates.
type View ¶
type View struct { // white point illumination -- typically cie.WhiteD65 WhitePoint math32.Vector3 // the ambient light strength in lux Luminance float32 `default:"200"` // the average luminance of 10 degrees around the color in question BgLuminance float32 `default:"50"` // the brightness of the entire environment Surround float32 `default:"2"` // whether the person's eyes have adapted to the lighting Adapted bool `default:"false"` // computed from Luminance AdaptingLuminance float32 `view:"-"` // BgYToWhiteY float32 `view:"-"` // AW float32 `view:"-"` // luminance level induction factor NBB float32 `view:"-"` // luminance level induction factor NCB float32 `view:"-"` // exponential nonlinearity C float32 `view:"-"` // chromatic induction factor NC float32 `view:"-"` // luminance-level adaptation factor, based on the HuntLiLuo03 equations FL float32 `view:"-"` // FL to the 1/4 power FLRoot float32 `view:"-"` // base exponential nonlinearity Z float32 `view:"-"` // inverse of the RGBD factors DRGBInverse math32.Vector3 `view:"-"` // cone responses to white point, adjusted for discounting RGBD math32.Vector3 `view:"-"` }
View represents viewing conditions under which a color is being perceived, which greatly affects the subjective perception. Defaults represent the standard defined such conditions, under which the CAM16 computations operate.
var TheStdView *View
TheStdView is the standard viewing conditions view returned by NewStdView if already created.
func NewStdView ¶
func NewStdView() *View
NewStdView returns a new standard viewing conditions model returns TheStdView if already created