1. Go to this page and download the library: Download hedronium/avity library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hedronium / avity example snippets
use Hedronium\Avity\Avity;
$avity = Avity::init()->generate()->jpg()->toBrowser();
$avity = Avity::init();
$avity->height(600)->width(500); // Long Vertical Identicon. WOW!
$avity->generate()->jpg()->toBrowser();
use Hedronium\Avity\Generator;
/**
* A Generator that uses php's `rand()` function.
*/
class YourRandGenerator extends Generator
{
public function next($x, $y)
{
// You could use the $x & $y values to
// return something specific but usually it souldn't matter.
return rand();
}
}
$avity = Avity::init([
'generator' => function () {
return new YourRandGenerator('Please be very random.');
}
]);
use Hedronium\Avity\Layout;
/**
* A Generator that uses php's `rand()` function.
*/
class NoMirror extends Layout
{
public function drawGrid(array $values)
{
// Sometimes, some style objects are not binary
// they may draw more than one shape of block
// thus the `$values` variable is passed in by the style.
$grid = [];
for ($y = 0; $y < $this->rows; $y++) {
$grid[$y] = [];
for ($x = 0; $x < $this->columns; $x++) {
// should draw takes the `$values` and
// returns a value based on
// generator output
$grid[$y][$x] = $this->shouldDraw($values);
}
}
return $grid;
}
}