MCPcopy Index your code
hub / github.com/clips/pattern / _rgb2hsb

Function _rgb2hsb

pattern/canvas.js:775–792  ·  view source on GitHub ↗
(r, g, b)

Source from the content-addressed store, hash-verified

773}
774
775function _rgb2hsb(r, g, b) {
776 /* Converts the given R,G,B values to H,S,B (between 0.0-1.0).
777 */
778 var h = 0;
779 var s = 0;
780 var v = Math.max(r, g, b);
781 var d = v - Math.min(r, g, b);
782 if (v != 0) {
783 s = d / v;
784 }
785 if (s != 0) {
786 if (r == v) { h = 0 + (g-b) / d; }
787 else if (g == v) { h = 2 + (b-r) / d; }
788 else { h = 4 + (r-g) / d; }
789 }
790 h = h / 6.0 % 1;
791 return [h, s, v];
792}
793
794function _hsb2rgb(h, s, v) {
795 /* Converts the given H,S,B color values to R,G,B (between 0.0-1.0).

Callers 6

canvas.jsFile · 0.85
darkerFunction · 0.85
lighterFunction · 0.85
analogFunction · 0.85
adjust_hueFunction · 0.85
blendFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…