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. Supported syntax:
  • #RGB, e.g. "#f00"
  • #RGBA, e.g. "#f00f"
  • #RRGGBB, e.g. "#ff0000"
  • #RRGGBBAA, e.g. "#ff0000ff"
  • rgb(r, g, b), e.g. "rgb(255, 0, 0)"
  • rgba(r, g, b, a), e.g. "rgb(255, 0, 0, 1)"
  • hsl(h, s, l), e.g. "hsl(0, 100%, 50%)"
  • hsla(h, s, l, a), e.g. "hsla(0, 100%, 50%, 1)"
  • Color keywords, e.g. "red"
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));