- /** seed the random number generator **/
- sq_mt_randomize();
-
- $color[3] = "#000000";
- $color[4] = "#000000";
- $used = array(array(0, 0, 0));
- $targetDistance = $TargetDistance;
- $Left = array(0, 5, 9, 10, 12);
- while (count($Left) > 0) {
- // Some background colors
- $r = mt_rand(32,64);
- $g = $r;
- $b = $r;
- if (IsUnique($targetDistance, $r, $g, $b, $used)) {
- $i = array_shift($Left);
- $color[$i] = sprintf("#%02X%02X%02X",$r,$g,$b);
- $used[] = array($r, $g, $b);
- $targetDistance = $TargetDistance;
- } else {
- $targetDistance *= 0.9;
- }
- }
-
- // Set the error color to some shade of red
- $r = mt_rand(196, 255);
- $g = mt_rand(144, ($r * .8));
- $color[2] = sprintf("#%02X%02X%02X", $r, $g, $g);
- $used = array(array($r, $g, $g));
-
- // Set normal text colors
- $cmin = 196;
- $cmax = 255;
- foreach (array(6, 8) as $i) {
- /** generate random color **/
- $r = mt_rand($cmin,$cmax);
- $g = mt_rand($cmin,$cmax);
- $b = mt_rand($cmin,$cmax);
- $color[$i] = sprintf("#%02X%02X%02X",$r,$g,$b);
- $used[] = array($r, $g, $b);
- }
-
- $Left = array(1, 7, 11, 13, 14, 15);
- $targetDistance = $TargetDistance;
- while (count($Left) > 0) {
- // Text colors -- Try to keep the colors distinct
- $cmin = 196;
- $cmax = 255;
-
- /** generate random color **/
- $r = mt_rand($cmin,$cmax);
- $g = mt_rand($cmin,$cmax);
- $b = mt_rand($cmin,$cmax);
-
- if (IsUnique($targetDistance, $r, $g, $b, $used)) {
- $i = array_shift($Left);
- $color[$i] = sprintf("#%02X%02X%02X",$r,$g,$b);
- $used[] = array($r, $g, $b);
- $targetDistance = $TargetDistance;
- } else {
- $targetDistance *= 0.9;
- }
- }