isaeken / blockies
php clone of https://github.com/ethereum/blockies
1.0
2021-06-06 19:48 UTC
Requires
- php: ^8.0
- illuminate/support: ^8.45
- intervention/image: ^2.5
- spatie/color: ^1.2
- spatie/regex: ^2.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- symfony/var-dumper: ^5.3
This package is auto-updated.
Last update: 2025-02-26 21:18:41 UTC
README
The php alternative for download13/blockies js package.
$blockies = new \IsaEken\Blockies\Blockies; $blockies->draw(); echo $blockies->svg(); // <svg... $blockies->image()->save('image.jpg'); // save generated image echo $blockies->image()->encode('data-url')->encoded; // data:image/png;base64...
Installation
You can install with using composer.
composer require isaeken/blockies
Usage
Create the instance first.
$blockies = new \IsaEken\Blockies\Blockies([ 'seed' => '130ef2f0a8b713', 'size' => 64, 'background' => \Spatie\Color\Hex::fromString('#ff0000')->toHsl(), ]); // or $blockies = new \IsaEken\Blockies\Blockies;
draw them.
$blockies->draw();
You can use this as SVG.
file_put_contents('image.svg', $blockies->svg());
or use this with Intervention\Image
$blockies->image()->greyscale()->save('black_and_white.jpg');
recreate your seed
$blockies->refresh(); $blockies->image(); // this is a new image.
resize and change background
$blockies ->setSize(120) ->setBackground(\Spatie\Color\Hex::fromString('#00ff00')->toHsl()) ->draw() ->image();
change seed
$blockies->setSeed('130ef2f0a8b713')->draw()->image();
get values
$blockies->getSeed(); // string $blockies->getBackground(); // \Spatie\Color\Hsl $blockies->getSize(); // int
Testing
composer test
License
The MIT License (MIT). Please see License File for more information.