{"id":17161149,"url":"https://github.com/barryvanveen/php-cca","last_synced_at":"2025-04-13T14:11:31.259Z","repository":{"id":62491862,"uuid":"103643375","full_name":"barryvanveen/php-cca","owner":"barryvanveen","description":"Create two-dimensional Cyclic Cellular Automaton. Export results as (animated) images. Includes presets of working rules.","archived":false,"fork":false,"pushed_at":"2018-07-17T20:41:31.000Z","size":265,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-03-27T05:12:33.899Z","etag":null,"topics":["animated-gif","cellular-automata","cellular-automaton","cyclic-cellular-automata","cyclic-cellular-automation","image-generation","php7"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/barryvanveen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-15T10:06:19.000Z","updated_at":"2022-02-12T08:06:08.000Z","dependencies_parsed_at":"2022-11-02T11:30:32.512Z","dependency_job_id":null,"html_url":"https://github.com/barryvanveen/php-cca","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barryvanveen%2Fphp-cca","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barryvanveen%2Fphp-cca/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barryvanveen%2Fphp-cca/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barryvanveen%2Fphp-cca/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/barryvanveen","download_url":"https://codeload.github.com/barryvanveen/php-cca/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248724629,"owners_count":21151561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["animated-gif","cellular-automata","cellular-automaton","cyclic-cellular-automata","cyclic-cellular-automation","image-generation","php7"],"created_at":"2024-10-14T22:27:19.585Z","updated_at":"2025-04-13T14:11:31.224Z","avatar_url":"https://github.com/barryvanveen.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Cyclic Cellular Automaton\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![Total Downloads][ico-downloads]][link-downloads]\n\n\nThis 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. \n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require barryvanveen/php-cca\n```\n\n*Please note that you need PHP 7.0 or higher and the GD extension to install this package.*\n\n## Usage\n\n### Creating a configuration\n\n``` php\n// using the ConfigBuilder\n$builder = Builders\\ConfigBuilder::createFromPreset(Config\\Presets::PRESET_CCA);\n$builder-\u003erows(50);\n$builder-\u003ecolumns(50);\n$config = $builder-\u003eget();\n \n// or build it from scratch\n$config = new Config([\n    Config\\Options::NEIGHBORHOOD_SIZE =\u003e 1,\n    Config\\Options::NEIGHBORHOOD_TYPE =\u003e Config\\NeighborhoodOptions::NEIGHBORHOOD_TYPE_NEUMANN,\n    Config\\Options::STATES =\u003e 14,\n    Config\\Options::THRESHOLD =\u003e 1,\n    Config\\Options::ROWS =\u003e 50,\n    Config\\Options::COLUMNS =\u003e 50,\n]);\n```\n\nIn `\\Barryvanveen\\CCA\\Config\\Presets.php` you can find all available presets.\n\n### Running the CCA \n\n```php\n// get a single state\n$runner = new Runner($config, Factories\\CCAFactory::create($config));\n$state = $runner-\u003egetLastState(234);\n \n// get a set of states\n$runner = new Runner($config, Factories\\CCAFactory::create($config));\n$states = $runner-\u003egetFirstStates(123);\n \n// get a set of states that loops (if possible)\n$runner = new Runner($config, Factories\\CCAFactory::create($config));\n$states = $runner-\u003egetFirstLoop(500);  \n```\n\nThe 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.\n\n### Generating images\n\n```php\n// create a static Gif from a single stae\n$image = Generators\\Gif::createFromState($config, $state);\n$image-\u003esave('/path/to/output.gif');\n \n// create a static Png from a single state\n$image = Generators\\Png::createFromState($config, $state);\n$image-\u003esave('/path/to/output.png');\n \n// create an animated Gif\n$image = Generators\\AnimatedGif::createFromStates($config, $states);\n$image-\u003esave('/path/to/output.gif');\n```\n\n## Examples\n\nThe `/examples` folder contains some scripts to generate different kinds of images. Here are some example images:\n\n![static gif from amoeba preset](examples/output/green-amoeba.gif?raw=true \"Amoeba preset\")\n![static gif from cca preset](examples/output/purple-cca.gif?raw=true \"CCA preset\")\n![static gif from lavalamp preset](examples/output/blue-lavalamp.gif?raw=true \"Lavalamp preset\")\n![static gif from cyclic spirals preset](examples/output/green-cyclic-spirals.gif?raw=true \"Cyclic spirals preset\")\n\n![animated gif from squarish spirals preset](/examples/output/red-looping-squarish-spirals.gif?raw=true \"Looping squarish spirals preset\")\n![animated looping gif from cyclic spirals preset](/examples/output/yellow-looping-cyclic-spirals.gif?raw=true \"Looping cyclic spirals preset\")\n![animated looping gif from cca preset](/examples/output/blue-looping-cca.gif?raw=true \"Looping CCA preset\")\n![animated looping gif from 313 preset](/examples/output/pink-looping-313.gif?raw=true \"Looping 313 preset\")\n\n## Changelog\n\nPlease see the [releases](releases) for more information on what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email barryvanveen@gmail.com instead of using the issue tracker.\n\n## Acknowledgments\n\nAll 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.\n\nThe colors for the images are generated using [talesoft/phim](https://github.com/Talesoft/phim) which is a project by Torben Köhn.\n\nAnimated gifs are created using [lunakid/anim-gif](https://github.com/lunakid/AnimGif).\n\n## Credits\n\n- [Barry van Veen][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/barryvanveen/php-cca.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/barryvanveen/php-cca/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/barryvanveen/php-cca.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/barryvanveen/php-cca.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/barryvanveen/php-cca.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/barryvanveen/php-cca\n[link-travis]: https://travis-ci.org/barryvanveen/php-cca\n[link-scrutinizer]: https://scrutinizer-ci.com/g/barryvanveen/php-cca/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/barryvanveen/php-cca\n[link-downloads]: https://packagist.org/packages/barryvanveen/php-cca\n[link-author]: https://github.com/barryvanveen\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarryvanveen%2Fphp-cca","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarryvanveen%2Fphp-cca","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarryvanveen%2Fphp-cca/lists"}