Main Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Mark

General Discussion / Re: Color
January 23, 2012, 07:18:18 PM
Here is one way to do it in JavaScript.

<script type="text/javascript">
var intRed=Math.floor(Math.random()*256) // generates a random number between 0 and 255
var intGreen=Math.floor(Math.random()*256)
var intBlue=Math.floor(Math.random()*256)
var strHexRed = intRed.toString(16); // converts the number to hex
var strHexGreen = intGreen.toString(16);
var strHexBlue = intBlue.toString(16);
// make the value two characters wide so red, green, and blue each take two characters in the RGB value
if (strHexRed.length == 1) { strHexRed="0"+strHexRed; }
if (strHexGreen.length == 1) { strHexGreen="0"+strHexGreen; }
if (strHexBlue.length == 1) { strHexBlue="0"+strHexBlue; }
var strRGB=strHexRed+strHexGreen+strHexBlue; // joins the three string vales to make a RGB value
document.write("The background page color is "+strRGB+"\n");
General Discussion / Re: Color
June 07, 2008, 05:18:26 PM
Here is one way you can randomly change the background color in PHP.

print "<html>\n";
$intRed rand(0,255); // generates a random number between 0 and 255
$intGreen rand(0,255);
$intBlue rand(0,255);
$hexRed dechex($intRed+0); // converts the number to hex
$hexGreen dechex($intGreen+0);
$hexBlue dechex($intBlue+0);
// makes the value two characters wide so red, green, and blue each take two characters in the RGB value
if (strlen($strRed) == 1) { $strRed="0".$strRed; }
if (
strlen($strGreen) == 1) { $strGreen="0".$strGreen; }
if (
strlen($strBlue) == 1) { $strBlue="0".$strBlue; }
$hexRGB=$strRed.$strGreen.$strBlue// joins the three string vales to make a RGB value
print "<body bgcolor=$hexRGB>\n";
"The background page color is $hexRGB\n";