source: trunk/forum/includes/captcha/captcha_gd.php

Last change on this file was 702, checked in by george, 15 years ago
  • Upraveno: Aktualizace fóra.
File size: 70.3 KB
Line 
1<?php
2/**
3*
4* @package VC
5* @version $Id$
6* @copyright (c) 2006 phpBB Group
7* @license http://opensource.org/licenses/gpl-license.php GNU Public License
8*
9*/
10
11/**
12* @ignore
13*/
14if (!defined('IN_PHPBB'))
15{
16 exit;
17}
18
19/**
20* Original Author - Xore (Robert Hetzler)
21* With contributions from Neothermic
22*
23* @package VC
24*/
25class captcha
26{
27 var $width = 360;
28 var $height = 96;
29
30
31 /**
32 * Create the image containing $code with a seed of $seed
33 */
34 function execute($code, $seed)
35 {
36 global $config;
37
38 mt_srand($seed);
39
40 // Create image
41 $img = imagecreatetruecolor($this->width, $this->height);
42
43 // Generate colours
44 $colour = new colour_manager($img, array(
45 'random' => true,
46 'min_value' => 60,
47 ), 'hsv');
48
49 $scheme = $colour->colour_scheme('background', false);
50 $scheme = $colour->mono_range($scheme, 10, false);
51 shuffle($scheme);
52
53 $bg_colours = array_splice($scheme, mt_rand(6, 12));
54
55 // Generate code characters
56 $characters = $sizes = $bounding_boxes = $noise = array();
57 $width_avail = $this->width - 15;
58 $code_len = strlen($code);
59 $captcha_bitmaps = $this->captcha_bitmaps();
60
61 for ($i = 0; $i < $code_len; ++$i)
62 {
63 $characters[$i] = new char_cube3d($captcha_bitmaps, $code[$i]);
64
65 list($min, $max) = $characters[$i]->range();
66 $sizes[$i] = mt_rand($min, $max);
67
68 $box = $characters[$i]->dimensions($sizes[$i]);
69 $width_avail -= ($box[2] - $box[0]);
70 $bounding_boxes[$i] = $box;
71 }
72
73
74 // Redistribute leftover x-space
75 $offset = array();
76 for ($i = 0; $i < $code_len; ++$i)
77 {
78 $denom = ($code_len - $i);
79 $denom = max(1.3, $denom);
80 $offset[$i] = mt_rand(0, (1.5 * $width_avail) / $denom);
81 $width_avail -= $offset[$i];
82 }
83
84 if ($config['captcha_gd_x_grid'])
85 {
86 $grid = (int) $config['captcha_gd_x_grid'];
87 for ($y = 0; $y < $this->height; $y += mt_rand($grid - 2, $grid + 2))
88 {
89 $current_colour = $scheme[array_rand($scheme)];
90 imageline($img, mt_rand(0,4), mt_rand($y - 3, $y), mt_rand($this->width - 5, $this->width), mt_rand($y - 3, $y), $current_colour);
91 }
92 }
93
94 if ($config['captcha_gd_y_grid'])
95 {
96 $grid = (int) $config['captcha_gd_y_grid'];
97 for ($x = 0; $x < $this->width; $x += mt_rand($grid - 2, $grid + 2))
98 {
99 $current_colour = $scheme[array_rand($scheme)];
100 imagedashedline($img, mt_rand($x -3, $x + 3), mt_rand(0, 4), mt_rand($x -3, $x + 3), mt_rand($this->height - 5, $this->height), $current_colour);
101 }
102 }
103 if ($config['captcha_gd_wave'] && ($config['captcha_gd_y_grid'] || $config['captcha_gd_y_grid']))
104 {
105 $this->wave($img);
106 }
107
108
109 if ($config['captcha_gd_3d_noise'])
110 {
111 $xoffset = mt_rand(0,9);
112 $noise_bitmaps = $this->captcha_noise_bg_bitmaps();
113 for ($i = 0; $i < $code_len; ++$i)
114 {
115 $noise[$i] = new char_cube3d($noise_bitmaps, mt_rand(1, count($noise_bitmaps['data'])));
116
117 list($min, $max) = $noise[$i]->range();
118 //$box = $noise[$i]->dimensions($sizes[$i]);
119 }
120 $xoffset = 0;
121 for ($i = 0; $i < $code_len; ++$i)
122 {
123 $dimm = $bounding_boxes[$i];
124 $xoffset += ($offset[$i] - $dimm[0]);
125 $yoffset = mt_rand(-$dimm[1], $this->height - $dimm[3]);
126
127 $noise[$i]->drawchar($sizes[$i], $xoffset, $yoffset, $img, $colour->get_resource('background'), $scheme);
128 $xoffset += $dimm[2];
129 }
130 }
131 $xoffset = 5;
132 for ($i = 0; $i < $code_len; ++$i)
133 {
134 $dimm = $bounding_boxes[$i];
135 $xoffset += ($offset[$i] - $dimm[0]);
136 $yoffset = mt_rand(-$dimm[1], $this->height - $dimm[3]);
137
138 $characters[$i]->drawchar($sizes[$i], $xoffset, $yoffset, $img, $colour->get_resource('background'), $scheme);
139 $xoffset += $dimm[2];
140 }
141 if ($config['captcha_gd_wave'])
142 {
143 $this->wave($img);
144 }
145 if ($config['captcha_gd_foreground_noise'])
146 {
147 $this->noise_line($img, 0, 0, $this->width, $this->height, $colour->get_resource('background'), $scheme, $bg_colours);
148 }
149 // Send image
150 header('Content-Type: image/png');
151 header('Cache-control: no-cache, no-store');
152 imagepng($img);
153 imagedestroy($img);
154 }
155
156 /**
157 * Sinus
158 */
159 function wave($img)
160 {
161 global $config;
162
163 $period_x = mt_rand(12,18);
164 $period_y = mt_rand(7,14);
165 $amp_x = mt_rand(5,10);
166 $amp_y = mt_rand(2,4);
167 $socket = mt_rand(0,100);
168
169 $dampen_x = mt_rand($this->width/5, $this->width/2);
170 $dampen_y = mt_rand($this->height/5, $this->height/2);
171 $direction_x = (mt_rand (0, 1));
172 $direction_y = (mt_rand (0, 1));
173
174 for ($i = 0; $i < $this->width; $i++)
175 {
176 $dir = ($direction_x) ? $i : ($this->width - $i);
177 imagecopy($img, $img, $i-1, sin($socket+ $i/($period_x + $dir/$dampen_x)) * $amp_x, $i, 0, 1, $this->height);
178 }
179 $socket = mt_rand(0,100);
180 for ($i = 0; $i < $this->height; $i++)
181 {
182 $dir = ($direction_y) ? $i : ($this->height - $i);
183 imagecopy($img, $img ,sin($socket + $i/($period_y + ($dir)/$dampen_y)) * $amp_y, $i-1, 0, $i, $this->width, 1);
184 }
185 return $img;
186 }
187
188 /**
189 * Noise line
190 */
191 function noise_line($img, $min_x, $min_y, $max_x, $max_y, $bg, $font, $non_font)
192 {
193 imagesetthickness($img, 2);
194
195 $x1 = $min_x;
196 $x2 = $max_x;
197 $y1 = $min_y;
198 $y2 = $min_y;
199
200 do
201 {
202 $line = array_merge(
203 array_fill(0, mt_rand(30, 60), $non_font[array_rand($non_font)]),
204 array_fill(0, mt_rand(30, 60), $bg)
205 );
206
207 imagesetstyle($img, $line);
208 imageline($img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
209
210 $y1 += mt_rand(12, 35);
211 $y2 += mt_rand(12, 35);
212 }
213 while ($y1 < $max_y && $y2 < $max_y);
214
215 $x1 = $min_x;
216 $x2 = $min_x;
217 $y1 = $min_y;
218 $y2 = $max_y;
219
220 do
221 {
222 $line = array_merge(
223 array_fill(0, mt_rand(30, 60), $non_font[array_rand($non_font)]),
224 array_fill(0, mt_rand(30, 60), $bg)
225 );
226
227 imagesetstyle($img, $line);
228 imageline($img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
229
230 $x1 += mt_rand(20, 35);
231 $x2 += mt_rand(20, 35);
232 }
233 while ($x1 < $max_x && $x2 < $max_x);
234 imagesetthickness($img, 1);
235 }
236
237
238 function captcha_noise_bg_bitmaps()
239 {
240 return array(
241 'width' => 15,
242 'height' => 5,
243 'data' => array(
244
245 1 => array(
246 array(1,0,0,0,1,0,0,0,0,0,0,0,0,0,0),
247 array(1,0,0,0,0,1,0,0,0,0,0,0,0,0,0),
248 array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
249 array(1,0,0,0,0,1,0,0,0,0,0,0,1,0,0),
250 array(1,0,0,0,0,0,1,0,0,0,0,1,0,0,0),
251 ),
252 2 => array(
253 array(1,1,mt_rand(0,1),1,0,1,1,1,1,0,0,0,0,0,0),
254 array(0,0,0,0,0,0,0,1,0,0,0,0,0,0,0),
255 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
256 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
257 array(0,0,0,0,0,0,0,0,0,1,1,0,1,1,1),
258 ),
259 3 => array(
260 array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,1),
261 array(1,0,0,0,0,0,0,0,0,0,0,0,0,1,0),
262 array(0,0,0,0,1,0,0,0,0,0,0,0,0,0,1),
263 array(1,0,0,0,0,0,0,0,0,0,0,0,0,1,0),
264 array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,1),
265 ),
266 4 => array(
267 array(1,0,1,0,1,0,0,1,1,0,0,0,0,0,0),
268 array(0,0,0,0,0,0,0,1,0,0,0,0,0,0,0),
269 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
270 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
271 array(1,0,1,0,0,0,0,0,0,0,0,0,0,0,0),
272 ),
273 5 => array(
274 array(1,1,1,1,0,0,0,1,1,1,0,0,1,0,1),
275 array(0,0,0,0,0,0,0,1,0,0,0,0,0,0,0),
276 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
277 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
278 array(1,0,1,0,0,0,0,0,0,0,0,0,0,0,0),
279 ),
280 6 => array(
281 array(mt_rand(0,1),mt_rand(0,1),mt_rand(0,1),mt_rand(0,1),mt_rand(0,1),0,mt_rand(0,1),mt_rand(0,1),mt_rand(0,1),mt_rand(0,1),mt_rand(0,1),0,mt_rand(0,1),mt_rand(0,1),mt_rand(0,1)),
282 array(0,0,0,0,0,0,0,mt_rand(0,1),0,0,0,0,0,0,0),
283 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
284 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
285 array(mt_rand(0,1),0,mt_rand(0,1),0,0,0,0,0,0,0,0,0,0,0,0),
286 ),
287 7 => array(
288 array(0,0,0,0,0,0,0,0,0,0,1,1,0,1,1),
289 array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
290 array(0,0,1,1,0,0,0,1,0,0,0,0,0,0,0),
291 array(0,1,0,0,0,1,0,0,0,0,0,0,0,0,0),
292 array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
293 ),
294 ));
295 }
296
297 /**
298 * Return bitmaps
299 */
300 function captcha_bitmaps()
301 {
302 global $config;
303
304 $chars = array(
305 'A' => array(
306 array(
307 array(0,0,0,0,1,0,0,0,0),
308 array(0,0,0,1,0,1,0,0,0),
309 array(0,0,0,1,0,1,0,0,0),
310 array(0,0,0,1,0,1,0,0,0),
311 array(0,0,1,0,0,0,1,0,0),
312 array(0,0,1,0,0,0,1,0,0),
313 array(0,0,1,0,0,0,1,0,0),
314 array(0,1,0,0,0,0,0,1,0),
315 array(0,1,0,0,0,0,0,1,0),
316 array(0,1,1,1,1,1,1,1,0),
317 array(0,1,0,0,0,0,0,1,0),
318 array(1,0,0,0,0,0,0,0,1),
319 array(1,0,0,0,0,0,0,0,1),
320 array(1,0,0,0,0,0,0,0,1),
321 array(1,0,0,0,0,0,0,0,1),
322 ),
323 array(
324 array(0,0,0,0,0,0,0,0,0),
325 array(0,0,0,0,0,0,0,0,0),
326 array(0,0,0,0,1,0,0,0,0),
327 array(0,0,0,1,0,1,0,0,0),
328 array(0,0,1,1,0,1,1,0,0),
329 array(0,0,1,0,0,0,1,0,0),
330 array(0,1,0,0,0,0,0,1,0),
331 array(0,1,0,0,0,0,0,1,0),
332 array(0,1,1,1,1,1,1,1,0),
333 array(0,1,0,0,0,0,0,1,0),
334 array(0,1,0,0,0,0,0,1,0),
335 array(0,1,0,0,0,0,0,1,0),
336 array(0,1,0,0,0,0,0,1,0),
337 array(0,1,0,0,0,0,0,1,0),
338 array(1,1,1,0,0,0,1,1,1),
339 ),
340 array(
341 array(0,0,0,0,0,0,0,0,0),
342 array(0,0,0,0,0,0,0,0,0),
343 array(0,0,0,0,0,0,0,0,0),
344 array(0,0,0,0,0,0,0,0,0),
345 array(0,0,1,1,1,1,1,0,0),
346 array(0,1,1,0,0,0,1,1,0),
347 array(1,1,0,0,0,0,0,1,1),
348 array(1,0,0,0,0,0,0,0,1),
349 array(0,0,0,0,0,0,0,1,1),
350 array(0,0,0,0,0,1,1,1,1),
351 array(0,0,0,1,1,1,0,0,1),
352 array(0,1,1,1,0,0,0,0,1),
353 array(1,0,0,0,0,0,0,0,1),
354 array(1,1,0,0,0,0,1,1,1),
355 array(0,1,1,1,1,1,1,0,1),
356 ),
357 ),
358 'B' => array(
359 array(
360 array(1,1,1,1,1,1,1,0,0),
361 array(1,0,0,0,0,0,0,1,0),
362 array(1,0,0,0,0,0,0,0,1),
363 array(1,0,0,0,0,0,0,0,1),
364 array(1,0,0,0,0,0,0,0,1),
365 array(1,0,0,0,0,0,0,0,1),
366 array(1,0,0,0,0,0,0,1,0),
367 array(1,1,1,1,1,1,1,0,0),
368 array(1,0,0,0,0,0,0,1,0),
369 array(1,0,0,0,0,0,0,0,1),
370 array(1,0,0,0,0,0,0,0,1),
371 array(1,0,0,0,0,0,0,0,1),
372 array(1,0,0,0,0,0,0,0,1),
373 array(1,0,0,0,0,0,0,1,0),
374 array(1,1,1,1,1,1,1,0,0),
375 ),
376 array(
377 array(1,1,1,1,1,1,1,0,0),
378 array(0,1,0,0,0,0,0,1,0),
379 array(0,1,0,0,0,0,0,0,1),
380 array(0,1,0,0,0,0,0,0,1),
381 array(0,1,0,0,0,0,0,0,1),
382 array(0,1,0,0,0,0,0,0,1),
383 array(0,1,0,0,0,0,0,1,0),
384 array(0,1,1,1,1,1,1,0,0),
385 array(0,1,0,0,0,0,0,1,0),
386 array(0,1,0,0,0,0,0,0,1),
387 array(0,1,0,0,0,0,0,0,1),
388 array(0,1,0,0,0,0,0,0,1),
389 array(0,1,0,0,0,0,0,0,1),
390 array(0,1,0,0,0,0,0,1,0),
391 array(1,1,1,1,1,1,1,0,0),
392 ),
393 array(
394 array(0,1,0,0,0,0,0,0,0),
395 array(0,1,0,0,0,0,0,0,0),
396 array(0,1,0,0,0,0,0,0,0),
397 array(0,1,0,0,0,0,0,0,0),
398 array(0,1,0,0,0,0,0,0,0),
399 array(0,1,0,0,0,0,0,0,0),
400 array(0,1,0,0,0,0,0,0,0),
401 array(0,1,1,1,1,1,1,0,0),
402 array(0,1,0,0,0,0,0,1,0),
403 array(0,1,0,0,0,0,0,0,1),
404 array(0,1,0,0,0,0,0,0,1),
405 array(0,1,0,0,0,0,0,0,1),
406 array(0,1,0,0,0,0,0,0,1),
407 array(0,1,0,0,0,0,0,1,0),
408 array(0,1,1,1,1,1,1,0,0),
409 ),
410 ),
411 'C' => array(
412 array(
413 array(0,0,1,1,1,1,1,0,0),
414 array(0,1,0,0,0,0,0,1,0),
415 array(1,0,0,0,0,0,0,0,1),
416 array(1,0,0,0,0,0,0,0,1),
417 array(1,0,0,0,0,0,0,0,0),
418 array(1,0,0,0,0,0,0,0,0),
419 array(1,0,0,0,0,0,0,0,0),
420 array(1,0,0,0,0,0,0,0,0),
421 array(1,0,0,0,0,0,0,0,0),
422 array(1,0,0,0,0,0,0,0,0),
423 array(1,0,0,0,0,0,0,0,0),
424 array(1,0,0,0,0,0,0,0,1),
425 array(1,0,0,0,0,0,0,0,1),
426 array(0,1,0,0,0,0,0,1,0),
427 array(0,0,1,1,1,1,1,0,0),
428 ),
429 array(
430 array(0,0,1,1,1,1,1,0,1),
431 array(0,1,0,0,0,0,0,1,1),
432 array(1,0,0,0,0,0,0,0,1),
433 array(1,0,0,0,0,0,0,0,1),
434 array(1,0,0,0,0,0,0,0,0),
435 array(1,0,0,0,0,0,0,0,0),
436 array(1,0,0,0,0,0,0,0,0),
437 array(1,0,0,0,0,0,0,0,0),
438 array(1,0,0,0,0,0,0,0,0),
439 array(1,0,0,0,0,0,0,0,0),
440 array(1,0,0,0,0,0,0,0,0),
441 array(1,0,0,0,0,0,0,0,1),
442 array(1,0,0,0,0,0,0,0,1),
443 array(0,1,0,0,0,0,0,1,1),
444 array(0,0,1,1,1,1,1,0,1),
445 ),
446 ),
447 'D' => array(
448 array(
449 array(1,1,1,1,1,1,1,0,0),
450 array(1,0,0,0,0,0,0,1,0),
451 array(1,0,0,0,0,0,0,0,1),
452 array(1,0,0,0,0,0,0,0,1),
453 array(1,0,0,0,0,0,0,0,1),
454 array(1,0,0,0,0,0,0,0,1),
455 array(1,0,0,0,0,0,0,0,1),
456 array(1,0,0,0,0,0,0,0,1),
457 array(1,0,0,0,0,0,0,0,1),
458 array(1,0,0,0,0,0,0,0,1),
459 array(1,0,0,0,0,0,0,0,1),
460 array(1,0,0,0,0,0,0,0,1),
461 array(1,0,0,0,0,0,0,0,1),
462 array(1,0,0,0,0,0,0,1,0),
463 array(1,1,1,1,1,1,1,0,0),
464 ),
465 array(
466 array(1,1,1,1,1,1,1,0,0),
467 array(0,1,0,0,0,0,0,1,0),
468 array(0,1,0,0,0,0,0,0,1),
469 array(0,1,0,0,0,0,0,0,1),
470 array(0,1,0,0,0,0,0,0,1),
471 array(0,1,0,0,0,0,0,0,1),
472 array(0,1,0,0,0,0,0,0,1),
473 array(0,1,0,0,0,0,0,0,1),
474 array(0,1,0,0,0,0,0,0,1),
475 array(0,1,0,0,0,0,0,0,1),
476 array(0,1,0,0,0,0,0,0,1),
477 array(0,1,0,0,0,0,0,0,1),
478 array(0,1,0,0,0,0,0,0,1),
479 array(0,1,0,0,0,0,0,1,0),
480 array(1,1,1,1,1,1,1,0,0),
481 ),
482 array(
483 array(0,0,0,0,0,0,0,0,1),
484 array(0,0,0,0,0,0,0,0,1),
485 array(0,0,0,0,0,0,0,0,1),
486 array(0,0,0,0,0,0,0,0,1),
487 array(0,0,0,0,0,0,0,0,1),
488 array(0,0,0,0,0,0,0,0,1),
489 array(0,0,0,0,0,0,0,0,1),
490 array(0,0,1,1,1,1,1,0,1),
491 array(0,1,1,0,0,0,1,1,1),
492 array(0,1,0,0,0,0,0,0,1),
493 array(0,1,0,0,0,0,0,0,1),
494 array(0,1,0,0,0,0,0,0,1),
495 array(0,1,0,0,0,0,0,0,1),
496 array(0,1,1,0,0,0,1,1,1),
497 array(0,0,1,1,1,1,1,0,1),
498 ),
499 ),
500 'E' => array(
501 array(
502 array(1,1,1,1,1,1,1,1,1),
503 array(1,0,0,0,0,0,0,0,0),
504 array(1,0,0,0,0,0,0,0,0),
505 array(1,0,0,0,0,0,0,0,0),
506 array(1,0,0,0,0,0,0,0,0),
507 array(1,0,0,0,0,0,0,0,0),
508 array(1,0,0,0,0,0,0,0,0),
509 array(1,1,1,1,1,1,1,1,0),
510 array(1,0,0,0,0,0,0,0,0),
511 array(1,0,0,0,0,0,0,0,0),
512 array(1,0,0,0,0,0,0,0,0),
513 array(1,0,0,0,0,0,0,0,0),
514 array(1,0,0,0,0,0,0,0,0),
515 array(1,0,0,0,0,0,0,0,0),
516 array(1,1,1,1,1,1,1,1,1),
517 ),
518 array(
519 array(1,1,1,1,1,1,1,1,1),
520 array(1,0,0,0,0,0,0,0,1),
521 array(1,0,0,0,0,0,0,0,0),
522 array(1,0,0,0,0,0,0,0,0),
523 array(1,0,0,0,0,0,0,0,0),
524 array(1,0,0,0,0,0,0,0,0),
525 array(1,0,0,0,0,0,0,0,0),
526 array(1,1,1,1,1,1,1,0,0),
527 array(1,0,0,0,0,0,0,0,0),
528 array(1,0,0,0,0,0,0,0,0),
529 array(1,0,0,0,0,0,0,0,0),
530 array(1,0,0,0,0,0,0,0,0),
531 array(1,0,0,0,0,0,0,0,0),
532 array(1,0,0,0,0,0,0,0,1),
533 array(1,1,1,1,1,1,1,1,1),
534 ),
535 array(
536 array(0,0,0,0,0,0,0,0,0),
537 array(0,0,0,0,0,0,0,0,0),
538 array(0,0,0,0,0,0,0,0,0),
539 array(0,0,0,0,0,0,0,0,0),
540 array(0,0,0,0,0,0,0,0,0),
541 array(0,0,0,0,0,0,0,0,0),
542 array(0,0,0,0,0,0,0,0,0),
543 array(0,0,1,1,1,1,1,0,0),
544 array(0,1,1,0,0,0,1,1,0),
545 array(1,1,0,0,0,0,0,1,1),
546 array(1,1,1,1,1,1,1,1,1),
547 array(1,0,0,0,0,0,0,0,0),
548 array(1,0,0,0,0,0,0,0,1),
549 array(1,1,0,0,0,0,0,1,1),
550 array(0,1,1,1,1,1,1,1,0),
551 ),
552 ),
553 'F' => array(
554 array(
555 array(1,1,1,1,1,1,1,1,1),
556 array(1,0,0,0,0,0,0,0,0),
557 array(1,0,0,0,0,0,0,0,0),
558 array(1,0,0,0,0,0,0,0,0),
559 array(1,0,0,0,0,0,0,0,0),
560 array(1,0,0,0,0,0,0,0,0),
561 array(1,0,0,0,0,0,0,0,0),
562 array(1,1,1,1,1,1,1,0,0),
563 array(1,0,0,0,0,0,0,0,0),
564 array(1,0,0,0,0,0,0,0,0),
565 array(1,0,0,0,0,0,0,0,0),
566 array(1,0,0,0,0,0,0,0,0),
567 array(1,0,0,0,0,0,0,0,0),
568 array(1,0,0,0,0,0,0,0,0),
569 array(1,0,0,0,0,0,0,0,0),
570 ),
571 array(
572 array(0,1,1,1,1,1,1,1,1),
573 array(0,1,0,0,0,0,0,0,1),
574 array(0,1,0,0,0,0,0,0,0),
575 array(0,1,0,0,0,0,0,0,0),
576 array(0,1,0,0,0,0,0,0,0),
577 array(0,1,0,0,0,0,0,0,0),
578 array(0,1,0,0,0,0,0,0,0),
579 array(0,1,1,1,1,1,1,0,0),
580 array(0,1,0,0,0,0,0,0,0),
581 array(0,1,0,0,0,0,0,0,0),
582 array(0,1,0,0,0,0,0,0,0),
583 array(0,1,0,0,0,0,0,0,0),
584 array(0,1,0,0,0,0,0,0,0),
585 array(0,1,0,0,0,0,0,0,0),
586 array(1,1,1,0,0,0,0,0,0),
587 ),
588 array(
589 array(0,0,0,1,1,0,0,0,0),
590 array(0,0,1,1,0,0,0,0,0),
591 array(0,1,1,0,0,0,0,0,0),
592 array(0,1,0,0,0,0,0,0,0),
593 array(0,1,0,0,0,0,0,0,0),
594 array(1,1,1,1,0,0,0,0,0),
595 array(0,1,0,0,0,0,0,0,0),
596 array(0,1,0,0,0,0,0,0,0),
597 array(0,1,0,0,0,0,0,0,0),
598 array(0,1,0,0,0,0,0,0,0),
599 array(0,1,0,0,0,0,0,0,0),
600 array(0,1,0,0,0,0,0,0,0),
601 array(0,1,0,0,0,0,0,0,0),
602 array(0,1,0,0,0,0,0,0,0),
603 array(0,1,0,0,0,0,0,0,0),
604 ),
605 ),
606 'G' => array(
607 array(
608 array(0,0,1,1,1,1,1,0,0),
609 array(0,1,0,0,0,0,0,1,0),
610 array(1,0,0,0,0,0,0,0,1),
611 array(1,0,0,0,0,0,0,0,0),
612 array(1,0,0,0,0,0,0,0,0),
613 array(1,0,0,0,0,0,0,0,0),
614 array(1,0,0,0,0,0,0,0,0),
615 array(1,0,0,0,0,0,0,0,0),
616 array(1,0,0,0,0,0,1,1,1),
617 array(1,0,0,0,0,0,0,0,1),
618 array(1,0,0,0,0,0,0,0,1),
619 array(1,0,0,0,0,0,0,0,1),
620 array(1,0,0,0,0,0,0,0,1),
621 array(0,1,0,0,0,0,0,1,0),
622 array(0,0,1,1,1,1,1,0,0),
623 ),
624 array(
625 array(0,0,1,1,1,1,1,0,1),
626 array(0,1,0,0,0,0,0,1,1),
627 array(1,0,0,0,0,0,0,0,1),
628 array(1,0,0,0,0,0,0,0,0),
629 array(1,0,0,0,0,0,0,0,0),
630 array(1,0,0,0,0,0,0,0,0),
631 array(1,0,0,0,0,0,0,0,0),
632 array(1,0,0,0,0,0,0,0,0),
633 array(1,0,0,0,1,1,1,1,1),
634 array(1,0,0,0,1,0,0,0,1),
635 array(1,0,0,0,1,0,0,0,1),
636 array(1,0,0,0,0,0,0,0,1),
637 array(1,0,0,0,0,0,0,0,1),
638 array(0,1,0,0,0,0,0,1,1),
639 array(0,0,1,1,1,1,1,0,1),
640 ),
641 array(
642 array(0,0,1,1,1,1,1,0,1),
643 array(0,1,1,0,0,0,0,1,1),
644 array(1,1,0,0,0,0,0,1,1),
645 array(1,0,0,0,0,0,0,0,1),
646 array(1,0,0,0,0,0,0,0,1),
647 array(1,1,1,0,0,0,0,0,1),
648 array(0,0,1,1,1,1,1,1,1),
649 array(0,0,0,0,0,0,0,0,1),
650 array(0,0,0,0,0,0,0,0,1),
651 array(0,0,0,0,0,0,0,0,1),
652 array(0,0,0,0,0,0,0,0,1),
653 array(0,0,0,0,0,0,0,1,1),
654 array(1,1,1,1,1,1,1,1,0),
655 array(0,0,0,0,0,0,0,0,0),
656 array(0,0,0,0,0,0,0,0,0),
657 ),
658 ),
659 'H' => array(
660 array(
661 array(1,0,0,0,0,0,0,0,1),
662 array(1,0,0,0,0,0,0,0,1),
663 array(1,0,0,0,0,0,0,0,1),
664 array(1,0,0,0,0,0,0,0,1),
665 array(1,0,0,0,0,0,0,0,1),
666 array(1,0,0,0,0,0,0,0,1),
667 array(1,0,0,0,0,0,0,0,1),
668 array(1,1,1,1,1,1,1,1,1),
669 array(1,0,0,0,0,0,0,0,1),
670 array(1,0,0,0,0,0,0,0,1),
671 array(1,0,0,0,0,0,0,0,1),
672 array(1,0,0,0,0,0,0,0,1),
673 array(1,0,0,0,0,0,0,0,1),
674 array(1,0,0,0,0,0,0,0,1),
675 array(1,0,0,0,0,0,0,0,1),
676 ),
677 array(
678 array(1,1,1,0,0,0,1,1,1),
679 array(0,1,0,0,0,0,0,1,0),
680 array(0,1,0,0,0,0,0,1,0),
681 array(0,1,0,0,0,0,0,1,0),
682 array(0,1,0,0,0,0,0,1,0),
683 array(0,1,0,0,0,0,0,1,0),
684 array(0,1,0,0,0,0,0,1,0),
685 array(0,1,1,1,1,1,1,1,0),
686 array(0,1,0,0,0,0,0,1,0),
687 array(0,1,0,0,0,0,0,1,0),
688 array(0,1,0,0,0,0,0,1,0),
689 array(0,1,0,0,0,0,0,1,0),
690 array(0,1,0,0,0,0,0,1,0),
691 array(0,1,0,0,0,0,0,1,0),
692 array(1,1,1,0,0,0,1,1,1),
693 ),
694 array(
695 array(1,0,0,0,0,0,0,0,0),
696 array(1,0,0,0,0,0,0,0,0),
697 array(1,0,0,0,0,0,0,0,0),
698 array(1,0,0,0,0,0,0,0,0),
699 array(1,0,0,0,0,0,0,0,0),
700 array(1,0,0,0,0,0,0,0,0),
701 array(1,0,0,0,0,0,0,0,0),
702 array(1,0,0,1,1,1,0,0,0),
703 array(1,1,1,1,0,1,1,0,0),
704 array(1,0,0,0,0,0,1,0,0),
705 array(1,0,0,0,0,0,1,0,0),
706 array(1,0,0,0,0,0,1,0,0),
707 array(1,0,0,0,0,0,1,0,0),
708 array(1,0,0,0,0,0,1,0,0),
709 array(1,0,0,0,0,0,1,0,0),
710 ),
711 ),
712 'I' => array(
713 array(
714 array(1,1,1,1,1,1,1,1,1),
715 array(0,0,0,0,1,0,0,0,0),
716 array(0,0,0,0,1,0,0,0,0),
717 array(0,0,0,0,1,0,0,0,0),
718 array(0,0,0,0,1,0,0,0,0),
719 array(0,0,0,0,1,0,0,0,0),
720 array(0,0,0,0,1,0,0,0,0),
721 array(0,0,0,0,1,0,0,0,0),
722 array(0,0,0,0,1,0,0,0,0),
723 array(0,0,0,0,1,0,0,0,0),
724 array(0,0,0,0,1,0,0,0,0),
725 array(0,0,0,0,1,0,0,0,0),
726 array(0,0,0,0,1,0,0,0,0),
727 array(0,0,0,0,1,0,0,0,0),
728 array(1,1,1,1,1,1,1,1,1),
729 ),
730 array(
731 array(0,0,0,1,1,1,0,0,0),
732 array(0,0,0,0,1,0,0,0,0),
733 array(0,0,0,0,1,0,0,0,0),
734 array(0,0,0,0,1,0,0,0,0),
735 array(0,0,0,0,1,0,0,0,0),
736 array(0,0,0,0,1,0,0,0,0),
737 array(0,0,0,0,1,0,0,0,0),
738 array(0,0,0,0,1,0,0,0,0),
739 array(0,0,0,0,1,0,0,0,0),
740 array(0,0,0,0,1,0,0,0,0),
741 array(0,0,0,0,1,0,0,0,0),
742 array(0,0,0,0,1,0,0,0,0),
743 array(0,0,0,0,1,0,0,0,0),
744 array(0,0,0,0,1,0,0,0,0),
745 array(0,0,0,1,1,1,0,0,0),
746 ),
747 array(
748 array(0,0,0,0,0,0,0,0,0),
749 array(0,0,0,0,0,0,0,0,0),
750 array(0,0,0,0,0,0,0,0,0),
751 array(0,0,0,0,1,0,0,0,0),
752 array(0,0,0,1,1,1,0,0,0),
753 array(0,0,0,0,1,0,0,0,0),
754 array(0,0,0,0,0,0,0,0,0),
755 array(0,0,0,0,1,0,0,0,0),
756 array(0,0,0,0,1,0,0,0,0),
757 array(0,0,0,0,1,0,0,0,0),
758 array(0,0,0,0,1,0,0,0,0),
759 array(0,0,0,0,1,0,0,0,0),
760 array(0,0,0,0,1,0,0,0,0),
761 array(0,0,0,0,1,0,0,0,0),
762 array(0,0,0,1,1,1,0,0,0),
763 ),
764 ),
765 'J' => array(
766 array(
767 array(1,1,1,1,1,1,1,1,1),
768 array(0,0,0,0,0,1,0,0,0),
769 array(0,0,0,0,0,1,0,0,0),
770 array(0,0,0,0,0,1,0,0,0),
771 array(0,0,0,0,0,1,0,0,0),
772 array(0,0,0,0,0,1,0,0,0),
773 array(0,0,0,0,0,1,0,0,0),
774 array(0,0,0,0,0,1,0,0,0),
775 array(0,0,0,0,0,1,0,0,0),
776 array(0,0,0,0,0,1,0,0,0),
777 array(0,0,0,0,0,1,0,0,0),
778 array(1,0,0,0,0,1,0,0,0),
779 array(1,0,0,0,0,1,0,0,0),
780 array(0,1,0,0,1,0,0,0,0),
781 array(0,0,1,1,0,0,0,0,0),
782 ),
783 array(
784 array(1,1,1,1,1,1,1,1,1),
785 array(0,0,0,0,0,1,0,0,0),
786 array(0,0,0,0,0,1,0,0,0),
787 array(0,0,0,0,0,1,0,0,0),
788 array(0,0,0,0,0,1,0,0,0),
789 array(0,0,0,0,0,1,0,0,0),
790 array(0,0,0,0,0,1,0,0,0),
791 array(0,0,0,0,0,1,0,0,0),
792 array(0,0,0,0,0,1,0,0,0),
793 array(0,0,0,0,0,1,0,0,0),
794 array(0,0,0,0,0,1,0,0,0),
795 array(1,0,0,0,0,1,0,0,0),
796 array(1,0,0,0,0,1,0,0,0),
797 array(1,1,0,0,1,0,0,0,0),
798 array(1,0,1,1,0,0,0,0,0),
799 ),
800 array(
801 array(0,0,0,0,0,0,0,0,0),
802 array(0,0,0,0,0,0,0,0,0),
803 array(0,0,0,0,0,0,0,0,0),
804 array(0,0,0,0,0,0,0,0,0),
805 array(0,0,0,0,0,1,0,0,0),
806 array(0,0,0,0,0,0,0,0,0),
807 array(0,0,0,0,0,1,0,0,0),
808 array(0,0,0,0,0,1,0,0,0),
809 array(0,0,0,0,0,1,0,0,0),
810 array(0,0,0,0,0,1,0,0,0),
811 array(0,0,0,0,0,1,0,0,0),
812 array(1,0,0,0,0,1,0,0,0),
813 array(1,0,0,0,0,1,0,0,0),
814 array(0,1,0,0,1,0,0,0,0),
815 array(0,0,1,1,0,0,0,0,0),
816 ),
817 ),
818 'K' => array(
819 array( // New 'K', supplied by NeoThermic
820 array(1,0,0,0,0,0,0,0,1),
821 array(1,0,0,0,0,0,0,1,0),
822 array(1,0,0,0,0,0,1,0,0),
823 array(1,0,0,0,0,1,0,0,0),
824 array(1,0,0,0,1,0,0,0,0),
825 array(1,0,0,1,0,0,0,0,0),
826 array(1,0,1,0,0,0,0,0,0),
827 array(1,1,0,0,0,0,0,0,0),
828 array(1,0,1,0,0,0,0,0,0),
829 array(1,0,0,1,0,0,0,0,0),
830 array(1,0,0,0,1,0,0,0,0),
831 array(1,0,0,0,0,1,0,0,0),
832 array(1,0,0,0,0,0,1,0,0),
833 array(1,0,0,0,0,0,0,1,0),
834 array(1,0,0,0,0,0,0,0,1),
835 ),
836 array(
837 array(0,1,0,0,0,0,0,0,1),
838 array(0,1,0,0,0,0,0,1,0),
839 array(0,1,0,0,0,0,1,0,0),
840 array(0,1,0,0,0,1,0,0,0),
841 array(0,1,0,0,1,0,0,0,0),
842 array(0,1,0,1,0,0,0,0,0),
843 array(0,1,1,0,0,0,0,0,0),
844 array(0,1,0,0,0,0,0,0,0),
845 array(0,1,1,0,0,0,0,0,0),
846 array(0,1,0,1,0,0,0,0,0),
847 array(0,1,0,0,1,0,0,0,0),
848 array(0,1,0,0,0,1,0,0,0),
849 array(0,1,0,0,0,0,1,0,0),
850 array(0,1,0,0,0,0,0,1,0),
851 array(1,1,1,0,0,0,1,1,1),
852 ),
853 array(
854 array(0,0,0,0,0,0,0,0,0),
855 array(0,1,0,0,0,0,0,0,0),
856 array(0,1,0,0,0,0,0,0,0),
857 array(0,1,0,0,0,1,0,0,0),
858 array(0,1,0,0,1,0,0,0,0),
859 array(0,1,0,1,0,0,0,0,0),
860 array(0,1,1,0,0,0,0,0,0),
861 array(0,1,0,0,0,0,0,0,0),
862 array(0,1,1,0,0,0,0,0,0),
863 array(0,1,0,1,0,0,0,0,0),
864 array(0,1,0,0,1,0,0,0,0),
865 array(0,1,0,0,0,1,0,0,0),
866 array(0,1,0,0,0,0,1,0,0),
867 array(0,1,0,0,0,0,0,1,0),
868 array(0,1,0,0,0,0,0,1,0),
869 ),
870 ),
871 'L' => array(
872 array(
873 array(0,0,0,0,0,0,0,0,0),
874 array(1,0,0,0,0,0,0,0,0),
875 array(1,0,0,0,0,0,0,0,0),
876 array(1,0,0,0,0,0,0,0,0),
877 array(1,0,0,0,0,0,0,0,0),
878 array(1,0,0,0,0,0,0,0,0),
879 array(1,0,0,0,0,0,0,0,0),
880 array(1,0,0,0,0,0,0,0,0),
881 array(1,0,0,0,0,0,0,0,0),
882 array(1,0,0,0,0,0,0,0,0),
883 array(1,0,0,0,0,0,0,0,0),
884 array(1,0,0,0,0,0,0,0,0),
885 array(1,0,0,0,0,0,0,0,0),
886 array(1,0,0,0,0,0,0,0,0),
887 array(1,1,1,1,1,1,1,1,1),
888 ),
889 array(
890 array(0,0,0,0,0,0,0,0,0),
891 array(0,1,0,0,0,0,0,0,0),
892 array(0,1,0,0,0,0,0,0,0),
893 array(0,1,0,0,0,0,0,0,0),
894 array(0,1,0,0,0,0,0,0,0),
895 array(0,1,0,0,0,0,0,0,0),
896 array(0,1,0,0,0,0,0,0,0),
897 array(0,1,0,0,0,0,0,0,0),
898 array(0,1,0,0,0,0,0,0,0),
899 array(0,1,0,0,0,0,0,0,0),
900 array(0,1,0,0,0,0,0,0,0),
901 array(0,1,0,0,0,0,0,0,0),
902 array(0,1,0,0,0,0,0,0,0),
903 array(0,1,0,0,0,0,0,0,1),
904 array(1,1,1,1,1,1,1,1,1),
905 ),
906 array(
907 array(0,0,0,0,0,0,0,0,0),
908 array(0,1,0,0,0,0,0,0,0),
909 array(0,1,0,0,0,0,0,0,0),
910 array(0,1,0,0,0,0,0,0,0),
911 array(0,1,0,0,0,0,0,0,0),
912 array(0,1,0,0,0,0,0,0,0),
913 array(0,1,0,0,0,0,0,0,0),
914 array(0,1,0,0,0,0,0,0,0),
915 array(0,1,0,0,0,0,0,0,0),
916 array(0,1,0,0,0,0,0,0,0),
917 array(0,1,0,0,0,0,0,0,0),
918 array(0,1,0,0,0,0,0,0,0),
919 array(0,1,0,0,0,0,0,0,0),
920 array(0,1,1,0,0,0,0,0,0),
921 array(0,0,1,1,1,0,0,0,0),
922 ),
923 ),
924 'M' => array(
925 array(
926 array(1,1,0,0,0,0,0,1,1),
927 array(1,1,0,0,0,0,0,1,1),
928 array(1,0,1,0,0,0,1,0,1),
929 array(1,0,1,0,0,0,1,0,1),
930 array(1,0,1,0,0,0,1,0,1),
931 array(1,0,0,1,0,1,0,0,1),
932 array(1,0,0,1,0,1,0,0,1),
933 array(1,0,0,1,0,1,0,0,1),
934 array(1,0,0,0,1,0,0,0,1),
935 array(1,0,0,0,1,0,0,0,1),
936 array(1,0,0,0,0,0,0,0,1),
937 array(1,0,0,0,0,0,0,0,1),
938 array(1,0,0,0,0,0,0,0,1),
939 array(1,0,0,0,0,0,0,0,1),
940 array(1,0,0,0,0,0,0,0,1),
941 ),
942 array(
943 array(0,0,0,0,0,0,0,0,0),
944 array(0,1,0,0,0,0,0,1,0),
945 array(0,1,1,0,0,0,1,1,0),
946 array(0,1,1,0,0,0,1,1,0),
947 array(0,1,1,0,0,0,1,1,0),
948 array(0,1,0,1,0,1,0,1,0),
949 array(0,1,0,1,0,1,0,1,0),
950 array(0,1,0,1,0,1,0,1,0),
951 array(0,1,0,0,1,0,0,1,0),
952 array(0,1,0,0,1,0,0,1,0),
953 array(0,1,0,0,0,0,0,1,0),
954 array(0,1,0,0,0,0,0,1,0),
955 array(0,1,0,0,0,0,0,1,0),
956 array(0,1,0,0,0,0,0,1,0),
957 array(1,1,1,0,0,0,1,1,1),
958 ),
959 array(
960 array(0,0,0,0,0,0,0,0,0),
961 array(0,0,0,0,0,0,0,0,0),
962 array(0,0,0,0,0,0,0,0,0),
963 array(0,0,0,0,0,0,0,0,0),
964 array(0,0,0,0,0,0,0,0,0),
965 array(0,0,0,0,0,0,0,0,0),
966 array(0,1,1,1,0,1,1,1,0),
967 array(1,1,0,1,1,1,0,1,1),
968 array(1,0,0,0,1,0,0,0,1),
969 array(1,0,0,0,1,0,0,0,1),
970 array(1,0,0,0,1,0,0,0,1),
971 array(1,0,0,0,1,0,0,0,1),
972 array(1,0,0,0,1,0,0,0,1),
973 array(1,0,0,0,1,0,0,0,1),
974 array(1,0,0,0,1,0,0,0,1),
975 ),
976 ),
977 'N' => array(
978 array(
979 array(1,1,0,0,0,0,0,0,1),
980 array(1,1,0,0,0,0,0,0,1),
981 array(1,0,1,0,0,0,0,0,1),
982 array(1,0,1,0,0,0,0,0,1),
983 array(1,0,0,1,0,0,0,0,1),
984 array(1,0,0,1,0,0,0,0,1),
985 array(1,0,0,0,1,0,0,0,1),
986 array(1,0,0,0,1,0,0,0,1),
987 array(1,0,0,0,1,0,0,0,1),
988 array(1,0,0,0,0,1,0,0,1),
989 array(1,0,0,0,0,1,0,0,1),
990 array(1,0,0,0,0,0,1,0,1),
991 array(1,0,0,0,0,0,1,0,1),
992 array(1,0,0,0,0,0,0,1,1),
993 array(1,0,0,0,0,0,0,1,1),
994 ),
995 array(
996 array(0,0,0,0,0,0,0,0,0),
997 array(0,1,0,0,0,0,0,1,0),
998 array(0,1,1,0,0,0,0,1,0),
999 array(0,1,1,0,0,0,0,1,0),
1000 array(0,1,1,0,0,0,0,1,0),
1001 array(0,1,0,1,0,0,0,1,0),
1002 array(0,1,0,1,0,0,0,1,0),
1003 array(0,1,0,1,0,0,0,1,0),
1004 array(0,1,0,0,1,0,0,1,0),
1005 array(0,1,0,0,1,1,0,1,0),
1006 array(0,1,0,0,0,1,0,1,0),
1007 array(0,1,0,0,0,1,1,1,0),
1008 array(0,1,0,0,0,0,1,1,0),
1009 array(0,1,0,0,0,0,0,1,0),
1010 array(1,1,1,0,0,0,1,1,1),
1011 ),
1012 array(
1013 array(0,0,0,0,0,0,0,0,0),
1014 array(0,0,0,0,0,0,0,0,0),
1015 array(0,0,0,0,0,0,0,0,0),
1016 array(0,0,0,0,0,0,0,0,0),
1017 array(0,0,0,0,0,0,0,0,0),
1018 array(0,0,0,0,0,0,0,0,0),
1019 array(0,0,0,0,0,0,0,0,0),
1020 array(1,0,1,1,1,1,0,0,0),
1021 array(1,1,1,0,0,1,1,0,0),
1022 array(1,0,0,0,0,0,1,0,0),
1023 array(1,0,0,0,0,0,1,0,0),
1024 array(1,0,0,0,0,0,1,0,0),
1025 array(1,0,0,0,0,0,1,0,0),
1026 array(1,0,0,0,0,0,1,0,0),
1027 array(1,0,0,0,0,0,1,0,0),
1028 ),
1029 ),
1030 'O' => array(
1031 array(
1032 array(0,0,1,1,1,1,1,0,0),
1033 array(0,1,0,0,0,0,0,1,0),
1034 array(1,0,0,0,0,0,0,0,1),
1035 array(1,0,0,0,0,0,0,0,1),
1036 array(1,0,0,0,0,0,0,0,1),
1037 array(1,0,0,0,0,0,0,0,1),
1038 array(1,0,0,0,0,0,0,0,1),
1039 array(1,0,0,0,0,0,0,0,1),
1040 array(1,0,0,0,0,0,0,0,1),
1041 array(1,0,0,0,0,0,0,0,1),
1042 array(1,0,0,0,0,0,0,0,1),
1043 array(1,0,0,0,0,0,0,0,1),
1044 array(1,0,0,0,0,0,0,0,1),
1045 array(0,1,0,0,0,0,0,1,0),
1046 array(0,0,1,1,1,1,1,0,0),
1047 ),
1048 array(
1049 array(0,0,1,1,1,1,1,0,0),
1050 array(0,1,0,0,0,0,0,1,0),
1051 array(1,1,0,0,0,0,0,1,1),
1052 array(1,1,0,0,0,0,0,1,1),
1053 array(1,1,0,0,0,0,0,1,1),
1054 array(1,1,0,0,0,0,0,1,1),
1055 array(1,1,0,0,0,0,0,1,1),
1056 array(1,1,0,0,0,0,0,1,1),
1057 array(1,1,0,0,0,0,0,1,1),
1058 array(1,1,0,0,0,0,0,1,1),
1059 array(1,1,0,0,0,0,0,1,1),
1060 array(1,1,0,0,0,0,0,1,1),
1061 array(1,1,0,0,0,0,0,1,1),
1062 array(0,1,0,0,0,0,0,1,0),
1063 array(0,0,1,1,1,1,1,0,0),
1064 ),
1065 array(
1066 array(0,0,0,0,0,0,0,0,0),
1067 array(0,0,0,0,0,0,0,0,0),
1068 array(0,0,0,0,0,0,0,0,0),
1069 array(0,0,0,0,0,0,0,0,0),
1070 array(0,0,0,0,0,0,0,0,0),
1071 array(0,0,0,0,0,0,0,0,0),
1072 array(0,0,0,0,0,0,0,0,0),
1073 array(0,1,1,1,1,1,0,0,0),
1074 array(1,1,1,0,0,1,1,0,0),
1075 array(1,0,0,0,0,0,1,0,0),
1076 array(1,0,0,0,0,0,1,0,0),
1077 array(1,0,0,0,0,0,1,0,0),
1078 array(1,0,0,0,0,0,1,0,0),
1079 array(1,1,0,0,0,1,1,0,0),
1080 array(0,1,1,1,1,1,0,0,0),
1081 ),
1082 ),
1083 'P' => array(
1084 array(
1085 array(1,1,1,1,1,1,1,0,0),
1086 array(1,0,0,0,0,0,0,1,0),
1087 array(1,0,0,0,0,0,0,0,1),
1088 array(1,0,0,0,0,0,0,0,1),
1089 array(1,0,0,0,0,0,0,0,1),
1090 array(1,0,0,0,0,0,0,0,1),
1091 array(1,0,0,0,0,0,0,1,0),
1092 array(1,1,1,1,1,1,1,0,0),
1093 array(1,0,0,0,0,0,0,0,0),
1094 array(1,0,0,0,0,0,0,0,0),
1095 array(1,0,0,0,0,0,0,0,0),
1096 array(1,0,0,0,0,0,0,0,0),
1097 array(1,0,0,0,0,0,0,0,0),
1098 array(1,0,0,0,0,0,0,0,0),
1099 array(1,0,0,0,0,0,0,0,0),
1100 ),
1101 array(
1102 array(1,1,1,1,1,1,1,0,0),
1103 array(0,1,0,0,0,0,0,1,0),
1104 array(0,1,0,0,0,0,0,0,1),
1105 array(0,1,0,0,0,0,0,0,1),
1106 array(0,1,0,0,0,0,0,0,1),
1107 array(0,1,0,0,0,0,0,0,1),
1108 array(0,1,0,0,0,0,0,1,0),
1109 array(1,1,1,1,1,1,1,0,0),
1110 array(0,1,0,0,0,0,0,0,0),
1111 array(0,1,0,0,0,0,0,0,0),
1112 array(0,1,0,0,0,0,0,0,0),
1113 array(0,1,0,0,0,0,0,0,0),
1114 array(0,1,0,0,0,0,0,0,0),
1115 array(0,1,0,0,0,0,0,0,0),
1116 array(1,1,1,0,0,0,0,0,0),
1117 ),
1118 array(
1119 array(0,0,0,0,0,0,0,0,0),
1120 array(0,0,0,0,0,0,0,0,0),
1121 array(1,0,0,0,0,0,0,0,0),
1122 array(1,0,1,1,0,0,0,0,0),
1123 array(1,1,0,1,1,0,0,0,0),
1124 array(1,0,0,0,1,0,0,0,0),
1125 array(1,0,0,0,1,0,0,0,0),
1126 array(1,0,0,1,1,0,0,0,0),
1127 array(1,1,1,1,0,0,0,0,0),
1128 array(1,0,0,0,0,0,0,0,0),
1129 array(1,0,0,0,0,0,0,0,0),
1130 array(1,0,0,0,0,0,0,0,0),
1131 array(1,0,0,0,0,0,0,0,0),
1132 array(1,0,0,0,0,0,0,0,0),
1133 array(1,0,0,0,0,0,0,0,0),
1134 ),
1135 ),
1136 'Q' => array(
1137 array(
1138 array(0,0,1,1,1,1,1,0,0),
1139 array(0,1,0,0,0,0,0,1,0),
1140 array(1,0,0,0,0,0,0,0,1),
1141 array(1,0,0,0,0,0,0,0,1),
1142 array(1,0,0,0,0,0,0,0,1),
1143 array(1,0,0,0,0,0,0,0,1),
1144 array(1,0,0,0,0,0,0,0,1),
1145 array(1,0,0,0,0,0,0,0,1),
1146 array(1,0,0,0,0,0,0,0,1),
1147 array(1,0,0,0,0,0,0,0,1),
1148 array(1,0,0,0,0,0,0,0,1),
1149 array(1,0,0,0,0,1,0,0,1),
1150 array(1,0,0,0,0,0,1,0,1),
1151 array(0,1,0,0,0,0,0,1,0),
1152 array(0,0,1,1,1,1,1,0,1),
1153 ),
1154 array(
1155 array(0,0,1,1,1,1,1,0,0),
1156 array(0,1,0,0,0,0,0,1,0),
1157 array(1,0,0,0,0,0,0,0,1),
1158 array(1,0,0,0,0,0,0,0,1),
1159 array(1,0,0,0,0,0,0,0,1),
1160 array(1,0,0,0,0,0,0,0,1),
1161 array(1,0,0,0,0,0,0,0,1),
1162 array(1,0,0,0,0,0,0,0,1),
1163 array(1,0,0,0,0,0,0,0,1),
1164 array(1,0,0,0,1,0,0,0,1),
1165 array(1,1,0,0,1,1,0,1,1),
1166 array(0,1,1,1,1,1,1,1,0),
1167 array(0,0,0,0,0,0,1,1,0),
1168 array(0,0,0,0,0,0,0,1,1),
1169 array(0,0,0,0,0,0,0,0,1),
1170 ),
1171 array(
1172 array(0,0,0,0,0,0,0,0,0),
1173 array(0,0,0,0,0,0,0,0,0),
1174 array(0,0,0,0,0,0,0,0,0),
1175 array(0,0,0,0,0,1,1,1,1),
1176 array(0,0,0,0,1,1,0,0,1),
1177 array(0,0,0,0,1,0,0,0,1),
1178 array(0,0,0,0,1,0,0,0,1),
1179 array(0,0,0,0,1,1,0,1,1),
1180 array(0,0,0,0,0,1,1,0,1),
1181 array(0,0,0,0,0,0,0,0,1),
1182 array(0,0,0,0,0,0,0,0,1),
1183 array(0,0,0,0,0,0,0,0,1),
1184 array(0,0,0,0,0,0,0,0,1),
1185 array(0,0,0,0,0,0,0,0,1),
1186 array(0,0,0,0,0,0,0,0,1),
1187 ),
1188 ),
1189 'R' => array(
1190 array(
1191 array(1,1,1,1,1,1,1,0,0),
1192 array(1,0,0,0,0,0,0,1,0),
1193 array(1,0,0,0,0,0,0,0,1),
1194 array(1,0,0,0,0,0,0,0,1),
1195 array(1,0,0,0,0,0,0,0,1),
1196 array(1,0,0,0,0,0,0,0,1),
1197 array(1,0,0,0,0,0,0,1,0),
1198 array(1,1,1,1,1,1,1,0,0),
1199 array(1,1,1,0,0,0,0,0,0),
1200 array(1,0,0,1,0,0,0,0,0),
1201 array(1,0,0,0,1,0,0,0,0),
1202 array(1,0,0,0,0,1,0,0,0),
1203 array(1,0,0,0,0,0,1,0,0),
1204 array(1,0,0,0,0,0,0,1,0),
1205 array(1,0,0,0,0,0,0,0,1),
1206 ),
1207 array(
1208 array(1,1,1,1,1,1,1,0,0),
1209 array(0,1,0,0,0,0,0,1,0),
1210 array(0,1,0,0,0,0,0,0,1),
1211 array(0,1,0,0,0,0,0,0,1),
1212 array(0,1,0,0,0,0,0,0,1),
1213 array(0,1,0,0,0,0,0,0,1),
1214 array(0,1,0,0,0,0,0,1,0),
1215 array(1,1,1,1,1,1,1,0,0),
1216 array(0,1,1,0,0,0,0,0,0),
1217 array(0,1,1,1,0,0,0,0,0),
1218 array(0,1,0,1,1,0,0,0,0),
1219 array(0,1,0,0,1,1,0,0,0),
1220 array(0,1,0,0,0,1,1,0,0),
1221 array(0,1,0,0,0,0,1,1,0),
1222 array(1,1,1,0,0,0,1,1,1),
1223 ),
1224 array(
1225 array(0,0,0,0,0,0,0,0,0),
1226 array(0,0,0,0,0,0,0,0,0),
1227 array(0,0,0,0,0,0,0,0,0),
1228 array(0,0,0,0,0,0,0,0,0),
1229 array(0,0,0,0,0,0,0,0,0),
1230 array(0,0,0,0,0,0,0,0,0),
1231 array(1,0,0,0,0,0,0,0,0),
1232 array(1,1,1,1,1,0,0,0,0),
1233 array(1,1,0,0,1,1,0,0,0),
1234 array(1,0,0,0,0,0,0,0,0),
1235 array(1,0,0,0,0,0,0,0,0),
1236 array(1,0,0,0,0,0,0,0,0),
1237 array(1,0,0,0,0,0,0,0,0),
1238 array(1,0,0,0,0,0,0,0,0),
1239 array(1,0,0,0,0,0,0,0,0),
1240 ),
1241 ),
1242 'S' => array(
1243 array(
1244 array(0,0,1,1,1,1,1,0,0),
1245 array(0,1,0,0,0,0,0,1,0),
1246 array(1,0,0,0,0,0,0,0,1),
1247 array(1,0,0,0,0,0,0,0,0),
1248 array(1,0,0,0,0,0,0,0,0),
1249 array(1,0,0,0,0,0,0,0,0),
1250 array(0,1,0,0,0,0,0,0,0),
1251 array(0,0,1,1,1,1,1,0,0),
1252 array(0,0,0,0,0,0,0,1,0),
1253 array(0,0,0,0,0,0,0,0,1),
1254 array(0,0,0,0,0,0,0,0,1),
1255 array(0,0,0,0,0,0,0,0,1),
1256 array(1,0,0,0,0,0,0,0,1),
1257 array(0,1,0,0,0,0,0,1,0),
1258 array(0,0,1,1,1,1,1,0,0),
1259 ),
1260 array(
1261 array(0,0,1,1,1,1,1,0,1),
1262 array(0,1,0,0,0,0,0,1,1),
1263 array(1,0,0,0,0,0,0,0,1),
1264 array(1,0,0,0,0,0,0,0,1),
1265 array(1,0,0,0,0,0,0,0,0),
1266 array(1,0,0,0,0,0,0,0,0),
1267 array(0,1,0,0,0,0,0,0,0),
1268 array(0,0,1,1,1,1,1,0,0),
1269 array(0,0,0,0,0,0,0,1,0),
1270 array(0,0,0,0,0,0,0,0,1),
1271 array(1,0,0,0,0,0,0,0,1),
1272 array(1,0,0,0,0,0,0,0,1),
1273 array(1,0,0,0,0,0,0,0,1),
1274 array(1,1,0,0,0,0,0,1,0),
1275 array(1,0,1,1,1,1,1,0,0),
1276 ),
1277 array(
1278 array(0,0,0,0,0,0,0,0,0),
1279 array(0,0,0,0,0,0,0,0,0),
1280 array(0,0,0,0,0,0,0,0,0),
1281 array(0,0,0,0,0,0,0,0,0),
1282 array(0,0,0,0,0,0,0,0,0),
1283 array(0,0,0,0,0,0,0,0,0),
1284 array(0,0,0,0,0,0,0,0,0),
1285 array(0,1,1,1,1,0,0,0,0),
1286 array(1,0,0,0,0,1,0,0,0),
1287 array(1,0,0,0,0,0,0,0,0),
1288 array(1,1,0,0,0,0,0,0,0),
1289 array(0,1,1,1,1,0,0,0,0),
1290 array(0,0,0,0,0,1,0,0,0),
1291 array(1,0,0,0,1,1,0,0,0),
1292 array(0,1,1,1,1,0,0,0,0),
1293 ),
1294 ),
1295 'T' => array(
1296 array(
1297 array(1,1,1,1,1,1,1,1,1),
1298 array(0,0,0,0,1,0,0,0,0),
1299 array(0,0,0,0,1,0,0,0,0),
1300 array(0,0,0,0,1,0,0,0,0),
1301 array(0,0,0,0,1,0,0,0,0),
1302 array(0,0,0,0,1,0,0,0,0),
1303 array(0,0,0,0,1,0,0,0,0),
1304 array(0,0,0,0,1,0,0,0,0),
1305 array(0,0,0,0,1,0,0,0,0),
1306 array(0,0,0,0,1,0,0,0,0),
1307 array(0,0,0,0,1,0,0,0,0),
1308 array(0,0,0,0,1,0,0,0,0),
1309 array(0,0,0,0,1,0,0,0,0),
1310 array(0,0,0,0,1,0,0,0,0),
1311 array(0,0,0,0,1,0,0,0,0),
1312 ),
1313 array(
1314 array(1,1,1,1,1,1,1,1,1),
1315 array(1,0,0,0,1,0,0,0,1),
1316 array(0,0,0,0,1,0,0,0,0),
1317 array(0,0,0,0,1,0,0,0,0),
1318 array(0,0,0,0,1,0,0,0,0),
1319 array(0,0,0,0,1,0,0,0,0),
1320 array(0,0,0,0,1,0,0,0,0),
1321 array(0,0,0,0,1,0,0,0,0),
1322 array(0,0,0,0,1,0,0,0,0),
1323 array(0,0,0,0,1,0,0,0,0),
1324 array(0,0,0,0,1,0,0,0,0),
1325 array(0,0,0,0,1,0,0,0,0),
1326 array(0,0,0,0,1,0,0,0,0),
1327 array(0,0,0,0,1,0,0,0,0),
1328 array(0,0,0,1,1,1,0,0,0),
1329 ),
1330 array(
1331 array(0,0,0,0,1,0,0,0,0),
1332 array(0,0,0,0,1,0,0,0,0),
1333 array(0,0,0,0,1,0,0,0,0),
1334 array(0,0,1,1,1,1,1,1,0),
1335 array(0,0,0,0,1,0,0,0,0),
1336 array(0,0,0,0,1,0,0,0,0),
1337 array(0,0,0,0,1,0,0,0,0),
1338 array(0,0,0,0,1,0,0,0,0),
1339 array(0,0,0,0,1,0,0,0,0),
1340 array(0,0,0,0,1,0,0,0,0),
1341 array(0,0,0,0,1,0,0,0,0),
1342 array(0,0,0,0,1,0,0,0,0),
1343 array(0,0,0,0,1,0,0,0,0),
1344 array(0,0,0,0,1,1,0,0,0),
1345 array(0,0,0,0,0,1,1,1,0),
1346 ),
1347 ),
1348 'U' => array(
1349 array(
1350 array(1,0,0,0,0,0,0,0,1),
1351 array(1,0,0,0,0,0,0,0,1),
1352 array(1,0,0,0,0,0,0,0,1),
1353 array(1,0,0,0,0,0,0,0,1),
1354 array(1,0,0,0,0,0,0,0,1),
1355 array(1,0,0,0,0,0,0,0,1),
1356 array(1,0,0,0,0,0,0,0,1),
1357 array(1,0,0,0,0,0,0,0,1),
1358 array(1,0,0,0,0,0,0,0,1),
1359 array(1,0,0,0,0,0,0,0,1),
1360 array(1,0,0,0,0,0,0,0,1),
1361 array(1,0,0,0,0,0,0,0,1),
1362 array(1,0,0,0,0,0,0,0,1),
1363 array(0,1,0,0,0,0,0,1,0),
1364 array(0,0,1,1,1,1,1,0,0),
1365 ),
1366 array(
1367 array(1,0,0,0,0,0,0,0,0),
1368 array(1,1,1,0,0,0,1,1,1),
1369 array(0,1,0,0,0,0,0,1,0),
1370 array(0,1,0,0,0,0,0,1,0),
1371 array(0,1,0,0,0,0,0,1,0),
1372 array(0,1,0,0,0,0,0,1,0),
1373 array(0,1,0,0,0,0,0,1,0),
1374 array(0,1,0,0,0,0,0,1,0),
1375 array(0,1,0,0,0,0,0,1,0),
1376 array(0,1,0,0,0,0,0,1,0),
1377 array(0,1,0,0,0,0,0,1,0),
1378 array(0,1,0,0,0,0,0,1,0),
1379 array(0,1,0,0,0,0,0,1,0),
1380 array(0,1,1,0,0,0,1,1,0),
1381 array(0,0,1,1,1,1,1,0,0),
1382 ),
1383 array(
1384 array(0,0,0,0,0,0,0,0,0),
1385 array(0,0,0,0,0,0,0,0,0),
1386 array(0,0,0,0,0,0,0,0,0),
1387 array(0,0,0,0,0,0,0,0,0),
1388 array(0,0,0,0,0,0,0,0,0),
1389 array(0,0,0,0,0,0,0,0,0),
1390 array(0,0,0,0,0,0,0,0,0),
1391 array(0,0,1,0,0,0,0,0,1),
1392 array(0,0,1,0,0,0,0,0,1),
1393 array(0,0,1,0,0,0,0,0,1),
1394 array(0,0,1,0,0,0,0,0,1),
1395 array(0,0,1,0,0,0,0,0,1),
1396 array(0,0,1,0,0,0,0,1,1),
1397 array(0,0,1,1,0,0,1,1,1),
1398 array(0,0,0,1,1,1,1,0,1),
1399 ),
1400 ),
1401 'V' => array(
1402 array(
1403 array(1,0,0,0,0,0,0,0,1),
1404 array(1,0,0,0,0,0,0,0,1),
1405 array(1,0,0,0,0,0,0,0,1),
1406 array(0,1,0,0,0,0,0,1,0),
1407 array(0,1,0,0,0,0,0,1,0),
1408 array(0,1,0,0,0,0,0,1,0),
1409 array(0,0,1,0,0,0,1,0,0),
1410 array(0,0,1,0,0,0,1,0,0),
1411 array(0,0,1,0,0,0,1,0,0),
1412 array(0,0,1,0,0,0,1,0,0),
1413 array(0,0,0,1,0,1,0,0,0),
1414 array(0,0,0,1,0,1,0,0,0),
1415 array(0,0,0,1,0,1,0,0,0),
1416 array(0,0,0,0,1,0,0,0,0),
1417 array(0,0,0,0,1,0,0,0,0),
1418 ),
1419 array(
1420 array(0,0,0,0,0,0,0,0,0),
1421 array(0,0,0,0,0,0,0,0,0),
1422 array(0,0,0,0,0,0,0,0,0),
1423 array(1,1,1,0,0,0,1,1,1),
1424 array(0,1,0,0,0,0,0,1,0),
1425 array(0,1,0,0,0,0,0,1,0),
1426 array(0,0,1,0,0,0,1,0,0),
1427 array(0,0,1,0,0,0,1,0,0),
1428 array(0,0,1,0,0,0,1,0,0),
1429 array(0,0,1,0,0,0,1,0,0),
1430 array(0,0,0,1,0,1,0,0,0),
1431 array(0,0,0,1,0,1,0,0,0),
1432 array(0,0,0,1,0,1,0,0,0),
1433 array(0,0,0,0,1,0,0,0,0),
1434 array(0,0,0,0,1,0,0,0,0),
1435 ),
1436 array(
1437 array(0,0,0,0,0,0,0,0,0),
1438 array(0,0,0,0,0,0,0,0,0),
1439 array(0,0,0,0,0,0,0,0,0),
1440 array(0,0,0,0,0,0,0,0,0),
1441 array(0,0,0,0,0,0,0,0,0),
1442 array(0,0,0,0,0,0,0,0,0),
1443 array(0,0,1,0,0,0,1,0,0),
1444 array(0,0,1,0,0,0,1,0,0),
1445 array(0,0,1,0,0,0,1,0,0),
1446 array(0,0,1,0,0,0,1,0,0),
1447 array(0,0,0,1,0,1,0,0,0),
1448 array(0,0,0,1,0,1,0,0,0),
1449 array(0,0,0,1,0,1,0,0,0),
1450 array(0,0,0,0,1,0,0,0,0),
1451 array(0,0,0,0,1,0,0,0,0),
1452 ),
1453 ),
1454 'W' => array(
1455 array(
1456 array(1,0,0,0,0,0,0,0,1),
1457 array(1,0,0,0,0,0,0,0,1),
1458 array(1,0,0,0,0,0,0,0,1),
1459 array(1,0,0,0,0,0,0,0,1),
1460 array(1,0,0,0,0,0,0,0,1),
1461 array(1,0,0,0,1,0,0,0,1),
1462 array(1,0,0,0,1,0,0,0,1),
1463 array(1,0,0,1,0,1,0,0,1),
1464 array(1,0,0,1,0,1,0,0,1),
1465 array(1,0,0,1,0,1,0,0,1),
1466 array(1,0,1,0,0,0,1,0,1),
1467 array(1,0,1,0,0,0,1,0,1),
1468 array(1,0,1,0,0,0,1,0,1),
1469 array(1,1,0,0,0,0,0,1,1),
1470 array(1,1,0,0,0,0,0,1,1),
1471 ),
1472 array(
1473 array(0,0,0,0,0,0,0,0,0),
1474 array(0,0,0,0,0,0,0,0,0),
1475 array(1,1,1,0,0,0,1,1,1),
1476 array(0,1,0,0,0,0,0,1,0),
1477 array(0,1,0,0,0,0,0,1,0),
1478 array(0,1,0,0,0,0,0,1,0),
1479 array(0,1,0,0,0,0,0,1,0),
1480 array(0,1,0,0,1,0,0,1,0),
1481 array(0,1,0,0,1,0,0,1,0),
1482 array(0,1,0,1,1,1,0,1,0),
1483 array(0,1,0,1,0,1,0,1,0),
1484 array(0,1,1,1,0,1,1,1,0),
1485 array(0,1,1,0,0,0,1,1,0),
1486 array(0,1,0,0,0,0,0,1,0),
1487 array(0,0,0,0,0,0,0,0,0),
1488 ),
1489 array(
1490 array(0,0,0,0,0,0,0,0,0),
1491 array(0,0,0,0,0,0,0,0,0),
1492 array(0,0,0,0,0,0,0,0,0),
1493 array(0,0,0,0,0,0,0,0,0),
1494 array(0,0,0,0,0,0,0,0,0),
1495 array(0,0,0,0,0,0,0,0,0),
1496 array(0,1,0,0,0,0,0,1,0),
1497 array(0,1,0,0,1,0,0,1,0),
1498 array(0,1,0,0,1,0,0,1,0),
1499 array(0,1,0,1,1,1,0,1,0),
1500 array(0,1,0,1,0,1,0,1,0),
1501 array(0,1,1,1,0,1,1,1,0),
1502 array(0,1,1,0,0,0,1,1,0),
1503 array(0,1,0,0,0,0,0,1,0),
1504 array(0,0,0,0,0,0,0,0,0),
1505 ),
1506 ),
1507 'X' => array(
1508 array(
1509 array(1,0,0,0,0,0,0,0,1),
1510 array(1,0,0,0,0,0,0,0,1),
1511 array(0,1,0,0,0,0,0,1,0),
1512 array(0,1,0,0,0,0,0,1,0),
1513 array(0,0,1,0,0,0,1,0,0),
1514 array(0,0,0,1,0,1,0,0,0),
1515 array(0,0,0,1,0,1,0,0,0),
1516 array(0,0,0,0,1,0,0,0,0),
1517 array(0,0,0,1,0,1,0,0,0),
1518 array(0,0,0,1,0,1,0,0,0),
1519 array(0,0,1,0,0,0,1,0,0),
1520 array(0,1,0,0,0,0,1,0,0),
1521 array(0,1,0,0,0,0,0,1,0),
1522 array(1,0,0,0,0,0,0,0,1),
1523 array(1,0,0,0,0,0,0,0,1),
1524 ),
1525 array(
1526 array(0,0,0,0,0,0,0,0,0),
1527 array(1,1,1,0,0,0,1,1,1),
1528 array(0,1,0,0,0,0,0,1,0),
1529 array(0,1,0,0,0,0,0,1,0),
1530 array(0,0,1,0,0,0,1,0,0),
1531 array(0,0,0,1,0,1,0,0,0),
1532 array(0,0,0,1,0,1,0,0,0),
1533 array(0,0,0,0,1,0,0,0,0),
1534 array(0,0,0,1,0,1,0,0,0),
1535 array(0,0,0,1,0,1,0,0,0),
1536 array(0,0,1,0,0,0,1,0,0),
1537 array(0,1,0,0,0,0,1,0,0),
1538 array(0,1,0,0,0,0,0,1,0),
1539 array(1,1,1,0,0,0,1,1,1),
1540 array(0,0,0,0,0,0,0,0,0),
1541 ),
1542 array(
1543 array(0,0,0,0,0,0,0,0,0),
1544 array(0,0,0,0,0,0,0,0,0),
1545 array(0,0,0,0,0,0,0,0,0),
1546 array(0,0,0,0,0,0,0,0,0),
1547 array(0,0,0,0,0,0,0,0,0),
1548 array(0,0,0,0,0,0,0,0,0),
1549 array(0,0,0,0,0,0,0,0,0),
1550 array(0,1,0,0,0,0,0,1,0),
1551 array(0,1,1,0,0,0,1,1,0),
1552 array(0,0,1,1,0,1,1,0,0),
1553 array(0,0,0,1,1,1,0,0,0),
1554 array(0,0,0,1,1,1,0,0,0),
1555 array(0,0,1,1,0,1,1,0,0),
1556 array(0,1,1,0,0,0,1,1,0),
1557 array(0,0,0,0,0,0,0,0,0),
1558 ),
1559 ),
1560 'Y' => array(
1561 array(
1562 array(1,0,0,0,0,0,0,0,1),
1563 array(1,0,0,0,0,0,0,0,1),
1564 array(0,1,0,0,0,0,0,1,0),
1565 array(0,1,0,0,0,0,0,1,0),
1566 array(0,0,1,0,0,0,1,0,0),
1567 array(0,0,1,0,0,0,1,0,0),
1568 array(0,0,0,1,0,1,0,0,0),
1569 array(0,0,0,0,1,0,0,0,0),
1570 array(0,0,0,0,1,0,0,0,0),
1571 array(0,0,0,0,1,0,0,0,0),
1572 array(0,0,0,0,1,0,0,0,0),
1573 array(0,0,0,0,1,0,0,0,0),
1574 array(0,0,0,0,1,0,0,0,0),
1575 array(0,0,0,0,1,0,0,0,0),
1576 array(0,0,0,0,1,0,0,0,0),
1577 ),
1578 array(
1579 array(0,0,0,0,0,0,0,0,0),
1580 array(1,1,1,0,0,0,1,1,1),
1581 array(0,1,0,0,0,0,0,1,0),
1582 array(0,1,0,0,0,0,0,1,0),
1583 array(0,0,1,0,0,0,1,0,0),
1584 array(0,0,1,0,0,0,1,0,0),
1585 array(0,0,0,1,0,1,0,0,0),
1586 array(0,0,0,0,1,0,0,0,0),
1587 array(0,0,0,0,1,0,0,0,0),
1588 array(0,0,0,0,1,0,0,0,0),
1589 array(0,0,0,0,1,0,0,0,0),
1590 array(0,0,0,0,1,0,0,0,0),
1591 array(0,0,0,0,1,0,0,0,0),
1592 array(0,0,0,0,1,0,0,0,0),
1593 array(0,0,0,1,1,1,0,0,0),
1594 ),
1595 array(
1596 array(0,0,0,0,0,0,0,0,0),
1597 array(0,0,0,0,0,0,0,0,0),
1598 array(0,0,0,0,0,0,0,0,0),
1599 array(0,0,0,0,0,0,0,0,0),
1600 array(0,0,0,1,0,0,0,0,1),
1601 array(0,0,0,1,1,0,0,0,1),
1602 array(0,0,0,0,1,0,0,1,1),
1603 array(0,0,0,0,1,1,0,1,0),
1604 array(0,0,0,0,0,1,1,1,0),
1605 array(0,0,0,0,0,0,1,0,0),
1606 array(0,0,0,0,0,1,1,0,0),
1607 array(0,0,0,0,0,1,0,0,0),
1608 array(0,0,0,0,1,1,0,0,0),
1609 array(0,0,1,1,1,0,0,0,0),
1610 array(0,0,0,0,0,0,0,0,0),
1611 ),
1612 ),
1613 'Z' => array(
1614 array(
1615 array(1,1,1,1,1,1,1,1,1),
1616 array(1,0,0,0,0,0,0,0,1),
1617 array(0,0,0,0,0,0,0,0,1),
1618 array(0,0,0,0,0,0,0,1,0),
1619 array(0,0,0,0,0,0,1,0,0),
1620 array(0,0,0,0,0,1,0,0,0),
1621 array(0,0,0,0,0,1,0,0,0),
1622 array(0,0,0,0,1,0,0,0,0),
1623 array(0,0,0,1,0,0,0,0,0),
1624 array(0,0,0,1,0,0,0,0,0),
1625 array(0,0,1,0,0,0,0,0,0),
1626 array(0,1,0,0,0,0,0,0,0),
1627 array(1,0,0,0,0,0,0,0,0),
1628 array(1,0,0,0,0,0,0,0,1),
1629 array(1,1,1,1,1,1,1,1,1),
1630 ),
1631 array(
1632 array(1,1,1,1,1,1,1,1,1),
1633 array(0,0,0,0,0,0,0,0,1),
1634 array(0,0,0,0,0,0,0,0,1),
1635 array(0,0,0,0,0,0,0,1,0),
1636 array(0,0,0,0,0,0,1,0,0),
1637 array(0,0,0,0,0,1,0,0,0),
1638 array(0,0,0,0,0,1,0,0,0),
1639 array(0,0,1,1,1,1,1,0,0),
1640 array(0,0,0,1,0,0,0,0,0),
1641 array(0,0,0,1,0,0,0,0,0),
1642 array(0,0,1,0,0,0,0,0,0),
1643 array(0,1,0,0,0,0,0,0,0),
1644 array(1,0,0,0,0,0,0,0,0),
1645 array(1,0,0,0,0,0,0,0,0),
1646 array(1,1,1,1,1,1,1,1,1),
1647 ),
1648 array(
1649 array(0,0,0,0,0,0,0,0,0),
1650 array(0,0,0,0,0,0,0,0,0),
1651 array(0,0,0,0,0,0,0,0,0),
1652 array(0,0,0,0,0,0,0,0,0),
1653 array(0,0,0,0,0,0,0,0,0),
1654 array(0,0,0,0,0,0,0,0,0),
1655 array(0,0,0,0,0,0,0,0,0),
1656 array(0,0,0,0,0,0,0,0,0),
1657 array(0,1,1,1,1,1,1,1,0),
1658 array(0,0,0,0,0,1,1,0,0),
1659 array(0,0,0,0,1,1,0,0,0),
1660 array(0,0,0,1,1,0,0,0,0),
1661 array(0,0,1,1,0,0,0,0,0),
1662 array(0,0,1,0,0,0,0,0,0),
1663 array(0,1,1,1,1,1,1,1,0),
1664 ),
1665 ),
1666 );
1667 return array(
1668 'width' => 9,
1669 'height' => 15,
1670 'data' => array(
1671
1672 'A' => $chars['A'][mt_rand(0, min(count($chars['A']), $config['captcha_gd_fonts']) -1)],
1673 'B' => $chars['B'][mt_rand(0, min(count($chars['B']), $config['captcha_gd_fonts']) -1)],
1674 'C' => $chars['C'][mt_rand(0, min(count($chars['C']), $config['captcha_gd_fonts']) -1)],
1675 'D' => $chars['D'][mt_rand(0, min(count($chars['D']), $config['captcha_gd_fonts']) -1)],
1676 'E' => $chars['E'][mt_rand(0, min(count($chars['E']), $config['captcha_gd_fonts']) -1)],
1677 'F' => $chars['F'][mt_rand(0, min(count($chars['F']), $config['captcha_gd_fonts']) -1)],
1678 'G' => $chars['G'][mt_rand(0, min(count($chars['G']), $config['captcha_gd_fonts']) -1)],
1679 'H' => $chars['H'][mt_rand(0, min(count($chars['H']), $config['captcha_gd_fonts']) -1)],
1680 'I' => $chars['I'][mt_rand(0, min(count($chars['I']), $config['captcha_gd_fonts']) -1)],
1681 'J' => $chars['J'][mt_rand(0, min(count($chars['J']), $config['captcha_gd_fonts']) -1)],
1682 'K' => $chars['K'][mt_rand(0, min(count($chars['K']), $config['captcha_gd_fonts']) -1)],
1683 'L' => $chars['L'][mt_rand(0, min(count($chars['L']), $config['captcha_gd_fonts']) -1)],
1684 'M' => $chars['M'][mt_rand(0, min(count($chars['M']), $config['captcha_gd_fonts']) -1)],
1685 'N' => $chars['N'][mt_rand(0, min(count($chars['N']), $config['captcha_gd_fonts']) -1)],
1686 'O' => $chars['O'][mt_rand(0, min(count($chars['O']), $config['captcha_gd_fonts']) -1)],
1687 'P' => $chars['P'][mt_rand(0, min(count($chars['P']), $config['captcha_gd_fonts']) -1)],
1688 'Q' => $chars['Q'][mt_rand(0, min(count($chars['Q']), $config['captcha_gd_fonts']) -1)],
1689 'R' => $chars['R'][mt_rand(0, min(count($chars['R']), $config['captcha_gd_fonts']) -1)],
1690 'S' => $chars['S'][mt_rand(0, min(count($chars['S']), $config['captcha_gd_fonts']) -1)],
1691 'T' => $chars['T'][mt_rand(0, min(count($chars['T']), $config['captcha_gd_fonts']) -1)],
1692 'U' => $chars['U'][mt_rand(0, min(count($chars['U']), $config['captcha_gd_fonts']) -1)],
1693 'V' => $chars['V'][mt_rand(0, min(count($chars['V']), $config['captcha_gd_fonts']) -1)],
1694 'W' => $chars['W'][mt_rand(0, min(count($chars['W']), $config['captcha_gd_fonts']) -1)],
1695 'X' => $chars['X'][mt_rand(0, min(count($chars['X']), $config['captcha_gd_fonts']) -1)],
1696 'Y' => $chars['Y'][mt_rand(0, min(count($chars['Y']), $config['captcha_gd_fonts']) -1)],
1697 'Z' => $chars['Z'][mt_rand(0, min(count($chars['Z']), $config['captcha_gd_fonts']) -1)],
1698
1699 '1' => array(
1700 array(0,0,0,1,1,0,0,0,0),
1701 array(0,0,1,0,1,0,0,0,0),
1702 array(0,1,0,0,1,0,0,0,0),
1703 array(0,0,0,0,1,0,0,0,0),
1704 array(0,0,0,0,1,0,0,0,0),
1705 array(0,0,0,0,1,0,0,0,0),
1706 array(0,0,0,0,1,0,0,0,0),
1707 array(0,0,0,0,1,0,0,0,0),
1708 array(0,0,0,0,1,0,0,0,0),
1709 array(0,0,0,0,1,0,0,0,0),
1710 array(0,0,0,0,1,0,0,0,0),
1711 array(0,0,0,0,1,0,0,0,0),
1712 array(0,0,0,0,1,0,0,0,0),
1713 array(0,0,0,0,1,0,0,0,0),
1714 array(0,1,1,1,1,1,1,1,0),
1715 ),
1716 '2' => array( // New '2' supplied by Anon
1717 array(0,0,0,1,1,1,0,0,0),
1718 array(0,0,1,0,0,0,1,0,0),
1719 array(0,1,0,0,0,0,1,1,0),
1720 array(0,0,0,0,0,0,0,0,1),
1721 array(0,0,0,0,0,0,0,0,1),
1722 array(0,0,0,0,0,0,0,1,1),
1723 array(0,0,0,0,0,0,0,1,0),
1724 array(0,0,0,0,0,0,1,0,0),
1725 array(0,0,0,0,0,1,0,0,0),
1726 array(0,0,0,0,1,0,0,0,0),
1727 array(0,0,0,1,0,0,0,0,0),
1728 array(0,0,1,0,0,0,0,0,0),
1729 array(0,1,0,0,0,0,0,0,0),
1730 array(1,1,1,1,1,1,1,1,1),
1731 array(0,0,0,0,0,0,0,0,0),
1732 ),
1733 '3' => array(
1734 array(0,0,1,1,1,1,1,0,0),
1735 array(0,1,0,0,0,0,0,1,0),
1736 array(1,0,0,0,0,0,0,0,1),
1737 array(0,0,0,0,0,0,0,0,1),
1738 array(0,0,0,0,0,0,0,0,1),
1739 array(0,0,0,0,0,0,0,0,1),
1740 array(0,0,0,0,0,0,0,1,0),
1741 array(0,0,0,0,0,1,1,0,0),
1742 array(0,0,0,0,0,0,0,1,0),
1743 array(0,0,0,0,0,0,0,0,1),
1744 array(0,0,0,0,0,0,0,0,1),
1745 array(0,0,0,0,0,0,0,0,1),
1746 array(1,0,0,0,0,0,0,0,1),
1747 array(0,1,0,0,0,0,0,1,0),
1748 array(0,0,1,1,1,1,1,0,0),
1749 ),
1750 '4' => array(
1751 array(0,0,0,0,0,0,1,1,0),
1752 array(0,0,0,0,0,1,0,1,0),
1753 array(0,0,0,0,1,0,0,1,0),
1754 array(0,0,0,1,0,0,0,1,0),
1755 array(0,0,1,0,0,0,0,1,0),
1756 array(0,1,0,0,0,0,0,1,0),
1757 array(1,0,0,0,0,0,0,1,0),
1758 array(1,0,0,0,0,0,0,1,0),
1759 array(1,1,1,1,1,1,1,1,1),
1760 array(0,0,0,0,0,0,0,1,0),
1761 array(0,0,0,0,0,0,0,1,0),
1762 array(0,0,0,0,0,0,0,1,0),
1763 array(0,0,0,0,0,0,0,1,0),
1764 array(0,0,0,0,0,0,0,1,0),
1765 array(0,0,0,0,0,0,0,1,0),
1766 ),
1767 '5' => array(
1768 array(1,1,1,1,1,1,1,1,1),
1769 array(1,0,0,0,0,0,0,0,0),
1770 array(1,0,0,0,0,0,0,0,0),
1771 array(1,0,0,0,0,0,0,0,0),
1772 array(1,0,0,0,0,0,0,0,0),
1773 array(0,1,0,0,0,0,0,0,0),
1774 array(0,0,1,1,1,1,1,0,0),
1775 array(0,0,0,0,0,0,0,1,0),
1776 array(0,0,0,0,0,0,0,0,1),
1777 array(0,0,0,0,0,0,0,0,1),
1778 array(0,0,0,0,0,0,0,0,1),
1779 array(0,0,0,0,0,0,0,0,1),
1780 array(1,0,0,0,0,0,0,0,1),
1781 array(0,1,0,0,0,0,0,1,0),
1782 array(0,0,1,1,1,1,1,0,0),
1783 ),
1784 '6' => array(
1785 array(0,0,1,1,1,1,1,0,0),
1786 array(0,1,0,0,0,0,0,1,0),
1787 array(1,0,0,0,0,0,0,0,1),
1788 array(1,0,0,0,0,0,0,0,1),
1789 array(1,0,0,0,0,0,0,0,0),
1790 array(1,0,0,0,0,0,0,0,0),
1791 array(1,0,0,1,1,1,1,0,0),
1792 array(1,0,1,0,0,0,0,1,0),
1793 array(1,1,0,0,0,0,0,0,1),
1794 array(1,0,0,0,0,0,0,0,1),
1795 array(1,0,0,0,0,0,0,0,1),
1796 array(1,0,0,0,0,0,0,0,1),
1797 array(1,0,0,0,0,0,0,0,1),
1798 array(0,1,0,0,0,0,0,1,0),
1799 array(0,0,1,1,1,1,1,0,0),
1800 ),
1801 '7' => array(
1802 array(1,1,1,1,1,1,1,1,1),
1803 array(0,0,0,0,0,0,0,0,1),
1804 array(0,0,0,0,0,0,0,1,0),
1805 array(0,0,0,0,0,0,0,1,0),
1806 array(0,0,0,0,0,0,1,0,0),
1807 array(0,0,0,0,0,1,0,0,0),
1808 array(0,0,0,0,0,1,0,0,0),
1809 array(0,0,0,0,1,0,0,0,0),
1810 array(0,0,0,1,0,0,0,0,0),
1811 array(0,0,0,1,0,0,0,0,0),
1812 array(0,0,1,0,0,0,0,0,0),
1813 array(0,1,0,0,0,0,0,0,0),
1814 array(0,1,0,0,0,0,0,0,0),
1815 array(1,0,0,0,0,0,0,0,0),
1816 array(1,0,0,0,0,0,0,0,0),
1817 ),
1818 '8' => array(
1819 array(0,0,1,1,1,1,1,0,0),
1820 array(0,1,0,0,0,0,0,1,0),
1821 array(1,0,0,0,0,0,0,0,1),
1822 array(1,0,0,0,0,0,0,0,1),
1823 array(1,0,0,0,0,0,0,0,1),
1824 array(1,0,0,0,0,0,0,0,1),
1825 array(0,1,0,0,0,0,0,1,0),
1826 array(0,0,1,1,1,1,1,0,0),
1827 array(0,1,0,0,0,0,0,1,0),
1828 array(1,0,0,0,0,0,0,0,1),
1829 array(1,0,0,0,0,0,0,0,1),
1830 array(1,0,0,0,0,0,0,0,1),
1831 array(1,0,0,0,0,0,0,0,1),
1832 array(0,1,0,0,0,0,0,1,0),
1833 array(0,0,1,1,1,1,1,0,0),
1834 ),
1835 '9' => array(
1836 array(0,0,1,1,1,1,1,0,0),
1837 array(0,1,0,0,0,0,0,1,0),
1838 array(1,0,0,0,0,0,0,0,1),
1839 array(1,0,0,0,0,0,0,0,1),
1840 array(1,0,0,0,0,0,0,0,1),
1841 array(1,0,0,0,0,0,0,0,1),
1842 array(1,0,0,0,0,0,0,1,1),
1843 array(0,1,0,0,0,0,1,0,1),
1844 array(0,0,1,1,1,1,0,0,1),
1845 array(0,0,0,0,0,0,0,0,1),
1846 array(0,0,0,0,0,0,0,0,1),
1847 array(1,0,0,0,0,0,0,0,1),
1848 array(1,0,0,0,0,0,0,0,1),
1849 array(0,1,0,0,0,0,0,1,0),
1850 array(0,0,1,1,1,1,1,0,0),
1851 ),
1852 )
1853 );
1854 }
1855}
1856
1857/**
1858* @package VC
1859*/
1860class char_cube3d
1861{
1862 var $bitmap;
1863 var $bitmap_width;
1864 var $bitmap_height;
1865
1866 var $basis_matrix = array(array(1, 0, 0), array(0, 1, 0), array(0, 0, 1));
1867 var $abs_x = array(1, 0);
1868 var $abs_y = array(0, 1);
1869 var $x = 0;
1870 var $y = 1;
1871 var $z = 2;
1872 var $letter = '';
1873
1874 /**
1875 */
1876 function char_cube3d(&$bitmaps, $letter)
1877 {
1878 $this->bitmap = $bitmaps['data'][$letter];
1879 $this->bitmap_width = $bitmaps['width'];
1880 $this->bitmap_height = $bitmaps['height'];
1881
1882 $this->basis_matrix[0][0] = mt_rand(-600, 600);
1883 $this->basis_matrix[0][1] = mt_rand(-600, 600);
1884 $this->basis_matrix[0][2] = (mt_rand(0, 1) * 2000) - 1000;
1885 $this->basis_matrix[1][0] = mt_rand(-1000, 1000);
1886 $this->basis_matrix[1][1] = mt_rand(-1000, 1000);
1887 $this->basis_matrix[1][2] = mt_rand(-1000, 1000);
1888
1889 $this->normalize($this->basis_matrix[0]);
1890 $this->normalize($this->basis_matrix[1]);
1891 $this->basis_matrix[2] = $this->cross_product($this->basis_matrix[0], $this->basis_matrix[1]);
1892 $this->normalize($this->basis_matrix[2]);
1893
1894 // $this->basis_matrix[1] might not be (probably isn't) orthogonal to $basis_matrix[0]
1895 $this->basis_matrix[1] = $this->cross_product($this->basis_matrix[0], $this->basis_matrix[2]);
1896 $this->normalize($this->basis_matrix[1]);
1897
1898 // Make sure our cube is facing into the canvas (assuming +z == in)
1899 for ($i = 0; $i < 3; ++$i)
1900 {
1901 if ($this->basis_matrix[$i][2] < 0)
1902 {
1903 $this->basis_matrix[$i][0] *= -1;
1904 $this->basis_matrix[$i][1] *= -1;
1905 $this->basis_matrix[$i][2] *= -1;
1906 }
1907 }
1908
1909 // Force our "z" basis vector to be the one with greatest absolute z value
1910 $this->x = 0;
1911 $this->y = 1;
1912 $this->z = 2;
1913
1914 // Swap "y" with "z"
1915 if ($this->basis_matrix[1][2] > $this->basis_matrix[2][2])
1916 {
1917 $this->z = 1;
1918 $this->y = 2;
1919 }
1920
1921 // Swap "x" with "z"
1922 if ($this->basis_matrix[0][2] > $this->basis_matrix[$this->z][2])
1923 {
1924 $this->x = $this->z;
1925 $this->z = 0;
1926 }
1927
1928 // Still need to determine which of $x,$y are which.
1929 // wrong orientation if y's y-component is less than it's x-component
1930 // likewise if x's x-component is less than it's y-component
1931 // if they disagree, go with the one with the greater weight difference.
1932 // rotate if positive
1933 $weight = (abs($this->basis_matrix[$this->x][1]) - abs($this->basis_matrix[$this->x][0])) + (abs($this->basis_matrix[$this->y][0]) - abs($this->basis_matrix[$this->y][1]));
1934
1935 // Swap "x" with "y"
1936 if ($weight > 0)
1937 {
1938 list($this->x, $this->y) = array($this->y, $this->x);
1939 }
1940
1941 $this->abs_x = array($this->basis_matrix[$this->x][0], $this->basis_matrix[$this->x][1]);
1942 $this->abs_y = array($this->basis_matrix[$this->y][0], $this->basis_matrix[$this->y][1]);
1943
1944 if ($this->abs_x[0] < 0)
1945 {
1946 $this->abs_x[0] *= -1;
1947 $this->abs_x[1] *= -1;
1948 }
1949
1950 if ($this->abs_y[1] > 0)
1951 {
1952 $this->abs_y[0] *= -1;
1953 $this->abs_y[1] *= -1;
1954 }
1955
1956 $this->letter = $letter;
1957 }
1958
1959 /**
1960 * Draw a character
1961 */
1962 function drawchar($scale, $xoff, $yoff, $img, $background, $colours)
1963 {
1964 $width = $this->bitmap_width;
1965 $height = $this->bitmap_height;
1966 $bitmap = $this->bitmap;
1967
1968 $colour1 = $colours[array_rand($colours)];
1969 $colour2 = $colours[array_rand($colours)];
1970
1971 $swapx = ($this->basis_matrix[$this->x][0] > 0);
1972 $swapy = ($this->basis_matrix[$this->y][1] < 0);
1973
1974 for ($y = 0; $y < $height; ++$y)
1975 {
1976 for ($x = 0; $x < $width; ++$x)
1977 {
1978 $xp = ($swapx) ? ($width - $x - 1) : $x;
1979 $yp = ($swapy) ? ($height - $y - 1) : $y;
1980
1981 if ($bitmap[$height - $yp - 1][$xp])
1982 {
1983 $dx = $this->scale($this->abs_x, ($xp - ($swapx ? ($width / 2) : ($width / 2) - 1)) * $scale);
1984 $dy = $this->scale($this->abs_y, ($yp - ($swapy ? ($height / 2) : ($height / 2) - 1)) * $scale);
1985 $xo = $xoff + $dx[0] + $dy[0];
1986 $yo = $yoff + $dx[1] + $dy[1];
1987
1988 $origin = array(0, 0, 0);
1989 $xvec = $this->scale($this->basis_matrix[$this->x], $scale);
1990 $yvec = $this->scale($this->basis_matrix[$this->y], $scale);
1991 $face_corner = $this->sum2($xvec, $yvec);
1992
1993 $zvec = $this->scale($this->basis_matrix[$this->z], $scale);
1994 $x_corner = $this->sum2($xvec, $zvec);
1995 $y_corner = $this->sum2($yvec, $zvec);
1996
1997 imagefilledpolygon($img, $this->gen_poly($xo, $yo, $origin, $xvec, $x_corner,$zvec), 4, $colour1);
1998 imagefilledpolygon($img, $this->gen_poly($xo, $yo, $origin, $yvec, $y_corner,$zvec), 4, $colour2);
1999
2000 $face = $this->gen_poly($xo, $yo, $origin, $xvec, $face_corner, $yvec);
2001
2002 imagefilledpolygon($img, $face, 4, $background);
2003 imagepolygon($img, $face, 4, $colour1);
2004 }
2005 }
2006 }
2007 }
2008
2009 /*
2010 * return a roughly acceptable range of sizes for rendering with this texttype
2011 */
2012 function range()
2013 {
2014 return array(3, 4);
2015 }
2016
2017 /**
2018 * Vector length
2019 */
2020 function vectorlen($vector)
2021 {
2022 return sqrt(pow($vector[0], 2) + pow($vector[1], 2) + pow($vector[2], 2));
2023 }
2024
2025 /**
2026 * Normalize
2027 */
2028 function normalize(&$vector, $length = 1)
2029 {
2030 $length = (( $length < 1) ? 1 : $length);
2031 $length /= $this->vectorlen($vector);
2032 $vector[0] *= $length;
2033 $vector[1] *= $length;
2034 $vector[2] *= $length;
2035 }
2036
2037 /**
2038 */
2039 function cross_product($vector1, $vector2)
2040 {
2041 $retval = array(0, 0, 0);
2042 $retval[0] = (($vector1[1] * $vector2[2]) - ($vector1[2] * $vector2[1]));
2043 $retval[1] = -(($vector1[0] * $vector2[2]) - ($vector1[2] * $vector2[0]));
2044 $retval[2] = (($vector1[0] * $vector2[1]) - ($vector1[1] * $vector2[0]));
2045
2046 return $retval;
2047 }
2048
2049 /**
2050 */
2051 function sum($vector1, $vector2)
2052 {
2053 return array($vector1[0] + $vector2[0], $vector1[1] + $vector2[1], $vector1[2] + $vector2[2]);
2054 }
2055
2056 /**
2057 */
2058 function sum2($vector1, $vector2)
2059 {
2060 return array($vector1[0] + $vector2[0], $vector1[1] + $vector2[1]);
2061 }
2062
2063 /**
2064 */
2065 function scale($vector, $length)
2066 {
2067 if (sizeof($vector) == 2)
2068 {
2069 return array($vector[0] * $length, $vector[1] * $length);
2070 }
2071
2072 return array($vector[0] * $length, $vector[1] * $length, $vector[2] * $length);
2073 }
2074
2075 /**
2076 */
2077 function gen_poly($xoff, $yoff, &$vec1, &$vec2, &$vec3, &$vec4)
2078 {
2079 $poly = array();
2080 $poly[0] = $xoff + $vec1[0];
2081 $poly[1] = $yoff + $vec1[1];
2082 $poly[2] = $xoff + $vec2[0];
2083 $poly[3] = $yoff + $vec2[1];
2084 $poly[4] = $xoff + $vec3[0];
2085 $poly[5] = $yoff + $vec3[1];
2086 $poly[6] = $xoff + $vec4[0];
2087 $poly[7] = $yoff + $vec4[1];
2088
2089 return $poly;
2090 }
2091
2092 /**
2093 * dimensions
2094 */
2095 function dimensions($size)
2096 {
2097 $xn = $this->scale($this->basis_matrix[$this->x], -($this->bitmap_width / 2) * $size);
2098 $xp = $this->scale($this->basis_matrix[$this->x], ($this->bitmap_width / 2) * $size);
2099 $yn = $this->scale($this->basis_matrix[$this->y], -($this->bitmap_height / 2) * $size);
2100 $yp = $this->scale($this->basis_matrix[$this->y], ($this->bitmap_height / 2) * $size);
2101
2102 $p = array();
2103 $p[0] = $this->sum2($xn, $yn);
2104 $p[1] = $this->sum2($xp, $yn);
2105 $p[2] = $this->sum2($xp, $yp);
2106 $p[3] = $this->sum2($xn, $yp);
2107
2108 $min_x = $max_x = $p[0][0];
2109 $min_y = $max_y = $p[0][1];
2110
2111 for ($i = 1; $i < 4; ++$i)
2112 {
2113 $min_x = ($min_x > $p[$i][0]) ? $p[$i][0] : $min_x;
2114 $min_y = ($min_y > $p[$i][1]) ? $p[$i][1] : $min_y;
2115 $max_x = ($max_x < $p[$i][0]) ? $p[$i][0] : $max_x;
2116 $max_y = ($max_y < $p[$i][1]) ? $p[$i][1] : $max_y;
2117 }
2118
2119 return array($min_x, $min_y, $max_x, $max_y);
2120 }
2121}
2122
2123/**
2124* @package VC
2125*/
2126class colour_manager
2127{
2128 var $img;
2129 var $mode;
2130 var $colours;
2131 var $named_colours;
2132
2133 /**
2134 * Create the colour manager, link it to the image resource
2135 */
2136 function colour_manager($img, $background = false, $mode = 'ahsv')
2137 {
2138 $this->img = $img;
2139 $this->mode = $mode;
2140 $this->colours = array();
2141 $this->named_colours = array();
2142
2143 if ($background !== false)
2144 {
2145 $bg = $this->allocate_named('background', $background);
2146 imagefill($this->img, 0, 0, $bg);
2147 }
2148 }
2149
2150 /**
2151 * Lookup a named colour resource
2152 */
2153 function get_resource($named_colour)
2154 {
2155 if (isset($this->named_colours[$named_colour]))
2156 {
2157 return $this->named_colours[$named_colour];
2158 }
2159
2160 if (isset($this->named_rgb[$named_colour]))
2161 {
2162 return $this->allocate_named($named_colour, $this->named_rgb[$named_colour], 'rgb');
2163 }
2164
2165 return false;
2166 }
2167
2168 /**
2169 * Assign a name to a colour resource
2170 */
2171 function name_colour($name, $resource)
2172 {
2173 $this->named_colours[$name] = $resource;
2174 }
2175
2176 /**
2177 * names and allocates a colour resource
2178 */
2179 function allocate_named($name, $colour, $mode = false)
2180 {
2181 $resource = $this->allocate($colour, $mode);
2182
2183 if ($resource !== false)
2184 {
2185 $this->name_colour($name, $resource);
2186 }
2187 return $resource;
2188 }
2189
2190 /**
2191 * allocates a specified colour into the image
2192 */
2193 function allocate($colour, $mode = false)
2194 {
2195 if ($mode === false)
2196 {
2197 $mode = $this->mode;
2198 }
2199
2200 if (!is_array($colour))
2201 {
2202 if (isset($this->named_rgb[$colour]))
2203 {
2204 return $this->allocate_named($colour, $this->named_rgb[$colour], 'rgb');
2205 }
2206
2207 if (!is_int($colour))
2208 {
2209 return false;
2210 }
2211
2212 $mode = 'rgb';
2213 $colour = array(255 & ($colour >> 16), 255 & ($colour >> 8), 255 & $colour);
2214 }
2215
2216 if (isset($colour['mode']))
2217 {
2218 $mode = $colour['mode'];
2219 unset($colour['mode']);
2220 }
2221
2222 if (isset($colour['random']))
2223 {
2224 unset($colour['random']);
2225 // everything else is params
2226 return $this->random_colour($colour, $mode);
2227 }
2228
2229 $rgb = colour_manager::model_convert($colour, $mode, 'rgb');
2230 $store = ($this->mode == 'rgb') ? $rgb : colour_manager::model_convert($colour, $mode, $this->mode);
2231 $resource = imagecolorallocate($this->img, $rgb[0], $rgb[1], $rgb[2]);
2232 $this->colours[$resource] = $store;
2233
2234 return $resource;
2235 }
2236
2237 /**
2238 * randomly generates a colour, with optional params
2239 */
2240 function random_colour($params = array(), $mode = false)
2241 {
2242 if ($mode === false)
2243 {
2244 $mode = $this->mode;
2245 }
2246
2247 switch ($mode)
2248 {
2249 case 'rgb':
2250 // @TODO random rgb generation. do we intend to do this, or is it just too tedious?
2251 break;
2252
2253 case 'ahsv':
2254 case 'hsv':
2255 default:
2256
2257 $default_params = array(
2258 'hue_bias' => false, // degree / 'r'/'g'/'b'/'c'/'m'/'y' /'o'
2259 'hue_range' => false, // if hue bias, then difference range +/- from bias
2260 'min_saturation' => 30, // 0 - 100
2261 'max_saturation' => 80, // 0 - 100
2262 'min_value' => 30, // 0 - 100
2263 'max_value' => 80, // 0 - 100
2264 );
2265
2266 $alt = ($mode == 'ahsv') ? true : false;
2267 $params = array_merge($default_params, $params);
2268
2269 $min_hue = 0;
2270 $max_hue = 359;
2271 $min_saturation = max(0, $params['min_saturation']);
2272 $max_saturation = min(100, $params['max_saturation']);
2273 $min_value = max(0, $params['min_value']);
2274 $max_value = min(100, $params['max_value']);
2275
2276 if ($params['hue_bias'] !== false)
2277 {
2278 if (is_numeric($params['hue_bias']))
2279 {
2280 $h = intval($params['hue_bias']) % 360;
2281 }
2282 else
2283 {
2284 switch ($params['hue_bias'])
2285 {
2286 case 'o':
2287 $h = $alt ? 60 : 30;
2288 break;
2289
2290 case 'y':
2291 $h = $alt ? 120 : 60;
2292 break;
2293
2294 case 'g':
2295 $h = $alt ? 180 : 120;
2296 break;
2297
2298 case 'c':
2299 $h = $alt ? 210 : 180;
2300 break;
2301
2302 case 'b':
2303 $h = 240;
2304 break;
2305
2306 case 'm':
2307 $h = 300;
2308 break;
2309
2310 case 'r':
2311 default:
2312 $h = 0;
2313 break;
2314 }
2315 }
2316
2317 $min_hue = $h + 360;
2318 $max_hue = $h + 360;
2319
2320 if ($params['hue_range'])
2321 {
2322 $min_hue -= min(180, $params['hue_range']);
2323 $max_hue += min(180, $params['hue_range']);
2324 }
2325 }
2326
2327 $h = mt_rand($min_hue, $max_hue);
2328 $s = mt_rand($min_saturation, $max_saturation);
2329 $v = mt_rand($min_value, $max_value);
2330
2331 return $this->allocate(array($h, $s, $v), $mode);
2332
2333 break;
2334 }
2335 }
2336
2337 /**
2338 */
2339 function colour_scheme($resource, $include_original = true)
2340 {
2341 $mode = 'hsv';
2342
2343 if (($pre = $this->get_resource($resource)) !== false)
2344 {
2345 $resource = $pre;
2346 }
2347
2348 $colour = colour_manager::model_convert($this->colours[$resource], $this->mode, $mode);
2349 $results = ($include_original) ? array($resource) : array();
2350 $colour2 = $colour3 = $colour4 = $colour;
2351 $colour2[0] += 150;
2352 $colour3[0] += 180;
2353 $colour4[0] += 210;
2354
2355
2356 $results[] = $this->allocate($colour2, $mode);
2357 $results[] = $this->allocate($colour3, $mode);
2358 $results[] = $this->allocate($colour4, $mode);
2359
2360 return $results;
2361 }
2362
2363 /**
2364 */
2365 function mono_range($resource, $count = 5, $include_original = true)
2366 {
2367 if (is_array($resource))
2368 {
2369 $results = array();
2370 for ($i = 0, $size = sizeof($resource); $i < $size; ++$i)
2371 {
2372 $results = array_merge($results, $this->mono_range($resource[$i], $count, $include_original));
2373 }
2374 return $results;
2375 }
2376
2377 $mode = (in_array($this->mode, array('hsv', 'ahsv'), true) ? $this->mode : 'ahsv');
2378 if (($pre = $this->get_resource($resource)) !== false)
2379 {
2380 $resource = $pre;
2381 }
2382
2383 $colour = colour_manager::model_convert($this->colours[$resource], $this->mode, $mode);
2384
2385 $results = array();
2386 if ($include_original)
2387 {
2388 $results[] = $resource;
2389 $count--;
2390 }
2391
2392 // This is a hard problem. I chicken out and try to maintain readability at the cost of less randomness.
2393
2394 while ($count > 0)
2395 {
2396 $colour[1] = ($colour[1] + mt_rand(40,60)) % 99;
2397 $colour[2] = ($colour[2] + mt_rand(40,60));
2398 $results[] = $this->allocate($colour, $mode);
2399 $count--;
2400 }
2401 return $results;
2402 }
2403
2404 /**
2405 * Convert from one colour model to another
2406 */
2407 function model_convert($colour, $from_model, $to_model)
2408 {
2409 if ($from_model == $to_model)
2410 {
2411 return $colour;
2412 }
2413
2414 switch ($to_model)
2415 {
2416 case 'hsv':
2417
2418 switch ($from_model)
2419 {
2420 case 'ahsv':
2421 return colour_manager::ah2h($colour);
2422 break;
2423
2424 case 'rgb':
2425 return colour_manager::rgb2hsv($colour);
2426 break;
2427 }
2428 break;
2429
2430 case 'ahsv':
2431
2432 switch ($from_model)
2433 {
2434 case 'hsv':
2435 return colour_manager::h2ah($colour);
2436 break;
2437
2438 case 'rgb':
2439 return colour_manager::h2ah(colour_manager::rgb2hsv($colour));
2440 break;
2441 }
2442 break;
2443
2444 case 'rgb':
2445 switch ($from_model)
2446 {
2447 case 'hsv':
2448 return colour_manager::hsv2rgb($colour);
2449 break;
2450
2451 case 'ahsv':
2452 return colour_manager::hsv2rgb(colour_manager::ah2h($colour));
2453 break;
2454 }
2455 break;
2456 }
2457 return false;
2458 }
2459
2460 /**
2461 * Slightly altered from wikipedia's algorithm
2462 */
2463 function hsv2rgb($hsv)
2464 {
2465 colour_manager::normalize_hue($hsv[0]);
2466
2467 $h = $hsv[0];
2468 $s = min(1, max(0, $hsv[1] / 100));
2469 $v = min(1, max(0, $hsv[2] / 100));
2470
2471 // calculate hue sector
2472 $hi = floor($hsv[0] / 60);
2473
2474 // calculate opposite colour
2475 $p = $v * (1 - $s);
2476
2477 // calculate distance between hex vertices
2478 $f = ($h / 60) - $hi;
2479
2480 // coming in or going out?
2481 if (!($hi & 1))
2482 {
2483 $f = 1 - $f;
2484 }
2485
2486 // calculate adjacent colour
2487 $q = $v * (1 - ($f * $s));
2488
2489 switch ($hi)
2490 {
2491 case 0:
2492 $rgb = array($v, $q, $p);
2493 break;
2494
2495 case 1:
2496 $rgb = array($q, $v, $p);
2497 break;
2498
2499 case 2:
2500 $rgb = array($p, $v, $q);
2501 break;
2502
2503 case 3:
2504 $rgb = array($p, $q, $v);
2505 break;
2506
2507 case 4:
2508 $rgb = array($q, $p, $v);
2509 break;
2510
2511 case 5:
2512 $rgb = array($v, $p, $q);
2513 break;
2514
2515 default:
2516 return array(0, 0, 0);
2517 break;
2518 }
2519
2520 return array(255 * $rgb[0], 255 * $rgb[1], 255 * $rgb[2]);
2521 }
2522
2523 /**
2524 * (more than) Slightly altered from wikipedia's algorithm
2525 */
2526 function rgb2hsv($rgb)
2527 {
2528 $r = min(255, max(0, $rgb[0]));
2529 $g = min(255, max(0, $rgb[1]));
2530 $b = min(255, max(0, $rgb[2]));
2531 $max = max($r, $g, $b);
2532 $min = min($r, $g, $b);
2533
2534 $v = $max / 255;
2535 $s = (!$max) ? 0 : 1 - ($min / $max);
2536
2537 // if max - min is 0, we want hue to be 0 anyway.
2538 $h = $max - $min;
2539
2540 if ($h)
2541 {
2542 switch ($max)
2543 {
2544 case $g:
2545 $h = 120 + (60 * ($b - $r) / $h);
2546 break;
2547
2548 case $b:
2549 $h = 240 + (60 * ($r - $g) / $h);
2550 break;
2551
2552 case $r:
2553 $h = 360 + (60 * ($g - $b) / $h);
2554 break;
2555 }
2556 }
2557 colour_manager::normalize_hue($h);
2558
2559 return array($h, $s * 100, $v * 100);
2560 }
2561
2562 /**
2563 */
2564 function normalize_hue(&$hue)
2565 {
2566 $hue %= 360;
2567
2568 if ($hue < 0)
2569 {
2570 $hue += 360;
2571 }
2572 }
2573
2574 /**
2575 * Alternate hue to hue
2576 */
2577 function ah2h($ahue)
2578 {
2579 if (is_array($ahue))
2580 {
2581 $ahue[0] = colour_manager::ah2h($ahue[0]);
2582 return $ahue;
2583 }
2584 colour_manager::normalize_hue($ahue);
2585
2586 // blue through red is already ok
2587 if ($ahue >= 240)
2588 {
2589 return $ahue;
2590 }
2591
2592 // ahue green is at 180
2593 if ($ahue >= 180)
2594 {
2595 // return (240 - (2 * (240 - $ahue)));
2596 return (2 * $ahue) - 240; // equivalent
2597 }
2598
2599 // ahue yellow is at 120 (RYB rather than RGB)
2600 if ($ahue >= 120)
2601 {
2602 return $ahue - 60;
2603 }
2604
2605 return $ahue / 2;
2606 }
2607
2608 /**
2609 * hue to Alternate hue
2610 */
2611 function h2ah($hue)
2612 {
2613 if (is_array($hue))
2614 {
2615 $hue[0] = colour_manager::h2ah($hue[0]);
2616 return $hue;
2617 }
2618 colour_manager::normalize_hue($hue);
2619
2620 // blue through red is already ok
2621 if ($hue >= 240)
2622 {
2623 return $hue;
2624 }
2625 else if ($hue <= 60)
2626 {
2627 return $hue * 2;
2628 }
2629 else if ($hue <= 120)
2630 {
2631 return $hue + 60;
2632 }
2633 else
2634 {
2635 return ($hue + 240) / 2;
2636 }
2637 }
2638}
2639
2640?>
Note: See TracBrowser for help on using the repository browser.