Closed Thread Icon

Topic awaiting preservation: loop through every color (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8428" title="Pages that link to Topic awaiting preservation: loop through every color (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: loop through every color <span class="small">(Page 1 of 1)</span>\

 
maninacan
Paranoid (IV) Inmate

From: Seattle, WA, USA
Insane since: Oct 2001

posted posted 12-08-2002 05:24

OK, so I would like to know how to loop through every color. You know how on some of those really annoying pages they have the background loop through every color, well that's what I want. Not to change the background, but to loop through every color. I'm not sure how I would go about it, can anyone help me?

behmer - Google Bomb, for my dad's site.
kewlster

HZR
Bipolar (III) Inmate

From: Cold Sweden
Insane since: Jul 2002

posted posted 12-08-2002 10:36

Every color? That's several million colors on a computer.

Nevel
Bipolar (III) Inmate

From: Amsterdam
Insane since: Jun 2002

posted posted 12-08-2002 12:27

Except it isn't several million colors, because HTML can't handle so many colors.
I guess you'll have to find a way to walk trough all different combinations in a way that fits the transistion you desire. Hexadecimal numbers always seem to do the trick.

Every color consists of three different teints(from 0 to F, F being actually nr 14). You can alter anyone of them to change the color you want to generate.

Hope this helps, I've just awoken and stuff .

HZR
Bipolar (III) Inmate

From: Cold Sweden
Insane since: Jul 2002

posted posted 12-08-2002 12:32

Oh, yea, sorry...

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 12-08-2002 17:51

Well, what he most likely wants is to loop through every *hue*, not every single shade of every hue.

here's how I would do it:

var col=.5 // number between 0 and 1 that specifies how far through the color cycle
var red=0;
var green=0;
var blue=0;

if (col < 1/6)
{
red=255;
green = (col/(1/6)) * 255;
}
else if (col < 2/6)
{
green=255;
red=255-((col-1/6)/(1/6))*255;
}
else if (col < 3/6)
{
green=255;
blue=((col-2/6)/(1/6))*255;
}
else if (col < 4/6)
{
blue=255;
green=255-((col-3/6)/(1/6))*255;
}
else if (col < 5/6)
{
blue=255;
red=((col-4/6)/(1/6))*255;
}
else
{
red=255;
blue=255-((col-5/6)/(1/6))*255;
}
red=Math.round(red);
green=Math.round(green);
blue=Math.round(blue);

maninacan
Paranoid (IV) Inmate

From: Seattle, WA, USA
Insane since: Oct 2001

posted posted 12-08-2002 21:30

hmm, I'll have to look through your code some more slime. But actually it's not on a computer, and it's sorta hard to explain, but every color is assigned a red, green, and blue, and each of those can be between 0 and 31 (in decimal). Maybe Slime's code will do it, I'll have to look at it some more.

behmer - Google Bomb, for my dad's site.
kewlster

« BackwardsOnwards »

Show Forum Drop Down Menu