src/GameOfLife/Outputs/GifOutput.php
/**
     * Creates an animated Gif from the gif files that were created by outputBoard().
     *
     * @param String $_simulationEndReason The reason why the simulation ended
     *
     * @throws \Exception The exception when the frames folder is empty or the gif file could not be written
     */
Creates an animated Gif from the gif files that were created by outputBoard().
@param String $_simulationEndReason The reason why the simulation ended

@throws \Exception The exception when the frames folder is empty or the gif file could not be written
Creates an animated Gif from the gif files that were created by outputBoard () . @param String $_simulationEndReason The reason why the simulation ended @throws \ Exception The exception when the frames folder is empty or the gif file could not be written
public function finishOutput(String $_simulationEndReason)
    {
        parent::finishOutput($_simulationEndReason);
        unset($this->imageCreator);
        echo "\nStarting GIF creation. One moment please...";
        if (count($this->frames) == 0) throw new \Exception("No frames in frames folder found.");
        $frameDurations = array();
        for ($i = 0; $i < count($this->frames) - 1; $i++)
        {
            $frameDurations[] = $this->frameTime;
        }
        $frameDurations[] = $this->frameTime + 200;
        $gifCreator = new GifCreator();
        $gifCreator->create($this->frames, $frameDurations, 0);
        $fileName = "Game_" . $this->getNewGameId("Gif") . ".gif";
        $this->fileSystemWriter->writeFile($this->baseOutputDirectory . "/Gif/" . $fileName, $gifCreator->getGif());
        $this->fileSystemWriter->deleteDirectory($this->baseOutputDirectory . "/tmp", true);
        echo "\nGIF creation complete.\n\n";
        unset ($this->fileSystemHandler);
    }
public function finishOutput ( String $ _simulationEndReason ) { parent :: finishOutput ( $ _simulationEndReason ) ; unset ( $ this -> imageCreator ) ; echo " \n Starting GIF creation. One moment please... " ; if ( count ( $ this -> frames ) == 0 ) throw new \ Exception ( " No frames in frames folder found. " ) ; $ frameDurations = array ( ) ; for ( $ i = 0 ; $ i < count ( $ this -> frames ) - 1 ; $ i ++ ) { $ frameDurations [ ] = $ this -> frameTime ; } $ frameDurations [ ] = $ this -> frameTime + 200 ; $ gifCreator = new GifCreator ( ) ; $ gifCreator -> create ( $ this -> frames , $ frameDurations , 0 ) ; $ fileName = " Game_ " . $ this -> getNewGameId ( " Gif " ) . " .gif " ; $ this -> fileSystemWriter -> writeFile ( $ this -> baseOutputDirectory . " /Gif/ " . $ fileName , $ gifCreator -> getGif ( ) ) ; $ this -> fileSystemWriter -> deleteDirectory ( $ this -> baseOutputDirectory . " /tmp " , true ) ; echo " \n GIF creation complete. \n \n " ; unset ( $ this -> fileSystemHandler ) ; }
Creates an animated Gif from the gif files that were created by outputBoard().
Creates an animated Gif from the gif files that were created by outputBoard () .