Fork of Smoothie to port to mbed non-LPC targets.
Fork of Smoothie by
Colors.h
00001 /* 00002 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 00003 Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 00004 Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 00005 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. 00006 */ 00007 #ifndef COLORS_H 00008 #define COLORS_H 00009 00010 void HSVtoRGB( float *r, float *g, float *b, float h, float s, float v ) 00011 { 00012 int i; 00013 float f, p, q, t; 00014 if( s == 0 ) { 00015 // achromatic (grey) 00016 *r = *g = *b = v; 00017 return; 00018 } 00019 h /= 60.0; // sector 0 to 5 00020 i = floor( h ); 00021 f = h - i; // factorial part of h 00022 p = v * ( 1.0 - s ); 00023 q = v * ( 1.0 - s * f ); 00024 t = v * ( 1.0 - s * ( 1.0 - f ) ); 00025 switch( i ) { 00026 case 0: 00027 *r = v; 00028 *g = t; 00029 *b = p; 00030 break; 00031 case 1: 00032 *r = q; 00033 *g = v; 00034 *b = p; 00035 break; 00036 case 2: 00037 *r = p; 00038 *g = v; 00039 *b = t; 00040 break; 00041 case 3: 00042 *r = p; 00043 *g = q; 00044 *b = v; 00045 break; 00046 case 4: 00047 *r = t; 00048 *g = p; 00049 *b = v; 00050 break; 00051 default: // case 5: 00052 *r = v; 00053 *g = p; 00054 *b = q; 00055 break; 00056 } 00057 } 00058 00059 #endif // COLORS_H 00060
Generated on Tue Jul 12 2022 20:09:00 by 1.7.2