# RGB to HSV conversion function destroying my Pixelblaze?

**URL:** <https://forum.electromage.com/t/rgb-to-hsv-conversion-function-destroying-my-pixelblaze/3650>\
**Category:** Patterns and Code\
**Created:** [July 11, 2024, 5:41pm UTC](https://forum.electromage.com/t/rgb-to-hsv-conversion-function-destroying-my-pixelblaze/3650 "2024-07-11T17:41:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![wizard](https://forum.electromage.com/user_avatar/forum.electromage.com/wizard/32/4_2.png) [@wizard](https://forum.electromage.com/u/wizard)\
**Post date:** [July 11, 2024, 7:30pm UTC](https://forum.electromage.com/t/rgb-to-hsv-conversion-function-destroying-my-pixelblaze/3650/2 "2024-07-11T19:30:37Z")

</div>

I would check the forums first before ChatGPT. That implementation is creating an array for every call.

> [@Color blending code](https://forum.electromage.com/t/color-blending-code/1429/2):
>
> I have a few handy, seen in folk’s patterns or ported from plain JS: //linear interpolation function lerp(a, b, t) { return a \* (1-t) + b \* t } //cross fade RGB between 2 colors using linear interpolation //output sets r,g,b globals function crossFadeColors(r1, g1, b1, r2, g2, b2, t) { r = lerp(r1, r2, t) g = lerp(g1, g2, t) b = lerp(b1, b2, t) } //convert HSV to RGB //output sets r,g,b globals function hsv2rgb(hh, ss, vv) { var h = mod(hh, 1) var s = clamp(ss, 0, 1) var v = cl…

---

_[View the full topic](https://forum.electromage.com/t/rgb-to-hsv-conversion-function-destroying-my-pixelblaze/3650)._
