src/GameOfLife/Outputs/ImageOutput.php
/**
     * Initializes the image creator.
     *
     * @param Getopt $_options User inputted option list
     * @param Board $_board Initial board
     *
     * @throws \Exception The exception when one of the input colors is invalid
     */
Initializes the image creator.
@param Getopt $_options User inputted option list
@param Board $_board Initial board

@throws \Exception The exception when one of the input colors is invalid
Initializes the image creator . @param Getopt $_options User inputted option list @param Board $_board Initial board @throws \ Exception The exception when one of the input colors is invalid
public function startOutput(Getopt $_options, Board $_board)
    {
        parent::startOutput($_options, $_board);
        try
        {
            $this->fileSystemWriter->createDirectory($this->imageOutputDirectory);
        }
        catch (\Exception $_exception)
        {
        }
        $colorSelector = new ColorSelector();
        $cellSize = $_options->getOption($this->optionPrefix . "OutputSize");
        if ($cellSize !== null) $cellSize = (int)$cellSize;
        else $cellSize = 100;
        $cellColorString = $_options->getOption($this->optionPrefix . "OutputCellColor");
        if ($cellColorString === null) $cellColorString = "black";
        $cellColor = $colorSelector->getColor($cellColorString);
        $backgroundColorString = $_options->getoption($this->optionPrefix . "OutputBackgroundColor");
        if ($backgroundColorString === null) $backgroundColorString = "white";
        $backgroundColor = $colorSelector->getColor($backgroundColorString);
        $gridColorString = $_options->getoption($this->optionPrefix . "OutputGridColor");
        if ($gridColorString === null) $gridColorString = "black";
        $gridColor = $colorSelector->getColor($gridColorString);
        $this->imageCreator = new ImageCreator($_board->height(), $_board->width(), $cellSize, $cellColor, $backgroundColor, $gridColor);
    }
public function startOutput ( Getopt $ _options , Board $ _board ) { parent :: startOutput ( $ _options , $ _board ) ; try { $ this -> fileSystemWriter -> createDirectory ( $ this -> imageOutputDirectory ) ; } catch ( \ Exception $ _exception ) { } $ colorSelector = new ColorSelector ( ) ; $ cellSize = $ _options -> getOption ( $ this -> optionPrefix . " OutputSize " ) ; if ( $ cellSize !== null ) $ cellSize = ( int ) $ cellSize ; else $ cellSize = 100 ; $ cellColorString = $ _options -> getOption ( $ this -> optionPrefix . " OutputCellColor " ) ; if ( $ cellColorString === null ) $ cellColorString = " black " ; $ cellColor = $ colorSelector -> getColor ( $ cellColorString ) ; $ backgroundColorString = $ _options -> getoption ( $ this -> optionPrefix . " OutputBackgroundColor " ) ; if ( $ backgroundColorString === null ) $ backgroundColorString = " white " ; $ backgroundColor = $ colorSelector -> getColor ( $ backgroundColorString ) ; $ gridColorString = $ _options -> getoption ( $ this -> optionPrefix . " OutputGridColor " ) ; if ( $ gridColorString === null ) $ gridColorString = " black " ; $ gridColor = $ colorSelector -> getColor ( $ gridColorString ) ; $ this -> imageCreator = new ImageCreator ( $ _board -> height ( ) , $ _board -> width ( ) , $ cellSize , $ cellColor , $ backgroundColor , $ gridColor ) ; }
Initializes the image creator.
Initializes the image creator .
// Ignore the exception // fetch options // initialize the ImageCreator