#!/bin/sh # rgb_chart_maker a script to generate color charts in HTML format # Copyright 2002 George Cardin # # This program 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 2 # of the License, or (at your option) any later version. # # This program 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. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. echo Generating RGB color chart, this may take a while. red=0 ; green=0 ; blue=0 ; echo > rgb_chart.html # set variables to 0 and clear output file echo " " >> rgb_chart.html echo " RGB Hex Codes " >> rgb_chart.html echo " " >> rgb_chart.html echo "
" >> rgb_chart.html red_hex () # jury-rig hex conversion, if anyone figures out a better way to do this, please let me know. { if [ $red -eq 10 ] then redvalue=a elif [ $red -eq 11 ] then redvalue=b elif [ $red -eq 12 ] then redvalue=c elif [ $red -eq 13 ] then redvalue=d elif [ $red -eq 14 ] then redvalue=e elif [ $red -eq 15 ] then redvalue=f fi } green_hex () { if [ $green -eq 10 ] then greenvalue=a elif [ $green -eq 11 ] then greenvalue=b elif [ $green -eq 12 ] then greenvalue=c elif [ $green -eq 13 ] then greenvalue=d elif [ $green -eq 14 ] then greenvalue=e elif [ $green -eq 15 ] then greenvalue=f fi } blue_hex () { if [ $blue -eq 10 ] then bluevalue=a elif [ $blue -eq 11 ] then bluevalue=b elif [ $blue -eq 12 ] then bluevalue=c elif [ $blue -eq 13 ] then bluevalue=d elif [ $blue -eq 14 ] then bluevalue=e elif [ $blue -eq 15 ] then bluevalue=f fi } while [ $red -lt 16 ] do echo Red=$red Green=$green Blue=$blue #progress indicator if [ $green -eq 15 ] then if [ $blue -eq 15 ] #no need to calculate totaltint as f+f+? will be 30+ then redvalue=$red red_hex greenvalue=f ; bluevalue=f ; red=`expr $red + 1` ; green=0 ; blue=0 echo "" >> rgb_chart.html echo "" >> rgb_chart.html elif [ $blue -lt 15 ] then redvalue=$red ; greenvalue=f ; bluevalue=$blue ; totaltint=`expr $red + $green + $blue` red_hex blue_hex if [ $totaltint -lt 22 ] # 22 is half way between ie. f+f+f=45 divided by 2 = 22 ( rounded down ) then echo "" >> rgb_chart.html else echo "" >> rgb_chart.html fi blue=`expr $blue + 1` fi elif [ $green -lt 15 ] then if [ $blue -eq 15 ] then redvalue=$red ; greenvalue=$green ; bluevalue=f ; totaltint=`expr $red + $green + $blue` red_hex green_hex if [ $totaltint -lt 22 ] then echo "" >> rgb_chart.html else echo "" >> rgb_chart.html fi echo "" >> rgb_chart.html green=`expr $green + 1` ; blue=0 elif [ $blue -lt 15 ] then redvalue=$red ; greenvalue=$green ; bluevalue=$blue ; totaltint=`expr $red + $green + $blue` red_hex green_hex blue_hex if [ $totaltint -lt 22 ] then echo "" >> rgb_chart.html else echo "" >> rgb_chart.html fi blue=`expr $blue + 1` fi fi done echo "
 "$redvalue"0"$greenvalue"0"$bluevalue"0
 "$redvalue"0"$greenvalue"0"$bluevalue"0 "$redvalue"0"$greenvalue"0"$bluevalue"0 "$redvalue"0"$greenvalue"0"$bluevalue"0 "$redvalue"0"$greenvalue"0"$bluevalue"0
 "$redvalue"0"$greenvalue"0"$bluevalue"0 "$redvalue"0"$greenvalue"0"$bluevalue"0
" >> rgb_chart.html