Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Color Scales

Posted on 2003-12-01
8
Medium Priority
?
278 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
[X]
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
  • 5
  • 3
8 Comments
 
LVL 14

Accepted Solution

by:
spiderfix earned 800 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

HOW TO CREATE A WEB 2.0 IMAGE WITH A REFLECTION I would like to start by saying I know Web 2.0 isn't a style. It is actually the practice of information sharing or  collaboration on the Web. It is also associated with the technology that is used …
The Summer 2017 Scholarship Winners have been announced!
In this tutorial viewers will learn how to select a color range in Photoshop and how to easily apply them to multiple projects. Open an image for editing in Photoshop: Open the select Color Range Selection tool by going to Select > Color Range: Sele…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Suggested Courses

715 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