2017 © Pedro Peláez
 

library php-cca

Create two-dimensional Cyclic Cellular Automaton with PHP. Export results as (animated) images. Includes presets of working rules.

image

barryvanveen/php-cca

Create two-dimensional Cyclic Cellular Automaton with PHP. Export results as (animated) images. Includes presets of working rules.

  • Tuesday, July 17, 2018
  • by barryvanveen
  • Repository
  • 1 Watchers
  • 2 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 186 % Grown

The README.md

PHP Cyclic Cellular Automaton

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads], (*1)

This project can be used to run two-dimensional Cyclic Cellular Automaton (CCA). Results can be saved as static images of animated gifs. The configuration (of the CCA or images) can be set using various presets or customized to your own liking., (*2)

Install

Via Composer, (*3)

``` bash $ composer require barryvanveen/php-cca, (*4)


*Please note that you need PHP 7.0 or higher and the GD extension to install this package.* ## Usage ### Creating a configuration ``` php // using the ConfigBuilder $builder = Builders\ConfigBuilder::createFromPreset(Config\Presets::PRESET_CCA); $builder->rows(50); $builder->columns(50); $config = $builder->get(); // or build it from scratch $config = new Config([ Config\Options::NEIGHBORHOOD_SIZE => 1, Config\Options::NEIGHBORHOOD_TYPE => Config\NeighborhoodOptions::NEIGHBORHOOD_TYPE_NEUMANN, Config\Options::STATES => 14, Config\Options::THRESHOLD => 1, Config\Options::ROWS => 50, Config\Options::COLUMNS => 50, ]);

In \Barryvanveen\CCA\Config\Presets.php you can find all available presets., (*5)

Running the CCA

// get a single state
$runner = new Runner($config, Factories\CCAFactory::create($config));
$state = $runner->getLastState(234);

// get a set of states
$runner = new Runner($config, Factories\CCAFactory::create($config));
$states = $runner->getFirstStates(123);

// get a set of states that loops (if possible)
$runner = new Runner($config, Factories\CCAFactory::create($config));
$states = $runner->getFirstLoop(500);  

The Runner is probably sufficient for most scenarios but if you want more control you can control the CCA yourself. Just look at the Runner implementation to get an idea of how this works., (*6)

Generating images

// create a static Gif from a single stae
$image = Generators\Gif::createFromState($config, $state);
$image->save('/path/to/output.gif');

// create a static Png from a single state
$image = Generators\Png::createFromState($config, $state);
$image->save('/path/to/output.png');

// create an animated Gif
$image = Generators\AnimatedGif::createFromStates($config, $states);
$image->save('/path/to/output.gif');

Examples

The /examples folder contains some scripts to generate different kinds of images. Here are some example images:, (*7)

static gif from amoeba preset static gif from cca preset static gif from lavalamp preset static gif from cyclic spirals preset, (*8)

animated gif from squarish spirals preset animated looping gif from cyclic spirals preset animated looping gif from cca preset animated looping gif from 313 preset, (*9)

Changelog

Please see the releases for more information on what has changed recently., (*10)

Testing

bash $ composer test, (*11)

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details., (*12)

Security

If you discover any security related issues, please email barryvanveen@gmail.com instead of using the issue tracker., (*13)

Acknowledgments

All preset configurations are taken from http://psoup.math.wisc.edu/mcell/rullex_cycl.html which is the work of Mirek Wójtowicz., (*14)

The colors for the images are generated using talesoft/phim which is a project by Torben Köhn., (*15)

Animated gifs are created using lunakid/anim-gif., (*16)

Credits

License

The MIT License (MIT). Please see License File for more information., (*17)

The Versions

17/07 2018

dev-develop

dev-develop https://github.com/barryvanveen/php-cca

Create two-dimensional Cyclic Cellular Automaton with PHP. Export results as (animated) images. Includes presets of working rules.

  Sources   Download

MIT

The Requires

 

The Development Requires

gif barryvanveen png automata automaton animated cellular cyclic php-cca

17/07 2018

dev-master

9999999-dev https://github.com/barryvanveen/php-cca

Create two-dimensional Cyclic Cellular Automaton with PHP. Export results as (animated) images. Includes presets of working rules.

  Sources   Download

MIT

The Requires

 

The Development Requires

gif barryvanveen png automata automaton animated cellular cyclic php-cca

17/07 2018

2.0.1

2.0.1.0 https://github.com/barryvanveen/php-cca

Create two-dimensional Cyclic Cellular Automaton with PHP. Export results as (animated) images. Includes presets of working rules.

  Sources   Download

MIT

The Requires

 

The Development Requires

gif barryvanveen png automata automaton animated cellular cyclic php-cca

17/07 2018

dev-feature-fix-scrutinizer-score

dev-feature-fix-scrutinizer-score https://github.com/barryvanveen/php-cca

Create two-dimensional Cyclic Cellular Automaton with PHP. Export results as (animated) images. Includes presets of working rules.

  Sources   Download

MIT

The Requires

 

The Development Requires

gif barryvanveen png automata automaton animated cellular cyclic php-cca

17/07 2018

2.0.0

2.0.0.0 https://github.com/barryvanveen/php-cca

Create two-dimensional Cyclic Cellular Automaton with PHP. Export results as (animated) images. Includes presets of working rules.

  Sources   Download

MIT

The Requires

 

The Development Requires

gif barryvanveen png automata automaton animated cellular cyclic php-cca

25/05 2018

dev-feature-config-builder

dev-feature-config-builder https://github.com/barryvanveen/php-cca

Create two-dimensional Cyclic Cellular Automaton with PHP. Export results as (animated) images. Includes presets of working rules.

  Sources   Download

MIT

The Requires

 

The Development Requires

gif barryvanveen png automata automaton animated cellular cyclic php-cca

31/03 2018

1.0.1

1.0.1.0 https://github.com/barryvanveen/php-cca

Create two-dimensional Cyclic Cellular Automaton with PHP. Export results as (animated) images. Includes presets of working rules.

  Sources   Download

MIT

The Requires

 

The Development Requires

gif barryvanveen png automata automaton animated cellular cyclic php-cca

17/02 2018

1.0

1.0.0.0 https://github.com/barryvanveen/php-cca

Create two-dimensional Cyclic Cellular Automaton with PHP. Export results as (animated) images. Includes presets of working rules.

  Sources   Download

MIT

The Requires

 

The Development Requires

gif barryvanveen png automata automaton animated cellular cyclic php-cca