2 /** Author: Tyler Akins
9 // Note: The text distance is actually pre-squared
10 // Background range is from 24-64, all three colors are the same
11 // Text range is from 196 to 255
12 $BackgroundTargetDistance = 12;
13 $BackgroundAdjust = 1;
14 $TextTargetDistance = 65536;
17 function IsUnique($Distance, $r, $g, $b, $usedArray)
19 foreach ($usedArray as $data) {
20 $a = abs($data[0] - $r);
21 $b = abs($data[1] - $g);
22 $c = abs($data[2] - $b);
23 $newDistance = $a * $a +
$b * $b +
$c * $c;
24 if ($newDistance < $Distance)
31 // Extra spiffy page fade if left frame
32 // Always tremble background
33 // This might make people go insane. Yes! *Victory dance!*
34 function Darkness_HeaderPlugin() {
35 global $PHP_SELF, $Darkness_Transition;
37 if (substr($PHP_SELF, -18) == "/src/left_main.php") {
38 echo '<meta http-equiv="Page-Enter" content="' .
39 'blendTrans(Duration=2.0)">' . "\n";
42 ?
><script language
=javascript
>
45 darkness_hex
= new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
46 "A", "B", "C", "D", "E", "F");
47 function DarknessTremble() {
48 if (darkness_color
>= 32 || darkness_color
<= 0)
49 darkness_dir
= - darkness_dir
;
50 darkness_color +
= darkness_dir
;
51 if (darkness_color
< 0)
53 bigDigit
= Math
.floor(darkness_color
/ 16);
54 littleDigit
= darkness_color
- (bigDigit
* 16);
55 Color
= darkness_hex
[bigDigit
] + darkness_hex
[littleDigit
];
56 document
.bgColor
="#" + Color + Color + Color
;
57 setTimeout("DarknessTremble()", 5000);
59 setTimeout("DarknessTremble()", 10000);
64 global $squirrelmail_plugin_hooks;
65 $squirrelmail_plugin_hooks['generic_header']['theme_darkness'] =
66 'Darkness_HeaderPlugin';
68 /** seed the random number generator **/
71 $color[3] = "#000000";
72 $color[4] = "#000000";
74 $targetDistance = $BackgroundTargetDistance;
75 $Left = array(0, 5, 9, 10, 12);
76 while (count($Left) > 0) {
77 // Some background colors
80 foreach ($used as $col) {
81 if (abs($r - $col) < $targetDistance)
85 $i = array_shift($Left);
86 $color[$i] = sprintf("#%02X%02X%02X",$r,$r, $r);
88 $targetDistance = $BackgroundTargetDistance;
90 $targetDistance -= $BackgroundAdjust;
94 // Set the error color to some shade of red
95 $r = mt_rand(196, 255);
96 $g = mt_rand(144, ($r * .8));
97 $color[2] = sprintf("#%02X%02X%02X", $r, $g, $g);
98 $used = array(array($r, $g, $g));
100 // Set normal text colors
103 foreach (array(6, 8) as $i) {
104 /** generate random color **/
105 $r = mt_rand($cmin,$cmax);
106 $g = mt_rand($cmin,$cmax);
107 $b = mt_rand($cmin,$cmax);
108 $color[$i] = sprintf("#%02X%02X%02X",$r,$g,$b);
109 $used[] = array($r, $g, $b);
112 $Left = array(1, 7, 11, 13, 14, 15);
113 $targetDistance = $TextTargetDistance;
114 while (count($Left) > 0) {
115 // Text colors -- Try to keep the colors distinct
119 /** generate random color **/
120 $r = mt_rand($cmin,$cmax);
121 $g = mt_rand($cmin,$cmax);
122 $b = mt_rand($cmin,$cmax);
124 if (IsUnique($targetDistance, $r, $g, $b, $used)) {
125 $i = array_shift($Left);
126 $color[$i] = sprintf("#%02X%02X%02X",$r,$g,$b);
127 $used[] = array($r, $g, $b);
128 $targetDistance = $TextTargetDistance;
130 $targetDistance *= $TextAdjust;
135 /** Reference from doc/themes.txt
137 b 0: Title Bar at the top of the page header
138 f 1: <not currently used>
139 f 2: Error messages, usually red
140 b 3: Left folder list background color
141 b 4: Normal background color
142 b 5: Header of the message index [From, Date, Subject]
143 f 6: Normal text on the left folder list
144 f 7: Links in the right frame, Folders with subfolders in left frame
145 f 8: Normal text [usually black]
146 b 9: Darker version of #0
147 b 10: Darker version of #9
148 f 11: Special folders color [Inbox, Trash, Sent]
149 b 12: Alternate color for message list [alters between 4 and this one]
150 f 13: Color for single-quoted text ("> text") when reading (default: #800000)
151 f 14: Color for text with more than one quote (default: #FF0000)