ccd202b0152fbff69521b8f7f86ee423211e8653
4 * Theme Name: 'Darkness'
8 * @copyright © 2001-2007 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @package squirrelmail
16 * Load up the usual suspects.. */
17 require_once(SM_PATH
. 'functions/strings.php');
19 // Note: The text distance is actually pre-squared
20 // Background range is from 24-64, all three colors are the same
21 // Text range is from 196 to 255
22 $BackgroundTargetDistance = 12;
23 $BackgroundAdjust = 1;
24 $TextTargetDistance = 65536;
27 function IsUnique($Distance, $r, $g, $b, $usedArray)
29 foreach ($usedArray as $data) {
30 $a = abs($data[0] - $r);
31 $b = abs($data[1] - $g);
32 $c = abs($data[2] - $b);
33 $newDistance = $a * $a +
$b * $b +
$c * $c;
34 if ($newDistance < $Distance)
41 // Extra spiffy page fade if left frame
42 // Always tremble background
43 // This might make people go insane. Yes! *Victory dance!*
44 function Darkness_HeaderPlugin() {
47 if (substr($PHP_SELF, -18) == '/src/left_main.php') {
48 echo '<meta http-equiv="Page-Enter" content="' .
49 'blendTrans(Duration=2.0)" />' . "\n";
52 ?
><script type
="text/javascript">
55 darkness_hex
= new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
56 'a', 'b', 'c', 'd', 'e', 'f');
57 function DarknessTremble() {
58 if (darkness_color
>= 32 || darkness_color
<= 0)
59 darkness_dir
= - darkness_dir
;
60 darkness_color +
= darkness_dir
;
61 if (darkness_color
< 0)
63 bigDigit
= Math
.floor(darkness_color
/ 16);
64 littleDigit
= darkness_color
- (bigDigit
* 16);
65 Color
= darkness_hex
[bigDigit
] + darkness_hex
[littleDigit
];
66 document
.bgColor
='#' + Color + Color + Color
;
67 setTimeout('DarknessTremble()', 5000);
69 setTimeout('DarknessTremble()', 10000);
74 global $squirrelmail_plugin_hooks;
75 $squirrelmail_plugin_hooks['generic_header']['theme_darkness'] =
76 'Darkness_HeaderPlugin';
78 /** seed the random number generator **/
81 $color[3] = '#000000';
82 $color[4] = '#000000';
84 $targetDistance = $BackgroundTargetDistance;
85 $Left = array(0, 5, 9, 10, 12);
86 while (count($Left) > 0) {
87 // Some background colors
90 foreach ($used as $col) {
91 if (abs($r - $col) < $targetDistance)
95 $i = array_shift($Left);
96 $color[$i] = sprintf('#%02X%02X%02X',$r,$r, $r);
98 $targetDistance = $BackgroundTargetDistance;
100 $targetDistance -= $BackgroundAdjust;
104 // Set the error color to some shade of red
105 $r = mt_rand(196, 255);
106 $g = mt_rand(144, ($r * .8));
107 $color[2] = sprintf('#%02X%02X%02X', $r, $g, $g);
108 $used = array(array($r, $g, $g));
110 // Set normal text colors
113 foreach (array(6, 8) as $i) {
114 /** generate random color **/
115 $r = mt_rand($cmin,$cmax);
116 $g = mt_rand($cmin,$cmax);
117 $b = mt_rand($cmin,$cmax);
118 $color[$i] = sprintf('#%02X%02X%02X',$r,$g,$b);
119 $used[] = array($r, $g, $b);
122 $Left = array(1, 7, 11, 13, 14, 15);
123 $targetDistance = $TextTargetDistance;
124 while (count($Left) > 0) {
125 // Text colors -- Try to keep the colors distinct
129 /** generate random color **/
130 $r = mt_rand($cmin,$cmax);
131 $g = mt_rand($cmin,$cmax);
132 $b = mt_rand($cmin,$cmax);
134 if (IsUnique($targetDistance, $r, $g, $b, $used)) {
135 $i = array_shift($Left);
136 $color[$i] = sprintf('#%02X%02X%02X',$r,$g,$b);
137 $used[] = array($r, $g, $b);
138 $targetDistance = $TextTargetDistance;
140 $targetDistance *= $TextAdjust;