updating composer requirements und identicon library

This commit is contained in:
El RIDO
2020-02-05 19:17:22 +01:00
parent df7a06315f
commit 2870023e9c
4 changed files with 205 additions and 195 deletions

View File

@@ -46,25 +46,28 @@ class SvgGenerator extends BaseGenerator implements GeneratorInterface
// prepare image
$w = $this->getPixelRatio() * 5;
$h = $this->getPixelRatio() * 5;
$svg = '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="'.$w.'" height="'.$h.'">';
$svg = '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="'.$w.'" height="'.$h.'" viewBox="0 0 5 5">';
$backgroundColor = '#FFFFFF';
$backgroundColor = '#FFF';
$rgbBackgroundColor = $this->getBackgroundColor();
if (!is_null($rgbBackgroundColor)) {
$backgroundColor = $this->_toUnderstandableColor($rgbBackgroundColor);
}
$svg .= '<rect width="'.$w.'" height="'.$h.'" style="fill:'.$backgroundColor.';stroke-width:1;stroke:'.$backgroundColor.'"/>';
$rgbColor = $this->_toUnderstandableColor($this->getColor());
$svg .= '<rect width="5" height="5" fill="'.$backgroundColor.'" stroke-width="0"/>';
$rects = [];
// draw content
foreach ($this->getArrayOfSquare() as $lineKey => $lineValue) {
foreach ($lineValue as $colKey => $colValue) {
if (true === $colValue) {
$svg .= '<rect x="'.$colKey * $this->getPixelRatio().'" y="'.$lineKey * $this->getPixelRatio().'" width="'.($this->getPixelRatio()).'" height="'.$this->getPixelRatio().'" style="fill:'.$rgbColor.';stroke-width:0;"/>';
$rects[] = 'M'.$colKey.','.$lineKey.'h1v1h-1v-1';
}
}
}
$rgbColor = $this->_toUnderstandableColor($this->getColor());
$svg .= '<path fill="'.$rgbColor.'" stroke-width="0" d="' . implode('', $rects) . '"/>';
$svg .= '</svg>';
$this->generatedImage = $svg;
@@ -80,7 +83,7 @@ class SvgGenerator extends BaseGenerator implements GeneratorInterface
protected function _toUnderstandableColor($color)
{
if (is_array($color)) {
return 'rgb('.implode(', ', $color).')';
return sprintf('#%X%X%X', $color[0], $color[1], $color[2]);
}
return $color;

View File

@@ -46,10 +46,10 @@ class Identicon
/**
* Display an Identicon image.
*
* @param string $string
* @param int $size
* @param string $color
* @param string $backgroundColor
* @param string $string
* @param int $size
* @param string|array $color
* @param string $backgroundColor
*/
public function displayImage($string, $size = 64, $color = null, $backgroundColor = null)
{
@@ -60,10 +60,10 @@ class Identicon
/**
* Get an Identicon PNG image data.
*
* @param string $string
* @param int $size
* @param string $color
* @param string $backgroundColor
* @param string $string
* @param int $size
* @param string|array $color
* @param string $backgroundColor
*
* @return string
*/
@@ -75,10 +75,10 @@ class Identicon
/**
* Get an Identicon PNG image resource.
*
* @param string $string
* @param int $size
* @param string $color
* @param string $backgroundColor
* @param string $string
* @param int $size
* @param string|array $color
* @param string $backgroundColor
*
* @return string
*/
@@ -90,10 +90,10 @@ class Identicon
/**
* Get an Identicon PNG image data as base 64 encoded.
*
* @param string $string
* @param int $size
* @param string $color
* @param string $backgroundColor
* @param string $string
* @param int $size
* @param string|array $color
* @param string $backgroundColor
*
* @return string
*/
@@ -101,13 +101,13 @@ class Identicon
{
return sprintf('data:%s;base64,%s', $this->generator->getMimeType(), base64_encode($this->getImageData($string, $size, $color, $backgroundColor)));
}
/**
* Get the color of the Identicon
*
* Returns an array with RGB values of the Identicon's color. Colors may be NULL if no image has been generated
* so far (e.g., when calling the method on a new Identicon()).
*
*
* @return array
*/
public function getColor()