4 * Theme Name: 'Darkness'
8 * @copyright 2001-2020 The SquirrelMail Project Team
9 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @package squirrelmail
15 // Note: The text distance is actually pre-squared
16 // Background range is from 24-64, all three colors are the same
17 // Text range is from 196 to 255
18 $BackgroundTargetDistance = 12;
19 $BackgroundAdjust = 1;
20 $TextTargetDistance = 65536;
23 function IsUnique($Distance, $r, $g, $b, $usedArray)
25 foreach ($usedArray as $data) {
26 $a = abs($data[0] - $r);
27 $b = abs($data[1] - $g);
28 $c = abs($data[2] - $b);
29 $newDistance = $a * $a +
$b * $b +
$c * $c;
30 if ($newDistance < $Distance)
37 // Extra spiffy page fade if left frame
38 // Always tremble background
39 // This might make people go insane. Yes! *Victory dance!*
40 function Darkness_HeaderPlugin() {
42 if (defined('PAGE_NAME') && PAGE_NAME
=='left_main') {
43 echo '<meta http-equiv="Page-Enter" content="' .
44 'blendTrans(Duration=2.0)" />' . "\n";
47 ?
><script type
="text/javascript">
50 darkness_hex
= new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
51 'a', 'b', 'c', 'd', 'e', 'f');
52 function DarknessTremble() {
53 if (darkness_color
>= 32 || darkness_color
<= 0)
54 darkness_dir
= - darkness_dir
;
55 darkness_color +
= darkness_dir
;
56 if (darkness_color
< 0)
58 bigDigit
= Math
.floor(darkness_color
/ 16);
59 littleDigit
= darkness_color
- (bigDigit
* 16);
60 Color
= darkness_hex
[bigDigit
] + darkness_hex
[littleDigit
];
61 document
.bgColor
='#' + Color + Color + Color
;
62 setTimeout('DarknessTremble()', 5000);
64 setTimeout('DarknessTremble()', 10000);
69 global $squirrelmail_plugin_hooks;
70 $squirrelmail_plugin_hooks['generic_header']['theme_darkness'] =
71 'Darkness_HeaderPlugin';
73 $color[3] = '#000000';
74 $color[4] = '#000000';
76 $targetDistance = $BackgroundTargetDistance;
77 $Left = array(0, 5, 9, 10, 12);
78 while (count($Left) > 0) {
79 // Some background colors
82 foreach ($used as $col) {
83 if (abs($r - $col) < $targetDistance)
87 $i = array_shift($Left);
88 $color[$i] = sprintf('#%02X%02X%02X',$r,$r, $r);
90 $targetDistance = $BackgroundTargetDistance;
92 $targetDistance -= $BackgroundAdjust;
96 // Set the error color to some shade of red
97 $r = mt_rand(196, 255);
98 $g = mt_rand(144, ($r * .8));
99 $color[2] = sprintf('#%02X%02X%02X', $r, $g, $g);
100 $used = array(array($r, $g, $g));
102 // Set normal text colors
105 foreach (array(6, 8) as $i) {
106 /** generate random color **/
107 $r = mt_rand($cmin,$cmax);
108 $g = mt_rand($cmin,$cmax);
109 $b = mt_rand($cmin,$cmax);
110 $color[$i] = sprintf('#%02X%02X%02X',$r,$g,$b);
111 $used[] = array($r, $g, $b);
114 $Left = array(1, 7, 11, 13, 14, 15);
115 $targetDistance = $TextTargetDistance;
116 while (count($Left) > 0) {
117 // Text colors -- Try to keep the colors distinct
121 /** generate random color **/
122 $r = mt_rand($cmin,$cmax);
123 $g = mt_rand($cmin,$cmax);
124 $b = mt_rand($cmin,$cmax);
126 if (IsUnique($targetDistance, $r, $g, $b, $used)) {
127 $i = array_shift($Left);
128 $color[$i] = sprintf('#%02X%02X%02X',$r,$g,$b);
129 $used[] = array($r, $g, $b);
130 $targetDistance = $TextTargetDistance;
132 $targetDistance *= $TextAdjust;