src/GameOfLife/Outputs/Helpers/ImageCreator.php
/**
     * Initializes and returns the background image of each image (an empty grid).
     *
     * Requires the class attribute $cellSize to be set
     *
     * @param int $_width Board width
     * @param int $_height Board height
     * @param ImageColor $_backgroundColor Color of the background
     * @param ImageColor $_gridColor Color of the grid
     *
     * @return resource Base Image
     */
Initializes and returns the background image of each image (an empty grid).
Requires the class attribute $cellSize to be set

@param int $_width Board width
@param int $_height Board height
@param ImageColor $_backgroundColor Color of the background
@param ImageColor $_gridColor Color of the grid

@return resource Base Image
Initializes and returns the background image of each image ( an empty grid ) . Requires the class attribute $cellSize to be set @param int $_width Board width @param int $_height Board height @param ImageColor $_backgroundColor Color of the background @param ImageColor $_gridColor Color of the grid @return resource Base Image
private function initializeBaseImage(int $_width, int $_height, ImageColor $_backgroundColor, ImageColor $_gridColor)
    {
        $baseImage = imagecreate($_width * $this->cellSize, $_height * $this->cellSize);
        imagefill($baseImage, 0, 0, $_backgroundColor->getColor($baseImage));
        imagesetthickness($baseImage, 1);
        for ($x = 0; $x < $_width * $this->cellSize; $x += $this->cellSize)
        {
            imageline($baseImage, $x, 0, $x, imagesy($baseImage), $_gridColor->getColor($baseImage));
        }
        for ($y = 0; $y < $_height * $this->cellSize; $y += $this->cellSize)
        {
            imageline($baseImage, 0, $y, imagesx($baseImage), $y, $_gridColor->getColor($baseImage));
        }
        imagesetthickness($baseImage, 1);
        return $baseImage;
    }
private function initializeBaseImage ( int $ _width , int $ _height , ImageColor $ _backgroundColor , ImageColor $ _gridColor ) { $ baseImage = imagecreate ( $ _width * $ this -> cellSize , $ _height * $ this -> cellSize ) ; imagefill ( $ baseImage , 0 , 0 , $ _backgroundColor -> getColor ( $ baseImage ) ) ; imagesetthickness ( $ baseImage , 1 ) ; for ( $ x = 0 ; $ x < $ _width * $ this -> cellSize ; $ x += $ this -> cellSize ) { imageline ( $ baseImage , $ x , 0 , $ x , imagesy ( $ baseImage ) , $ _gridColor -> getColor ( $ baseImage ) ) ; } for ( $ y = 0 ; $ y < $ _height * $ this -> cellSize ; $ y += $ this -> cellSize ) { imageline ( $ baseImage , 0 , $ y , imagesx ( $ baseImage ) , $ y , $ _gridColor -> getColor ( $ baseImage ) ) ; } imagesetthickness ( $ baseImage , 1 ) ; return $ baseImage ; }
Initializes and returns the background image of each image (an empty grid).
Initializes and returns the background image of each image ( an empty grid ) .
// draw grid // Vertical lines // Horizontal lines