void LLFloaterColorPicker::hslToRgb ( F32 hValIn, F32 sValIn, F32 lValIn, F32& rValOut, F32& gValOut, F32& bValOut ) { if ( sValIn < 0.00001f ) { rValOut = lValIn; gValOut = lValIn; bValOut = lValIn; } else { F32 interVal1; F32 interVal2; if ( lValIn < 0.5f ) interVal2 = lValIn * ( 1.0f + sValIn ); else interVal2 = ( lValIn + sValIn ) - ( sValIn * lValIn ); interVal1 = 2.0f * lValIn - interVal2; rValOut = hueToRgb ( interVal1, interVal2, hValIn + ( 1.f / 3.f ) ); gValOut = hueToRgb ( interVal1, interVal2, hValIn ); bValOut = hueToRgb ( interVal1, interVal2, hValIn - ( 1.f / 3.f ) ); } }
void LLColor3::setHSL ( F32 hValIn, F32 sValIn, F32 lValIn) { if ( sValIn < 0.00001f ) { mV[VRED] = lValIn; mV[VGREEN] = lValIn; mV[VBLUE] = lValIn; } else { F32 interVal1; F32 interVal2; if ( lValIn < 0.5f ) interVal2 = lValIn * ( 1.0f + sValIn ); else interVal2 = ( lValIn + sValIn ) - ( sValIn * lValIn ); interVal1 = 2.0f * lValIn - interVal2; mV[VRED] = hueToRgb ( interVal1, interVal2, hValIn + ( 1.f / 3.f ) ); mV[VGREEN] = hueToRgb ( interVal1, interVal2, hValIn ); mV[VBLUE] = hueToRgb ( interVal1, interVal2, hValIn - ( 1.f / 3.f ) ); } }
int main(void) { struct winsize w; ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); int i = w.ws_col; int h = w.ws_row; //h = 1; int a[3]; int shift = map(1, w.ws_col, 360); while(h--) { while(i--) { hueToRgb(map(i, w.ws_col, 360)+h*shift, a); printf("\e[48;5;%im ", rgb8ToConsole(a)); //printf("R: %i, G: %i, B:%i, hue: %i\n", a[r], a[g], a[b], map(i, w.ws_col, 360)); } i = w.ws_col; }