MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / hueToRgb

Method hueToRgb

javascript/selenium-webdriver/lib/color.js:172–179  ·  view source on GitHub ↗
(l1, l2, hue)

Source from the content-addressed store, hash-verified

170 const luminocity2 = l < 0.5 ? l * (1 + s) : l + s - l * s
171 const luminocity1 = 2 * l - luminocity2
172 const hueToRgb = (l1, l2, hue) => {
173 if (hue < 0) hue += 1
174 if (hue > 1) hue -= 1
175 if (hue < 1 / 6) return l1 + (l2 - l1) * 6 * hue
176 if (hue < 1 / 2) return l2
177 if (hue < 2 / 3) return l1 + (l2 - l1) * (2 / 3 - hue) * 6
178 return l1
179 }
180 const r = Math.round(hueToRgb(luminocity1, luminocity2, h + 1 / 3) * 255)
181 const g = Math.round(hueToRgb(luminocity1, luminocity2, h) * 255)
182 const b = Math.round(hueToRgb(luminocity1, luminocity2, h - 1 / 3) * 255)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected