Download the PHP package hedronium/avity without Composer
On this page you can find all versions of the php package hedronium/avity. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package avity
Avity
Highly Customizable Identicon Generator for PHP.
Installation
Get it through composer cli.
Getting Started
Thats it thats all you really need to generate an Identicon. The above code will generate an Identicon based on Random values.
Basic Customization
Customizing Image Dimensions
You can call the height($value)
and width($value)
method on the Avity
instance
after initialization. Like:
Yes, its a Fluent API, method chaining is cool!
Customizing Background & Foreground Color
Both the methods accept $r, $g, $b
parameters.
Customizing the Grid
Padding
Style Specific Customizations.
Often the style class used has specific methods that customize its behaviour
which are not directly available on the Avity object for such cases the style
instance can be fetched with the style()
method on the Avity
instance.
Like:
Controlling the Output
Output Format
Avity can output as jpg
, png
or gif
Output Quality
The quality of the generated image may also be set. Give it a number between 1 and 100. (Only aplicable for jpg
& png
)
Output To Browser
Output To File
Generators
Generators
are objects that generate numbers. These numbers are used by Layouts
to set blocks onto the grid.
To use a different generator you can pass in an associative array
of options with the generator
key and the class bane as the value. Like:
available classes:
\Hedronium\Avity\Generators\Hash
(default)\Hedronium\Avity\Generators\Random
The Hash Generator
Once you got the generator setup like above to pass in a value to hash you can call hash()
on the Avity
instance.
(it can be anything, like the user's username or email address or id)
This will generate the same identicon each time you give it the same value to hash.
Layouts
Layout
objects use Generator
objects to set blocks onto the grid.
Avity comes with 3 built in Layout
classes:
\Hedronium\Avity\Layouts\VerticalMirror
(default)\Hedronium\Avity\Layouts\HorizontalMirror
\Hedronium\Avity\Layouts\DiagonalMirror
changing the layout class
Styles
Style
objects use Layout
objects to draw the grid onto a canvas.
Avity comes with 4 built in Style
classes:
\Hedronium\Avity\Styles\Square
(default)\Hedronium\Avity\Styles\SquareCircle
\Hedronium\Avity\Styles\Circle
\Hedronium\Avity\Styles\Triangle
changing the style class
spacing()
All built in Style
classes have a spacing(_int_ $value)
method that can be
used to set the space between blocks.
Like:
variedColor()
This ones a fun method available to all default Style
classes. Just call it and see the magic happen.
Like:
Advanced Customization
Custom Generator
A generator class should always extend Hedronium\Avity\Generator
example:
Using a custom generator
Take construction into your own hands.
Custom Layouts
A generator class should always extend Hedronium\Avity\Layout
Please check the source code for more details. (We promise its simple and readable.)
Using a custom layout
take construction into your own hands.
the callback receive the generator instance as it's very likely that you will be generating the grid based on the generaotr output.