PageRenderTime 253ms CodeModel.GetById 9ms app.highlight 228ms RepoModel.GetById 1ms app.codeStats 0ms

/phpBB/includes/captcha/captcha_gd.php

http://github.com/phpbb/phpbb3
PHP | 2271 lines | 2066 code | 107 blank | 98 comment | 49 complexity | 8d76373e9f54f9b05aa8bf0095a9af91 MD5 | raw file
   1<?php
   2/**
   3*
   4* @package VC
   5* @copyright (c) 2006 phpBB Group
   6* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
   7*
   8*/
   9
  10/**
  11* @ignore
  12*/
  13if (!defined('IN_PHPBB'))
  14{
  15	exit;
  16}
  17
  18/**
  19* Original Author - Xore (Robert Hetzler)
  20* With contributions from Neothermic
  21*
  22* @package VC
  23*/
  24class captcha
  25{
  26	var $width = 360;
  27	var $height = 96;
  28
  29
  30	/**
  31	* Create the image containing $code with a seed of $seed
  32	*/
  33	function execute($code, $seed)
  34	{
  35		global $config;
  36		
  37		mt_srand($seed);
  38
  39		// Create image
  40		$img = imagecreatetruecolor($this->width, $this->height);
  41
  42		// Generate colours
  43		$colour = new colour_manager($img, array(
  44			'random'	=> true,
  45			'min_value'	=> 60,
  46		), 'hsv');
  47
  48		$scheme = $colour->colour_scheme('background', false);
  49		$scheme = $colour->mono_range($scheme, 10, false);
  50		shuffle($scheme);
  51
  52		$bg_colours = array_splice($scheme, mt_rand(6, 12));
  53
  54		// Generate code characters
  55		$characters = $sizes = $bounding_boxes = $noise = array();
  56		$width_avail = $this->width - 15;
  57		$code_len = strlen($code);
  58		$captcha_bitmaps = $this->captcha_bitmaps();
  59
  60		for ($i = 0; $i < $code_len; ++$i)
  61		{
  62			$characters[$i] = new char_cube3d($captcha_bitmaps, $code[$i]);
  63
  64			list($min, $max) = $characters[$i]->range();
  65			$sizes[$i] = mt_rand($min, $max);
  66
  67			$box = $characters[$i]->dimensions($sizes[$i]);
  68			$width_avail -= ($box[2] - $box[0]);
  69			$bounding_boxes[$i] = $box;
  70		}
  71
  72 
  73		// Redistribute leftover x-space
  74		$offset = array();
  75		for ($i = 0; $i < $code_len; ++$i)
  76		{
  77			$denom = ($code_len - $i);
  78			$denom = max(1.3, $denom);
  79			$offset[$i] = phpbb_mt_rand(0, (int) round((1.5 * $width_avail) / $denom));
  80			$width_avail -= $offset[$i];
  81		}
  82
  83		if ($config['captcha_gd_x_grid'])
  84		{
  85			$grid = (int) $config['captcha_gd_x_grid'];
  86			for ($y = 0; $y < $this->height; $y += mt_rand($grid - 2, $grid + 2))
  87			{
  88				$current_colour = $scheme[array_rand($scheme)];
  89				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);
  90			}
  91		}
  92
  93		if ($config['captcha_gd_y_grid'])
  94		{
  95			$grid = (int) $config['captcha_gd_y_grid'];
  96			for ($x = 0; $x < $this->width; $x += mt_rand($grid - 2, $grid + 2))
  97			{
  98				$current_colour = $scheme[array_rand($scheme)];
  99				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);
 100			}
 101		}
 102		if ($config['captcha_gd_wave'] && ($config['captcha_gd_y_grid'] || $config['captcha_gd_y_grid']))
 103		{
 104			$this->wave($img);
 105		}
 106		
 107		
 108		if ($config['captcha_gd_3d_noise'])
 109		{
 110			$xoffset = mt_rand(0,9);
 111			$noise_bitmaps = $this->captcha_noise_bg_bitmaps();
 112			for ($i = 0; $i < $code_len; ++$i)
 113			{
 114				$noise[$i] = new char_cube3d($noise_bitmaps, mt_rand(1, sizeof($noise_bitmaps['data'])));
 115
 116				list($min, $max) = $noise[$i]->range();
 117				//$box = $noise[$i]->dimensions($sizes[$i]);
 118			}
 119			$xoffset = 0;
 120			for ($i = 0; $i < $code_len; ++$i)
 121			{
 122				$dimm = $bounding_boxes[$i];
 123				$xoffset += ($offset[$i] - $dimm[0]);
 124				$yoffset = mt_rand(-$dimm[1], $this->height - $dimm[3]);
 125	 
 126				$noise[$i]->drawchar($sizes[$i], $xoffset, $yoffset, $img, $colour->get_resource('background'), $scheme);
 127				$xoffset += $dimm[2];
 128			}
 129		}
 130		$xoffset = 5;
 131		for ($i = 0; $i < $code_len; ++$i)
 132		{
 133			$dimm = $bounding_boxes[$i];
 134			$xoffset += ($offset[$i] - $dimm[0]);
 135			$yoffset = mt_rand(-$dimm[1], $this->height - $dimm[3]);
 136
 137			$characters[$i]->drawchar($sizes[$i], $xoffset, $yoffset, $img, $colour->get_resource('background'), $scheme);
 138			$xoffset += $dimm[2];
 139		}
 140		if ($config['captcha_gd_wave'])
 141		{
 142			$this->wave($img);
 143		}
 144		if ($config['captcha_gd_foreground_noise'])
 145		{
 146			$this->noise_line($img, 0, 0, $this->width, $this->height, $colour->get_resource('background'), $scheme, $bg_colours);
 147		}
 148		// Send image
 149		header('Content-Type: image/png');
 150		header('Cache-control: no-cache, no-store');
 151		imagepng($img);
 152		imagedestroy($img);
 153	}
 154
 155	/**
 156	* Sinus
 157	*/
 158	function wave($img)
 159	{
 160		global $config;
 161		
 162		$period_x = mt_rand(12,18);
 163		$period_y = mt_rand(7,14);
 164		$amp_x = mt_rand(5,10);
 165		$amp_y = mt_rand(2,4); 
 166		$socket = mt_rand(0,100);
 167		
 168		$dampen_x = mt_rand($this->width/5, $this->width/2);
 169		$dampen_y = mt_rand($this->height/5, $this->height/2);
 170		$direction_x = (mt_rand (0, 1));
 171		$direction_y = (mt_rand (0, 1));
 172
 173		for ($i = 0; $i < $this->width; $i++)
 174		{
 175			$dir = ($direction_x) ? $i : ($this->width - $i);
 176			imagecopy($img, $img, $i-1, sin($socket+ $i/($period_x + $dir/$dampen_x)) * $amp_x, $i, 0, 1, $this->height);
 177		}
 178		$socket = mt_rand(0,100);
 179		for ($i = 0; $i < $this->height; $i++)
 180		{
 181			$dir = ($direction_y) ? $i : ($this->height - $i);
 182			imagecopy($img, $img ,sin($socket + $i/($period_y + ($dir)/$dampen_y)) * $amp_y, $i-1, 0, $i, $this->width, 1);
 183		}
 184		return $img;
 185	}
 186	
 187	/**
 188	* Noise line
 189	*/
 190	function noise_line($img, $min_x, $min_y, $max_x, $max_y, $bg, $font, $non_font)
 191	{
 192		imagesetthickness($img, 2);
 193
 194		$x1 = $min_x;
 195		$x2 = $max_x;
 196		$y1 = $min_y;
 197		$y2 = $min_y;
 198
 199		do
 200		{
 201			$line = array_merge(
 202				array_fill(0, mt_rand(30, 60), $non_font[array_rand($non_font)]),
 203				array_fill(0, mt_rand(30, 60), $bg)
 204			);
 205
 206			imagesetstyle($img, $line);
 207			imageline($img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
 208
 209			$y1 += mt_rand(12, 35);
 210			$y2 += mt_rand(12, 35);
 211		}
 212		while ($y1 < $max_y && $y2 < $max_y);
 213
 214		$x1 = $min_x;
 215		$x2 = $min_x;
 216		$y1 = $min_y;
 217		$y2 = $max_y;
 218
 219		do
 220		{
 221			$line = array_merge(
 222				array_fill(0, mt_rand(30, 60), $non_font[array_rand($non_font)]),
 223				array_fill(0, mt_rand(30, 60), $bg)
 224			);
 225
 226			imagesetstyle($img, $line);
 227			imageline($img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
 228
 229			$x1 += mt_rand(20, 35);
 230			$x2 += mt_rand(20, 35);
 231		}
 232		while ($x1 < $max_x && $x2 < $max_x);
 233		imagesetthickness($img, 1);
 234	}
 235
 236
 237	function captcha_noise_bg_bitmaps()
 238	{		
 239		return array(
 240			'width'		=> 15,
 241			'height'	=> 5,
 242			'data'		=> array(
 243
 244			1 => array(
 245				array(1,0,0,0,1,0,0,0,0,0,0,0,0,0,0),
 246				array(1,0,0,0,0,1,0,0,0,0,0,0,0,0,0),
 247				array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
 248				array(1,0,0,0,0,1,0,0,0,0,0,0,1,0,0),
 249				array(1,0,0,0,0,0,1,0,0,0,0,1,0,0,0),
 250			),
 251			2 => array(
 252				array(1,1,mt_rand(0,1),1,0,1,1,1,1,0,0,0,0,0,0),
 253				array(0,0,0,0,0,0,0,1,0,0,0,0,0,0,0),
 254				array(0,0,0,0,0,0,0,0,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,1,1,0,1,1,1),
 257			),
 258			3 => array(
 259				array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,1),
 260				array(1,0,0,0,0,0,0,0,0,0,0,0,0,1,0),
 261				array(0,0,0,0,1,0,0,0,0,0,0,0,0,0,1),
 262				array(1,0,0,0,0,0,0,0,0,0,0,0,0,1,0),
 263				array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,1),
 264			),
 265			4 => array(
 266				array(1,0,1,0,1,0,0,1,1,0,0,0,0,0,0),
 267				array(0,0,0,0,0,0,0,1,0,0,0,0,0,0,0),
 268				array(0,0,0,0,0,0,0,0,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(1,0,1,0,0,0,0,0,0,0,0,0,0,0,0),
 271			),
 272			5 => array(
 273				array(1,1,1,1,0,0,0,1,1,1,0,0,1,0,1),
 274				array(0,0,0,0,0,0,0,1,0,0,0,0,0,0,0),
 275				array(0,0,0,0,0,0,0,0,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(1,0,1,0,0,0,0,0,0,0,0,0,0,0,0),
 278			),
 279			6 => array(
 280				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)),
 281				array(0,0,0,0,0,0,0,mt_rand(0,1),0,0,0,0,0,0,0),
 282				array(0,0,0,0,0,0,0,0,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(mt_rand(0,1),0,mt_rand(0,1),0,0,0,0,0,0,0,0,0,0,0,0),
 285			),
 286			7 => array(
 287				array(0,0,0,0,0,0,0,0,0,0,1,1,0,1,1),
 288				array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
 289				array(0,0,1,1,0,0,0,1,0,0,0,0,0,0,0),
 290				array(0,1,0,0,0,1,0,0,0,0,0,0,0,0,0),
 291				array(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
 292			),
 293		));
 294	}
 295	
 296	/**
 297	* Return bitmaps
 298	*/
 299	function captcha_bitmaps()
 300	{
 301		global $config;
 302		
 303		$chars = array(
 304			'A'	=>	array(
 305						array(
 306							array(0,0,0,0,1,0,0,0,0),
 307							array(0,0,0,1,0,1,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,1,0,0,0,1,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,1,0,0,0,0,0,1,0),
 314							array(0,1,0,0,0,0,0,1,0),
 315							array(0,1,1,1,1,1,1,1,0),
 316							array(0,1,0,0,0,0,0,1,0),
 317							array(1,0,0,0,0,0,0,0,1),
 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						),
 322						array(
 323							array(0,0,0,0,0,0,0,0,0),
 324							array(0,0,0,0,0,0,0,0,0),
 325							array(0,0,0,0,1,0,0,0,0),
 326							array(0,0,0,1,0,1,0,0,0),
 327							array(0,0,1,1,0,1,1,0,0),
 328							array(0,0,1,0,0,0,1,0,0),
 329							array(0,1,0,0,0,0,0,1,0),
 330							array(0,1,0,0,0,0,0,1,0),
 331							array(0,1,1,1,1,1,1,1,0),
 332							array(0,1,0,0,0,0,0,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(1,1,1,0,0,0,1,1,1),
 338						),
 339						array(
 340							array(0,0,0,0,0,0,0,0,0),
 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,1,1,1,1,1,0,0),
 345							array(0,1,1,0,0,0,1,1,0),
 346							array(1,1,0,0,0,0,0,1,1),
 347							array(1,0,0,0,0,0,0,0,1),
 348							array(0,0,0,0,0,0,0,1,1),
 349							array(0,0,0,0,0,1,1,1,1),
 350							array(0,0,0,1,1,1,0,0,1),
 351							array(0,1,1,1,0,0,0,0,1),
 352							array(1,0,0,0,0,0,0,0,1),
 353							array(1,1,0,0,0,0,1,1,1),
 354							array(0,1,1,1,1,1,1,0,1),
 355						),
 356					),
 357		'B'	=>		array(
 358						array(
 359							array(1,1,1,1,1,1,1,0,0),
 360							array(1,0,0,0,0,0,0,1,0),
 361							array(1,0,0,0,0,0,0,0,1),
 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,1,0),
 366							array(1,1,1,1,1,1,1,0,0),
 367							array(1,0,0,0,0,0,0,1,0),
 368							array(1,0,0,0,0,0,0,0,1),
 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,1,0),
 373							array(1,1,1,1,1,1,1,0,0),
 374						),
 375						array(
 376							array(1,1,1,1,1,1,1,0,0),
 377							array(0,1,0,0,0,0,0,1,0),
 378							array(0,1,0,0,0,0,0,0,1),
 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,1,0),
 383							array(0,1,1,1,1,1,1,0,0),
 384							array(0,1,0,0,0,0,0,1,0),
 385							array(0,1,0,0,0,0,0,0,1),
 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,1,0),
 390							array(1,1,1,1,1,1,1,0,0),
 391						),
 392						array(
 393							array(0,1,0,0,0,0,0,0,0),
 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,1,1,1,1,1,0,0),
 401							array(0,1,0,0,0,0,0,1,0),
 402							array(0,1,0,0,0,0,0,0,1),
 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,1,0),
 407							array(0,1,1,1,1,1,1,0,0),
 408						),
 409					),
 410		'C'	=>		array(
 411						array(
 412							array(0,0,1,1,1,1,1,0,0),
 413							array(0,1,0,0,0,0,0,1,0),
 414							array(1,0,0,0,0,0,0,0,1),
 415							array(1,0,0,0,0,0,0,0,1),
 416							array(1,0,0,0,0,0,0,0,0),
 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,1),
 424							array(1,0,0,0,0,0,0,0,1),
 425							array(0,1,0,0,0,0,0,1,0),
 426							array(0,0,1,1,1,1,1,0,0),
 427						),
 428						array(
 429							array(0,0,1,1,1,1,1,0,1),
 430							array(0,1,0,0,0,0,0,1,1),
 431							array(1,0,0,0,0,0,0,0,1),
 432							array(1,0,0,0,0,0,0,0,1),
 433							array(1,0,0,0,0,0,0,0,0),
 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,1),
 441							array(1,0,0,0,0,0,0,0,1),
 442							array(0,1,0,0,0,0,0,1,1),
 443							array(0,0,1,1,1,1,1,0,1),
 444						),
 445					),
 446		'D'	=>		array(
 447						array(
 448							array(1,1,1,1,1,1,1,0,0),
 449							array(1,0,0,0,0,0,0,1,0),
 450							array(1,0,0,0,0,0,0,0,1),
 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,1,0),
 462							array(1,1,1,1,1,1,1,0,0),
 463						),
 464						array(
 465							array(1,1,1,1,1,1,1,0,0),
 466							array(0,1,0,0,0,0,0,1,0),
 467							array(0,1,0,0,0,0,0,0,1),
 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,1,0),
 479							array(1,1,1,1,1,1,1,0,0),
 480						),
 481						array(
 482							array(0,0,0,0,0,0,0,0,1),
 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,1,1,1,1,1,0,1),
 490							array(0,1,1,0,0,0,1,1,1),
 491							array(0,1,0,0,0,0,0,0,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,1,0,0,0,1,1,1),
 496							array(0,0,1,1,1,1,1,0,1),
 497						),
 498					),
 499		'E'	=>		array(
 500						array(
 501							array(1,1,1,1,1,1,1,1,1),
 502							array(1,0,0,0,0,0,0,0,0),
 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,1,1,1,1,1,1,1,0),
 509							array(1,0,0,0,0,0,0,0,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,1,1,1,1,1,1,1,1),
 516						),
 517						array(
 518							array(1,1,1,1,1,1,1,1,1),
 519							array(1,0,0,0,0,0,0,0,1),
 520							array(1,0,0,0,0,0,0,0,0),
 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,1,1,1,1,1,1,0,0),
 526							array(1,0,0,0,0,0,0,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,1),
 532							array(1,1,1,1,1,1,1,1,1),
 533						),
 534						array(
 535							array(0,0,0,0,0,0,0,0,0),
 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,1,1,1,1,1,0,0),
 543							array(0,1,1,0,0,0,1,1,0),
 544							array(1,1,0,0,0,0,0,1,1),
 545							array(1,1,1,1,1,1,1,1,1),
 546							array(1,0,0,0,0,0,0,0,0),
 547							array(1,0,0,0,0,0,0,0,1),
 548							array(1,1,0,0,0,0,0,1,1),
 549							array(0,1,1,1,1,1,1,1,0),
 550						),
 551					),
 552		'F'	=>		array(
 553						array(
 554							array(1,1,1,1,1,1,1,1,1),
 555							array(1,0,0,0,0,0,0,0,0),
 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,1,1,1,1,1,1,0,0),
 562							array(1,0,0,0,0,0,0,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						),
 570						array(
 571							array(0,1,1,1,1,1,1,1,1),
 572							array(0,1,0,0,0,0,0,0,1),
 573							array(0,1,0,0,0,0,0,0,0),
 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,1,1,1,1,1,0,0),
 579							array(0,1,0,0,0,0,0,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(1,1,1,0,0,0,0,0,0),
 586						),
 587						array(
 588							array(0,0,0,1,1,0,0,0,0),
 589							array(0,0,1,1,0,0,0,0,0),
 590							array(0,1,1,0,0,0,0,0,0),
 591							array(0,1,0,0,0,0,0,0,0),
 592							array(0,1,0,0,0,0,0,0,0),
 593							array(1,1,1,1,0,0,0,0,0),
 594							array(0,1,0,0,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						),
 604					),
 605		'G'	=>		array(
 606						array(
 607							array(0,0,1,1,1,1,1,0,0),
 608							array(0,1,0,0,0,0,0,1,0),
 609							array(1,0,0,0,0,0,0,0,1),
 610							array(1,0,0,0,0,0,0,0,0),
 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,1,1,1),
 616							array(1,0,0,0,0,0,0,0,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(0,1,0,0,0,0,0,1,0),
 621							array(0,0,1,1,1,1,1,0,0),
 622						),
 623						array(
 624							array(0,0,1,1,1,1,1,0,1),
 625							array(0,1,0,0,0,0,0,1,1),
 626							array(1,0,0,0,0,0,0,0,1),
 627							array(1,0,0,0,0,0,0,0,0),
 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,1,1,1,1,1),
 633							array(1,0,0,0,1,0,0,0,1),
 634							array(1,0,0,0,1,0,0,0,1),
 635							array(1,0,0,0,0,0,0,0,1),
 636							array(1,0,0,0,0,0,0,0,1),
 637							array(0,1,0,0,0,0,0,1,1),
 638							array(0,0,1,1,1,1,1,0,1),
 639						),
 640						array(
 641							array(0,0,1,1,1,1,1,0,1),
 642							array(0,1,1,0,0,0,0,1,1),
 643							array(1,1,0,0,0,0,0,1,1),
 644							array(1,0,0,0,0,0,0,0,1),
 645							array(1,0,0,0,0,0,0,0,1),
 646							array(1,1,1,0,0,0,0,0,1),
 647							array(0,0,1,1,1,1,1,1,1),
 648							array(0,0,0,0,0,0,0,0,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,1,1),
 653							array(1,1,1,1,1,1,1,1,0),
 654							array(0,0,0,0,0,0,0,0,0),
 655							array(0,0,0,0,0,0,0,0,0),
 656						),
 657					),
 658		'H'	=>		array(
 659						array(
 660							array(1,0,0,0,0,0,0,0,1),
 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,1,1,1,1,1,1,1,1),
 668							array(1,0,0,0,0,0,0,0,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						),
 676						array(
 677							array(1,1,1,0,0,0,1,1,1),
 678							array(0,1,0,0,0,0,0,1,0),
 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,1,1,1,1,1,1,0),
 685							array(0,1,0,0,0,0,0,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(1,1,1,0,0,0,1,1,1),
 692						),
 693						array(
 694							array(1,0,0,0,0,0,0,0,0),
 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,1,1,1,0,0,0),
 702							array(1,1,1,1,0,1,1,0,0),
 703							array(1,0,0,0,0,0,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						),
 710					),
 711		'I'	=>		array(
 712						array(
 713							array(1,1,1,1,1,1,1,1,1),
 714							array(0,0,0,0,1,0,0,0,0),
 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(1,1,1,1,1,1,1,1,1),
 728						),
 729						array(
 730							array(0,0,0,1,1,1,0,0,0),
 731							array(0,0,0,0,1,0,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,1,1,1,0,0,0),
 745						),
 746						array(
 747							array(0,0,0,0,0,0,0,0,0),
 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,1,0,0,0,0),
 751							array(0,0,0,1,1,1,0,0,0),
 752							array(0,0,0,0,1,0,0,0,0),
 753							array(0,0,0,0,0,0,0,0,0),
 754							array(0,0,0,0,1,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,1,1,1,0,0,0),
 762						),
 763					),
 764		'J'	=>		array(
 765						array(
 766							array(1,1,1,1,1,1,1,1,1),
 767							array(0,0,0,0,0,1,0,0,0),
 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(1,0,0,0,0,1,0,0,0),
 778							array(1,0,0,0,0,1,0,0,0),
 779							array(0,1,0,0,1,0,0,0,0),
 780							array(0,0,1,1,0,0,0,0,0),
 781						),
 782						array(
 783							array(1,1,1,1,1,1,1,1,1),
 784							array(0,0,0,0,0,1,0,0,0),
 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(1,0,0,0,0,1,0,0,0),
 795							array(1,0,0,0,0,1,0,0,0),
 796							array(1,1,0,0,1,0,0,0,0),
 797							array(1,0,1,1,0,0,0,0,0),
 798						),
 799						array(
 800							array(0,0,0,0,0,0,0,0,0),
 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,1,0,0,0),
 805							array(0,0,0,0,0,0,0,0,0),
 806							array(0,0,0,0,0,1,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(1,0,0,0,0,1,0,0,0),
 812							array(1,0,0,0,0,1,0,0,0),
 813							array(0,1,0,0,1,0,0,0,0),
 814							array(0,0,1,1,0,0,0,0,0),
 815						),
 816					),
 817		'K'	=>		array(
 818						array(    // New 'K', supplied by NeoThermic
 819							array(1,0,0,0,0,0,0,0,1),
 820							array(1,0,0,0,0,0,0,1,0),
 821							array(1,0,0,0,0,0,1,0,0),
 822							array(1,0,0,0,0,1,0,0,0),
 823							array(1,0,0,0,1,0,0,0,0),
 824							array(1,0,0,1,0,0,0,0,0),
 825							array(1,0,1,0,0,0,0,0,0),
 826							array(1,1,0,0,0,0,0,0,0),
 827							array(1,0,1,0,0,0,0,0,0),
 828							array(1,0,0,1,0,0,0,0,0),
 829							array(1,0,0,0,1,0,0,0,0),
 830							array(1,0,0,0,0,1,0,0,0),
 831							array(1,0,0,0,0,0,1,0,0),
 832							array(1,0,0,0,0,0,0,1,0),
 833							array(1,0,0,0,0,0,0,0,1),
 834						),
 835						array(
 836							array(0,1,0,0,0,0,0,0,1),
 837							array(0,1,0,0,0,0,0,1,0),
 838							array(0,1,0,0,0,0,1,0,0),
 839							array(0,1,0,0,0,1,0,0,0),
 840							array(0,1,0,0,1,0,0,0,0),
 841							array(0,1,0,1,0,0,0,0,0),
 842							array(0,1,1,0,0,0,0,0,0),
 843							array(0,1,0,0,0,0,0,0,0),
 844							array(0,1,1,0,0,0,0,0,0),
 845							array(0,1,0,1,0,0,0,0,0),
 846							array(0,1,0,0,1,0,0,0,0),
 847							array(0,1,0,0,0,1,0,0,0),
 848							array(0,1,0,0,0,0,1,0,0),
 849							array(0,1,0,0,0,0,0,1,0),
 850							array(1,1,1,0,0,0,1,1,1),
 851						),
 852						array(
 853							array(0,0,0,0,0,0,0,0,0),
 854							array(0,1,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,1,0,0,0),
 857							array(0,1,0,0,1,0,0,0,0),
 858							array(0,1,0,1,0,0,0,0,0),
 859							array(0,1,1,0,0,0,0,0,0),
 860							array(0,1,0,0,0,0,0,0,0),
 861							array(0,1,1,0,0,0,0,0,0),
 862							array(0,1,0,1,0,0,0,0,0),
 863							array(0,1,0,0,1,0,0,0,0),
 864							array(0,1,0,0,0,1,0,0,0),
 865							array(0,1,0,0,0,0,1,0,0),
 866							array(0,1,0,0,0,0,0,1,0),
 867							array(0,1,0,0,0,0,0,1,0),
 868						),
 869					),
 870		'L'	=>		array(
 871						array(
 872							array(0,0,0,0,0,0,0,0,0),
 873							array(1,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,1,1,1,1,1,1,1,1),
 887						),
 888						array(
 889							array(0,0,0,0,0,0,0,0,0),
 890							array(0,1,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,1),
 903							array(1,1,1,1,1,1,1,1,1),
 904						),
 905						array(
 906							array(0,0,0,0,0,0,0,0,0),
 907							array(0,1,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,1,0,0,0,0,0,0),
 920							array(0,0,1,1,1,0,0,0,0),
 921						),
 922					),
 923		'M'	=>		array(
 924						array(
 925							array(1,1,0,0,0,0,0,1,1),
 926							array(1,1,0,0,0,0,0,1,1),
 927							array(1,0,1,0,0,0,1,0,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,0,1,0,1,0,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,0,1,0,0,0,1),
 934							array(1,0,0,0,1,0,0,0,1),
 935							array(1,0,0,0,0,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						),
 941						array(
 942							array(0,0,0,0,0,0,0,0,0),
 943							array(0,1,0,0,0,0,0,1,0),
 944							array(0,1,1,0,0,0,1,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,0,1,0,1,0,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,0,1,0,0,1,0),
 951							array(0,1,0,0,1,0,0,1,0),
 952							array(0,1,0,0,0,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(1,1,1,0,0,0,1,1,1),
 957						),
 958						array(
 959							array(0,0,0,0,0,0,0,0,0),
 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,1,1,1,0,1,1,1,0),
 966							array(1,1,0,1,1,1,0,1,1),
 967							array(1,0,0,0,1,0,0,0,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						),
 975					),
 976		'N'	=>		array(
 977						array(
 978							array(1,1,0,0,0,0,0,0,1),
 979							array(1,1,0,0,0,0,0,0,1),
 980							array(1,0,1,0,0,0,0,0,1),
 981							array(1,0,1,0,0,0,0,0,1),
 982							array(1,0,0,1,0,0,0,0,1),
 983							array(1,0,0,1,0,0,0,0,1),
 984							array(1,0,0,0,1,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,0,1,0,0,1),
 988							array(1,0,0,0,0,1,0,0,1),
 989							array(1,0,0,0,0,0,1,0,1),
 990							array(1,0,0,0,0,0,1,0,1),
 991							array(1,0,0,0,0,0,0,1,1),
 992							array(1,0,0,0,0,0,0,1,1),
 993						),
 994						array(
 995							array(0,0,0,0,0,0,0,0,0),
 996							array(0,1,0,0,0,0,0,1,0),
 997							array(0,1,1,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,0,1,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,0,1,0,0,1,0),
1004							array(0,1,0,0,1,1,0,1,0),
1005							array(0,1,0,0,0,1,0,1,0),
1006							array(0,1,0,0,0,1,1,1,0),
1007							array(0,1,0,0,0,0,1,1,0),
1008							array(0,1,0,0,0,0,0,1,0),
1009							array(1,1,1,0,0,0,1,1,1),
1010						),
1011						array(
1012							array(0,0,0,0,0,0,0,0,0),
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(1,0,1,1,1,1,0,0,0),
1020							array(1,1,1,0,0,1,1,0,0),
1021							array(1,0,0,0,0,0,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						),
1028					),
1029		'O'	=>		array(
1030						array(
1031							array(0,0,1,1,1,1,1,0,0),
1032							array(0,1,0,0,0,0,0,1,0),
1033							array(1,0,0,0,0,0,0,0,1),
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(0,1,0,0,0,0,0,1,0),
1045							array(0,0,1,1,1,1,1,0,0),
1046						),
1047						array(
1048							array(0,0,1,1,1,1,1,0,0),
1049							array(0,1,0,0,0,0,0,1,0),
1050							array(1,1,0,0,0,0,0,1,1),
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(0,1,0,0,0,0,0,1,0),
1062							array(0,0,1,1,1,1,1,0,0),
1063						),
1064						array(
1065							array(0,0,0,0,0,0,0,0,0),
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,1,1,1,1,1,0,0,0),
1073							array(1,1,1,0,0,1,1,0,0),
1074							array(1,0,0,0,0,0,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,1,0,0,0,1,1,0,0),
1079							array(0,1,1,1,1,1,0,0,0),
1080						),
1081					),
1082		'P'	=>		array(
1083						array(
1084							array(1,1,1,1,1,1,1,0,0),
1085							array(1,0,0,0,0,0,0,1,0),
1086							array(1,0,0,0,0,0,0,0,1),
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,1,0),
1091							array(1,1,1,1,1,1,1,0,0),
1092							array(1,0,0,0,0,0,0,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						),
1100						array(
1101							array(1,1,1,1,1,1,1,0,0),
1102							array(0,1,0,0,0,0,0,1,0),
1103							array(0,1,0,0,0,0,0,0,1),
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,1,0),
1108							array(1,1,1,1,1,1,1,0,0),
1109							array(0,1,0,0,0,0,0,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(1,1,1,0,0,0,0,0,0),
1116						),
1117						array(
1118							array(0,0,0,0,0,0,0,0,0),
1119							array(0,0,0,0,0,0,0,0,0),
1120							array(1,0,0,0,0,0,0,0,0),
1121							array(1,0,1,1,0,0,0,0,0),
1122							array(1,1,0,1,1,0,0,0,0),
1123							array(1,0,0,0,1,0,0,0,0),
1124							array(1,0,0,0,1,0,0,0,0),
1125							array(1,0,0,1,1,0,0,0,0),
1126							array(1,1,1,1,0,0,0,0,0),
1127							array(1,0,0,0,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						),
1134					),
1135		'Q'	=>		array(
1136						array(
1137							array(0,0,1,1,1,1,1,0,0),
1138							array(0,1,0,0,0,0,0,1,0),
1139							array(1,0,0,0,0,0,0,0,1),
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,1,0,0,1),
1149							array(1,0,0,0,0,0,1,0,1),
1150							array(0,1,0,0,0,0,0,1,0),
1151							array(0,0,1,1,1,1,1,0,1),
1152						),
1153						array(
1154							array(0,0,1,1,1,1,1,0,0),
1155							array(0,1,0,0,0,0,0,1,0),
1156							array(1,0,0,0,0,0,0,0,1),
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,1,0,0,0,1),
1164							array(1,1,0,0,1,1,0,1,1),
1165							array(0,1,1,1,1,1,1,1,0),
1166							array(0,0,0,0,0,0,1,1,0),
1167							array(0,0,0,0,0,0,0,1,1),
1168							array(0,0,0,0,0,0,0,0,1),
1169						),
1170						array(
1171							array(0,0,0,0,0,0,0,0,0),
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,1,1,1,1),
1175							array(0,0,0,0,1,1,0,0,1),
1176							array(0,0,0,0,1,0,0,0,1),
1177							array(0,0,0,0,1,0,0,0,1),
1178							array(0,0,0,0,1,1,0,1,1),
1179							array(0,0,0,0,0,1,1,0,1),
1180							array(0,0,0,0,0,0,0,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						),
1187					),
1188		'R'	=>		array(
1189						array(
1190							array(1,1,1,1,1,1,1,0,0),
1191							array(1,0,0,0,0,0,0,1,0),
1192							array(1,0,0,0,0,0,0,0,1),
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,1,0),
1197							array(1,1,1,1,1,1,1,0,0),
1198							array(1,1,1,0,0,0,0,0,0),
1199							array(1,0,0,1,0,0,0,0,0),
1200							array(1,0,0,0,1,0,0,0,0),
1201							array(1,0,0,0,0,1,0,0,0),
1202							array(1,0,0,0,0,0,1,0,0),
1203							array(1,0,0,0,0,0,0,1,0),
1204							array(1,0,0,0,0,0,0,0,1),
1205						),
1206						array(
1207							array(1,1,1,1,1,1,1,0,0),
1208							array(0,1,0,0,0,0,0,1,0),
1209							array(0,1,0,0,0,0,0,0,1),
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,1,0),
1214							array(1,1,1,1,1,1,1,0,0),
1215							array(0,1,1,0,0,0,0,0,0),
1216							array(0,1,1,1,0,0,0,0,0),
1217							array(0,1,0,1,1,0,0,0,0),
1218							array(0,1,0,0,1,1,0,0,0),
1219							array(0,1,0,0,0,1,1,0,0),
1220							array(0,1,0,0,0,0,1,1,0),
1221							array(1,1,1,0,0,0,1,1,1),
1222						),
1223						array(
1224							array(0,0,0,0,0,0,0,0,0),
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(1,0,0,0,0,0,0,0,0),
1231							array(1,1,1,1,1,0,0,0,0),
1232							array(1,1,0,0,1,1,0,0,0),
1233							array(1,0,0,0,0,0,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						),
1240					),
1241		'S'	=>		array(
1242						array(
1243							array(0,0,1,1,1,1,1,0,0),
1244							array(0,1,0,0,0,0,0,1,0),
1245							array(1,0,0,0,0,0,0,0,1),
1246							array(1,0,0,0,0,0,0,0,0),
1247							array(1,0,0,0,0,0,0,0,0),
1248							array(1,0,0,0,0,0,0,0,0),
1249							array(0,1,0,0,0,0,0,0,0),
1250							array(0,0,1,1,1,1,1,0,0),
1251							array(0,0,0,0,0,0,0,1,0),
1252							array(0,0,0,0,0,0,0,0,1),
1253							array(0,0,0,0,0,0,0,0,1),
1254							array(0,0,0,0,0,0,0,0,1),
1255							array(1,0,0,0,0,0,0,0,1),
1256							array(0,1,0,0,0,0,0,1,0),
1257							array(0,0,1,1,1,1,1,0,0),
1258						),
1259						array(
1260							array(0,0,1,1,1,1,1,0,1),
1261							array(0,1,0,0,0,0,0,1,1),
1262							array(1,0,0,0,0,0,0,0,1),
1263							array(1,0,0,0,0,0,0,0,1),
1264							array(1,0,0,0,0,0,0,0,0),
1265							array(1,0,0,0,0,0,0,0,0),
1266							array(0,1,0,0,0,0,0,0,0),
1267							array(0,0,1,1,1,1,1,0,0),
1268							array(0,0,0,0,0,0,0,1,0),
1269							array(0,0,0,0,0,0,0,0,1),
1270							array(1,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,1,0,0,0,0,0,1,0),
1274							array(1,0,1,1,1,1,1,0,0),
1275						),
1276						array(
1277							array(0,0,0,0,0,0,0,0,0),
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,1,1,1,1,0,0,0,0),
1285							array(1,0,0,0,0,1,0,0,0),
1286							array(1,0,0,0,0,0,0,0,0),
1287							array(1,1,0,0,0,0,0,0,0),
1288							array(0,1,1,1,1,0,0,0,0),
1289							array(0,0,0,0,0,1,0,0,0),
1290							array(1,0,0,0,1,1,0,0,0),
1291							array(0,1,1,1,1,0,0,0,0),
1292						),
1293					),
1294		'T'	=>		array(
1295						array(
1296							array(1,1,1,1,1,1,1,1,1),
1297							array(0,0,0,0,1,0,0,0,0),
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						),
1312						array(
1313							array(1,1,1,1,1,1,1,1,1),
1314							array(1,0,0,0,1,0,0,0,1),
1315							array(0,0,0,0,1,0,0,0,0),
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,1,1,1,0,0,0),
1328						),
1329						array(
1330							array(0,0,0,0,1,0,0,0,0),
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,1,1,1,1,1,1,0),
1334							array(0,0,0,0,1,0,0,0,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,1,0,0,0),
1344							array(0,0,0,0,0,1,1,1,0),
1345						),
1346					),
1347		'U'	=>		array(
1348						array(
1349							array(1,0,0,0,0,0,0,0,1),
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(0,1,0,0,0,0,0,1,0),
1363							array(0,0,1,1,1,1,1,0,0),
1364						),
1365						array(
1366							array(1,0,0,0,0,0,0,0,0),
1367							array(1,1,1,0,0,0,1,1,1),
1368							array(0,1,0,0,0,0,0,1,0),
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,1,0,0,0,1,1,0),
1380							array(0,0,1,1,1,1,1,0,0),
1381						),
1382						array(
1383							array(0,0,0,0,0,0,0,0,0),
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,1,0,0,0,0,0,1),
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,1,1),
1396							array(0,0,1,1,0,0,1,1,1),
1397							array(0,0,0,1,1,1,1,0,1),
1398						),
1399					),
1400		'V'	=>		array(
1401						array(
1402							array(1,0,0,0,0,0,0,0,1),
1403							array(1,0,0,0,0,0,0,0,1),
1404							array(1,0,0,0,0,0,0,0,1),
1405							array(0,1,0,0,0,0,0,1,0),
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,0,1,0,0,0,1,0,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,0,1,0,1,0,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,0,1,0,0,0,0),
1416							array(0,0,0,0,1,0,0,0,0),
1417						),
1418						array(
1419							array(0,0,0,0,0,0,0,0,0),
1420							array(0,0,0,0,0,0,0,0,0),
1421							array(0,0,0,0,0,0,0,0,0),
1422							array(1,1,1,0,0,0,1,1,1),
1423							array(0,1,0,0,0,0,0,1,0),
1424							array(0,1,0,0,0,0,0,1,0),
1425							array(0,0,1,0,0,0,1,0,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,0,1,0,1,0,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,0,1,0,0,0,0),
1433							array(0,0,0,0,1,0,0,0,0),
1434						),
1435						array(
1436							array(0,0,0,0,0,0,0,0,0),
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,1,0,0,0,1,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,0,1,0,1,0,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,0,1,0,0,0,0),
1450							array(0,0,0,0,1,0,0,0,0),
1451						),
1452					),
1453		'W'	=>		array(
1454						array(
1455							array(1,0,0,0,0,0,0,0,1),
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,1,0,0,0,1),
1461							array(1,0,0,0,1,0,0,0,1),
1462							array(1,0,0,1,0,1,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,1,0,0,0,1,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,1,0,0,0,0,0,1,1),
1469							array(1,1,0,0,0,0,0,1,1),
1470						),
1471						array(
1472							array(0,0,0,0,0,0,0,0,0),
1473							array(0,0,0,0,0,0,0,0,0),
1474							array(1,1,1,0,0,0,1,1,1),
1475							array(0,1,0,0,0,0,0,1,0),
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,1,0,0,1,0),
1480							array(0,1,0,0,1,0,0,1,0),
1481							array(0,1,0,1,1,1,0,1,0),
1482							array(0,1,0,1,0,1,0,1,0),
1483							array(0,1,1,1,0,1,1,1,0),
1484							array(0,1,1,0,0,0,1,1,0),
1485							array(0,1,0,0,0,0,0,1,0),
1486							array(0,0,0,0,0,0,0,0,0),
1487						),
1488						array(
1489							array(0,0,0,0,0,0,0,0,0),
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,1,0,0,0,0,0,1,0),
1496							array(0,1,0,0,1,0,0,1,0),
1497							array(0,1,0,0,1,0,0,1,0),
1498							array(0,1,0,1,1,1,0,1,0),
1499							array(0,1,0,1,0,1,0,1,0),
1500							array(0,1,1,1,0,1,1,1,0),
1501							array(0,1,1,0,0,0,1,1,0),
1502							array(0,1,0,0,0,0,0,1,0),
1503							array(0,0,0,0,0,0,0,0,0),
1504						),
1505					),
1506		'X'	=>		array(
1507						array(
1508							array(1,0,0,0,0,0,0,0,1),
1509							array(1,0,0,0,0,0,0,0,1),
1510							array(0,1,0,0,0,0,0,1,0),
1511							array(0,1,0,0,0,0,0,1,0),
1512							array(0,0,1,0,0,0,1,0,0),
1513							array(0,0,0,1,0,1,0,0,0),
1514							array(0,0,0,1,0,1,0,0,0),
1515							array(0,0,0,0,1,0,0,0,0),
1516							array(0,0,0,1,0,1,0,0,0),
1517							array(0,0,0,1,0,1,0,0,0),
1518							array(0,0,1,0,0,0,1,0,0),
1519							array(0,1,0,0,0,0,1,0,0),
1520							array(0,1,0,0,0,0,0,1,0),
1521							array(1,0,0,0,0,0,0,0,1),
1522							array(1,0,0,0,0,0,0,0,1),
1523						),
1524						array(
1525							array(0,0,0,0,0,0,0,0,0),
1526							array(1,1,1,0,0,0,1,1,1),
1527							array(0,1,0,0,0,0,0,1,0),
1528							array(0,1,0,0,0,0,0,1,0),
1529							array(0,0,1,0,0,0,1,0,0),
1530							array(0,0,0,1,0,1,0,0,0),
1531							array(0,0,0,1,0,1,0,0,0),
1532							array(0,0,0,0,1,0,0,0,0),
1533							array(0,0,0,1,0,1,0,0,0),
1534							array(0,0,0,1,0,1,0,0,0),
1535							array(0,0,1,0,0,0,1,0,0),
1536							array(0,1,0,0,0,0,1,0,0),
1537							array(0,1,0,0,0,0,0,1,0),
1538							array(1,1,1,0,0,0,1,1,1),
1539							array(0,0,0,0,0,0,0,0,0),
1540						),
1541						array(
1542							array(0,0,0,0,0,0,0,0,0),
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,1,0,0,0,0,0,1,0),
1550							array(0,1,1,0,0,0,1,1,0),
1551							array(0,0,1,1,0,1,1,0,0),
1552							array(0,0,0,1,1,1,0,0,0),
1553							array(0,0,0,1,1,1,0,0,0),
1554							array(0,0,1,1,0,1,1,0,0),
1555							array(0,1,1,0,0,0,1,1,0),
1556							array(0,0,0,0,0,0,0,0,0),
1557						),
1558					),
1559		'Y'	=>		array(
1560						array(
1561							array(1,0,0,0,0,0,0,0,1),
1562							array(1,0,0,0,0,0,0,0,1),
1563							array(0,1,0,0,0,0,0,1,0),
1564							array(0,1,0,0,0,0,0,1,0),
1565							array(0,0,1,0,0,0,1,0,0),
1566							array(0,0,1,0,0,0,1,0,0),
1567							array(0,0,0,1,0,1,0,0,0),
1568							array(0,0,0,0,1,0,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						),
1577						array(
1578							array(0,0,0,0,0,0,0,0,0),
1579							array(1,1,1,0,0,0,1,1,1),
1580							array(0,1,0,0,0,0,0,1,0),
1581							array(0,1,0,0,0,0,0,1,0),
1582							array(0,0,1,0,0,0,1,0,0),
1583							array(0,0,1,0,0,0,1,0,0),
1584							array(0,0,0,1,0,1,0,0,0),
1585							array(0,0,0,0,1,0,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,1,1,1,0,0,0),
1593						),
1594						array(
1595							array(0,0,0,0,0,0,0,0,0),
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,1,0,0,0,0,1),
1600							array(0,0,0,1,1,0,0,0,1),
1601							array(0,0,0,0,1,0,0,1,1),
1602							array(0,0,0,0,1,1,0,1,0),
1603							array(0,0,0,0,0,1,1,1,0),
1604							array(0,0,0,0,0,0,1,0,0),
1605							array(0,0,0,0,0,1,1,0,0),
1606							array(0,0,0,0,0,1,0,0,0),
1607							array(0,0,0,0,1,1,0,0,0),
1608							array(0,0,1,1,1,0,0,0,0),
1609							array(0,0,0,0,0,0,0,0,0),
1610						),
1611					),
1612		'Z'	=>		array(
1613						array(
1614							array(1,1,1,1,1,1,1,1,1),
1615							array(1,0,0,0,0,0,0,0,1),
1616							array(0,0,0,0,0,0,0,0,1),
1617							array(0,0,0,0,0,0,0,1,0),
1618							array(0,0,0,0,0,0,1,0,0),
1619							array(0,0,0,0,0,1,0,0,0),
1620							array(0,0,0,0,0,1,0,0,0),
1621							array(0,0,0,0,1,0,0,0,0),
1622							array(0,0,0,1,0,0,0,0,0),
1623							array(0,0,0,1,0,0,0,0,0),
1624							array(0,0,1,0,0,0,0,0,0),
1625							array(0,1,0,0,0,0,0,0,0),
1626							array(1,0,0,0,0,0,0,0,0),
1627							array(1,0,0,0,0,0,0,0,1),
1628							array(1,1,1,1,1,1,1,1,1),
1629						),
1630						array(
1631							array(1,1,1,1,1,1,1,1,1),
1632							array(0,0,0,0,0,0,0,0,1),
1633							array(0,0,0,0,0,0,0,0,1),
1634							array(0,0,0,0,0,0,0,1,0),
1635							array(0,0,0,0,0,0,1,0,0),
1636							array(0,0,0,0,0,1,0,0,0),
1637							array(0,0,0,0,0,1,0,0,0),
1638							array(0,0,1,1,1,1,1,0,0),
1639							array(0,0,0,1,0,0,0,0,0),
1640							array(0,0,0,1,0,0,0,0,0),
1641							array(0,0,1,0,0,0,0,0,0),
1642							array(0,1,0,0,0,0,0,0,0),
1643							array(1,0,0,0,0,0,0,0,0),
1644							array(1,0,0,0,0,0,0,0,0),
1645							array(1,1,1,1,1,1,1,1,1),
1646						),
1647						array(
1648							array(0,0,0,0,0,0,0,0,0),
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,1,1,1,1,1,1,1,0),
1657							array(0,0,0,0,0,1,1,0,0),
1658							array(0,0,0,0,1,1,0,0,0),
1659							array(0,0,0,1,1,0,0,0,0),
1660							array(0,0,1,1,0,0,0,0,0),
1661							array(0,0,1,0,0,0,0,0,0),
1662							array(0,1,1,1,1,1,1,1,0),
1663						),
1664					),
1665				);
1666		return array(
1667			'width'		=> 9,
1668			'height'	=> 15,
1669			'data'		=> array(
1670
1671			'A' =>	$chars['A'][mt_rand(0, min(sizeof($chars['A']), $config['captcha_gd_fonts']) -1)],
1672			'B' =>	$chars['B'][mt_rand(0, min(sizeof($chars['B']), $config['captcha_gd_fonts']) -1)],
1673			'C' =>	$chars['C'][mt_rand(0, min(sizeof($chars['C']), $config['captcha_gd_fonts']) -1)],
1674			'D' =>	$chars['D'][mt_rand(0, min(sizeof($chars['D']), $config['captcha_gd_fonts']) -1)],
1675			'E' =>	$chars['E'][mt_rand(0, min(sizeof($chars['E']), $config['captcha_gd_fonts']) -1)],
1676			'F' =>	$chars['F'][mt_rand(0, min(sizeof($chars['F']), $config['captcha_gd_fonts']) -1)],
1677			'G' =>	$chars['G'][mt_rand(0, min(sizeof($chars['G']), $config['captcha_gd_fonts']) -1)],
1678			'H' =>	$chars['H'][mt_rand(0, min(sizeof($chars['H']), $config['captcha_gd_fonts']) -1)],
1679			'I' =>	$chars['I'][mt_rand(0, min(sizeof($chars['I']), $config['captcha_gd_fonts']) -1)],
1680			'J' =>	$chars['J'][mt_rand(0, min(sizeof($chars['J']), $config['captcha_gd_fonts']) -1)],
1681			'K' =>	$chars['K'][mt_rand(0, min(sizeof($chars['K']), $config['captcha_gd_fonts']) -1)],
1682			'L' =>	$chars['L'][mt_rand(0, min(sizeof($chars['L']), $config['captcha_gd_fonts']) -1)],
1683			'M' =>	$chars['M'][mt_rand(0, min(sizeof($chars['M']), $config['captcha_gd_fonts']) -1)],  
1684			'N' =>	$chars['N'][mt_rand(0, min(sizeof($chars['N']), $config['captcha_gd_fonts']) -1)],
1685			'O' =>	$chars['O'][mt_rand(0, min(sizeof($chars['O']), $config['captcha_gd_fonts']) -1)],
1686			'P' =>	$chars['P'][mt_rand(0, min(sizeof($chars['P']), $config['captcha_gd_fonts']) -1)],
1687			'Q' =>	$chars['Q'][mt_rand(0, min(sizeof($chars['Q']), $config['captcha_gd_fonts']) -1)],
1688			'R' =>	$chars['R'][mt_rand(0, min(sizeof($chars['R']), $config['captcha_gd_fonts']) -1)],
1689			'S' =>	$chars['S'][mt_rand(0, min(sizeof($chars['S']), $config['captcha_gd_fonts']) -1)],
1690			'T' =>	$chars['T'][mt_rand(0, min(sizeof($chars['T']), $config['captcha_gd_fonts']) -1)],
1691			'U' =>	$chars['U'][mt_rand(0, min(sizeof($chars['U']), $config['captcha_gd_fonts']) -1)],
1692			'V' =>	$chars['V'][mt_rand(0, min(sizeof($chars['V']), $config['captcha_gd_fonts']) -1)],
1693			'W' =>	$chars['W'][mt_rand(0, min(sizeof($chars['W']), $config['captcha_gd_fonts']) -1)],
1694			'X' =>	$chars['X'][mt_rand(0, min(sizeof($chars['X']), $config['captcha_gd_fonts']) -1)],
1695			'Y' =>	$chars['Y'][mt_rand(0, min(sizeof($chars['Y']), $config['captcha_gd_fonts']) -1)],
1696			'Z' =>	$chars['Z'][mt_rand(0, min(sizeof($chars['Z']), $config['captcha_gd_fonts']) -1)],
1697
1698			'1' => array(
1699				array(0,0,0,1,1,0,0,0,0),
1700				array(0,0,1,0,1,0,0,0,0),
1701				array(0,1,0,0,1,0,0,0,0),
1702				array(0,0,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,1,1,1,1,1,1,1,0),
1714			),
1715			'2' => array(    // New '2' supplied by Anon
1716				array(0,0,0,1,1,1,0,0,0),
1717				array(0,0,1,0,0,0,1,0,0),
1718				array(0,1,0,0,0,0,1,1,0),
1719				array(0,0,0,0,0,0,0,0,1),
1720				array(0,0,0,0,0,0,0,0,1),
1721				array(0,0,0,0,0,0,0,1,1),
1722				array(0,0,0,0,0,0,0,1,0),
1723				array(0,0,0,0,0,0,1,0,0),
1724				array(0,0,0,0,0,1,0,0,0),
1725				array(0,0,0,0,1,0,0,0,0),
1726				array(0,0,0,1,0,0,0,0,0),
1727				array(0,0,1,0,0,0,0,0,0),
1728				array(0,1,0,0,0,0,0,0,0),
1729				array(1,1,1,1,1,1,1,1,1),
1730				array(0,0,0,0,0,0,0,0,0),
1731			),
1732			'3' => array(
1733				array(0,0,1,1,1,1,1,0,0),
1734				array(0,1,0,0,0,0,0,1,0),
1735				array(1,0,0,0,0,0,0,0,1),
1736				array(0,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,1,0),
1740				array(0,0,0,0,0,1,1,0,0),
1741				array(0,0,0,0,0,0,0,1,0),
1742				array(0,0,0,0,0,0,0,0,1),
1743				array(0,0,0,0,0,0,0,0,1),
1744				array(0,0,0,0,0,0,0,0,1),
1745				array(1,0,0,0,0,0,0,0,1),
1746				array(0,1,0,0,0,0,0,1,0),
1747				array(0,0,1,1,1,1,1,0,0),
1748			),
1749			'4' => array(
1750				array(0,0,0,0,0,0,1,1,0),
1751				array(0,0,0,0,0,1,0,1,0),
1752				array(0,0,0,0,1,0,0,1,0),
1753				array(0,0,0,1,0,0,0,1,0),
1754				array(0,0,1,0,0,0,0,1,0),
1755				array(0,1,0,0,0,0,0,1,0),
1756				array(1,0,0,0,0,0,0,1,0),
1757				array(1,0,0,0,0,0,0,1,0),
1758				array(1,1,1,1,1,1,1,1,1),
1759				array(0,0,0,0,0,0,0,1,0),
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			),
1766			'5' => array(
1767				array(1,1,1,1,1,1,1,1,1),
1768				array(1,0,0,0,0,0,0,0,0),
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(0,1,0,0,0,0,0,0,0),
1773				array(0,0,1,1,1,1,1,0,0),
1774				array(0,0,0,0,0,0,0,1,0),
1775				array(0,0,0,0,0,0,0,0,1),
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(1,0,0,0,0,0,0,0,1),
1780				array(0,1,0,0,0,0,0,1,0),
1781				array(0,0,1,1,1,1,1,0,0),
1782			),
1783			'6' => array(
1784				array(0,0,1,1,1,1,1,0,0),
1785				array(0,1,0,0,0,0,0,1,0),
1786				array(1,0,0,0,0,0,0,0,1),
1787				array(1,0,0,0,0,0,0,0,1),
1788				array(1,0,0,0,0,0,0,0,0),
1789				array(1,0,0,0,0,0,0,0,0),
1790				array(1,0,0,1,1,1,1,0,0),
1791				array(1,0,1,0,0,0,0,1,0),
1792				array(1,1,0,0,0,0,0,0,1),
1793				array(1,0,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(0,1,0,0,0,0,0,1,0),
1798				array(0,0,1,1,1,1,1,0,0),
1799			),
1800			'7' => array(
1801				array(1,1,1,1,1,1,1,1,1),
1802				array(0,0,0,0,0,0,0,0,1),
1803				array(0,0,0,0,0,0,0,1,0),
1804				array(0,0,0,0,0,0,0,1,0),
1805				array(0,0,0,0,0,0,1,0,0),
1806				array(0,0,0,0,0,1,0,0,0),
1807				array(0,0,0,0,0,1,0,0,0),
1808				array(0,0,0,0,1,0,0,0,0),
1809				array(0,0,0,1,0,0,0,0,0),
1810				array(0,0,0,1,0,0,0,0,0),
1811				array(0,0,1,0,0,0,0,0,0),
1812				array(0,1,0,0,0,0,0,0,0),
1813				array(0,1,0,0,0,0,0,0,0),
1814				array(1,0,0,0,0,0,0,0,0),
1815				array(1,0,0,0,0,0,0,0,0),
1816			),
1817			'8' => array(
1818				array(0,0,1,1,1,1,1,0,0),
1819				array(0,1,0,0,0,0,0,1,0),
1820				array(1,0,0,0,0,0,0,0,1),
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(0,1,0,0,0,0,0,1,0),
1825				array(0,0,1,1,1,1,1,0,0),
1826				array(0,1,0,0,0,0,0,1,0),
1827				array(1,0,0,0,0,0,0,0,1),
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(0,1,0,0,0,0,0,1,0),
1832				array(0,0,1,1,1,1,1,0,0),
1833			),
1834			'9' => array(
1835				array(0,0,1,1,1,1,1,0,0),
1836				array(0,1,0,0,0,0,0,1,0),
1837				array(1,0,0,0,0,0,0,0,1),
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,1,1),
1842				array(0,1,0,0,0,0,1,0,1),
1843				array(0,0,1,1,1,1,0,0,1),
1844				array(0,0,0,0,0,0,0,0,1),
1845				array(0,0,0,0,0,0,0,0,1),
1846				array(1,0,0,0,0,0,0,0,1),
1847				array(1,0,0,0,0,0,0,0,1),
1848				array(0,1,0,0,0,0,0,1,0),
1849				array(0,0,1,1,1,1,1,0,0),
1850			),
1851			)
1852		);
1853	}
1854}
1855
1856/**
1857* @package VC
1858*/
1859class char_cube3d
1860{
1861	var $bitmap;
1862	var $bitmap_width;
1863	var $bitmap_height;
1864
1865	var $basis_matrix = array(array(1, 0, 0), array(0, 1, 0), array(0, 0, 1));
1866	var $abs_x = array(1, 0);
1867	var $abs_y = array(0, 1);
1868	var $x = 0;
1869	var $y = 1;
1870	var $z = 2;
1871	var $letter = '';
1872
1873	/**
1874	*/
1875	function char_cube3d(&$bitmaps, $letter)
1876	{
1877		$this->bitmap			= $bitmaps['data'][$letter];
1878		$this->bitmap_width		= $bitmaps['width'];
1879		$this->bitmap_height	= $bitmaps['height'];
1880
1881		$this->basis_matrix[0][0] = mt_rand(-600, 600);
1882		$this->basis_matrix[0][1] = mt_rand(-600, 600);
1883		$this->basis_matrix[0][2] = (mt_rand(0, 1) * 2000) - 1000;
1884		$this->basis_matrix[1][0] = mt_rand(-1000, 1000);
1885		$this->basis_matrix[1][1] = mt_rand(-1000, 1000);
1886		$this->basis_matrix[1][2] = mt_rand(-1000, 1000);
1887
1888		$this->normalize($this->basis_matrix[0]);
1889		$this->normalize($this->basis_matrix[1]);
1890		$this->basis_matrix[2] = $this->cross_product($this->basis_matrix[0], $this->basis_matrix[1]);
1891		$this->normalize($this->basis_matrix[2]);
1892
1893		// $this->basis_matrix[1] might not be (probably isn't) orthogonal to $basis_matrix[0]
1894		$this->basis_matrix[1] = $this->cross_product($this->basis_matrix[0], $this->basis_matrix[2]);
1895		$this->normalize($this->basis_matrix[1]);
1896
1897		// Make sure our cube is facing into the canvas (assuming +z == in)
1898		for ($i = 0; $i < 3; ++$i)
1899		{
1900			if ($this->basis_matrix[$i][2] < 0)
1901			{
1902				$this->basis_matrix[$i][0] *= -1;
1903				$this->basis_matrix[$i][1] *= -1;
1904				$this->basis_matrix[$i][2] *= -1;
1905			}
1906		}
1907
1908		// Force our "z" basis vector to be the one with greatest absolute z value
1909		$this->x = 0;
1910		$this->y = 1;
1911		$this->z = 2;
1912
1913		// Swap "y" with "z"
1914		if ($this->basis_matrix[1][2] > $this->basis_matrix[2][2])
1915		{
1916			$this->z = 1;
1917			$this->y = 2;
1918		}
1919
1920		// Swap "x" with "z"
1921		if ($this->basis_matrix[0][2] > $this->basis_matrix[$this->z][2])
1922		{
1923			$this->x = $this->z;
1924			$this->z = 0;
1925		}
1926
1927		// Still need to determine which of $x,$y are which.
1928		// wrong orientation if y's y-component is less than it's x-component
1929		// likewise if x's x-component is less than it's y-component
1930		// if they disagree, go with the one with the greater weight difference.
1931		// rotate if positive
1932		$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]));
1933
1934		// Swap "x" with "y"
1935		if ($weight > 0)
1936		{
1937			list($this->x, $this->y) = array($this->y, $this->x);
1938		}
1939
1940		$this->abs_x = array($this->basis_matrix[$this->x][0], $this->basis_matrix[$this->x][1]);
1941		$this->abs_y = array($this->basis_matrix[$this->y][0], $this->basis_matrix[$this->y][1]);
1942
1943		if ($this->abs_x[0] < 0)
1944		{
1945			$this->abs_x[0] *= -1;
1946			$this->abs_x[1] *= -1;
1947		}
1948
1949		if ($this->abs_y[1] > 0)
1950		{
1951			$this->abs_y[0] *= -1;
1952			$this->abs_y[1] *= -1;
1953		}
1954
1955		$this->letter = $letter;
1956	}
1957
1958	/**
1959	* Draw a character
1960	*/
1961	function drawchar($scale, $xoff, $yoff, $img, $background, $colours)
1962	{
1963		$width	= $this->bitmap_width;
1964		$height	= $this->bitmap_height;
1965		$bitmap	= $this->bitmap;
1966
1967		$colour1 = $colours[array_rand($colours)];
1968		$colour2 = $colours[array_rand($colours)];
1969
1970		$swapx = ($this->basis_matrix[$this->x][0] > 0);
1971		$swapy = ($this->basis_matrix[$this->y][1] < 0);
1972
1973		for ($y = 0; $y < $height; ++$y)
1974		{
1975			for ($x = 0; $x < $width; ++$x)
1976			{
1977				$xp = ($swapx) ? ($width - $x - 1) : $x;
1978				$yp = ($swapy) ? ($height - $y - 1) : $y;
1979
1980				if ($bitmap[$height - $yp - 1][$xp])
1981				{
1982					$dx = $this->scale($this->abs_x, ($xp - ($swapx ? ($width / 2) : ($width / 2) - 1)) * $scale);
1983					$dy = $this->scale($this->abs_y, ($yp - ($swapy ? ($height / 2) : ($height / 2) - 1)) * $scale);
1984					$xo = $xoff + $dx[0] + $dy[0];
1985					$yo = $yoff + $dx[1] + $dy[1];
1986
1987					$origin = array(0, 0, 0);
1988					$xvec = $this->scale($this->basis_matrix[$this->x], $scale);
1989					$yvec = $this->scale($this->basis_matrix[$this->y], $scale);
1990					$face_corner = $this->sum2($xvec, $yvec);
1991
1992					$zvec = $this->scale($this->basis_matrix[$this->z], $scale);
1993					$x_corner = $this->sum2($xvec, $zvec);
1994					$y_corner = $this->sum2($yvec, $zvec);
1995
1996					imagefilledpolygon($img, $this->gen_poly($xo, $yo, $origin, $xvec, $x_corner,$zvec), 4, $colour1);
1997					imagefilledpolygon($img, $this->gen_poly($xo, $yo, $origin, $yvec, $y_corner,$zvec), 4, $colour2);
1998
1999					$face = $this->gen_poly($xo, $yo, $origin, $xvec, $face_corner, $yvec);
2000
2001					imagefilledpolygon($img, $face, 4, $background);
2002					imagepolygon($img, $face, 4, $colour1);
2003				}
2004			}
2005		}
2006	}
2007
2008	/*
2009	* return a roughly acceptable range of sizes for rendering with this texttype
2010	*/
2011	function range()
2012	{
2013		return array(3, 4);
2014	}
2015
2016	/**
2017	* Vector length
2018	*/
2019	function vectorlen($vector)
2020	{
2021		return sqrt(pow($vector[0], 2) + pow($vector[1], 2) + pow($vector[2], 2));
2022	}
2023
2024	/**
2025	* Normalize
2026	*/
2027	function normalize(&$vector, $length = 1)
2028	{
2029		$length = (( $length < 1) ? 1 : $length);
2030		$length /= $this->vectorlen($vector);
2031		$vector[0] *= $length;
2032		$vector[1] *= $length;
2033		$vector[2] *= $length;
2034	}
2035
2036	/**
2037	*/
2038	function cross_product($vector1, $vector2)
2039	{
2040		$retval = array(0, 0, 0);
2041		$retval[0] =  (($vector1[1] * $vector2[2]) - ($vector1[2] * $vector2[1]));
2042		$retval[1] = -(($vector1[0] * $vector2[2]) - ($vector1[2] * $vector2[0]));
2043		$retval[2] =  (($vector1[0] * $vector2[1]) - ($vector1[1] * $vector2[0]));
2044
2045		return $retval;
2046	}
2047
2048	/**
2049	*/
2050	function sum($vector1, $vector2)
2051	{
2052		return array($vector1[0] + $vector2[0], $vector1[1] + $vector2[1], $vector1[2] + $vector2[2]);
2053	}
2054
2055	/**
2056	*/
2057	function sum2($vector1, $vector2)
2058	{
2059		return array($vector1[0] + $vector2[0], $vector1[1] + $vector2[1]);
2060	}
2061
2062	/**
2063	*/
2064	function scale($vector, $length)
2065	{
2066		if (sizeof($vector) == 2)
2067		{
2068			return array($vector[0] * $length, $vector[1] * $length);
2069		}
2070
2071		return array($vector[0] * $length, $vector[1] * $length, $vector[2] * $length);
2072	}
2073
2074	/**
2075	*/
2076	function gen_poly($xoff, $yoff, &$vec1, &$vec2, &$vec3, &$vec4)
2077	{
2078		$poly = array();
2079		$poly[0] = $xoff + $vec1[0];
2080		$poly[1] = $yoff + $vec1[1];
2081		$poly[2] = $xoff + $vec2[0];
2082		$poly[3] = $yoff + $vec2[1];
2083		$poly[4] = $xoff + $vec3[0];
2084		$poly[5] = $yoff + $vec3[1];
2085		$poly[6] = $xoff + $vec4[0];
2086		$poly[7] = $yoff + $vec4[1];
2087
2088		return $poly;
2089	}
2090
2091	/**
2092	* dimensions
2093	*/
2094	function dimensions($size)
2095	{
2096		$xn = $this->scale($this->basis_matrix[$this->x], -($this->bitmap_width / 2) * $size);
2097		$xp = $this->scale($this->basis_matrix[$this->x], ($this->bitmap_width / 2) * $size);
2098		$yn = $this->scale($this->basis_matrix[$this->y], -($this->bitmap_height / 2) * $size);
2099		$yp = $this->scale($this->basis_matrix[$this->y], ($this->bitmap_height / 2) * $size);
2100
2101		$p = array();
2102		$p[0] = $this->sum2($xn, $yn);
2103		$p[1] = $this->sum2($xp, $yn);
2104		$p[2] = $this->sum2($xp, $yp);
2105		$p[3] = $this->sum2($xn, $yp);
2106
2107		$min_x = $max_x = $p[0][0];
2108		$min_y = $max_y = $p[0][1];
2109
2110		for ($i = 1; $i < 4; ++$i)
2111		{
2112			$min_x = ($min_x > $p[$i][0]) ? $p[$i][0] : $min_x;
2113			$min_y = ($min_y > $p[$i][1]) ? $p[$i][1] : $min_y;
2114			$max_x = ($max_x < $p[$i][0]) ? $p[$i][0] : $max_x;
2115			$max_y = ($max_y < $p[$i][1]) ? $p[$i][1] : $max_y;
2116		}
2117
2118		return array($min_x, $min_y, $max_x, $max_y);
2119	}
2120}
2121
2122/**
2123* @package VC
2124*/
2125class colour_manager
2126{
2127	var $img;
2128	var $mode;
2129	var $colours;
2130	var $named_colours;
2131
2132	/**
2133	* Create the colour manager, link it to the image resource
2134	*/
2135	function colour_manager($img, $background = false, $mode = 'ahsv')
2136	{
2137		$this->img = $img;
2138		$this->mode = $mode;
2139		$this->colours = array();
2140		$this->named_colours = array();
2141
2142		if ($background !== false)
2143		{
2144			$bg = $this->allocate_named('background', $background);
2145			imagefill($this->img, 0, 0, $bg);
2146		}
2147	}
2148
2149	/**
2150	* Lookup a named colour resource
2151	*/
2152	function get_resource($named_colour)
2153	{
2154		if (isset($this->named_colours[$named_colour]))
2155		{
2156			return $this->named_colours[$named_colour];
2157		}
2158
2159		if (isset($this->named_rgb[$named_colour]))
2160		{
2161			return $this->allocate_named($named_colour, $this->named_rgb[$named_colour], 'rgb');
2162		}
2163
2164		return false;
2165	}
2166
2167	/**
2168	* Assign a name to a colour resource
2169	*/
2170	function name_colour($name, $resource)
2171	{
2172		$this->named_colours[$name] = $resource;
2173	}
2174
2175	/**
2176	* names and allocates a colour resource
2177	*/
2178	function allocate_named($name, $colour, $mode = false)
2179	{
2180		$resource = $this->allocate($colour, $mode);
2181
2182		if ($resource !== false)
2183		{
2184			$this->name_colour($name, $resource);
2185		}
2186		return $resource;
2187	}
2188
2189	/**
2190	* allocates a specified colour into the image
2191	*/
2192	function allocate($colour, $mode = false)
2193	{
2194		if ($mode === false)
2195		{
2196			$mode = $this->mode;
2197		}
2198		
2199		if (!is_array($colour))
2200		{
2201			if (isset($this->named_rgb[$colour]))
2202			{
2203				return $this->allocate_named($colour, $this->named_rgb[$colour], 'rgb');
2204			}
2205
2206			if (!is_int($colour))
2207			{
2208				return false;
2209			}
2210
2211			$mode = 'rgb';
2212			$colour = array(255 & ($colour >> 16), 255 & ($colour >>  8), 255 & $colour);
2213		}
2214
2215		if (isset($colour['mode']))
2216		{
2217			$mode = $colour['mode'];
2218			unset($colour['mode']);
2219		}
2220
2221		if (isset($colour['random']))
2222		{
2223			unset($colour['random']);
2224			// everything else is params
2225			return $this->random_colour($colour, $mode);
2226		}
2227
2228		$rgb		= colour_manager::model_convert($colour, $mode, 'rgb');
2229		$store		= ($this->mode == 'rgb') ? $rgb : colour_manager::model_convert($colour, $mode, $this->mode);
2230		$resource	= imagecolorallocate($this->img, $rgb[0], $rgb[1], $rgb[2]);
2231		$this->colours[$resource] = $store;
2232
2233		return $resource;
2234	}
2235
2236	/**
2237	* randomly generates a colour, with optional params
2238	*/
2239	function random_colour($params = array(), $mode = false)
2240	{
2241		if ($mode === false)
2242		{
2243			$mode = $this->mode;
2244		}
2245
2246		switch ($mode)
2247		{
2248			case 'rgb':
2249				// @TODO random rgb generation. do we intend to do this, or is it just too tedious?
2250			break;
2251
2252			case 'ahsv':
2253			case 'hsv':
2254			default:
2255
2256				$default_params = array(
2257					'hue_bias'			=> false,	// degree / 'r'/'g'/'b'/'c'/'m'/'y'   /'o'
2258					'hue_range'			=> false,	// if hue bias, then difference range +/- from bias
2259					'min_saturation'	=> 30,		// 0 - 100
2260					'max_saturation'	=> 80,		// 0 - 100
2261					'min_value'			=> 30,		// 0 - 100
2262					'max_value'			=> 80,		// 0 - 100
2263				);
2264
2265				$alt = ($mode == 'ahsv') ? true : false;
2266				$params = array_merge($default_params, $params);
2267
2268				$min_hue		= 0;
2269				$max_hue		= 359;
2270				$min_saturation	= max(0, $params['min_saturation']);
2271				$max_saturation	=