source: trunk/client/modules/Elezioni/grafici/jpgraph_rgb.inc.php@ 28

Last change on this file since 28 was 2, checked in by root, 15 years ago

importo il progetto

File size: 19.9 KB
Line 
1<?php
2//=======================================================================
3// File: JPGRAPH_RGB.INC.PHP
4// Description: Class to handle RGb color space specification and
5// named colors
6// Created: 2001-01-08 (Refactored to separate file 2008-08-01)
7// Ver: $Id: jpgraph_rgb.inc.php 1049 2008-08-01 19:58:07Z ljp $
8//
9// Copyright (c) Aditus Consulting. All rights reserved.
10//========================================================================
11
12
13//===================================================
14// CLASS RGB
15// Description: Color definitions as RGB triples
16//===================================================
17class RGB {
18 public $rgb_table;
19 public $img;
20
21 function RGB($aImg=null) {
22 $this->img = $aImg;
23
24 // Conversion array between color names and RGB
25 $this->rgb_table = array(
26 "aqua"=> array(0,255,255),
27 "lime"=> array(0,255,0),
28 "teal"=> array(0,128,128),
29 "whitesmoke"=>array(245,245,245),
30 "gainsboro"=>array(220,220,220),
31 "oldlace"=>array(253,245,230),
32 "linen"=>array(250,240,230),
33 "antiquewhite"=>array(250,235,215),
34 "papayawhip"=>array(255,239,213),
35 "blanchedalmond"=>array(255,235,205),
36 "bisque"=>array(255,228,196),
37 "peachpuff"=>array(255,218,185),
38 "navajowhite"=>array(255,222,173),
39 "moccasin"=>array(255,228,181),
40 "cornsilk"=>array(255,248,220),
41 "ivory"=>array(255,255,240),
42 "lemonchiffon"=>array(255,250,205),
43 "seashell"=>array(255,245,238),
44 "mintcream"=>array(245,255,250),
45 "azure"=>array(240,255,255),
46 "aliceblue"=>array(240,248,255),
47 "lavender"=>array(230,230,250),
48 "lavenderblush"=>array(255,240,245),
49 "mistyrose"=>array(255,228,225),
50 "white"=>array(255,255,255),
51 "black"=>array(0,0,0),
52 "darkslategray"=>array(47,79,79),
53 "dimgray"=>array(105,105,105),
54 "slategray"=>array(112,128,144),
55 "lightslategray"=>array(119,136,153),
56 "gray"=>array(190,190,190),
57 "lightgray"=>array(211,211,211),
58 "midnightblue"=>array(25,25,112),
59 "navy"=>array(0,0,128),
60 "cornflowerblue"=>array(100,149,237),
61 "darkslateblue"=>array(72,61,139),
62 "slateblue"=>array(106,90,205),
63 "mediumslateblue"=>array(123,104,238),
64 "lightslateblue"=>array(132,112,255),
65 "mediumblue"=>array(0,0,205),
66 "royalblue"=>array(65,105,225),
67 "blue"=>array(0,0,255),
68 "dodgerblue"=>array(30,144,255),
69 "deepskyblue"=>array(0,191,255),
70 "skyblue"=>array(135,206,235),
71 "lightskyblue"=>array(135,206,250),
72 "steelblue"=>array(70,130,180),
73 "lightred"=>array(211,167,168),
74 "lightsteelblue"=>array(176,196,222),
75 "lightblue"=>array(173,216,230),
76 "powderblue"=>array(176,224,230),
77 "paleturquoise"=>array(175,238,238),
78 "darkturquoise"=>array(0,206,209),
79 "mediumturquoise"=>array(72,209,204),
80 "turquoise"=>array(64,224,208),
81 "cyan"=>array(0,255,255),
82 "lightcyan"=>array(224,255,255),
83 "cadetblue"=>array(95,158,160),
84 "mediumaquamarine"=>array(102,205,170),
85 "aquamarine"=>array(127,255,212),
86 "darkgreen"=>array(0,100,0),
87 "darkolivegreen"=>array(85,107,47),
88 "darkseagreen"=>array(143,188,143),
89 "seagreen"=>array(46,139,87),
90 "mediumseagreen"=>array(60,179,113),
91 "lightseagreen"=>array(32,178,170),
92 "palegreen"=>array(152,251,152),
93 "springgreen"=>array(0,255,127),
94 "lawngreen"=>array(124,252,0),
95 "green"=>array(0,255,0),
96 "chartreuse"=>array(127,255,0),
97 "mediumspringgreen"=>array(0,250,154),
98 "greenyellow"=>array(173,255,47),
99 "limegreen"=>array(50,205,50),
100 "yellowgreen"=>array(154,205,50),
101 "forestgreen"=>array(34,139,34),
102 "olivedrab"=>array(107,142,35),
103 "darkkhaki"=>array(189,183,107),
104 "khaki"=>array(240,230,140),
105 "palegoldenrod"=>array(238,232,170),
106 "lightgoldenrodyellow"=>array(250,250,210),
107 "lightyellow"=>array(255,255,200),
108 "yellow"=>array(255,255,0),
109 "gold"=>array(255,215,0),
110 "lightgoldenrod"=>array(238,221,130),
111 "goldenrod"=>array(218,165,32),
112 "darkgoldenrod"=>array(184,134,11),
113 "rosybrown"=>array(188,143,143),
114 "indianred"=>array(205,92,92),
115 "saddlebrown"=>array(139,69,19),
116 "sienna"=>array(160,82,45),
117 "peru"=>array(205,133,63),
118 "burlywood"=>array(222,184,135),
119 "beige"=>array(245,245,220),
120 "wheat"=>array(245,222,179),
121 "sandybrown"=>array(244,164,96),
122 "tan"=>array(210,180,140),
123 "chocolate"=>array(210,105,30),
124 "firebrick"=>array(178,34,34),
125 "brown"=>array(165,42,42),
126 "darksalmon"=>array(233,150,122),
127 "salmon"=>array(250,128,114),
128 "lightsalmon"=>array(255,160,122),
129 "orange"=>array(255,165,0),
130 "darkorange"=>array(255,140,0),
131 "coral"=>array(255,127,80),
132 "lightcoral"=>array(240,128,128),
133 "tomato"=>array(255,99,71),
134 "orangered"=>array(255,69,0),
135 "red"=>array(255,0,0),
136 "hotpink"=>array(255,105,180),
137 "deeppink"=>array(255,20,147),
138 "pink"=>array(255,192,203),
139 "lightpink"=>array(255,182,193),
140 "palevioletred"=>array(219,112,147),
141 "maroon"=>array(176,48,96),
142 "mediumvioletred"=>array(199,21,133),
143 "violetred"=>array(208,32,144),
144 "magenta"=>array(255,0,255),
145 "violet"=>array(238,130,238),
146 "plum"=>array(221,160,221),
147 "orchid"=>array(218,112,214),
148 "mediumorchid"=>array(186,85,211),
149 "darkorchid"=>array(153,50,204),
150 "darkviolet"=>array(148,0,211),
151 "blueviolet"=>array(138,43,226),
152 "purple"=>array(160,32,240),
153 "mediumpurple"=>array(147,112,219),
154 "thistle"=>array(216,191,216),
155 "snow1"=>array(255,250,250),
156 "snow2"=>array(238,233,233),
157 "snow3"=>array(205,201,201),
158 "snow4"=>array(139,137,137),
159 "seashell1"=>array(255,245,238),
160 "seashell2"=>array(238,229,222),
161 "seashell3"=>array(205,197,191),
162 "seashell4"=>array(139,134,130),
163 "AntiqueWhite1"=>array(255,239,219),
164 "AntiqueWhite2"=>array(238,223,204),
165 "AntiqueWhite3"=>array(205,192,176),
166 "AntiqueWhite4"=>array(139,131,120),
167 "bisque1"=>array(255,228,196),
168 "bisque2"=>array(238,213,183),
169 "bisque3"=>array(205,183,158),
170 "bisque4"=>array(139,125,107),
171 "peachPuff1"=>array(255,218,185),
172 "peachpuff2"=>array(238,203,173),
173 "peachpuff3"=>array(205,175,149),
174 "peachpuff4"=>array(139,119,101),
175 "navajowhite1"=>array(255,222,173),
176 "navajowhite2"=>array(238,207,161),
177 "navajowhite3"=>array(205,179,139),
178 "navajowhite4"=>array(139,121,94),
179 "lemonchiffon1"=>array(255,250,205),
180 "lemonchiffon2"=>array(238,233,191),
181 "lemonchiffon3"=>array(205,201,165),
182 "lemonchiffon4"=>array(139,137,112),
183 "ivory1"=>array(255,255,240),
184 "ivory2"=>array(238,238,224),
185 "ivory3"=>array(205,205,193),
186 "ivory4"=>array(139,139,131),
187 "honeydew"=>array(193,205,193),
188 "lavenderblush1"=>array(255,240,245),
189 "lavenderblush2"=>array(238,224,229),
190 "lavenderblush3"=>array(205,193,197),
191 "lavenderblush4"=>array(139,131,134),
192 "mistyrose1"=>array(255,228,225),
193 "mistyrose2"=>array(238,213,210),
194 "mistyrose3"=>array(205,183,181),
195 "mistyrose4"=>array(139,125,123),
196 "azure1"=>array(240,255,255),
197 "azure2"=>array(224,238,238),
198 "azure3"=>array(193,205,205),
199 "azure4"=>array(131,139,139),
200 "slateblue1"=>array(131,111,255),
201 "slateblue2"=>array(122,103,238),
202 "slateblue3"=>array(105,89,205),
203 "slateblue4"=>array(71,60,139),
204 "royalblue1"=>array(72,118,255),
205 "royalblue2"=>array(67,110,238),
206 "royalblue3"=>array(58,95,205),
207 "royalblue4"=>array(39,64,139),
208 "dodgerblue1"=>array(30,144,255),
209 "dodgerblue2"=>array(28,134,238),
210 "dodgerblue3"=>array(24,116,205),
211 "dodgerblue4"=>array(16,78,139),
212 "steelblue1"=>array(99,184,255),
213 "steelblue2"=>array(92,172,238),
214 "steelblue3"=>array(79,148,205),
215 "steelblue4"=>array(54,100,139),
216 "deepskyblue1"=>array(0,191,255),
217 "deepskyblue2"=>array(0,178,238),
218 "deepskyblue3"=>array(0,154,205),
219 "deepskyblue4"=>array(0,104,139),
220 "skyblue1"=>array(135,206,255),
221 "skyblue2"=>array(126,192,238),
222 "skyblue3"=>array(108,166,205),
223 "skyblue4"=>array(74,112,139),
224 "lightskyblue1"=>array(176,226,255),
225 "lightskyblue2"=>array(164,211,238),
226 "lightskyblue3"=>array(141,182,205),
227 "lightskyblue4"=>array(96,123,139),
228 "slategray1"=>array(198,226,255),
229 "slategray2"=>array(185,211,238),
230 "slategray3"=>array(159,182,205),
231 "slategray4"=>array(108,123,139),
232 "lightsteelblue1"=>array(202,225,255),
233 "lightsteelblue2"=>array(188,210,238),
234 "lightsteelblue3"=>array(162,181,205),
235 "lightsteelblue4"=>array(110,123,139),
236 "lightblue1"=>array(191,239,255),
237 "lightblue2"=>array(178,223,238),
238 "lightblue3"=>array(154,192,205),
239 "lightblue4"=>array(104,131,139),
240 "lightcyan1"=>array(224,255,255),
241 "lightcyan2"=>array(209,238,238),
242 "lightcyan3"=>array(180,205,205),
243 "lightcyan4"=>array(122,139,139),
244 "paleturquoise1"=>array(187,255,255),
245 "paleturquoise2"=>array(174,238,238),
246 "paleturquoise3"=>array(150,205,205),
247 "paleturquoise4"=>array(102,139,139),
248 "cadetblue1"=>array(152,245,255),
249 "cadetblue2"=>array(142,229,238),
250 "cadetblue3"=>array(122,197,205),
251 "cadetblue4"=>array(83,134,139),
252 "turquoise1"=>array(0,245,255),
253 "turquoise2"=>array(0,229,238),
254 "turquoise3"=>array(0,197,205),
255 "turquoise4"=>array(0,134,139),
256 "cyan1"=>array(0,255,255),
257 "cyan2"=>array(0,238,238),
258 "cyan3"=>array(0,205,205),
259 "cyan4"=>array(0,139,139),
260 "darkslategray1"=>array(151,255,255),
261 "darkslategray2"=>array(141,238,238),
262 "darkslategray3"=>array(121,205,205),
263 "darkslategray4"=>array(82,139,139),
264 "aquamarine1"=>array(127,255,212),
265 "aquamarine2"=>array(118,238,198),
266 "aquamarine3"=>array(102,205,170),
267 "aquamarine4"=>array(69,139,116),
268 "darkseagreen1"=>array(193,255,193),
269 "darkseagreen2"=>array(180,238,180),
270 "darkseagreen3"=>array(155,205,155),
271 "darkseagreen4"=>array(105,139,105),
272 "seagreen1"=>array(84,255,159),
273 "seagreen2"=>array(78,238,148),
274 "seagreen3"=>array(67,205,128),
275 "seagreen4"=>array(46,139,87),
276 "palegreen1"=>array(154,255,154),
277 "palegreen2"=>array(144,238,144),
278 "palegreen3"=>array(124,205,124),
279 "palegreen4"=>array(84,139,84),
280 "springgreen1"=>array(0,255,127),
281 "springgreen2"=>array(0,238,118),
282 "springgreen3"=>array(0,205,102),
283 "springgreen4"=>array(0,139,69),
284 "chartreuse1"=>array(127,255,0),
285 "chartreuse2"=>array(118,238,0),
286 "chartreuse3"=>array(102,205,0),
287 "chartreuse4"=>array(69,139,0),
288 "olivedrab1"=>array(192,255,62),
289 "olivedrab2"=>array(179,238,58),
290 "olivedrab3"=>array(154,205,50),
291 "olivedrab4"=>array(105,139,34),
292 "darkolivegreen1"=>array(202,255,112),
293 "darkolivegreen2"=>array(188,238,104),
294 "darkolivegreen3"=>array(162,205,90),
295 "darkolivegreen4"=>array(110,139,61),
296 "khaki1"=>array(255,246,143),
297 "khaki2"=>array(238,230,133),
298 "khaki3"=>array(205,198,115),
299 "khaki4"=>array(139,134,78),
300 "lightgoldenrod1"=>array(255,236,139),
301 "lightgoldenrod2"=>array(238,220,130),
302 "lightgoldenrod3"=>array(205,190,112),
303 "lightgoldenrod4"=>array(139,129,76),
304 "yellow1"=>array(255,255,0),
305 "yellow2"=>array(238,238,0),
306 "yellow3"=>array(205,205,0),
307 "yellow4"=>array(139,139,0),
308 "gold1"=>array(255,215,0),
309 "gold2"=>array(238,201,0),
310 "gold3"=>array(205,173,0),
311 "gold4"=>array(139,117,0),
312 "goldenrod1"=>array(255,193,37),
313 "goldenrod2"=>array(238,180,34),
314 "goldenrod3"=>array(205,155,29),
315 "goldenrod4"=>array(139,105,20),
316 "darkgoldenrod1"=>array(255,185,15),
317 "darkgoldenrod2"=>array(238,173,14),
318 "darkgoldenrod3"=>array(205,149,12),
319 "darkgoldenrod4"=>array(139,101,8),
320 "rosybrown1"=>array(255,193,193),
321 "rosybrown2"=>array(238,180,180),
322 "rosybrown3"=>array(205,155,155),
323 "rosybrown4"=>array(139,105,105),
324 "indianred1"=>array(255,106,106),
325 "indianred2"=>array(238,99,99),
326 "indianred3"=>array(205,85,85),
327 "indianred4"=>array(139,58,58),
328 "sienna1"=>array(255,130,71),
329 "sienna2"=>array(238,121,66),
330 "sienna3"=>array(205,104,57),
331 "sienna4"=>array(139,71,38),
332 "burlywood1"=>array(255,211,155),
333 "burlywood2"=>array(238,197,145),
334 "burlywood3"=>array(205,170,125),
335 "burlywood4"=>array(139,115,85),
336 "wheat1"=>array(255,231,186),
337 "wheat2"=>array(238,216,174),
338 "wheat3"=>array(205,186,150),
339 "wheat4"=>array(139,126,102),
340 "tan1"=>array(255,165,79),
341 "tan2"=>array(238,154,73),
342 "tan3"=>array(205,133,63),
343 "tan4"=>array(139,90,43),
344 "chocolate1"=>array(255,127,36),
345 "chocolate2"=>array(238,118,33),
346 "chocolate3"=>array(205,102,29),
347 "chocolate4"=>array(139,69,19),
348 "firebrick1"=>array(255,48,48),
349 "firebrick2"=>array(238,44,44),
350 "firebrick3"=>array(205,38,38),
351 "firebrick4"=>array(139,26,26),
352 "brown1"=>array(255,64,64),
353 "brown2"=>array(238,59,59),
354 "brown3"=>array(205,51,51),
355 "brown4"=>array(139,35,35),
356 "salmon1"=>array(255,140,105),
357 "salmon2"=>array(238,130,98),
358 "salmon3"=>array(205,112,84),
359 "salmon4"=>array(139,76,57),
360 "lightsalmon1"=>array(255,160,122),
361 "lightsalmon2"=>array(238,149,114),
362 "lightsalmon3"=>array(205,129,98),
363 "lightsalmon4"=>array(139,87,66),
364 "orange1"=>array(255,165,0),
365 "orange2"=>array(238,154,0),
366 "orange3"=>array(205,133,0),
367 "orange4"=>array(139,90,0),
368 "darkorange1"=>array(255,127,0),
369 "darkorange2"=>array(238,118,0),
370 "darkorange3"=>array(205,102,0),
371 "darkorange4"=>array(139,69,0),
372 "coral1"=>array(255,114,86),
373 "coral2"=>array(238,106,80),
374 "coral3"=>array(205,91,69),
375 "coral4"=>array(139,62,47),
376 "tomato1"=>array(255,99,71),
377 "tomato2"=>array(238,92,66),
378 "tomato3"=>array(205,79,57),
379 "tomato4"=>array(139,54,38),
380 "orangered1"=>array(255,69,0),
381 "orangered2"=>array(238,64,0),
382 "orangered3"=>array(205,55,0),
383 "orangered4"=>array(139,37,0),
384 "deeppink1"=>array(255,20,147),
385 "deeppink2"=>array(238,18,137),
386 "deeppink3"=>array(205,16,118),
387 "deeppink4"=>array(139,10,80),
388 "hotpink1"=>array(255,110,180),
389 "hotpink2"=>array(238,106,167),
390 "hotpink3"=>array(205,96,144),
391 "hotpink4"=>array(139,58,98),
392 "pink1"=>array(255,181,197),
393 "pink2"=>array(238,169,184),
394 "pink3"=>array(205,145,158),
395 "pink4"=>array(139,99,108),
396 "lightpink1"=>array(255,174,185),
397 "lightpink2"=>array(238,162,173),
398 "lightpink3"=>array(205,140,149),
399 "lightpink4"=>array(139,95,101),
400 "palevioletred1"=>array(255,130,171),
401 "palevioletred2"=>array(238,121,159),
402 "palevioletred3"=>array(205,104,137),
403 "palevioletred4"=>array(139,71,93),
404 "maroon1"=>array(255,52,179),
405 "maroon2"=>array(238,48,167),
406 "maroon3"=>array(205,41,144),
407 "maroon4"=>array(139,28,98),
408 "violetred1"=>array(255,62,150),
409 "violetred2"=>array(238,58,140),
410 "violetred3"=>array(205,50,120),
411 "violetred4"=>array(139,34,82),
412 "magenta1"=>array(255,0,255),
413 "magenta2"=>array(238,0,238),
414 "magenta3"=>array(205,0,205),
415 "magenta4"=>array(139,0,139),
416 "mediumred"=>array(140,34,34),
417 "orchid1"=>array(255,131,250),
418 "orchid2"=>array(238,122,233),
419 "orchid3"=>array(205,105,201),
420 "orchid4"=>array(139,71,137),
421 "plum1"=>array(255,187,255),
422 "plum2"=>array(238,174,238),
423 "plum3"=>array(205,150,205),
424 "plum4"=>array(139,102,139),
425 "mediumorchid1"=>array(224,102,255),
426 "mediumorchid2"=>array(209,95,238),
427 "mediumorchid3"=>array(180,82,205),
428 "mediumorchid4"=>array(122,55,139),
429 "darkorchid1"=>array(191,62,255),
430 "darkorchid2"=>array(178,58,238),
431 "darkorchid3"=>array(154,50,205),
432 "darkorchid4"=>array(104,34,139),
433 "purple1"=>array(155,48,255),
434 "purple2"=>array(145,44,238),
435 "purple3"=>array(125,38,205),
436 "purple4"=>array(85,26,139),
437 "mediumpurple1"=>array(171,130,255),
438 "mediumpurple2"=>array(159,121,238),
439 "mediumpurple3"=>array(137,104,205),
440 "mediumpurple4"=>array(93,71,139),
441 "thistle1"=>array(255,225,255),
442 "thistle2"=>array(238,210,238),
443 "thistle3"=>array(205,181,205),
444 "thistle4"=>array(139,123,139),
445 "gray1"=>array(10,10,10),
446 "gray2"=>array(40,40,30),
447 "gray3"=>array(70,70,70),
448 "gray4"=>array(100,100,100),
449 "gray5"=>array(130,130,130),
450 "gray6"=>array(160,160,160),
451 "gray7"=>array(190,190,190),
452 "gray8"=>array(210,210,210),
453 "gray9"=>array(240,240,240),
454 "darkgray"=>array(100,100,100),
455 "darkblue"=>array(0,0,139),
456 "darkcyan"=>array(0,139,139),
457 "darkmagenta"=>array(139,0,139),
458 "darkred"=>array(139,0,0),
459 "silver"=>array(192, 192, 192),
460 "eggplant"=>array(144,176,168),
461 "lightgreen"=>array(144,238,144));
462 }
463//----------------
464// PUBLIC METHODS
465 // Colors can be specified as either
466 // 1. #xxxxxx HTML style
467 // 2. "colorname" as a named color
468 // 3. array(r,g,b) RGB triple
469 // This function translates this to a native RGB format and returns an
470 // RGB triple.
471 function Color($aColor) {
472 if (is_string($aColor)) {
473 // Strip of any alpha factor
474 $pos = strpos($aColor,'@');
475 if( $pos === false ) {
476 $alpha = 0;
477 }
478 else {
479 $pos2 = strpos($aColor,':');
480 if( $pos2===false )
481 $pos2 = $pos-1; // Sentinel
482 if( $pos > $pos2 ) {
483 $alpha = str_replace(',','.',substr($aColor,$pos+1));
484 $aColor = substr($aColor,0,$pos);
485 }
486 else {
487 $alpha = substr($aColor,$pos+1,$pos2-$pos-1);
488 $aColor = substr($aColor,0,$pos).substr($aColor,$pos2);
489 }
490 }
491
492 // Extract potential adjustment figure at end of color
493 // specification
494 $pos = strpos($aColor,":");
495 if( $pos === false ) {
496 $adj = 1.0;
497 }
498 else {
499 $adj = 0.0 + str_replace(',','.',substr($aColor,$pos+1));
500 $aColor = substr($aColor,0,$pos);
501 }
502 if( $adj < 0 )
503 JpGraphError::RaiseL(25077);//('Adjustment factor for color must be > 0');
504
505 if (substr($aColor, 0, 1) == "#") {
506 $r = hexdec(substr($aColor, 1, 2));
507 $g = hexdec(substr($aColor, 3, 2));
508 $b = hexdec(substr($aColor, 5, 2));
509 } else {
510 if(!isset($this->rgb_table[$aColor]) )
511 JpGraphError::RaiseL(25078,$aColor);//(" Unknown color: $aColor");
512 $tmp=$this->rgb_table[$aColor];
513 $r = $tmp[0];
514 $g = $tmp[1];
515 $b = $tmp[2];
516 }
517 // Scale adj so that an adj=2 always
518 // makes the color 100% white (i.e. 255,255,255.
519 // and adj=1 neutral and adj=0 black.
520 if( $adj > 1 ) {
521 $m = ($adj-1.0)*(255-min(255,min($r,min($g,$b))));
522 return array(min(255,$r+$m), min(255,$g+$m), min(255,$b+$m),$alpha);
523 }
524 elseif( $adj < 1 ) {
525 $m = ($adj-1.0)*max(255,max($r,max($g,$b)));
526 return array(max(0,$r+$m), max(0,$g+$m), max(0,$b+$m),$alpha);
527 }
528 else {
529 return array($r,$g,$b,$alpha);
530 }
531
532 } elseif( is_array($aColor) ) {
533 if( count($aColor)==3 ) {
534 $aColor[3]=0;
535 return $aColor;
536 }
537 else
538 return $aColor;
539 }
540 else
541 JpGraphError::RaiseL(25079,$aColor,count($aColor));//(" Unknown color specification: $aColor , size=".count($aColor));
542 }
543
544 // Compare two colors
545 // return true if equal
546 function Equal($aCol1,$aCol2) {
547 $c1 = $this->Color($aCol1);
548 $c2 = $this->Color($aCol2);
549 if( $c1[0]==$c2[0] && $c1[1]==$c2[1] && $c1[2]==$c2[2] )
550 return true;
551 else
552 return false;
553 }
554
555 // Allocate a new color in the current image
556 // Return new color index, -1 if no more colors could be allocated
557 function Allocate($aColor,$aAlpha=0.0) {
558 list ($r, $g, $b, $a) = $this->color($aColor);
559 // If alpha is specified in the color string then this
560 // takes precedence over the second argument
561 if( $a > 0 )
562 $aAlpha = $a;
563 if( $aAlpha < 0 || $aAlpha > 1 ) {
564 JpGraphError::RaiseL(25080);//('Alpha parameter for color must be between 0.0 and 1.0');
565 }
566 return imagecolorresolvealpha($this->img, $r, $g, $b, round($aAlpha * 127));
567 }
568} // Class
569
570?>
Note: See TracBrowser for help on using the repository browser.