Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Color Scales

Posted on 2003-12-01
8
274 Views
Last Modified: 2010-05-18
I use both AutoCAD and Photoshop to create maps.  I often have trouble predicting printed results for autocad because it doesnt offer some of the features like monitor calibration etc.  Im not familiar with hex charts or color number charts at all.  Is there a website or something that can help me out.  The color I want to be diplayed in Autocad comes up as FFF9A5, however Autocad uses a number like 255,255,163.  How do I convert FFF9A5 to a number I can use in Autocad.  In general, I find this color matching stuff very confusing.

Thanks,

Bill
0
Comment
Question by:BillPowell
  • 5
  • 3
8 Comments
 
LVL 14

Accepted Solution

by:
spiderfix earned 200 total points
ID: 9854078
You can run this...save in Notepad as *.html

-----------------------  cut  --------------------------
<html>
<head>
<title>color converter</title>
<script language="JavaScript">
redValue = 255;
blueValue = 255;
greenValue = 255;
redForeValue = 0;
blueForeValue = 0;
greenForeValue = 0;
maxValue = 255;
hexValues = new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
i = 0;
function toHex(integer) {
hexDigit1 = Math.floor(integer / 16);
hexDigit2 = (integer % 16);
return hexValues[hexDigit1] + hexValues[hexDigit2];
}
function shiftFG() {
redFGHex = toHex(redForeValue);
blueFGHex = toHex(blueForeValue);
greenFGHex = toHex(greenForeValue);
bigFGHex = redFGHex + greenFGHex + blueFGHex;
document.fgColor = bigFGHex;
document.Interface.fgHex.value = bigFGHex;
document.Interface.redFG.value = redForeValue;
document.Interface.blueFG.value = blueForeValue;
document.Interface.greenFG.value = greenForeValue;
}
function shiftBG() {
redHex = toHex(redValue);
blueHex = toHex(blueValue);
greenHex = toHex(greenValue);
bigHex = redHex + greenHex + blueHex;
document.bgColor = bigHex;
document.Interface.bgHex.value = bigHex;
document.Interface.red.value = redValue;
document.Interface.blue.value = blueValue;
document.Interface.green.value = greenValue;
}
function incrementRed(isBackground) {
if (isBackground == true ) {
redValue = redValue + 8;
if (redValue > maxValue) {
redValue = 0;
}
shiftBG();
}
if (isBackground == false) {
redForeValue = redForeValue + 8;
if (redForeValue > maxValue) {
redForeValue = 0;
}
shiftFG();
   }
}
function decrementRed(isBackground) {
if (isBackground == true) {
redValue = redValue - 8;
if (redValue < 0 ) {
redValue = 255;
}
shiftBG();
}
else {
redForeValue = redForeValue - 8;
if (redForeValue < 0) {
redForeValue = 255;
}
shiftFG();
   }
}
function setRed(value, isBackground) {
if(value > -1 && value < 256) {
if( isBackground == true ) {
redValue = value;
shiftBG();
}
else {
redForeValue = value;
shiftFG();
      }
   }
}
function incrementBlue(isBackground) {
if ( isBackground == true ) {
blueValue = blueValue + 8;
if (blueValue > maxValue) {
blueValue = 0;
}                  
shiftBG();
}
else {
blueForeValue = blueForeValue + 8;
if ( blueForeValue > maxValue ) {
blueForeValue = 0;
}
shiftFG();
   }
}
function decrementBlue(isBackground) {
if (isBackground == true) {
blueValue = blueValue - 8;
if (blueValue < 0) {
blueValue = 255;
}
shiftBG();
}
else {
blueForeValue = blueForeValue - 8;
if (blueForeValue < 0) {
blueForeValue = 255;
}
shiftFG();
   }
}
function setBlue(value, isBackground) {
if (value > -1 && value < 256) {
if ( isBackground == true ) {
blueValue = value;
shiftBG();
}
else {
blueForeValue = value;
shiftFG();
      }
   }
}
function incrementGreen(isBackground) {
if (isBackground == true) {
greenValue = greenValue + 8;
if (greenValue > maxValue) {
greenValue = 0;
}
shiftBG();
}
else {
greenForeValue = greenForeValue + 8;
if (greenForeValue > maxValue) {
greenForeValue = 0;
}
shiftFG();
   }
}
function decrementGreen(isBackground) {
if (isBackground == true) {
greenValue = greenValue - 8;
if (greenValue < 0 ) {
greenValue = 255;
}
shiftBG();
}
else {
greenForeValue = greenForeValue - 8;
if (greenForeValue < 0) {
greenForeValue = 255;
}
shiftFG();
   }
}
function setGreen(value, isBackground) {
if ( value > -1 && value < 256 ) {
if ( isBackground == true ) {
greenValue = value;
shiftBG();
}
else {
greenForeValue = value;
shiftFG();
      }
   }
}
function unHex(string, fgbg) {
hex = string.toUpperCase();
counter = 0;
while (hex.charAt(0) != hexValues[counter])
counter++;
r = 16 * counter;
counter = 0;
while (hex.charAt(1) !=  hexValues[counter])
counter++;
r = r + counter;
counter = 0;
while (hex.charAt(2) != hexValues[counter])
counter++;
g = 16 * counter;
counter = 0;
while (hex.charAt(3) != hexValues[counter])
counter++;
g = g + counter;
counter = 0;
while (hex.charAt(4) != hexValues[counter])
counter++;
b = 16 * counter;
counter = 0;
while (hex.charAt(5) != hexValues[counter])
counter++;
b = b + counter;
if (fgbg == "bg") {
redValue = r;
blueValue = b;
greenValue = g;
document.Interface.red.value = redValue;
document.Interface.blue.value = blueValue;
document.Interface.green.value = greenValue;
}
if (fgbg == "fg") {
redForeValue = r;
blueForeValue = b;
greenForeValue = g;
document.Interface.redFG.value = redForeValue;
document.Interface.blueFG.value = blueForeValue;
document.Interface.greenFG.value = greenForeValue;
   }
}      
function validChar(char) {
for (j = 0; j < hexValues.length; j++) {
if (char == hexValues[j]) {
return true;
   }
}
return false;
}
function isHex(string) {
if (string.length != 6) {
return false;
}
for (k = 0; k < 6; k++) {
if (! validChar(string.charAt(k))) {
return false;
   }
}
return true;
}
function setBGHex(value) {
if (isHex(value.toUpperCase())) {
document.bgColor = value;
unHex(value, "bg");
   }
}
function setFGHex(value) {
if (isHex(value.toUpperCase())) {
document.fgColor = value;
unHex(value, "fg");
   }
}
</script>

</head>
<body>
<center>
<form name=Interface>
<table border=4 cellspacing=0 cellpadding=4>
<tr>
<td colspan=3 align=center>Background</td>
<td><input type=text name=bgHex onKeyup="setBGHex(this.value)"></td>
<td colspan=2 align=center>Foreground</td>
<td><input type=text name=fgHex onKeyup="setFGHex(this.value)"></td>
</tr>
<tr>
<td>Red</td>
<td><input type=button value=" + " onClick="incrementRed(true)"></td>
<td><input type=button value=" - " onClick="decrementRed(true)"></td>
<td><input type=text name="red" onKeyup="setRed(this.value, true)"></td>
<td><input type=button value=" + " onClick="incrementRed(false)"></td>
<td><input type=button value=" - " onClick="decrementRed(false)"></td>
<td><input type=text name=redFG onKeyup="setRed(this.value, false)"></td>
</tr>
<tr>
<td>Green</td>
<td><input type=button value=" + " onClick="incrementGreen(true)"></td>
<td><input type=button value=" - " onClick="decrementGreen(true)"></td>
<td><input type=text name="green" onKeyup="setGreen(this.value, true)"></td>
<td><input type=button value=" + " onClick="incrementGreen(false)"></td>
<td><input type=button value=" - " onClick="decrementGreen(false)"></td>
<td><input type=text name=greenFG onKeyup="setGreen(this.value, false)"></td>
</tr>
<tr>
<td>Blue</td>
<td><input type=button value=" + " onClick="incrementBlue(true)"></td>
<td><input type=button value=" - " onClick="decrementBlue(true)"></td>
<td><input type=text name="blue" onKeyup="setBlue(this.value, true)"></td>
<td><input type=button value=" + " onClick="incrementBlue(false)"></td>
<td><input type=button value=" - " onClick="decrementBlue(false)"></td>
<td><input type=text name=blueFG onKeyup="setBlue(this.value, false)"></td>
</tr>
</table>
</form></center>
</body>
</html>
-----------------------  cut  --------------------------
0
 
LVL 14

Expert Comment

by:spiderfix
ID: 9854115
I just ran that FFF9A5 in the little JavaScript ditty, it converts to
R = 255
G = 249
B = 165
0
 
LVL 11

Author Comment

by:BillPowell
ID: 9854848
OK.  Seems good.  Should there be a button to initiate the conversion.  When I paste FFF9A5 into the box at the top, theres no effect on the RGB values.  However,  if I put values in the RGB boxes, it displays the correct number in the top box.  Am I reading this right.

Bill
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 14

Expert Comment

by:spiderfix
ID: 9855096
The RGB values should show up automatically.

Try my online one and match the source code to the one you made.

http://seafoods.hypermart.net/hex_color/color_converter.html

hypermart is going to throw some popups and/or inject some code
into the page so be aware of that addition of code.
0
 
LVL 11

Author Comment

by:BillPowell
ID: 9855337
OK, I see, your using the onKeyup event.  I was pasting a value into the textbox so the event did not fire unless I type it in manually.
0
 
LVL 14

Expert Comment

by:spiderfix
ID: 9855489
Pasting should be working in those cells as well as typing it out.

What O/S are you using?
What browser?
0
 
LVL 11

Author Comment

by:BillPowell
ID: 9855626
Ive tried this on:

Windows 2000
Windows ME

IE 6

But you know what, I know enough html and javascript to take it from here.  Thanks for your help.

Bill
0
 
LVL 14

Expert Comment

by:spiderfix
ID: 9855682
Sounds good, glad to help.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
make a picture with rounded border and frame 5 187
Using Envelope Distort for Ribbon Effect 3 118
adobe error 2 120
Photoshop ELements on Mac and lighting adjustments 2 97
Introduction When sharing photos, especially via e-mail, the large resolution images that most cameras take today make for extremely large file sizes. The time required to upload these files to forums, send in e-mails, post to blogs or even placi…
Read about why website design really matters in today's demanding market.
In this tutorial viewers will learn how to correct colors in Photoshop using the Hue and Saturation adjustment Open a photo for editing in Photoshop: Begin by creating a new adjustment layer by going to Layer > New Adjustment Layer > Hue and Saturat…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question