Initial commit

This commit is contained in:
2017-10-26 00:42:37 +02:00
commit a410ce8b19
11 changed files with 602 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
<?php
namespace NoccyLabs\GdLabel\Elements;
use NoccyLabs\GdLabel\Element;
class StringElement extends Element
{
protected function draw($gd, int $x, int $y, int $width, int $height, array $params)
{
if (($bound = $this->getProp("bind-value"))) {
$value = array_key_exists($bound, $params)?$params[$bound]:"?{$bound}?";
} else {
$value = $this->getProp("value");
}
$value = \preg_replace_callback('/([åäöÅÄÖ]{1})/', function ($c) {
switch ($c) {
case 'å':
case 'ä':
return "a";
case 'ö':
return "o";
case 'Å':
case 'Ä':
return "A";
case 'Ö':
return "O";
}
}, $value);
$color = $this->getPropRgb("text-color");
$size = $this->getProp("text-size", 0) * 2;
$weight = $this->getProp("font-weight");
if ($weight == "bold") {
$size++;
}
imagestring($gd, $size, $x, $y, $value, $color);
}
}