Applied fixes from StyleCI
This commit is contained in:
committed by
StyleCI Bot
parent
be5df5334f
commit
d637c2b23f
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
include('../lib/WideImage.php');
|
||||
|
||||
include '../lib/WideImage.php';
|
||||
|
||||
$img = WideImage::createTrueColorImage(400, 200);
|
||||
$canvas = $img->getCanvas();
|
||||
@@ -31,40 +32,39 @@ $text = '#j';
|
||||
// First we create our bounding box
|
||||
$bbox = imageftbbox($font_size, $angle, $font, $text);
|
||||
|
||||
|
||||
function normalize_bbox($bbox)
|
||||
{
|
||||
return array(
|
||||
'up-left' => array('x' => $bbox[6], 'y' => $bbox[7]),
|
||||
'up-right' => array('x' => $bbox[4], 'y' => $bbox[5]),
|
||||
'down-left' => array('x' => $bbox[0], 'y' => $bbox[1]),
|
||||
'down-right' => array('x' => $bbox[2], 'y' => $bbox[3]),
|
||||
);
|
||||
return [
|
||||
'up-left' => ['x' => $bbox[6], 'y' => $bbox[7]],
|
||||
'up-right' => ['x' => $bbox[4], 'y' => $bbox[5]],
|
||||
'down-left' => ['x' => $bbox[0], 'y' => $bbox[1]],
|
||||
'down-right' => ['x' => $bbox[2], 'y' => $bbox[3]],
|
||||
];
|
||||
}
|
||||
|
||||
function outer_box($box)
|
||||
{
|
||||
return array(
|
||||
'left' => min($box['up-left']['x'], $box['up-right']['x'], $box['down-left']['x'], $box['down-right']['x']),
|
||||
'top' => min($box['up-left']['y'], $box['up-right']['y'], $box['down-left']['y'], $box['down-right']['y']),
|
||||
'right' => max($box['up-left']['x'], $box['up-right']['x'], $box['down-left']['x'], $box['down-right']['x']),
|
||||
'bottom' => max($box['up-left']['y'], $box['up-right']['y'], $box['down-left']['y'], $box['down-right']['y'])
|
||||
);
|
||||
return [
|
||||
'left' => min($box['up-left']['x'], $box['up-right']['x'], $box['down-left']['x'], $box['down-right']['x']),
|
||||
'top' => min($box['up-left']['y'], $box['up-right']['y'], $box['down-left']['y'], $box['down-right']['y']),
|
||||
'right' => max($box['up-left']['x'], $box['up-right']['x'], $box['down-left']['x'], $box['down-right']['x']),
|
||||
'bottom' => max($box['up-left']['y'], $box['up-right']['y'], $box['down-left']['y'], $box['down-right']['y']),
|
||||
];
|
||||
}
|
||||
|
||||
$box = normalize_bbox($bbox);
|
||||
|
||||
// This is our cordinates for X and Y
|
||||
#$x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) - 5;
|
||||
#$y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5;
|
||||
#$x = 300;
|
||||
#$y = 175;
|
||||
//$x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) - 5;
|
||||
//$y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5;
|
||||
//$x = 300;
|
||||
//$y = 175;
|
||||
|
||||
$obox = outer_box(normalize_bbox(imageftbbox($font_size, $angle, $font, '')));
|
||||
$obox = outer_box(normalize_bbox(imageftbbox($font_size, $angle, $font, $text)));
|
||||
|
||||
#$x = imagesx($im) - $obox['right'] - 1;
|
||||
#$y = imagesy($im) - $obox['bottom'] - 1;
|
||||
//$x = imagesx($im) - $obox['right'] - 1;
|
||||
//$y = imagesy($im) - $obox['bottom'] - 1;
|
||||
$x = 0;
|
||||
$y = 0;
|
||||
|
||||
@@ -72,9 +72,8 @@ $gc = imagecolorallocate($im, 255, 200, 200);
|
||||
imageline($im, imagesx($im) / 2, 0, imagesx($im) / 2, imagesy($im), $gc);
|
||||
imageline($im, 0, imagesy($im) / 2, imagesx($im), imagesy($im) / 2, $gc);
|
||||
|
||||
|
||||
imagefttext($im, $font_size, $angle, $x, $y, $black, $font, $text);
|
||||
#imagefttext($im, $font_size, $angle, $x, $y, $black, $font, 'aj');
|
||||
//imagefttext($im, $font_size, $angle, $x, $y, $black, $font, 'aj');
|
||||
|
||||
$c = imagecolorallocate($im, 0, 255, 0);
|
||||
imageline($im, $box['up-left']['x'] + $x, $box['up-left']['y'] + $y, $box['up-right']['x'] + $x, $box['up-right']['y'] + $y, $c);
|
||||
@@ -91,7 +90,6 @@ imageline($im, $obox['left'] + $x, $obox['bottom'] + $y, $obox['left'] + $x, $ob
|
||||
|
||||
imagefilledellipse($im, $x, $y, 3, 3, imagecolorallocate($im, 255, 0, 0));
|
||||
|
||||
|
||||
// Output to browser
|
||||
header('Content-type: image/png');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user