Class Jdenticon\IdenticonStyle

Stylesheet specifying the appearance of an identicon.

Methods

Method__constructorCreates a new IdenticonStyle. Optionally an associative array containing style options can be passed to the constructor.

Options

The following options are available to the IdenticonStyle class. The options can either be set using magic properties, or by passing the options in an associative array to the constructor or the setOptions method.

PropertyTypeDescription
Propertyhuesarray(integer)A list of allowed hues specified in degrees that can be used in icons. Only a single hue per icon will be used. If no hue is specified, all hues are allowed.
PropertybackgroundColorJdenticon\Color | stringThe background color of the entire icon, including the padding. The color is specified as a CSS3 color.
PropertypaddingfloatThe padding of the icon in percent in the range [0, 0.4].
PropertycolorSaturationfloatSaturation of colored identicon shapes specified in the range [0, 1].
PropertygrayscaleSaturationfloatSaturation of the originally grayscale identicon shapes specified in the range [0, 1].
PropertycolorLightnessarray(float, float)Lightness of colored identicon shapes. The value is specified as an array containing the minimum and maximum lightness in the range [0, 1], e.g. array(0.3, 0.5).
PropertygrayscaleLightnessarray(float, float)Lightness of the originally grayscale identicon shapes. The value is specified as an array containing the minimum and maximum lightness in the range [0, 1], e.g. array(0.3, 0.5).

The following example shows multiple ways how to set options of the IdenticonStyle class.

<?php
include_once("vendor/autoload.php");

// Associative array to the constructor
$icon = new \Jdenticon\IdenticonStyle(array(
'backgroundColor' => 'rgba(255, 128, 0, 0.8)',
'hues' => array(321)
));

// Magic properties
$icon->backgroundColor = 'rgba(255, 128, 0, 0.8)';
$icon->hues = array(321);

// Public setters
$icon->setBackgroundColor('rgba(255, 128, 0, 0.8)');
$icon->setHues(array(321));