PDA

View Full Version : Displaying all hexidecimal colors...


Mhtml
11-13-2002, 03:40 AM
I have had a go at making a script to list all the hexcidecimal colors, I can easily get the non letter codes but getting ones with letters has me stumped.


<%
'MyArray = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", 1, 2, 3, 4, 5, 6, 7, 8, 9, 0)
for i = 00 to 99
response.write("<input onMouseover="&chr(34)&"ChangeColors(this.style.backgroundColor , this.style.backgroundColor)"&chr(34)&" class="&chr(34)&"this"&chr(34) & " style="&chr(34)&"background-color:0000"&i&""&chr(34)&">")
next
Response.Write("<br>")
for i = 00 to 99
response.write("<input onMouseover="&chr(34)&"ChangeColors(this.style.backgroundColor , this.style.backgroundColor)"&chr(34)&" class="&chr(34)&"this"&chr(34) & " style="&chr(34)&"background-color:00"&i&"00"&chr(34)&">")
next
Response.Write("<br>")
for i = 00 to 99
response.write("<input onMouseover="&chr(34)&" ChangeColors(this.style.backgroundColor , this.style.backgroundColor)"&chr(34)&" class="&chr(34)&"this"&chr(34) & " style="&chr(34)&"background-color:"&i&"0000"&chr(34)&">")
next
Response.Write("<br>")
%>
<style>
.this{border-style:none;height:13;width:5}
.that{border-style:none;}
</style>
<br><br>
<script>
function ChangeColors(CT , CBC){
cc.value = CT ;
ccc.style.backgroundColor = CBC ;
}
</script>
Hexidecimal code / color:
<input id="cc" class="that"><input id="ccc" class="that">


You can see at the top of my code I made an array, I know there has to be a way to cycle through each letter and number combination...

like it picks out the letter a and then writes aa ab ac ad ae etc until it has gone through each combination.

Also is there a way to stop the page loading until all of the fields have been placed on the page?

Roy Sinclair
11-13-2002, 04:13 PM
You should be aware that the "letters" only include "ABCDEF" and not the whole alphabet. You also don't need to include char(34) to get an inline double-quote, all you need to do is place two double quote marks in a row:

<% response.write ("<input type=""text"">")

Next you should know that the range of values is #000000 to #FFFFFF so you need six nested loops to run through the full range of possible values for each character in the code. Last is a simple note that 16 x 16 x 16 x 16 x 16 x16 is a very, very large number and your generated web page will be unmanagably huge. This project is simply not going to work.

whammy
11-13-2002, 11:51 PM
Wow, I can't even count that high. ;)

If you're going to do it, I might suggest doing the so-called "web safe" palette (although modern browsers should support just about any hexadecimal color, I would think)... that should shorten the size a bit, at any rate, although I'm not exactly sure what the formula is for a valid "web safe" color. If you're interested you might want to do some "google" research. ;)

oracleguy
11-14-2002, 02:55 AM
Just some intresting pages worth looking at:

For web safe color listing:
http://www.w3schools.com/css/css_colors.asp

And...

http://www.w3schools.com/css/css_colornames.asp

:)

whammy
11-14-2002, 02:59 AM
Wow, my favorite site rears its head again! ;)

glenngv
11-14-2002, 03:47 AM
try this nice little script :)


<%
response.buffer=true
max = 10 'max is 255
for i=0 to max
for j=0 to max
for k=0 to max
hexval = hex(RGB(i, j, k))
hexcol = cstr(hexval)
if len(hexcol)<6 then
hexcol = hexcol & mid("00000",1,6-len(hexcol))
end if
response.write("<font color='#" & hexcol & "'><b>RGB(" & i & "," & j & "," & k & ") = #" & hexcol & "</b></font><br>" & VbCrLf)
response.flush
next
next
next
%>


Note that RGB values range from 0 to 255, therefore there are 256*256*256 = 16,777,215 different color permutations. So for the purpose of demonstration, I set max to just 10

ReyN
11-16-2002, 02:23 PM
okay

here's one (http://aspalliance.com/aspxtreme/aspnet/syntax/props/colortable.aspx) done in ASP.NET. :D

Mhtml
11-19-2002, 01:22 AM
I haven't been able to connect to the net for a while so I tinkered around using RGB and HEx but could only get 3/4s of the colors.

In the end I realised I had to increase green by 1 each time red got to 255 and the once green was at 2 start blue counting up by 1 .....How to do it? I have no idea. lol :)

I have a better color picker now anyway, I got it from flashkit it is fairly small and loads as if it is a .gif it is that quick.

I don't even think I will use a color picker in the end..