MCPcopy Index your code
hub / github.com/aofei/cameron / hueToRGB

Function hueToRGB

cameron.go:129–146  ·  view source on GitHub ↗

hueToRGB converts a hue offset t into a single RGB component.

(p, q, t float64)

Source from the content-addressed store, hash-verified

127
128// hueToRGB converts a hue offset t into a single RGB component.
129func hueToRGB(p, q, t float64) float64 {
130 if t < 0 {
131 t += 1
132 }
133 if t > 1 {
134 t -= 1
135 }
136 switch {
137 case t < 1.0/6.0:
138 return p + (q-p)*6*t
139 case t < 1.0/2.0:
140 return q
141 case t < 2.0/3.0:
142 return p + (q-p)*(2.0/3.0-t)*6
143 default:
144 return p
145 }
146}

Callers 2

TestHueToRGBFunction · 0.85
hslToNRGBAFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestHueToRGBFunction · 0.68