src/GameOfLife/Outputs/Helpers/ImageCreator.php
/**
     * Initializes and returns the image for living cells.
     *
     * Requires the class attribute $cellSize to be set
     *
     * @param ImageColor $_backgroundColor Color of the background
     * @param ImageColor $_cellAliveColor Color of living cells
     *
     * @return resource Cell image
     */
Initializes and returns the image for living cells.
Requires the class attribute $cellSize to be set

@param ImageColor $_backgroundColor Color of the background
@param ImageColor $_cellAliveColor Color of living cells

@return resource Cell image
Initializes and returns the image for living cells . Requires the class attribute $cellSize to be set @param ImageColor $_backgroundColor Color of the background @param ImageColor $_cellAliveColor Color of living cells @return resource Cell image
private function initializeCellImage(ImageColor $_backgroundColor, ImageColor $_cellAliveColor)
    {
        $transparentColorRed = 0;
        while ($transparentColorRed == $_backgroundColor->red() || $transparentColorRed == $_cellAliveColor->red())
        {
            $transparentColorRed++;
        }
        $transparentColor = new ImageColor($transparentColorRed, 0, 0);
        $cellImage = imagecreatetruecolor($this->cellSize, $this->cellSize);
        imagefill($cellImage, 0, 0, $transparentColor->getColor($cellImage));
        $headSize = $this->cellSize * 4/5;
        $padding = ($this->cellSize - $headSize) / 2;
        imagefilledellipse($cellImage, $this->cellSize / 2, $this->cellSize / 2, $headSize, $headSize, $_cellAliveColor->getColor($cellImage));
        imagefilledellipse($cellImage, $padding + $headSize * 1/4, $padding + $headSize / 4, $headSize / 4, $headSize / 4, $_backgroundColor->getColor($cellImage));
        imagefilledellipse($cellImage, $padding + $headSize * 3/4, $padding + $headSize / 4, $headSize / 4, $headSize / 4, $_backgroundColor->getColor($cellImage));
        imagesetthickness($cellImage, 5);
        imagearc($cellImage, $padding + $headSize / 2, $padding + $headSize / 2, $headSize * 3/4,$headSize * 3/4, 25, 155, $_backgroundColor->getColor($cellImage));
        imagecolortransparent($cellImage, $transparentColor->getColor($cellImage));
        return $cellImage;
    }
private function initializeCellImage ( ImageColor $ _backgroundColor , ImageColor $ _cellAliveColor ) { $ transparentColorRed = 0 ; while ( $ transparentColorRed == $ _backgroundColor -> red ( ) || $ transparentColorRed == $ _cellAliveColor -> red ( ) ) { $ transparentColorRed ++ ; } $ transparentColor = new ImageColor ( $ transparentColorRed , 0 , 0 ) ; $ cellImage = imagecreatetruecolor ( $ this -> cellSize , $ this -> cellSize ) ; imagefill ( $ cellImage , 0 , 0 , $ transparentColor -> getColor ( $ cellImage ) ) ; $ headSize = $ this -> cellSize * 4 / 5 ; $ padding = ( $ this -> cellSize - $ headSize ) / 2 ; imagefilledellipse ( $ cellImage , $ this -> cellSize / 2 , $ this -> cellSize / 2 , $ headSize , $ headSize , $ _cellAliveColor -> getColor ( $ cellImage ) ) ; imagefilledellipse ( $ cellImage , $ padding + $ headSize * 1 / 4 , $ padding + $ headSize / 4 , $ headSize / 4 , $ headSize / 4 , $ _backgroundColor -> getColor ( $ cellImage ) ) ; imagefilledellipse ( $ cellImage , $ padding + $ headSize * 3 / 4 , $ padding + $ headSize / 4 , $ headSize / 4 , $ headSize / 4 , $ _backgroundColor -> getColor ( $ cellImage ) ) ; imagesetthickness ( $ cellImage , 5 ) ; imagearc ( $ cellImage , $ padding + $ headSize / 2 , $ padding + $ headSize / 2 , $ headSize * 3 / 4 , $ headSize * 3 / 4 , 25 , 155 , $ _backgroundColor -> getColor ( $ cellImage ) ) ; imagecolortransparent ( $ cellImage , $ transparentColor -> getColor ( $ cellImage ) ) ; return $ cellImage ; }
Initializes and returns the image for living cells.
Initializes and returns the image for living cells .
// Generate a color that is unequal to the background as well as the cell color // The color is used to make the space around the smiley transparent // Create Smiley Image for living cells // Head // Eyes // Mouth