CellBackgroundDrawer.class.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  *   Copyright (C) 2004-2007 by Dmitry E. Demidov                          *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation; either version 3 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  ***************************************************************************/
00011 
00015     final class CellBackgroundDrawer extends BackgroundDrawer
00016     {
00017         private $step = null;
00018     
00019         public function __construct($step)
00020         {
00021             $this->step = $step;
00022         }
00023         
00027         public function draw()
00028         {
00029             $x = mt_rand(-$this->step, $this->step);
00030             $width = $this->getTuringImage()->getWidth();
00031             
00032             while ($x < $width) {
00033                 $color = $this->makeColor();
00034                 $colorId = $this->getTuringImage()->getColorIdentifier($color);
00035 
00036                 imageline(
00037                     $this->getTuringImage()->getImageId(),
00038                     $x,
00039                     0,
00040                     $x,
00041                     $this->getTuringImage()->getHeight(),
00042                     $colorId
00043                 );
00044                 
00045                 $x += $this->step;
00046             }
00047     
00048             $y = mt_rand(-$this->step, $this->step);
00049             $height = $this->getTuringImage()->getHeight();
00050             
00051             while ($y < $height) {
00052                 $color = $this->makeColor();
00053                 $colorId = $this->getTuringImage()->getColorIdentifier($color);
00054 
00055                 imageline(
00056                     $this->getTuringImage()->getImageId(),
00057                     0,
00058                     $y,
00059                     $this->getTuringImage()->getWidth(),
00060                     $y,
00061                     $colorId
00062                 );
00063                 
00064                 $y += $this->step;
00065             }
00066             
00067             return $this;
00068         }
00069     }
00070 ?>