Revisions
-
strathmeyer revised this gist
Aug 12, 2012 . 1 changed file with 9 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ void HSV_to_RGB(float h, float s, float v, byte &r, byte &g, byte &b) { int i; float f,p,q,t; h = constrain(h, 0.0, 360.0); s = constrain(s, 0.0, 100.0); @@ -9,18 +10,18 @@ void HSV_to_RGB(float h, float s, float v, byte &r, byte &g, byte &b) s /= 100; v /= 100; if (s == 0) { // Achromatic (grey) r = g = b = round(v*255); return; } h /= 60.0; i = floor(h); // sector 0 to 5 f = h - (float)i; // factorial part of h p = v * (1.0 - s); q = v * (1.0 - s * f); t = v * (1.0 - s * (1 - f)); switch(i) { case 0: r = round(255*v); -
strathmeyer revised this gist
Aug 12, 2012 . 1 changed file with 20 additions and 20 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ void HSV_to_RGB(float h, float s, float v, byte &r, byte &g, byte &b) { int i,f,p,q,t; @@ -11,7 +11,7 @@ void HSV_to_RGB(float h, float s, float v, byte *r, byte *g, byte *b) if(s == 0) { // Achromatic (grey) r = g = b = round(v*255); return; } @@ -23,33 +23,33 @@ void HSV_to_RGB(float h, float s, float v, byte *r, byte *g, byte *b) t = v * (1 - s * (1 - f)); switch(i) { case 0: r = round(255*v); g = round(255*t); b = round(255*p); break; case 1: r = round(255*q); g = round(255*v); b = round(255*p); break; case 2: r = round(255*p); g = round(255*v); b = round(255*t); break; case 3: r = round(255*p); g = round(255*q); b = round(255*v); break; case 4: r = round(255*t); g = round(255*p); b = round(255*v); break; default: // case 5: r = round(255*v); g = round(255*p); b = round(255*q); } } -
strathmeyer revised this gist
Aug 12, 2012 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,9 +2,9 @@ void HSV_to_RGB(float h, float s, float v, byte *r, byte *g, byte *b) { int i,f,p,q,t; h = constrain(h, 0.0, 360.0); s = constrain(s, 0.0, 100.0); v = constrain(v, 0.0, 100.0); s /= 100; v /= 100; @@ -52,4 +52,4 @@ void HSV_to_RGB(float h, float s, float v, byte *r, byte *g, byte *b) *g = round(255*p); *b = round(255*q); } } -
hdznrrd revised this gist
Oct 31, 2010 . 1 changed file with 18 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,33 +23,33 @@ void HSV_to_RGB(float h, float s, float v, byte *r, byte *g, byte *b) t = v * (1 - s * (1 - f)); switch(i) { case 0: *r = round(255*v); *g = round(255*t); *b = round(255*p); break; case 1: *r = round(255*q); *g = round(255*v); *b = round(255*p); break; case 2: *r = round(255*p); *g = round(255*v); *b = round(255*t); break; case 3: *r = round(255*p); *g = round(255*q); *b = round(255*v); break; case 4: *r = round(255*t); *g = round(255*p); *b = round(255*v); break; default: // case 5: *r = round(255*v); *g = round(255*p); *b = round(255*q); } } -
hdznrrd created this gist
Oct 31, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,55 @@ void HSV_to_RGB(float h, float s, float v, byte *r, byte *g, byte *b) { int i,f,p,q,t; h = max(0.0, min(360.0, h)); s = max(0.0, min(100.0, s)); v = max(0.0, min(100.0, v)); s /= 100; v /= 100; if(s == 0) { // Achromatic (grey) *r = *g = *b = round(v*255); return; } h /= 60; // sector 0 to 5 i = floor(h); f = h - i; // factorial part of h p = v * (1 - s); q = v * (1 - s * f); t = v * (1 - s * (1 - f)); switch(i) { case 0: *r = v; *g = t; *b = p; break; case 1: *r = q; *g = v; *b = p; break; case 2: *r = p; *g = v; *b = t; break; case 3: *r = p; *g = q; *b = v; break; case 4: *r = t; *g = p; *b = v; break; default: // case 5: *r = v; *g = p; *b = q; } }