JS Bug! Please Reload!


by Golf 464
The text box for C/C/P the codes is here. Please copy the codes and put them in your file manager. Then print out the explanation and read as you follow the codes.

Explanation: The variable NC produces the random color from the sets of color codes in the Array by mixing and matching to produce different colors.

Also when using the NC variable in a code

example: rightcolor="'+NC+'" leftcolor="'+(Math.random()*NC)+'" bgcolor="'+NC+'" gradcolor="'+(Math.random()*NC)+'"

The first one is NC and the second is random NC. This has to be done because the NC color code produces one color code at a time and if you don't do this both color codes will produce the same color at the same time.

Here's the explanation for the script and added commentary that might help understand the script better. Gary

<script>
for(a=0;a<=30;a++){
var p = new Array(6); p[0] = "00"; p[1] = "33"; p[2] = "66"; p[3] = "99"; p[4] = "cc"; p[5] = "ff";


This tells webtv / computer there are 6 items in the array or list for the script to choose data from.

Now each one of these (Var j,k,l) are for the color code. Since the color code is made up of 6 letters/numbers or 3 sets of 2 letters/numbers in the array I broke down the usage of each variable below.

j = Math.floor(Math.random()*6);
k = Math.floor(Math.random()*6);
l = Math.floor(Math.random()*6);

var j
is for the first two letters or numbers in the color code.
example: 00XXXX, 33XXXX, 66XXXX, 99XXXX, CCXXXX, FFXXXX

var k is for the second set of two letters or numbers in the color code.
example: XX00XX, XX33XX, XX66XX, XX99XX, XXCCXX, XXFFXX

var l is for the last set of letters or numbers in the color code.
example: XXXX00, XXXX33, XXXX66, XXXX99, XXXXCC, XXXXFF

Now each variable needs to be randomized to give you a random number. Using Math.floor or Math.round or just plain old Math.random, depends on the application. Since, I'm using predetermined numbers and letters the proper usage for this is Math.floor(Math.random()*6), but like you pointed out, I mixed my usage of (Math.random()*6) which is also correct.

Math.floor and Math.round are types of random. You can use either, or none at all. It just boils down basically on how you use it in the application for the desired effect that you want.

You can get away with using this, it works equally well. But without the Math.floor to make it more evenly distributed you might get more of the same colors in a row.

j = (Math.random()*6);
k = (Math.random()*6);
l = (Math.random()*6);
NC1 = p[j]; NC2 = p[k]; NC3 = p[l];


Now it is time to put the variables to work.

p is the array and [j] [k] [l] are the random letters/numbers the webtv/computer is to choose from inside that array.

NC1 =p[j]; this part of the code sets the first set of random letter/numbers to make the color code.

NC2 =p[k]; this part of the code sets the second set of random letter/numbers to make the color code.

NC3 =p[l]; this part of the code sets the third set of random letter/numbers to make the color code.

NC = NC1 + NC2 + NC3

The new color or NC is produced when the 3 random variables or color codes are added together.

example: 00+CC+00=00CC00, FF+33+CC=FF33CC, and so on.


EXAMPLE

Random Color Scopes

Back to Index