src/GameOfLife/Outputs/Helpers/ImageCreator.php
/**
     * Creates and returns an image of the current board.
     *
     * @param Board $_board The current board
     *
     * @return resource The image
     */
Creates and returns an image of the current board.
@param Board $_board The current board

@return resource The image
Creates and returns an image of the current board . @param Board $_board The current board @return resource The image
public function createImage (Board $_board)
    {
        $image = imagecreate(imagesx($this->baseImage), imagesy($this->baseImage));
        imagecopy($image, $this->baseImage, 0,0,0,0,imagesx($this->baseImage), imagesy($this->baseImage));
        foreach ($_board->fields() as $y=> $row)
        {
            foreach ($row as $x=>$field)
            {
                if ($field instanceof Field)
                {
                    if ($field->isAlive())
                    {
                        imagecopymerge($image, $this->cellImage, $x * $this->cellSize, $y * $this->cellSize, 0, 0, $this->cellSize, $this->cellSize, 100);
                    }
                }
            }
        }
        return $image;
    }
public function createImage ( Board $ _board ) { $ image = imagecreate ( imagesx ( $ this -> baseImage ) , imagesy ( $ this -> baseImage ) ) ; imagecopy ( $ image , $ this -> baseImage , 0 , 0 , 0 , 0 , imagesx ( $ this -> baseImage ) , imagesy ( $ this -> baseImage ) ) ; foreach ( $ _board -> fields ( ) as $ y => $ row ) { foreach ( $ row as $ x => $ field ) { if ( $ field instanceof Field ) { if ( $ field -> isAlive ( ) ) { imagecopymerge ( $ image , $ this -> cellImage , $ x * $ this -> cellSize , $ y * $ this -> cellSize , 0 , 0 , $ this -> cellSize , $ this -> cellSize , 100 ) ; } } } } return $ image ; }
Creates and returns an image of the current board.
Creates and returns an image of the current board .
// Draw the cells