MCPcopy Create free account
hub / github.com/tdewolff/canvas / hue

Function hue

resources/docs/colors/main.go:12–35  ·  view source on GitHub ↗
(col color.RGBA)

Source from the content-addressed store, hash-verified

10)
11
12func hue(col color.RGBA) float64 {
13 var hue float64
14 a := float64(col.A) / 255.0
15 r := float64(col.R) / 255.0 / a
16 g := float64(col.G) / 255.0 / a
17 b := float64(col.B) / 255.0 / a
18
19 min := math.Min(r, math.Min(g, b))
20 max := math.Max(r, math.Max(g, b))
21 if min == max {
22 return -1.0
23 } else if r == max {
24 hue = (g - b) / (max - min)
25 } else if g == max {
26 hue = 2.0 + (b-r)/(max-min)
27 } else if b == max {
28 hue = 4.0 + (r-g)/(max-min)
29 }
30 hue *= 60.0
31 if hue < 0.0 {
32 hue += 360.0
33 }
34 return hue
35}
36
37func lum(col color.RGBA) float64 {
38 a := float64(col.A) / 255.0

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected