PHPackages                             barryvanveen/php-cca - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. barryvanveen/php-cca

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

barryvanveen/php-cca
====================

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

2.0.1(7y ago)998MITPHPPHP ~7.0

Since Feb 17Pushed 7y ago1 watchersCompare

[ Source](https://github.com/barryvanveen/php-cca)[ Packagist](https://packagist.org/packages/barryvanveen/php-cca)[ Docs](https://github.com/barryvanveen/php-cca)[ RSS](/packages/barryvanveen-php-cca/feed)WikiDiscussions develop Synced yesterday

READMEChangelog (4)Dependencies (5)Versions (6)Used By (0)

PHP Cyclic Cellular Automaton
=============================

[](#php-cyclic-cellular-automaton)

[![Latest Version on Packagist](https://camo.githubusercontent.com/479500c1ed09a80241bfd639ce1fd99390c45bae57132af9de77bf080382c17a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626172727976616e7665656e2f7068702d6363612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/barryvanveen/php-cca)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/466771b7d91399216b85f9ab6b703f77b213a3796075b4400f023f4b8d8fd65a/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f626172727976616e7665656e2f7068702d6363612f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/barryvanveen/php-cca)[![Coverage Status](https://camo.githubusercontent.com/6d313eab1d0598c7e6741c851999e3c679e1f64d4bf3616269625895af4e7ee0/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f626172727976616e7665656e2f7068702d6363612e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/barryvanveen/php-cca/code-structure)[![Quality Score](https://camo.githubusercontent.com/770dc9f1124f4d092ef06777287f8950d588ceeb20fdeb68ef236fbe690cc019/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f626172727976616e7665656e2f7068702d6363612e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/barryvanveen/php-cca)[![Total Downloads](https://camo.githubusercontent.com/4f30de116b6e89172c768c7b52addd7807f1bacc45cac9f2417166e6ddbfa330/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626172727976616e7665656e2f7068702d6363612e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/barryvanveen/php-cca)

This project can be used to run two-dimensional [Cyclic Cellular Automaton](https://en.wikipedia.org/wiki/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.

Install
-------

[](#install)

Via Composer

```
$ composer require barryvanveen/php-cca
```

*Please note that you need PHP 7.0 or higher and the GD extension to install this package.*

Usage
-----

[](#usage)

### Creating a configuration

[](#creating-a-configuration)

```
// 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.

### Running the CCA

[](#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.

### Generating images

[](#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
--------

[](#examples)

The `/examples` folder contains some scripts to generate different kinds of images. Here are some example images:

[![static gif from amoeba preset](examples/output/green-amoeba.gif?raw=true "Amoeba preset")](examples/output/green-amoeba.gif?raw=true)[![static gif from cca preset](examples/output/purple-cca.gif?raw=true "CCA preset")](examples/output/purple-cca.gif?raw=true)[![static gif from lavalamp preset](examples/output/blue-lavalamp.gif?raw=true "Lavalamp preset")](examples/output/blue-lavalamp.gif?raw=true)[![static gif from cyclic spirals preset](examples/output/green-cyclic-spirals.gif?raw=true "Cyclic spirals preset")](examples/output/green-cyclic-spirals.gif?raw=true)

[![animated gif from squarish spirals preset](/examples/output/red-looping-squarish-spirals.gif?raw=true "Looping squarish spirals preset")](/examples/output/red-looping-squarish-spirals.gif?raw=true)[![animated looping gif from cyclic spirals preset](/examples/output/yellow-looping-cyclic-spirals.gif?raw=true "Looping cyclic spirals preset")](/examples/output/yellow-looping-cyclic-spirals.gif?raw=true)[![animated looping gif from cca preset](/examples/output/blue-looping-cca.gif?raw=true "Looping CCA preset")](/examples/output/blue-looping-cca.gif?raw=true)[![animated looping gif from 313 preset](/examples/output/pink-looping-313.gif?raw=true "Looping 313 preset")](/examples/output/pink-looping-313.gif?raw=true)

Changelog
---------

[](#changelog)

Please see the [releases](releases) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Acknowledgments
---------------

[](#acknowledgments)

All preset configurations are taken from [http://psoup.math.wisc.edu/mcell/rullex\_cycl.html](http://psoup.math.wisc.edu/mcell/rullex_cycl.html) which is the work of Mirek Wójtowicz.

The colors for the images are generated using [talesoft/phim](https://github.com/Talesoft/phim) which is a project by Torben Köhn.

Animated gifs are created using [lunakid/anim-gif](https://github.com/lunakid/AnimGif).

Credits
-------

[](#credits)

- [Barry van Veen](https://github.com/barryvanveen)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 94% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~50 days

Total

4

Last Release

2904d ago

Major Versions

1.0.1 → 2.0.02018-07-17

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8548677?v=4)[Barry van Veen](/maintainers/barryvanveen)[@barryvanveen](https://github.com/barryvanveen)

---

Top Contributors

[![barryvanveen](https://avatars.githubusercontent.com/u/8548677?v=4)](https://github.com/barryvanveen "barryvanveen (78 commits)")[![barryatswisnl](https://avatars.githubusercontent.com/u/18284224?v=4)](https://github.com/barryatswisnl "barryatswisnl (5 commits)")

---

Tags

animated-gifcellular-automatacellular-automatoncyclic-cellular-automatacyclic-cellular-automationimage-generationphp7gifpnganimatedautomataautomatoncellularcyclicBarryvanveenphp-cca

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/barryvanveen-php-cca/health.svg)

```
[![Health](https://phpackages.com/badges/barryvanveen-php-cca/health.svg)](https://phpackages.com/packages/barryvanveen-php-cca)
```

###  Alternatives

[sybio/gif-frame-extractor

PHP class that separates all the frames (and their duration) of an animated GIF

179431.1k9](/packages/sybio-gif-frame-extractor)[flesler/jquery.scrollto

Lightweight, cross-browser and highly customizable animated scrolling with jQuery

3.7k40.5k](/packages/flesler-jqueryscrollto)[legacy-icons/famfamfam-flags

FamFamFam Flags icon pack, as individual icons or as a CSS spritesheet

6819.3k1](/packages/legacy-icons-famfamfam-flags)[image-charts/image-charts

Official Image-Charts.com API client library

2866.4k](/packages/image-charts-image-charts)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
