barryvanveen/php-cca
Composer 安装命令:
composer require barryvanveen/php-cca
包简介
Create two-dimensional Cyclic Cellular Automaton with PHP. Export results as (animated) images. Includes presets of working rules.
README 文档
README
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.
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
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
// 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
// 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:
Changelog
Please see the releases for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email barryvanveen@gmail.com instead of using the issue tracker.
Acknowledgments
All preset configurations are taken from 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 which is a project by Torben Köhn.
Animated gifs are created using lunakid/anim-gif.
Credits
License
The MIT License (MIT). Please see License File for more information.
barryvanveen/php-cca 适用场景与选型建议
barryvanveen/php-cca 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 98 次下载、GitHub Stars 达 8, 最近一次更新时间为 2018 年 02 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「png」 「automata」 「gif」 「animated」 「automaton」 「cellular」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 barryvanveen/php-cca 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 barryvanveen/php-cca 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 barryvanveen/php-cca 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Cli Image - This library converts a given image to ASCII string.
Image optimization widget for Yii2 Framework with auto WebP/AVIF image format generation from PNG/JPG files.
FormalTheory is a library that allows for manipulation and conversion of NFAs, DFAs and Regular Expressions.
Generates QR Codes
State machines for Eloquent models with Enums
Convert and serve jpeg/png to webp with PHP (if at all possible)
统计信息
- 总下载量: 98
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-17







