hwg-graphics archives | Feb 1998 | new search | results | previous | next |
Re: hexidecimal colorsby "Andrew Folkins" <afolkins(at)networkx.com> |
|
On Mon, 16 Feb 1998 21:27:49 -0600, "Shay" <shay(at)wcnet.net> wrote: > Peter > > Unfortunately I know nothing about Corel PhotoPaint 5 - though I have Corel > PhotoPaint 7 on my pc, I never use it - However, I have a little program, > called ColorHexer, (about 480K zipped) that'll decode RGB values and give > you a hex output - It's a great little side kick and it's the only thing it > does. If you're interested in this, let me know privately and I'll send it > to you. Little? Four hundred and eighty thousand bytes?? Archived??? (Insert expression of shocked disbelief.) What the #^&@ was it written in? In any decent language, it should only be about ten lines of code (and on any decent O/S about a 4k executable, but I digress). Here - free yourself up some disk space: <HTML> <HEAD> <TITLE>RGB - Hex converter</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- // Author: Andrew Folkins (afolkins(at)networkx.com) // You may bend, fold or mutilate this code any way you want, but if // you make a million bucks off it buy me a beer. function hex2rgb(form) { var hexStr = "" + form.hex.value; if (hexStr.length == 6) { form.red.value = parseInt("0x" + hexStr.substring(0, 2)); form.green.value = parseInt("0x" + hexStr.substring(2, 4)); form.blue.value = parseInt("0x" + hexStr.substring(4, 6)); } } function toHex(dec) { var hexChars = "0123456789ABCDEF"; if (dec < 0 || dec > 255) return("--"); var t = dec % 16; return(hexChars.charAt((dec - t) / 16) + hexChars.charAt(t)); } function rgb2hex(form) { form.hex.value = toHex(form.red.value) + toHex(form.green.value) + toHex(form.blue.value); } // --> </SCRIPT> </HEAD> <P> <FORM NAME="convertForm"> <TABLE> <TR> <TD> R <INPUT TYPE="text" NAME="red" SIZE=6 VALUE="0"><BR> G <INPUT TYPE="text" NAME="green" SIZE=6 VALUE="0"><BR> B <INPUT TYPE="text" NAME="blue" SIZE=6 VALUE="0"> </TD> <TD> <INPUT TYPE="button" NAME="hex2rgbButton" VALUE=" <-- " onClick="hex2rgb(this.form); return false"> <BR> <INPUT TYPE="button" NAME="rgb2hexButton" VALUE=" --> " onClick="rgb2hex(this.form); return false"> </TD> <TD> Hex <INPUT TYPE="text" NAME="hex" SIZE=10 VALUE="000000"> </TD> </TR> <TR> <TD COLSPAN=3><INPUT TYPE="reset"></TD> </TR> </TABLE> </FORM> </BODY> </HTML> -- Andrew Folkins afolkins(at)networkx.com http://www.networkx.com/afolkins Networks Research www.networkx.com
HWG: hwg-graphics mailing list archives, maintained by Webmasters @ IWA