Ajout d'une étape de linting dans DroneCi (#3)

Corrige un doublons laissé par le rebase semi-manuel

Ajout d'une étape de linting dans DroneCi

Fix linting

Co-authored-by: Nigel Sheldon <nigelsheldon@live.fr>
Reviewed-on: https://gitea.nemunai.re/halo-battle/game/pulls/3
This commit is contained in:
Nigel 2020-11-21 18:54:32 +00:00
commit dd61d3b66b
263 changed files with 45327 additions and 42695 deletions

View file

@ -9,10 +9,10 @@
//========================================================================
*/
DEFINE('CORNER_TOPLEFT',0);
DEFINE('CORNER_TOPRIGHT',1);
DEFINE('CORNER_BOTTOMRIGHT',2);
DEFINE('CORNER_BOTTOMLEFT',3);
DEFINE('CORNER_TOPLEFT', 0);
DEFINE('CORNER_TOPRIGHT', 1);
DEFINE('CORNER_BOTTOMRIGHT', 2);
DEFINE('CORNER_BOTTOMLEFT', 3);
//===================================================
@ -21,44 +21,53 @@ DEFINE('CORNER_BOTTOMLEFT',3);
// can abstract away with absolute pixels
//===================================================
class CanvasScale {
class CanvasScale
{
private $g;
private $w,$h;
private $ixmin=0,$ixmax=10,$iymin=0,$iymax=10;
private $w;
private $h;
private $ixmin=0;
private $ixmax=10;
private $iymin=0;
private $iymax=10;
function CanvasScale($graph,$xmin=0,$xmax=10,$ymin=0,$ymax=10) {
$this->g = $graph;
$this->w = $graph->img->width;
$this->h = $graph->img->height;
$this->ixmin = $xmin;
$this->ixmax = $xmax;
$this->iymin = $ymin;
$this->iymax = $ymax;
public function CanvasScale($graph, $xmin=0, $xmax=10, $ymin=0, $ymax=10)
{
$this->g = $graph;
$this->w = $graph->img->width;
$this->h = $graph->img->height;
$this->ixmin = $xmin;
$this->ixmax = $xmax;
$this->iymin = $ymin;
$this->iymax = $ymax;
}
function Set($xmin=0,$xmax=10,$ymin=0,$ymax=10) {
$this->ixmin = $xmin;
$this->ixmax = $xmax;
$this->iymin = $ymin;
$this->iymax = $ymax;
public function Set($xmin=0, $xmax=10, $ymin=0, $ymax=10)
{
$this->ixmin = $xmin;
$this->ixmax = $xmax;
$this->iymin = $ymin;
$this->iymax = $ymax;
}
function Translate($x,$y) {
$xp = round(($x-$this->ixmin)/($this->ixmax - $this->ixmin) * $this->w);
$yp = round(($y-$this->iymin)/($this->iymax - $this->iymin) * $this->h);
return array($xp,$yp);
public function Translate($x, $y)
{
$xp = round(($x-$this->ixmin)/($this->ixmax - $this->ixmin) * $this->w);
$yp = round(($y-$this->iymin)/($this->iymax - $this->iymin) * $this->h);
return array($xp,$yp);
}
function TranslateX($x) {
$xp = round(($x-$this->ixmin)/($this->ixmax - $this->ixmin) * $this->w);
return $xp;
public function TranslateX($x)
{
$xp = round(($x-$this->ixmin)/($this->ixmax - $this->ixmin) * $this->w);
return $xp;
}
function TranslateY($y) {
$yp = round(($y-$this->iymin)/($this->iymax - $this->iymin) * $this->h);
return $yp;
public function TranslateY($y)
{
$yp = round(($y-$this->iymin)/($this->iymax - $this->iymin) * $this->h);
return $yp;
}
}
@ -66,41 +75,48 @@ class CanvasScale {
// CLASS Shape
// Description: Methods to draw shapes on canvas
//===================================================
class Shape {
private $img,$scale;
class Shape
{
private $img;
private $scale;
function Shape($aGraph,$scale) {
$this->img = $aGraph->img;
$this->img->SetColor('black');
$this->scale = $scale;
public function Shape($aGraph, $scale)
{
$this->img = $aGraph->img;
$this->img->SetColor('black');
$this->scale = $scale;
}
function SetColor($aColor) {
$this->img->SetColor($aColor);
public function SetColor($aColor)
{
$this->img->SetColor($aColor);
}
function Line($x1,$y1,$x2,$y2) {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
list($x2,$y2) = $this->scale->Translate($x2,$y2);
$this->img->Line($x1,$y1,$x2,$y2);
public function Line($x1, $y1, $x2, $y2)
{
list($x1, $y1) = $this->scale->Translate($x1, $y1);
list($x2, $y2) = $this->scale->Translate($x2, $y2);
$this->img->Line($x1, $y1, $x2, $y2);
}
function Polygon($p,$aClosed=false) {
$n=count($p);
for($i=0; $i < $n; $i+=2 ) {
$p[$i] = $this->scale->TranslateX($p[$i]);
$p[$i+1] = $this->scale->TranslateY($p[$i+1]);
}
$this->img->Polygon($p,$aClosed);
public function Polygon($p, $aClosed=false)
{
$n=count($p);
for ($i=0; $i < $n; $i+=2) {
$p[$i] = $this->scale->TranslateX($p[$i]);
$p[$i+1] = $this->scale->TranslateY($p[$i+1]);
}
$this->img->Polygon($p, $aClosed);
}
function FilledPolygon($p) {
$n=count($p);
for($i=0; $i < $n; $i+=2 ) {
$p[$i] = $this->scale->TranslateX($p[$i]);
$p[$i+1] = $this->scale->TranslateY($p[$i+1]);
}
$this->img->FilledPolygon($p);
public function FilledPolygon($p)
{
$n=count($p);
for ($i=0; $i < $n; $i+=2) {
$p[$i] = $this->scale->TranslateX($p[$i]);
$p[$i+1] = $this->scale->TranslateY($p[$i+1]);
}
$this->img->FilledPolygon($p);
}
@ -110,406 +126,447 @@ class Shape {
// 2=x1, 3=y1
// 4=x2, 5=y2
// 6=x3, 7=y3
function Bezier($p,$aSteps=40) {
$x0 = $p[0];
$y0 = $p[1];
// Calculate coefficients
$cx = 3*($p[2]-$p[0]);
$bx = 3*($p[4]-$p[2])-$cx;
$ax = $p[6]-$p[0]-$cx-$bx;
$cy = 3*($p[3]-$p[1]);
$by = 3*($p[5]-$p[3])-$cy;
$ay = $p[7]-$p[1]-$cy-$by;
public function Bezier($p, $aSteps=40)
{
$x0 = $p[0];
$y0 = $p[1];
// Calculate coefficients
$cx = 3*($p[2]-$p[0]);
$bx = 3*($p[4]-$p[2])-$cx;
$ax = $p[6]-$p[0]-$cx-$bx;
$cy = 3*($p[3]-$p[1]);
$by = 3*($p[5]-$p[3])-$cy;
$ay = $p[7]-$p[1]-$cy-$by;
// Step size
$delta = 1.0/$aSteps;
// Step size
$delta = 1.0/$aSteps;
$x_old = $x0;
$y_old = $y0;
for($t=$delta; $t<=1.0; $t+=$delta) {
$tt = $t*$t; $ttt=$tt*$t;
$x = $ax*$ttt + $bx*$tt + $cx*$t + $x0;
$y = $ay*$ttt + $by*$tt + $cy*$t + $y0;
$this->Line($x_old,$y_old,$x,$y);
$x_old = $x;
$y_old = $y;
}
$this->Line($x_old,$y_old,$p[6],$p[7]);
$x_old = $x0;
$y_old = $y0;
for ($t=$delta; $t<=1.0; $t+=$delta) {
$tt = $t*$t;
$ttt=$tt*$t;
$x = $ax*$ttt + $bx*$tt + $cx*$t + $x0;
$y = $ay*$ttt + $by*$tt + $cy*$t + $y0;
$this->Line($x_old, $y_old, $x, $y);
$x_old = $x;
$y_old = $y;
}
$this->Line($x_old, $y_old, $p[6], $p[7]);
}
function Rectangle($x1,$y1,$x2,$y2) {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
list($x2,$y2) = $this->scale->Translate($x2,$y2);
$this->img->Rectangle($x1,$y1,$x2,$y2);
public function Rectangle($x1, $y1, $x2, $y2)
{
list($x1, $y1) = $this->scale->Translate($x1, $y1);
list($x2, $y2) = $this->scale->Translate($x2, $y2);
$this->img->Rectangle($x1, $y1, $x2, $y2);
}
function FilledRectangle($x1,$y1,$x2,$y2) {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
list($x2,$y2) = $this->scale->Translate($x2,$y2);
$this->img->FilledRectangle($x1,$y1,$x2,$y2);
public function FilledRectangle($x1, $y1, $x2, $y2)
{
list($x1, $y1) = $this->scale->Translate($x1, $y1);
list($x2, $y2) = $this->scale->Translate($x2, $y2);
$this->img->FilledRectangle($x1, $y1, $x2, $y2);
}
function Circle($x1,$y1,$r) {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
if( $r >= 0 )
$r = $this->scale->TranslateX($r);
else
$r = -$r;
$this->img->Circle($x1,$y1,$r);
public function Circle($x1, $y1, $r)
{
list($x1, $y1) = $this->scale->Translate($x1, $y1);
if ($r >= 0) {
$r = $this->scale->TranslateX($r);
} else {
$r = -$r;
}
$this->img->Circle($x1, $y1, $r);
}
function FilledCircle($x1,$y1,$r) {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
if( $r >= 0 )
$r = $this->scale->TranslateX($r);
else
$r = -$r;
$this->img->FilledCircle($x1,$y1,$r);
public function FilledCircle($x1, $y1, $r)
{
list($x1, $y1) = $this->scale->Translate($x1, $y1);
if ($r >= 0) {
$r = $this->scale->TranslateX($r);
} else {
$r = -$r;
}
$this->img->FilledCircle($x1, $y1, $r);
}
function RoundedRectangle($x1,$y1,$x2,$y2,$r=null) {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
list($x2,$y2) = $this->scale->Translate($x2,$y2);
public function RoundedRectangle($x1, $y1, $x2, $y2, $r=null)
{
list($x1, $y1) = $this->scale->Translate($x1, $y1);
list($x2, $y2) = $this->scale->Translate($x2, $y2);
if( $r == null )
$r = 5;
elseif( $r >= 0 )
$r = $this->scale->TranslateX($r);
else
$r = -$r;
$this->img->RoundedRectangle($x1,$y1,$x2,$y2,$r);
if ($r == null) {
$r = 5;
} elseif ($r >= 0) {
$r = $this->scale->TranslateX($r);
} else {
$r = -$r;
}
$this->img->RoundedRectangle($x1, $y1, $x2, $y2, $r);
}
function FilledRoundedRectangle($x1,$y1,$x2,$y2,$r=null) {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
list($x2,$y2) = $this->scale->Translate($x2,$y2);
public function FilledRoundedRectangle($x1, $y1, $x2, $y2, $r=null)
{
list($x1, $y1) = $this->scale->Translate($x1, $y1);
list($x2, $y2) = $this->scale->Translate($x2, $y2);
if( $r == null )
$r = 5;
elseif( $r > 0 )
$r = $this->scale->TranslateX($r);
else
$r = -$r;
$this->img->FilledRoundedRectangle($x1,$y1,$x2,$y2,$r);
if ($r == null) {
$r = 5;
} elseif ($r > 0) {
$r = $this->scale->TranslateX($r);
} else {
$r = -$r;
}
$this->img->FilledRoundedRectangle($x1, $y1, $x2, $y2, $r);
}
function ShadowRectangle($x1,$y1,$x2,$y2,$fcolor=false,$shadow_width=null,$shadow_color=array(102,102,102)) {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
list($x2,$y2) = $this->scale->Translate($x2,$y2);
if( $shadow_width == null )
$shadow_width=4;
else
$shadow_width=$this->scale->TranslateX($shadow_width);
$this->img->ShadowRectangle($x1,$y1,$x2,$y2,$fcolor,$shadow_width,$shadow_color);
public function ShadowRectangle($x1, $y1, $x2, $y2, $fcolor=false, $shadow_width=null, $shadow_color=array(102,102,102))
{
list($x1, $y1) = $this->scale->Translate($x1, $y1);
list($x2, $y2) = $this->scale->Translate($x2, $y2);
if ($shadow_width == null) {
$shadow_width=4;
} else {
$shadow_width=$this->scale->TranslateX($shadow_width);
}
$this->img->ShadowRectangle($x1, $y1, $x2, $y2, $fcolor, $shadow_width, $shadow_color);
}
function SetTextAlign($halign,$valign="bottom") {
$this->img->SetTextAlign($halign,$valign="bottom");
public function SetTextAlign($halign, $valign="bottom")
{
$this->img->SetTextAlign($halign, $valign="bottom");
}
function StrokeText($x1,$y1,$txt,$dir=0,$paragraph_align="left") {
list($x1,$y1) = $this->scale->Translate($x1,$y1);
$this->img->StrokeText($x1,$y1,$txt,$dir,$paragraph_align);
public function StrokeText($x1, $y1, $txt, $dir=0, $paragraph_align="left")
{
list($x1, $y1) = $this->scale->Translate($x1, $y1);
$this->img->StrokeText($x1, $y1, $txt, $dir, $paragraph_align);
}
// A rounded rectangle where one of the corner has been moved "into" the
// rectangle 'iw' width and 'ih' height. Corners:
// 0=Top left, 1=top right, 2=bottom right, 3=bottom left
function IndentedRectangle($xt,$yt,$w,$h,$iw=0,$ih=0,$aCorner=3,$aFillColor="",$r=4) {
public function IndentedRectangle($xt, $yt, $w, $h, $iw=0, $ih=0, $aCorner=3, $aFillColor="", $r=4)
{
list($xt, $yt) = $this->scale->Translate($xt, $yt);
list($w, $h) = $this->scale->Translate($w, $h);
list($iw, $ih) = $this->scale->Translate($iw, $ih);
list($xt,$yt) = $this->scale->Translate($xt,$yt);
list($w,$h) = $this->scale->Translate($w,$h);
list($iw,$ih) = $this->scale->Translate($iw,$ih);
$xr = $xt + $w - 0;
$yl = $yt + $h - 0;
$xr = $xt + $w - 0;
$yl = $yt + $h - 0;
switch( $aCorner ) {
case 0: // Upper left
// Bottom line, left & right arc
$this->img->Line($xt+$r,$yl,$xr-$r,$yl);
$this->img->Arc($xt+$r,$yl-$r,$r*2,$r*2,90,180);
$this->img->Arc($xr-$r,$yl-$r,$r*2,$r*2,0,90);
switch ($aCorner) {
case 0: // Upper left
// Bottom line, left & right arc
$this->img->Line($xt+$r, $yl, $xr-$r, $yl);
$this->img->Arc($xt+$r, $yl-$r, $r*2, $r*2, 90, 180);
$this->img->Arc($xr-$r, $yl-$r, $r*2, $r*2, 0, 90);
// Right line, Top right arc
$this->img->Line($xr,$yt+$r,$xr,$yl-$r);
$this->img->Arc($xr-$r,$yt+$r,$r*2,$r*2,270,360);
// Right line, Top right arc
$this->img->Line($xr, $yt+$r, $xr, $yl-$r);
$this->img->Arc($xr-$r, $yt+$r, $r*2, $r*2, 270, 360);
// Top line, Top left arc
$this->img->Line($xt+$iw+$r,$yt,$xr-$r,$yt);
$this->img->Arc($xt+$iw+$r,$yt+$r,$r*2,$r*2,180,270);
// Top line, Top left arc
$this->img->Line($xt+$iw+$r, $yt, $xr-$r, $yt);
$this->img->Arc($xt+$iw+$r, $yt+$r, $r*2, $r*2, 180, 270);
// Left line
$this->img->Line($xt,$yt+$ih+$r,$xt,$yl-$r);
// Left line
$this->img->Line($xt, $yt+$ih+$r, $xt, $yl-$r);
// Indent horizontal, Lower left arc
$this->img->Line($xt+$r,$yt+$ih,$xt+$iw-$r,$yt+$ih);
$this->img->Arc($xt+$r,$yt+$ih+$r,$r*2,$r*2,180,270);
// Indent horizontal, Lower left arc
$this->img->Line($xt+$r, $yt+$ih, $xt+$iw-$r, $yt+$ih);
$this->img->Arc($xt+$r, $yt+$ih+$r, $r*2, $r*2, 180, 270);
// Indent vertical, Indent arc
$this->img->Line($xt+$iw,$yt+$r,$xt+$iw,$yt+$ih-$r);
$this->img->Arc($xt+$iw-$r,$yt+$ih-$r,$r*2,$r*2,0,90);
// Indent vertical, Indent arc
$this->img->Line($xt+$iw, $yt+$r, $xt+$iw, $yt+$ih-$r);
$this->img->Arc($xt+$iw-$r, $yt+$ih-$r, $r*2, $r*2, 0, 90);
if( $aFillColor != '' ) {
$bc = $this->img->current_color_name;
$this->img->PushColor($aFillColor);
$this->img->FillToBorder($xr-$r,$yl-$r,$bc);
$this->img->PopColor();
}
if ($aFillColor != '') {
$bc = $this->img->current_color_name;
$this->img->PushColor($aFillColor);
$this->img->FillToBorder($xr-$r, $yl-$r, $bc);
$this->img->PopColor();
}
break;
break;
case 1: // Upper right
case 1: // Upper right
// Bottom line, left & right arc
$this->img->Line($xt+$r,$yl,$xr-$r,$yl);
$this->img->Arc($xt+$r,$yl-$r,$r*2,$r*2,90,180);
$this->img->Arc($xr-$r,$yl-$r,$r*2,$r*2,0,90);
// Bottom line, left & right arc
$this->img->Line($xt+$r, $yl, $xr-$r, $yl);
$this->img->Arc($xt+$r, $yl-$r, $r*2, $r*2, 90, 180);
$this->img->Arc($xr-$r, $yl-$r, $r*2, $r*2, 0, 90);
// Left line, Top left arc
$this->img->Line($xt,$yt+$r,$xt,$yl-$r);
$this->img->Arc($xt+$r,$yt+$r,$r*2,$r*2,180,270);
// Left line, Top left arc
$this->img->Line($xt, $yt+$r, $xt, $yl-$r);
$this->img->Arc($xt+$r, $yt+$r, $r*2, $r*2, 180, 270);
// Top line, Top right arc
$this->img->Line($xt+$r,$yt,$xr-$iw-$r,$yt);
$this->img->Arc($xr-$iw-$r,$yt+$r,$r*2,$r*2,270,360);
// Top line, Top right arc
$this->img->Line($xt+$r, $yt, $xr-$iw-$r, $yt);
$this->img->Arc($xr-$iw-$r, $yt+$r, $r*2, $r*2, 270, 360);
// Right line
$this->img->Line($xr,$yt+$ih+$r,$xr,$yl-$r);
// Right line
$this->img->Line($xr, $yt+$ih+$r, $xr, $yl-$r);
// Indent horizontal, Lower right arc
$this->img->Line($xr-$iw+$r,$yt+$ih,$xr-$r,$yt+$ih);
$this->img->Arc($xr-$r,$yt+$ih+$r,$r*2,$r*2,270,360);
// Indent horizontal, Lower right arc
$this->img->Line($xr-$iw+$r, $yt+$ih, $xr-$r, $yt+$ih);
$this->img->Arc($xr-$r, $yt+$ih+$r, $r*2, $r*2, 270, 360);
// Indent vertical, Indent arc
$this->img->Line($xr-$iw,$yt+$r,$xr-$iw,$yt+$ih-$r);
$this->img->Arc($xr-$iw+$r,$yt+$ih-$r,$r*2,$r*2,90,180);
// Indent vertical, Indent arc
$this->img->Line($xr-$iw, $yt+$r, $xr-$iw, $yt+$ih-$r);
$this->img->Arc($xr-$iw+$r, $yt+$ih-$r, $r*2, $r*2, 90, 180);
if( $aFillColor != '' ) {
$bc = $this->img->current_color_name;
$this->img->PushColor($aFillColor);
$this->img->FillToBorder($xt+$r,$yl-$r,$bc);
$this->img->PopColor();
}
if ($aFillColor != '') {
$bc = $this->img->current_color_name;
$this->img->PushColor($aFillColor);
$this->img->FillToBorder($xt+$r, $yl-$r, $bc);
$this->img->PopColor();
}
break;
break;
case 2: // Lower right
// Top line, Top left & Top right arc
$this->img->Line($xt+$r,$yt,$xr-$r,$yt);
$this->img->Arc($xt+$r,$yt+$r,$r*2,$r*2,180,270);
$this->img->Arc($xr-$r,$yt+$r,$r*2,$r*2,270,360);
case 2: // Lower right
// Top line, Top left & Top right arc
$this->img->Line($xt+$r, $yt, $xr-$r, $yt);
$this->img->Arc($xt+$r, $yt+$r, $r*2, $r*2, 180, 270);
$this->img->Arc($xr-$r, $yt+$r, $r*2, $r*2, 270, 360);
// Left line, Bottom left arc
$this->img->Line($xt,$yt+$r,$xt,$yl-$r);
$this->img->Arc($xt+$r,$yl-$r,$r*2,$r*2,90,180);
// Left line, Bottom left arc
$this->img->Line($xt, $yt+$r, $xt, $yl-$r);
$this->img->Arc($xt+$r, $yl-$r, $r*2, $r*2, 90, 180);
// Bottom line, Bottom right arc
$this->img->Line($xt+$r,$yl,$xr-$iw-$r,$yl);
$this->img->Arc($xr-$iw-$r,$yl-$r,$r*2,$r*2,0,90);
// Bottom line, Bottom right arc
$this->img->Line($xt+$r, $yl, $xr-$iw-$r, $yl);
$this->img->Arc($xr-$iw-$r, $yl-$r, $r*2, $r*2, 0, 90);
// Right line
$this->img->Line($xr,$yt+$r,$xr,$yl-$ih-$r);
// Indent horizontal, Lower right arc
$this->img->Line($xr-$r,$yl-$ih,$xr-$iw+$r,$yl-$ih);
$this->img->Arc($xr-$r,$yl-$ih-$r,$r*2,$r*2,0,90);
// Right line
$this->img->Line($xr, $yt+$r, $xr, $yl-$ih-$r);
// Indent horizontal, Lower right arc
$this->img->Line($xr-$r, $yl-$ih, $xr-$iw+$r, $yl-$ih);
$this->img->Arc($xr-$r, $yl-$ih-$r, $r*2, $r*2, 0, 90);
// Indent vertical, Indent arc
$this->img->Line($xr-$iw,$yl-$r,$xr-$iw,$yl-$ih+$r);
$this->img->Arc($xr-$iw+$r,$yl-$ih+$r,$r*2,$r*2,180,270);
// Indent vertical, Indent arc
$this->img->Line($xr-$iw, $yl-$r, $xr-$iw, $yl-$ih+$r);
$this->img->Arc($xr-$iw+$r, $yl-$ih+$r, $r*2, $r*2, 180, 270);
if( $aFillColor != '' ) {
$bc = $this->img->current_color_name;
$this->img->PushColor($aFillColor);
$this->img->FillToBorder($xt+$r,$yt+$r,$bc);
$this->img->PopColor();
}
if ($aFillColor != '') {
$bc = $this->img->current_color_name;
$this->img->PushColor($aFillColor);
$this->img->FillToBorder($xt+$r, $yt+$r, $bc);
$this->img->PopColor();
}
break;
break;
case 3: // Lower left
// Top line, Top left & Top right arc
$this->img->Line($xt+$r,$yt,$xr-$r,$yt);
$this->img->Arc($xt+$r,$yt+$r,$r*2,$r*2,180,270);
$this->img->Arc($xr-$r,$yt+$r,$r*2,$r*2,270,360);
case 3: // Lower left
// Top line, Top left & Top right arc
$this->img->Line($xt+$r, $yt, $xr-$r, $yt);
$this->img->Arc($xt+$r, $yt+$r, $r*2, $r*2, 180, 270);
$this->img->Arc($xr-$r, $yt+$r, $r*2, $r*2, 270, 360);
// Right line, Bottom right arc
$this->img->Line($xr,$yt+$r,$xr,$yl-$r);
$this->img->Arc($xr-$r,$yl-$r,$r*2,$r*2,0,90);
// Right line, Bottom right arc
$this->img->Line($xr, $yt+$r, $xr, $yl-$r);
$this->img->Arc($xr-$r, $yl-$r, $r*2, $r*2, 0, 90);
// Bottom line, Bottom left arc
$this->img->Line($xt+$iw+$r,$yl,$xr-$r,$yl);
$this->img->Arc($xt+$iw+$r,$yl-$r,$r*2,$r*2,90,180);
// Bottom line, Bottom left arc
$this->img->Line($xt+$iw+$r, $yl, $xr-$r, $yl);
$this->img->Arc($xt+$iw+$r, $yl-$r, $r*2, $r*2, 90, 180);
// Left line
$this->img->Line($xt,$yt+$r,$xt,$yl-$ih-$r);
// Indent horizontal, Lower left arc
$this->img->Line($xt+$r,$yl-$ih,$xt+$iw-$r,$yl-$ih);
$this->img->Arc($xt+$r,$yl-$ih-$r,$r*2,$r*2,90,180);
// Left line
$this->img->Line($xt, $yt+$r, $xt, $yl-$ih-$r);
// Indent horizontal, Lower left arc
$this->img->Line($xt+$r, $yl-$ih, $xt+$iw-$r, $yl-$ih);
$this->img->Arc($xt+$r, $yl-$ih-$r, $r*2, $r*2, 90, 180);
// Indent vertical, Indent arc
$this->img->Line($xt+$iw,$yl-$ih+$r,$xt+$iw,$yl-$r);
$this->img->Arc($xt+$iw-$r,$yl-$ih+$r,$r*2,$r*2,270,360);
// Indent vertical, Indent arc
$this->img->Line($xt+$iw, $yl-$ih+$r, $xt+$iw, $yl-$r);
$this->img->Arc($xt+$iw-$r, $yl-$ih+$r, $r*2, $r*2, 270, 360);
if( $aFillColor != '' ) {
$bc = $this->img->current_color_name;
$this->img->PushColor($aFillColor);
$this->img->FillToBorder($xr-$r,$yt+$r,$bc);
$this->img->PopColor();
}
if ($aFillColor != '') {
$bc = $this->img->current_color_name;
$this->img->PushColor($aFillColor);
$this->img->FillToBorder($xr-$r, $yt+$r, $bc);
$this->img->PopColor();
}
break;
}
break;
}
}
}
//===================================================
// CLASS RectangleText
// Description: Draws a text paragraph inside a
// Description: Draws a text paragraph inside a
// rounded, possible filled, rectangle.
//===================================================
class CanvasRectangleText {
private $ix,$iy,$iw,$ih,$ir=4;
private $iTxt,$iColor='black',$iFillColor='',$iFontColor='black';
class CanvasRectangleText
{
private $ix;
private $iy;
private $iw;
private $ih;
private $ir=4;
private $iTxt;
private $iColor='black';
private $iFillColor='';
private $iFontColor='black';
private $iParaAlign='center';
private $iAutoBoxMargin=5;
private $iShadowWidth=3,$iShadowColor='';
private $iShadowWidth=3;
private $iShadowColor='';
function CanvasRectangleText($aTxt='',$xl=0,$yt=0,$w=0,$h=0) {
$this->iTxt = new Text($aTxt);
$this->ix = $xl;
$this->iy = $yt;
$this->iw = $w;
$this->ih = $h;
public function CanvasRectangleText($aTxt='', $xl=0, $yt=0, $w=0, $h=0)
{
$this->iTxt = new Text($aTxt);
$this->ix = $xl;
$this->iy = $yt;
$this->iw = $w;
$this->ih = $h;
}
function SetShadow($aColor='gray',$aWidth=3) {
$this->iShadowColor = $aColor;
$this->iShadowWidth = $aWidth;
public function SetShadow($aColor='gray', $aWidth=3)
{
$this->iShadowColor = $aColor;
$this->iShadowWidth = $aWidth;
}
function SetFont($FontFam,$aFontStyle,$aFontSize=12) {
$this->iTxt->SetFont($FontFam,$aFontStyle,$aFontSize);
public function SetFont($FontFam, $aFontStyle, $aFontSize=12)
{
$this->iTxt->SetFont($FontFam, $aFontStyle, $aFontSize);
}
function SetTxt($aTxt) {
$this->iTxt->Set($aTxt);
public function SetTxt($aTxt)
{
$this->iTxt->Set($aTxt);
}
function ParagraphAlign($aParaAlign) {
$this->iParaAlign = $aParaAlign;
public function ParagraphAlign($aParaAlign)
{
$this->iParaAlign = $aParaAlign;
}
function SetFillColor($aFillColor) {
$this->iFillColor = $aFillColor;
public function SetFillColor($aFillColor)
{
$this->iFillColor = $aFillColor;
}
function SetAutoMargin($aMargin) {
$this->iAutoBoxMargin=$aMargin;
public function SetAutoMargin($aMargin)
{
$this->iAutoBoxMargin=$aMargin;
}
function SetColor($aColor) {
$this->iColor = $aColor;
public function SetColor($aColor)
{
$this->iColor = $aColor;
}
function SetFontColor($aColor) {
$this->iFontColor = $aColor;
public function SetFontColor($aColor)
{
$this->iFontColor = $aColor;
}
function SetPos($xl=0,$yt=0,$w=0,$h=0) {
$this->ix = $xl;
$this->iy = $yt;
$this->iw = $w;
$this->ih = $h;
public function SetPos($xl=0, $yt=0, $w=0, $h=0)
{
$this->ix = $xl;
$this->iy = $yt;
$this->iw = $w;
$this->ih = $h;
}
function Pos($xl=0,$yt=0,$w=0,$h=0) {
$this->ix = $xl;
$this->iy = $yt;
$this->iw = $w;
$this->ih = $h;
public function Pos($xl=0, $yt=0, $w=0, $h=0)
{
$this->ix = $xl;
$this->iy = $yt;
$this->iw = $w;
$this->ih = $h;
}
function Set($aTxt,$xl,$yt,$w=0,$h=0) {
$this->iTxt->Set($aTxt);
$this->ix = $xl;
$this->iy = $yt;
$this->iw = $w;
$this->ih = $h;
public function Set($aTxt, $xl, $yt, $w=0, $h=0)
{
$this->iTxt->Set($aTxt);
$this->ix = $xl;
$this->iy = $yt;
$this->iw = $w;
$this->ih = $h;
}
function SetCornerRadius($aRad=5) {
$this->ir = $aRad;
public function SetCornerRadius($aRad=5)
{
$this->ir = $aRad;
}
function Stroke($aImg,$scale) {
// If coordinates are specifed as negative this means we should
// treat them as abolsute (pixels) coordinates
if( $this->ix > 0 ) {
$this->ix = $scale->TranslateX($this->ix) ;
}
else {
$this->ix = -$this->ix;
}
public function Stroke($aImg, $scale)
{
// If coordinates are specifed as negative this means we should
// treat them as abolsute (pixels) coordinates
if ($this->ix > 0) {
$this->ix = $scale->TranslateX($this->ix) ;
} else {
$this->ix = -$this->ix;
}
if( $this->iy > 0 ) {
$this->iy = $scale->TranslateY($this->iy) ;
}
else {
$this->iy = -$this->iy;
}
list($this->iw,$this->ih) = $scale->Translate($this->iw,$this->ih) ;
if ($this->iy > 0) {
$this->iy = $scale->TranslateY($this->iy) ;
} else {
$this->iy = -$this->iy;
}
list($this->iw, $this->ih) = $scale->Translate($this->iw, $this->ih) ;
if( $this->iw == 0 )
$this->iw = round($this->iTxt->GetWidth($aImg) + $this->iAutoBoxMargin);
if( $this->ih == 0 ) {
$this->ih = round($this->iTxt->GetTextHeight($aImg) + $this->iAutoBoxMargin);
}
if ($this->iw == 0) {
$this->iw = round($this->iTxt->GetWidth($aImg) + $this->iAutoBoxMargin);
}
if ($this->ih == 0) {
$this->ih = round($this->iTxt->GetTextHeight($aImg) + $this->iAutoBoxMargin);
}
if( $this->iShadowColor != '' ) {
$aImg->PushColor($this->iShadowColor);
$aImg->FilledRoundedRectangle($this->ix+$this->iShadowWidth,
$this->iy+$this->iShadowWidth,
$this->ix+$this->iw-1+$this->iShadowWidth,
$this->iy+$this->ih-1+$this->iShadowWidth,
$this->ir);
$aImg->PopColor();
}
if ($this->iShadowColor != '') {
$aImg->PushColor($this->iShadowColor);
$aImg->FilledRoundedRectangle(
$this->ix+$this->iShadowWidth,
$this->iy+$this->iShadowWidth,
$this->ix+$this->iw-1+$this->iShadowWidth,
$this->iy+$this->ih-1+$this->iShadowWidth,
$this->ir
);
$aImg->PopColor();
}
if( $this->iFillColor != '' ) {
$aImg->PushColor($this->iFillColor);
$aImg->FilledRoundedRectangle($this->ix,$this->iy,
$this->ix+$this->iw-1,
$this->iy+$this->ih-1,
$this->ir);
$aImg->PopColor();
}
if ($this->iFillColor != '') {
$aImg->PushColor($this->iFillColor);
$aImg->FilledRoundedRectangle(
$this->ix,
$this->iy,
$this->ix+$this->iw-1,
$this->iy+$this->ih-1,
$this->ir
);
$aImg->PopColor();
}
if( $this->iColor != '' ) {
$aImg->PushColor($this->iColor);
$aImg->RoundedRectangle($this->ix,$this->iy,
$this->ix+$this->iw-1,
$this->iy+$this->ih-1,
$this->ir);
$aImg->PopColor();
}
$this->iTxt->Align('center','center');
$this->iTxt->ParagraphAlign($this->iParaAlign);
$this->iTxt->SetColor($this->iFontColor);
$this->iTxt->Stroke($aImg, $this->ix+$this->iw/2, $this->iy+$this->ih/2);
return array($this->iw, $this->ih);
if ($this->iColor != '') {
$aImg->PushColor($this->iColor);
$aImg->RoundedRectangle(
$this->ix,
$this->iy,
$this->ix+$this->iw-1,
$this->iy+$this->ih-1,
$this->ir
);
$aImg->PopColor();
}
$this->iTxt->Align('center', 'center');
$this->iTxt->ParagraphAlign($this->iParaAlign);
$this->iTxt->SetColor($this->iFontColor);
$this->iTxt->Stroke($aImg, $this->ix+$this->iw/2, $this->iy+$this->ih/2);
return array($this->iw, $this->ih);
}
}
?>