Синхронизировал частично с CMS2

This commit is contained in:
origami11 2017-02-09 17:14:11 +03:00
parent 6b412f5d6f
commit f2938b1353
30 changed files with 1447 additions and 1099 deletions

View file

@ -2,7 +2,6 @@
class Drawing
{
const ALIGN_LEFT = "left";
const ALIGN_TOP = "top";
const ALIGN_BOTTOM = "bottom";
@ -26,7 +25,6 @@ class Drawing
static function imagettftextbox(&$image, $size, $angle, $left, $top, $color, $font, $text,
$max_width, $max_height, $align, $valign)
{
// echo var_dump($font);
// echo $left,"\n", $top, "\n";
// echo $max_width,"\n", $max_height, "\n";
// self::drawrectnagle($image, $left, $top, $max_width, $max_height, array(0xFF,0,0));
@ -44,7 +42,6 @@ class Drawing
$last_width = 0;
for ($i = 0; $i < count($words); $i++) {
$item = $words[$i];
// echo "->", $font, "\n";
$dimensions = imagettfbbox($size, $angle, $font, $current_line . ($first_word ? '' : ' ') . $item);
$line_width = $dimensions[2] - $dimensions[0];
$line_height = $dimensions[1] - $dimensions[7];
@ -75,6 +72,7 @@ class Drawing
}
// vertical align
$top_offset = 0;
if ($valign == self::ALIGN_CENTER) {
$top_offset = ($max_height - $largest_line_height * count($lines)) / 2;
} elseif ($valign == self::ALIGN_BOTTOM) {
@ -84,17 +82,15 @@ class Drawing
$top += $largest_line_height + $top_offset;
$i = 0;
fb($lines);
fb($line_widths);
foreach ($lines as $line) {
// horizontal align
$left_offset = 0;
if ($align == self::ALIGN_CENTER) {
$left_offset = ($max_width - $line_widths[$i]) / 2;
} elseif ($align == self::ALIGN_RIGHT) {
$left_offset = ($max_width - $line_widths[$i]);
}
// echo $font, "\n";
imagettftext($image, $size, $angle, $left + $left_offset, $top + ($largest_line_height * $i), $color, $font, $line);
$i++;
}