#!/bin/bash exec {bcout}<> <(:) exec {bcin}> >(exec stdbuf -o0 bc >&$bcout) cat >&$bcin < g) { if (g < b) { min=g } else { min=b } if (r > b) { max=r } else { max=b } } else { if (r < b) { min=r } else { min=b } if (g > b) { max=g } else { max=b } } scale=0 if (max > min) { if (max == r) { t= ( 60 * ( g - b ) / ( max - min ) + 360 ) % 360 } else if (max == g) { t= 60 * ( b - r ) / ( max - min ) + 120 } else { t= 60 * ( r - g ) / ( max - min ) + 240 } } scale=20 if ( max > 0 ) { s= 1 - ( min / max ) } scale=0 print t/1," ",s," ",max,"\n" scale=20 } eohsvrgbinit rgb() { local -n _re=$4;echo >&$bcin "rgb($1,$2,$3)";read -u $bcout -t 3 -ra _re;} hsv() { local -n _re=$4;echo >&$bcin "hsv($1,$2,$3)";read -u $bcout -t 3 -ra _re;}