PageRenderTime 121ms CodeModel.GetById 32ms app.highlight 62ms RepoModel.GetById 1ms app.codeStats 2ms

/libs/pChart2.1.3/class/pDraw.class.php

https://github.com/CodeYellowBV/piwik
PHP | 6203 lines | 5027 code | 1048 blank | 128 comment | 2366 complexity | f27d42bc9fa34966f4483546254c312c MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1<?php
   2 /*
   3     pDraw - class extension with drawing methods
   4
   5     Version     : 2.1.3
   6     Made by     : Jean-Damien POGOLOTTI
   7     Last Update : 09/09/11
   8
   9     This file can be distributed under the license you can find at :
  10
  11                       http://www.pchart.net/license
  12
  13     You can find the whole class documentation on the pChart web site.
  14 */
  15
  16 define("DIRECTION_VERTICAL"		, 690001);
  17 define("DIRECTION_HORIZONTAL"		, 690002);
  18
  19 define("SCALE_POS_LEFTRIGHT"		, 690101);
  20 define("SCALE_POS_TOPBOTTOM"		, 690102);
  21
  22 define("SCALE_MODE_FLOATING"		, 690201);
  23 define("SCALE_MODE_START0"		, 690202);
  24 define("SCALE_MODE_ADDALL"		, 690203);
  25 define("SCALE_MODE_ADDALL_START0"	, 690204);
  26 define("SCALE_MODE_MANUAL"		, 690205);
  27
  28 define("SCALE_SKIP_NONE"		, 690301);
  29 define("SCALE_SKIP_SAME"		, 690302);
  30 define("SCALE_SKIP_NUMBERS"		, 690303);
  31
  32 define("TEXT_ALIGN_TOPLEFT"		, 690401);
  33 define("TEXT_ALIGN_TOPMIDDLE"		, 690402);
  34 define("TEXT_ALIGN_TOPRIGHT"		, 690403);
  35 define("TEXT_ALIGN_MIDDLELEFT"		, 690404);
  36 define("TEXT_ALIGN_MIDDLEMIDDLE"	, 690405);
  37 define("TEXT_ALIGN_MIDDLERIGHT"	, 690406);
  38 define("TEXT_ALIGN_BOTTOMLEFT"		, 690407);
  39 define("TEXT_ALIGN_BOTTOMMIDDLE"	, 690408);
  40 define("TEXT_ALIGN_BOTTOMRIGHT"	, 690409);
  41
  42 define("POSITION_TOP"                  , 690501);
  43 define("POSITION_BOTTOM"               , 690502);
  44
  45 define("LABEL_POS_LEFT"		, 690601);
  46 define("LABEL_POS_CENTER"		, 690602);
  47 define("LABEL_POS_RIGHT"		, 690603);
  48 define("LABEL_POS_TOP"			, 690604);
  49 define("LABEL_POS_BOTTOM"		, 690605);
  50 define("LABEL_POS_INSIDE"		, 690606);
  51 define("LABEL_POS_OUTSIDE"		, 690607);
  52
  53 define("ORIENTATION_HORIZONTAL"	, 690701);
  54 define("ORIENTATION_VERTICAL"		, 690702);
  55 define("ORIENTATION_AUTO"		, 690703);
  56
  57 define("LEGEND_NOBORDER"		, 690800);
  58 define("LEGEND_BOX"			, 690801);
  59 define("LEGEND_ROUND"			, 690802);
  60
  61 define("LEGEND_VERTICAL"		, 690901);
  62 define("LEGEND_HORIZONTAL"		, 690902);
  63
  64 define("LEGEND_FAMILY_BOX"		, 691051);
  65 define("LEGEND_FAMILY_CIRCLE"		, 691052);
  66 define("LEGEND_FAMILY_LINE"		, 691053);
  67
  68 define("DISPLAY_AUTO"			, 691001);
  69 define("DISPLAY_MANUAL"		, 691002);
  70
  71 define("LABELING_ALL"			, 691011);
  72 define("LABELING_DIFFERENT"		, 691012);
  73
  74 define("BOUND_MIN"			, 691021);
  75 define("BOUND_MAX"			, 691022);
  76 define("BOUND_BOTH"			, 691023);
  77
  78 define("BOUND_LABEL_POS_TOP"		, 691031);
  79 define("BOUND_LABEL_POS_BOTTOM"	, 691032);
  80 define("BOUND_LABEL_POS_AUTO"		, 691033);
  81
  82 define("CAPTION_LEFT_TOP"		, 691041);
  83 define("CAPTION_RIGHT_BOTTOM"		, 691042);
  84
  85 define("GRADIENT_SIMPLE"		, 691051);
  86 define("GRADIENT_EFFECT_CAN"		, 691052);
  87
  88 define("LABEL_TITLE_NOBACKGROUND"	, 691061);
  89 define("LABEL_TITLE_BACKGROUND"	, 691062);
  90
  91 define("LABEL_POINT_NONE"		, 691071);
  92 define("LABEL_POINT_CIRCLE"		, 691072);
  93 define("LABEL_POINT_BOX"		, 691073);
  94
  95 define("ZONE_NAME_ANGLE_AUTO"		, 691081);
  96
  97 define("PI"		, 3.14159265);
  98 define("ALL"		, 69);
  99 define("NONE"		, 31);
 100 define("AUTO"		, 690000);
 101 define("OUT_OF_SIGHT"	, -10000000000000);
 102
 103 class pDraw
 104  {
 105   /* Returns the number of drawable series */
 106   function countDrawableSeries()
 107    {
 108     $Results = 0;
 109     $Data = $this->DataSet->getData();
 110
 111     foreach($Data["Series"] as $SerieName => $Serie)
 112      { if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] ) { $Results++; } }
 113
 114     return($Results);
 115    }
 116
 117   /* Fix box coordinates */
 118   function fixBoxCoordinates($Xa,$Ya,$Xb,$Yb)
 119    {
 120     $X1 = min($Xa,$Xb); $Y1 = min($Ya,$Yb);
 121     $X2 = max($Xa,$Xb); $Y2 = max($Ya,$Yb);
 122
 123     return(array($X1,$Y1,$X2,$Y2));
 124    }
 125
 126   /* Draw a polygon */
 127   function drawPolygon($Points,$Format="")
 128    {
 129     $R			= isset($Format["R"]) ? $Format["R"] : 0;
 130     $G			= isset($Format["G"]) ? $Format["G"] : 0;
 131     $B			= isset($Format["B"]) ? $Format["B"] : 0;
 132     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
 133     $NoFill		= isset($Format["NoFill"]) ? $Format["NoFill"] : FALSE;
 134     $NoBorder		= isset($Format["NoBorder"]) ? $Format["NoBorder"] : FALSE;
 135     $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : $R;
 136     $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : $G;
 137     $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : $B;
 138     $BorderAlpha 	= isset($Format["Alpha"]) ? $Format["Alpha"] : $Alpha / 2;
 139     $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
 140     $SkipX		= isset($Format["SkipX"]) ? $Format["SkipX"] : OUT_OF_SIGHT;
 141     $SkipY		= isset($Format["SkipY"]) ? $Format["SkipY"] : OUT_OF_SIGHT;
 142
 143     /* Calling the ImageFilledPolygon() function over the $Points array will round it */ 	
 144     $Backup = $Points;
 145
 146     if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
 147
 148     if ( $SkipX != OUT_OF_SIGHT ) { $SkipX = floor($SkipX); }
 149     if ( $SkipY != OUT_OF_SIGHT ) { $SkipY = floor($SkipY); }
 150
 151     $RestoreShadow = $this->Shadow;
 152     if ( !$NoFill )
 153      {
 154       if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
 155        {
 156         $this->Shadow = FALSE;
 157         for($i=0;$i<=count($Points)-1;$i=$i+2)
 158          { $Shadow[] = $Points[$i] + $this->ShadowX; $Shadow[] = $Points[$i+1] + $this->ShadowY; }
 159         $this->drawPolygon($Shadow,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa,"NoBorder"=>TRUE));
 160        }
 161
 162       $FillColor = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
 163
 164       if ( count($Points) >= 6 )
 165        { ImageFilledPolygon($this->Picture,$Points,count($Points)/2,$FillColor); }
 166      }
 167
 168     if ( !$NoBorder )
 169      {
 170       $Points = $Backup;
 171
 172       if ( $NoFill )
 173        $BorderSettings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
 174       else
 175        $BorderSettings = array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha);
 176
 177       for($i=0;$i<=count($Points)-1;$i=$i+2)
 178        {
 179         if ( isset($Points[$i+2]) )
 180          {
 181           if ( !($Points[$i] == $Points[$i+2] && $Points[$i] == $SkipX ) && !($Points[$i+1] == $Points[$i+3] && $Points[$i+1] == $SkipY ) )
 182            $this->drawLine($Points[$i],$Points[$i+1],$Points[$i+2],$Points[$i+3],$BorderSettings);
 183          }
 184         else
 185          {
 186           if ( !($Points[$i] == $Points[0] && $Points[$i] == $SkipX ) && !($Points[$i+1] == $Points[1] && $Points[$i+1] == $SkipY ) )
 187            $this->drawLine($Points[$i],$Points[$i+1],$Points[0],$Points[1],$BorderSettings);
 188          }
 189        }
 190      }
 191
 192     $this->Shadow = $RestoreShadow;
 193    }
 194
 195   /* Apply AALias correction to the rounded box boundaries */
 196   function offsetCorrection($Value,$Mode)
 197    {
 198     $Value = round($Value,1);
 199
 200     if ( $Value == 0 && $Mode == 1 ) { return(.9); }
 201     if ( $Value == 0 ) { return(0); }
 202
 203     if ( $Mode == 1) 
 204      { if ( $Value == 1 ) { return(.9); }; if ( $Value == .1 ) { return(.9); }; if ( $Value == .2 ) { return(.8); }; if ( $Value == .3 ) { return(.8); }; if ( $Value == .4 ) { return(.7); }; if ( $Value == .5 ) { return(.5); }; if ( $Value == .6 ) { return(.8); }; if ( $Value == .7 ) { return(.7); }; if ( $Value == .8 ) { return(.6); }; if ( $Value == .9 ) { return(.9); }; }
 205
 206     if ( $Mode == 2) 
 207      { if ( $Value == 1 ) { return(.9); }; if ( $Value == .1 ) { return(.1); }; if ( $Value == .2 ) { return(.2); }; if ( $Value == .3 ) { return(.3); }; if ( $Value == .4 ) { return(.4); }; if ( $Value == .5 ) { return(.5); }; if ( $Value == .6 ) { return(.8); }; if ( $Value == .7 ) { return(.7); }; if ( $Value == .8 ) { return(.8); }; if ( $Value == .9 ) { return(.9); }; }
 208
 209     if ( $Mode == 3) 
 210      { if ( $Value == 1 ) { return(.1); }; if ( $Value == .1 ) { return(.1); }; if ( $Value == .2 ) { return(.2); }; if ( $Value == .3 ) { return(.3); }; if ( $Value == .4 ) { return(.4); }; if ( $Value == .5 ) { return(.9); }; if ( $Value == .6 ) { return(.6); }; if ( $Value == .7 ) { return(.7); }; if ( $Value == .8 ) { return(.4); }; if ( $Value == .9 ) { return(.5); }; }
 211
 212     if ( $Mode == 4) 
 213      { if ( $Value == 1 ) { return(-1); }; if ( $Value == .1 ) { return(.1); }; if ( $Value == .2 ) { return(.2); }; if ( $Value == .3 ) { return(.3); }; if ( $Value == .4 ) { return(.1); }; if ( $Value == .5 ) { return(-.1); }; if ( $Value == .6 ) { return(.8); }; if ( $Value == .7 ) { return(.1); }; if ( $Value == .8 ) { return(.1); }; if ( $Value == .9 ) { return(.1); }; }
 214    }
 215
 216   /* Draw a rectangle with rounded corners */
 217   function drawRoundedRectangle($X1,$Y1,$X2,$Y2,$Radius,$Format="")
 218    {
 219     $R	    = isset($Format["R"]) ? $Format["R"] : 0;
 220     $G	    = isset($Format["G"]) ? $Format["G"] : 0;
 221     $B	    = isset($Format["B"]) ? $Format["B"] : 0;
 222     $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
 223
 224     list($X1,$Y1,$X2,$Y2) = $this->fixBoxCoordinates($X1,$Y1,$X2,$Y2);
 225
 226     if ( $X2 - $X1 < $Radius ) { $Radius = floor((($X2-$X1))/2); }
 227     if ( $Y2 - $Y1 < $Radius ) { $Radius = floor((($Y2-$Y1))/2); }
 228
 229     $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"NoBorder"=>TRUE);
 230
 231     if ( $Radius <= 0 ) { $this->drawRectangle($X1,$Y1,$X2,$Y2,$Color); return(0); }
 232
 233     if ( $this->Antialias )
 234      {
 235       $this->drawLine($X1+$Radius,$Y1,$X2-$Radius,$Y1,$Color);
 236       $this->drawLine($X2,$Y1+$Radius,$X2,$Y2-$Radius,$Color);
 237       $this->drawLine($X2-$Radius,$Y2,$X1+$Radius,$Y2,$Color);
 238       $this->drawLine($X1,$Y1+$Radius,$X1,$Y2-$Radius,$Color);
 239      }
 240     else
 241      {
 242       $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
 243       imageline($this->Picture,$X1+$Radius,$Y1,$X2-$Radius,$Y1,$Color);
 244       imageline($this->Picture,$X2,$Y1+$Radius,$X2,$Y2-$Radius,$Color);
 245       imageline($this->Picture,$X2-$Radius,$Y2,$X1+$Radius,$Y2,$Color);
 246       imageline($this->Picture,$X1,$Y1+$Radius,$X1,$Y2-$Radius,$Color);
 247      }
 248
 249     $Step = 360 / (2 * PI * $Radius);
 250     for($i=0;$i<=90;$i=$i+$Step)
 251      {
 252       $X = cos(($i+180)*PI/180) * $Radius + $X1 + $Radius;
 253       $Y = sin(($i+180)*PI/180) * $Radius + $Y1 + $Radius;
 254       $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
 255
 256       $X = cos(($i+90)*PI/180) * $Radius + $X1 + $Radius;
 257       $Y = sin(($i+90)*PI/180) * $Radius + $Y2 - $Radius;
 258       $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
 259
 260       $X = cos($i*PI/180) * $Radius + $X2 - $Radius;
 261       $Y = sin($i*PI/180) * $Radius + $Y2 - $Radius;
 262       $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
 263
 264       $X = cos(($i+270)*PI/180) * $Radius + $X2 - $Radius;
 265       $Y = sin(($i+270)*PI/180) * $Radius + $Y1 + $Radius;
 266       $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
 267      }
 268    }
 269
 270   /* Draw a rectangle with rounded corners */
 271   function drawRoundedFilledRectangle($X1,$Y1,$X2,$Y2,$Radius,$Format="")
 272    {
 273     $R			= isset($Format["R"]) ? $Format["R"] : 0;
 274     $G			= isset($Format["G"]) ? $Format["G"] : 0;
 275     $B			= isset($Format["B"]) ? $Format["B"] : 0;
 276     $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
 277     $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
 278     $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
 279     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
 280     $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
 281
 282     /* Temporary fix for AA issue */
 283     $Y1 = floor($Y1); $Y2 = floor($Y2); $X1 = floor($X1); $X2 = floor($X2);
 284
 285     if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
 286     if ( $BorderR == -1 ) { $BorderR = $R; $BorderG = $G; $BorderB = $B; }
 287
 288     list($X1,$Y1,$X2,$Y2) = $this->fixBoxCoordinates($X1,$Y1,$X2,$Y2);
 289
 290     if ( $X2 - $X1 < $Radius*2 ) { $Radius = floor((($X2-$X1))/4); }
 291     if ( $Y2 - $Y1 < $Radius*2 ) { $Radius = floor((($Y2-$Y1))/4); }
 292
 293     $RestoreShadow = $this->Shadow;
 294     if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
 295      {
 296       $this->Shadow = FALSE;
 297       $this->drawRoundedFilledRectangle($X1+$this->ShadowX,$Y1+$this->ShadowY,$X2+$this->ShadowX,$Y2+$this->ShadowY,$Radius,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa));
 298      }
 299
 300     $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"NoBorder"=>TRUE);
 301
 302     if ( $Radius <= 0 ) { $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,$Color); return(0); }
 303
 304     $YTop    = $Y1+$Radius;
 305     $YBottom = $Y2-$Radius;
 306
 307     $Step = 360 / (2 * PI * $Radius);
 308     $Positions = ""; $Radius--; $MinY = ""; $MaxY = "";
 309     for($i=0;$i<=90;$i=$i+$Step)
 310      {
 311       $Xp1 = cos(($i+180)*PI/180) * $Radius + $X1 + $Radius;
 312       $Xp2 = cos(((90-$i)+270)*PI/180) * $Radius + $X2 - $Radius;
 313       $Yp  = floor(sin(($i+180)*PI/180) * $Radius + $YTop);
 314       if ( $MinY == "" || $Yp > $MinY ) { $MinY = $Yp; }
 315
 316       if ( $Xp1 <= floor($X1) )  { $Xp1++; }
 317       if ( $Xp2 >= floor($X2) )  { $Xp2--; }
 318       $Xp1++;
 319
 320       if ( !isset($Positions[$Yp]) )
 321        { $Positions[$Yp]["X1"] = $Xp1; $Positions[$Yp]["X2"] = $Xp2; }
 322       else
 323        { $Positions[$Yp]["X1"] = ($Positions[$Yp]["X1"]+$Xp1)/2; $Positions[$Yp]["X2"] = ($Positions[$Yp]["X2"]+$Xp2)/2; }
 324
 325       $Xp1 = cos(($i+90)*PI/180) * $Radius + $X1 + $Radius;
 326       $Xp2 = cos((90-$i)*PI/180) * $Radius + $X2 - $Radius;
 327       $Yp  = floor(sin(($i+90)*PI/180) * $Radius + $YBottom);
 328       if ( $MaxY == "" || $Yp < $MaxY ) { $MaxY = $Yp; }
 329
 330       if ( $Xp1 <= floor($X1) ) { $Xp1++; }
 331       if ( $Xp2 >= floor($X2) ) { $Xp2--; }
 332       $Xp1++;
 333
 334       if ( !isset($Positions[$Yp]) )
 335        { $Positions[$Yp]["X1"] = $Xp1; $Positions[$Yp]["X2"] = $Xp2; }
 336       else
 337        { $Positions[$Yp]["X1"] = ($Positions[$Yp]["X1"]+$Xp1)/2; $Positions[$Yp]["X2"] = ($Positions[$Yp]["X2"]+$Xp2)/2; }
 338      }
 339
 340     $ManualColor  = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
 341     foreach($Positions as $Yp => $Bounds)
 342      {
 343       $X1 = $Bounds["X1"]; $X1Dec = $this->getFirstDecimal($X1); if ( $X1Dec != 0 ) { $X1 = floor($X1)+1; }
 344       $X2 = $Bounds["X2"]; $X2Dec = $this->getFirstDecimal($X2); if ( $X2Dec != 0 ) { $X2 = floor($X2)-1; }
 345       imageline($this->Picture,$X1,$Yp,$X2,$Yp,$ManualColor);
 346      }
 347     $this->drawFilledRectangle($X1,$MinY+1,floor($X2),$MaxY-1,$Color);
 348
 349     $Radius++;
 350     $this->drawRoundedRectangle($X1,$Y1,$X2+1,$Y2-1,$Radius,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
 351
 352     $this->Shadow = $RestoreShadow;
 353    }
 354
 355   /* Draw a rectangle with rounded corners */
 356   function drawRoundedFilledRectangle_deprecated($X1,$Y1,$X2,$Y2,$Radius,$Format="")
 357    {
 358     $R			= isset($Format["R"]) ? $Format["R"] : 0;
 359     $G			= isset($Format["G"]) ? $Format["G"] : 0;
 360     $B			= isset($Format["B"]) ? $Format["B"] : 0;
 361     $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
 362     $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
 363     $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
 364     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
 365     $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
 366
 367     if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
 368     if ( $BorderR == -1 ) { $BorderR = $R; $BorderG = $G; $BorderB = $B; }
 369
 370     list($X1,$Y1,$X2,$Y2) = $this->fixBoxCoordinates($X1,$Y1,$X2,$Y2);
 371
 372     if ( $X2 - $X1 < $Radius ) { $Radius = floor((($X2-$X1)+2)/2); }
 373     if ( $Y2 - $Y1 < $Radius ) { $Radius = floor((($Y2-$Y1)+2)/2); }
 374
 375     $RestoreShadow = $this->Shadow;
 376     if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
 377      {
 378       $this->Shadow = FALSE;
 379       $this->drawRoundedFilledRectangle($X1+$this->ShadowX,$Y1+$this->ShadowY,$X2+$this->ShadowX,$Y2+$this->ShadowY,$Radius,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa));
 380      }
 381
 382     if ( $this->getFirstDecimal($X2) >= 5 )  { $XOffset2 = 1; } else { $XOffset2 = 0; }
 383     if ( $this->getFirstDecimal($X1) <= 5 )  { $XOffset1 = 1; } else { $XOffset1 = 0; }
 384
 385     if ( !$this->Antialias ) { $XOffset1 = 1; $XOffset2 = 1; }
 386
 387     $YTop    = floor($Y1+$Radius);
 388     $YBottom = floor($Y2-$Radius);
 389
 390     $this->drawFilledRectangle($X1-$XOffset1,$YTop,$X2+$XOffset2,$YBottom,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"NoBorder"=>TRUE));
 391
 392     $Step = 360 / (2 * PI * $Radius);
 393     $Color  = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
 394     $Color2 = $this->allocateColor($this->Picture,255,0,0,$Alpha);
 395     $Drawn = "";
 396
 397     if ( $Alpha < 100 )  { $Drawn[$YTop] = FALSE; }
 398     if ( $Alpha < 100 )  { $Drawn[$YBottom] = TRUE; }
 399     
 400     for($i=0;$i<=90;$i=$i+$Step)
 401      {
 402       $Xp1 = cos(($i+180)*PI/180) * $Radius + $X1 + $Radius;
 403       $Xp2 = cos(((90-$i)+270)*PI/180) * $Radius + $X2 - $Radius;
 404       $Yp  = sin(($i+180)*PI/180) * $Radius + $YTop;
 405
 406       if ( $this->getFirstDecimal($Xp1) > 5 )  { $XOffset1 = 1; } else { $XOffset1 = 0; }
 407       if ( $this->getFirstDecimal($Xp2) > 5 )  { $XOffset2 = 1; } else { $XOffset2 = 0; }
 408       if ( $this->getFirstDecimal($Yp) > 5 )  { $YOffset = 1; } else { $YOffset = 0; }
 409
 410       if ( !isset($Drawn[$Yp+$YOffset]) || $Alpha == 100 )
 411        imageline($this->Picture,$Xp1+$XOffset1,$Yp+$YOffset,$Xp2+$XOffset2,$Yp+$YOffset,$Color);
 412
 413       $Drawn[$Yp+$YOffset] = $Xp2;
 414
 415       $Xp1 = cos(($i+90)*PI/180) * $Radius + $X1 + $Radius;
 416       $Xp2 = cos((90-$i)*PI/180) * $Radius + $X2 - $Radius;
 417       $Yp  = sin(($i+90)*PI/180) * $Radius + $YBottom;
 418
 419       if ( $this->getFirstDecimal($Xp1) > 7 )  { $XOffset1 = 1; } else { $XOffset1 = 0; }
 420       if ( $this->getFirstDecimal($Xp2) > 7 )  { $XOffset2 = 1; } else { $XOffset2 = 0; }
 421       if ( $this->getFirstDecimal($Yp) > 5 )  { $YOffset = 1; } else { $YOffset = 0; }
 422
 423       if ( !isset($Drawn[$Yp+$YOffset]) || $Alpha == 100 )
 424        imageline($this->Picture,$Xp1+$XOffset1,$Yp+$YOffset,$Xp2+$XOffset2,$Yp+$YOffset,$Color);
 425
 426       $Drawn[$Yp+$YOffset] = $Xp2;
 427      }
 428
 429     $this->drawRoundedRectangle($X1,$Y1,$X2,$Y2,$Radius,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
 430
 431     $this->Shadow = $RestoreShadow;
 432    }
 433
 434   /* Draw a rectangle */
 435   function drawRectangle($X1,$Y1,$X2,$Y2,$Format="")
 436    {
 437     $R		= isset($Format["R"]) ? $Format["R"] : 0;
 438     $G		= isset($Format["G"]) ? $Format["G"] : 0;
 439     $B		= isset($Format["B"]) ? $Format["B"] : 0;
 440     $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
 441     $Ticks	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
 442     $NoAngle	= isset($Format["NoAngle"]) ? $Format["NoAngle"] : FALSE;
 443
 444     if ($X1 > $X2) { list($X1, $X2) = array($X2, $X1); }
 445     if ($Y1 > $Y2) { list($Y1, $Y2) = array($Y2, $Y1); }
 446
 447     if ( $this->Antialias )
 448      {
 449       if ( $NoAngle )
 450        {
 451         $this->drawLine($X1+1,$Y1,$X2-1,$Y1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
 452         $this->drawLine($X2,$Y1+1,$X2,$Y2-1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
 453         $this->drawLine($X2-1,$Y2,$X1+1,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
 454         $this->drawLine($X1,$Y1+1,$X1,$Y2-1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
 455        }
 456       else
 457        {
 458         $this->drawLine($X1+1,$Y1,$X2-1,$Y1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
 459         $this->drawLine($X2,$Y1,$X2,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
 460         $this->drawLine($X2-1,$Y2,$X1+1,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
 461         $this->drawLine($X1,$Y1,$X1,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
 462        }
 463      }
 464     else
 465      {
 466       $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
 467       imagerectangle($this->Picture,$X1,$Y1,$X2,$Y2,$Color);
 468      }
 469    }
 470
 471   /* Draw a filled rectangle */
 472   function drawFilledRectangle($X1,$Y1,$X2,$Y2,$Format="")
 473    {
 474     $R			= isset($Format["R"]) ? $Format["R"] : 0;
 475     $G			= isset($Format["G"]) ? $Format["G"] : 0;
 476     $B			= isset($Format["B"]) ? $Format["B"] : 0;
 477     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
 478     $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
 479     $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
 480     $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
 481     $BorderAlpha	= isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : $Alpha;
 482     $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
 483     $Ticks		= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
 484     $NoAngle		= isset($Format["NoAngle"]) ? $Format["NoAngle"] : NULL;
 485     $Dash		= isset($Format["Dash"]) ? $Format["Dash"] : FALSE;
 486     $DashStep		= isset($Format["DashStep"]) ? $Format["DashStep"] : 4;
 487     $DashR		= isset($Format["DashR"]) ? $Format["DashR"] : 0;
 488     $DashG		= isset($Format["DashG"]) ? $Format["DashG"] : 0;
 489     $DashB		= isset($Format["DashB"]) ? $Format["DashB"] : 0;
 490     $NoBorder		= isset($Format["NoBorder"]) ? $Format["NoBorder"] : FALSE;
 491
 492     if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
 493
 494     if ($X1 > $X2) { list($X1, $X2) = array($X2, $X1); }
 495     if ($Y1 > $Y2) { list($Y1, $Y2) = array($Y2, $Y1); }
 496
 497     $RestoreShadow = $this->Shadow;
 498     if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
 499      {
 500       $this->Shadow = FALSE;
 501       $this->drawFilledRectangle($X1+$this->ShadowX,$Y1+$this->ShadowY,$X2+$this->ShadowX,$Y2+$this->ShadowY,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa,"Ticks"=>$Ticks,"NoAngle"=>$NoAngle));
 502      }
 503
 504     $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
 505     if ( $NoAngle )
 506      {
 507       imagefilledrectangle($this->Picture,ceil($X1)+1,ceil($Y1),floor($X2)-1,floor($Y2),$Color);
 508       imageline($this->Picture,ceil($X1),ceil($Y1)+1,ceil($X1),floor($Y2)-1,$Color);
 509       imageline($this->Picture,floor($X2),ceil($Y1)+1,floor($X2),floor($Y2)-1,$Color);
 510      }
 511     else
 512      imagefilledrectangle($this->Picture,ceil($X1),ceil($Y1),floor($X2),floor($Y2),$Color);
 513
 514     if ( $Dash )
 515      {
 516       if ( $BorderR != -1 ) { $iX1=$X1+1; $iY1=$Y1+1; $iX2=$X2-1; $iY2=$Y2-1; } else { $iX1=$X1; $iY1=$Y1; $iX2=$X2; $iY2=$Y2; }
 517
 518       $Color = $this->allocateColor($this->Picture,$DashR,$DashG,$DashB,$Alpha);
 519       $Y=$iY1-$DashStep;
 520       for($X=$iX1; $X<=$iX2+($iY2-$iY1); $X=$X+$DashStep)
 521        {
 522         $Y=$Y+$DashStep;
 523         if ( $X > $iX2 ) { $Xa = $X-($X-$iX2); $Ya = $iY1+($X-$iX2); } else { $Xa = $X; $Ya = $iY1; }
 524         if ( $Y > $iY2 ) { $Xb = $iX1+($Y-$iY2); $Yb = $Y-($Y-$iY2); } else { $Xb = $iX1; $Yb = $Y; }
 525         imageline($this->Picture,$Xa,$Ya,$Xb,$Yb,$Color);
 526        }
 527      }
 528
 529     if ( $this->Antialias && !$NoBorder )
 530      {
 531       if ( $X1 < ceil($X1) )
 532        {
 533         $AlphaA = $Alpha * (ceil($X1) - $X1);
 534         $Color = $this->allocateColor($this->Picture,$R,$G,$B,$AlphaA);
 535         imageline($this->Picture,ceil($X1)-1,ceil($Y1),ceil($X1)-1,floor($Y2),$Color);
 536        }
 537
 538       if ( $Y1 < ceil($Y1) )
 539        {
 540         $AlphaA = $Alpha * (ceil($Y1) - $Y1);
 541         $Color = $this->allocateColor($this->Picture,$R,$G,$B,$AlphaA);
 542         imageline($this->Picture,ceil($X1),ceil($Y1)-1,floor($X2),ceil($Y1)-1,$Color);
 543        }
 544
 545       if ( $X2 > floor($X2) )
 546        {
 547         $AlphaA = $Alpha * (.5-($X2 - floor($X2)));
 548         $Color = $this->allocateColor($this->Picture,$R,$G,$B,$AlphaA);
 549         imageline($this->Picture,floor($X2)+1,ceil($Y1),floor($X2)+1,floor($Y2),$Color);
 550        } 
 551
 552       if ( $Y2 > floor($Y2) )
 553        {
 554         $AlphaA = $Alpha * (.5-($Y2 - floor($Y2)));
 555         $Color = $this->allocateColor($this->Picture,$R,$G,$B,$AlphaA);
 556         imageline($this->Picture,ceil($X1),floor($Y2)+1,floor($X2),floor($Y2)+1,$Color);
 557        }
 558      }
 559
 560     if ( $BorderR != -1 )
 561      $this->drawRectangle($X1,$Y1,$X2,$Y2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$Ticks,"NoAngle"=>$NoAngle));
 562
 563     $this->Shadow = $RestoreShadow;
 564    }
 565
 566   /* Draw a rectangular marker of the specified size */
 567   function drawRectangleMarker($X,$Y,$Format="")
 568    {
 569     $Size = isset($Format["Size"]) ? $Format["Size"] : 4;
 570
 571     $HalfSize = floor($Size/2);
 572     $this->drawFilledRectangle($X-$HalfSize,$Y-$HalfSize,$X+$HalfSize,$Y+$HalfSize,$Format);
 573    }
 574
 575   /* Drawn a spline based on the bezier function */
 576   function drawSpline($Coordinates,$Format="")
 577    {
 578     $R		= isset($Format["R"]) ? $Format["R"] : 0;
 579     $G		= isset($Format["G"]) ? $Format["G"] : 0;
 580     $B		= isset($Format["B"]) ? $Format["B"] : 0;
 581     $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
 582     $Force	= isset($Format["Force"]) ? $Format["Force"] : 30;
 583     $Forces	= isset($Format["Forces"]) ? $Format["Forces"] : NULL;
 584     $ShowC	= isset($Format["ShowControl"]) ? $Format["ShowControl"] : FALSE;
 585     $Ticks	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
 586     $PathOnly	= isset($Format["PathOnly"]) ? $Format["PathOnly"] : FALSE;
 587     $Weight	= isset($Format["Weight"]) ? $Format["Weight"] : NULL;
 588
 589     $Cpt = NULL; $Mode = NULL; $Result = "";
 590     for($i=1;$i<=count($Coordinates)-1;$i++)
 591      {
 592       $X1 = $Coordinates[$i-1][0]; $Y1 = $Coordinates[$i-1][1];
 593       $X2 = $Coordinates[$i][0];   $Y2 = $Coordinates[$i][1];
 594
 595       if ( $Forces != NULL ) { $Force = $Forces[$i]; }
 596
 597       /* First segment */
 598       if ( $i == 1 )
 599        { $Xv1 = $X1; $Yv1 = $Y1; }
 600       else
 601        {
 602         $Angle1 = $this->getAngle($XLast,$YLast,$X1,$Y1);
 603         $Angle2 = $this->getAngle($X1,$Y1,$X2,$Y2);
 604         $XOff = cos($Angle2 * PI / 180) * $Force + $X1;
 605         $YOff = sin($Angle2 * PI / 180) * $Force + $Y1;
 606
 607         $Xv1 = cos($Angle1 * PI / 180) * $Force + $XOff;
 608         $Yv1 = sin($Angle1 * PI / 180) * $Force + $YOff;
 609        }
 610
 611       /* Last segment */
 612       if ( $i == count($Coordinates)-1 )
 613        { $Xv2 = $X2; $Yv2 = $Y2; }
 614       else
 615        {
 616         $Angle1 = $this->getAngle($X2,$Y2,$Coordinates[$i+1][0],$Coordinates[$i+1][1]);
 617         $Angle2 = $this->getAngle($X1,$Y1,$X2,$Y2);
 618         $XOff = cos(($Angle2+180) * PI / 180) * $Force + $X2;
 619         $YOff = sin(($Angle2+180) * PI / 180) * $Force + $Y2;
 620
 621         $Xv2 = cos(($Angle1+180) * PI / 180) * $Force + $XOff;
 622         $Yv2 = sin(($Angle1+180) * PI / 180) * $Force + $YOff;
 623        }
 624
 625       $Path = $this->drawBezier($X1,$Y1,$X2,$Y2,$Xv1,$Yv1,$Xv2,$Yv2,$Format);
 626       if ($PathOnly) { $Result[] = $Path; }
 627
 628       $XLast = $X1; $YLast = $Y1;
 629      }
 630
 631     return($Result);
 632    }
 633
 634   /* Draw a bezier curve with two controls points */
 635   function drawBezier($X1,$Y1,$X2,$Y2,$Xv1,$Yv1,$Xv2,$Yv2,$Format="")
 636    {
 637     $R		= isset($Format["R"]) ? $Format["R"] : 0;
 638     $G		= isset($Format["G"]) ? $Format["G"] : 0;
 639     $B		= isset($Format["B"]) ? $Format["B"] : 0;
 640     $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
 641     $ShowC	= isset($Format["ShowControl"]) ? $Format["ShowControl"] : FALSE;
 642     $Segments	= isset($Format["Segments"]) ? $Format["Segments"] : NULL;
 643     $Ticks	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
 644     $NoDraw    = isset($Format["NoDraw"]) ? $Format["NoDraw"] : FALSE;
 645     $PathOnly  = isset($Format["PathOnly"]) ? $Format["PathOnly"] : FALSE;
 646     $Weight    = isset($Format["Weight"]) ? $Format["Weight"] : NULL;
 647     $DrawArrow		= isset($Format["DrawArrow"]) ? $Format["DrawArrow"] : FALSE;
 648     $ArrowSize		= isset($Format["ArrowSize"]) ? $Format["ArrowSize"] : 10;
 649     $ArrowRatio	= isset($Format["ArrowRatio"]) ? $Format["ArrowRatio"] : .5;
 650     $ArrowTwoHeads	= isset($Format["ArrowTwoHeads"]) ? $Format["ArrowTwoHeads"] : FALSE;
 651
 652     if ( $Segments == NULL )
 653      {
 654       $Length    = $this->getLength($X1,$Y1,$X2,$Y2);
 655       $Precision = ($Length*125)/1000;
 656      }
 657     else
 658      $Precision = $Segments;
 659
 660     $P[0]["X"] = $X1;  $P[0]["Y"] = $Y1;
 661     $P[1]["X"] = $Xv1; $P[1]["Y"] = $Yv1;
 662     $P[2]["X"] = $Xv2; $P[2]["Y"] = $Yv2;
 663     $P[3]["X"] = $X2;  $P[3]["Y"] = $Y2;
 664
 665     /* Compute the bezier points */
 666     $Q = ""; $ID = 0; $Path = "";
 667     for($i=0;$i<=$Precision;$i=$i+1)
 668      {
 669       $u = $i / $Precision;
 670
 671       $C    = "";
 672       $C[0] = (1 - $u) * (1 - $u) * (1 - $u);
 673       $C[1] = ($u * 3) * (1 - $u) * (1 - $u);
 674       $C[2] = 3 * $u * $u * (1 - $u);
 675       $C[3] = $u * $u * $u;
 676
 677       for($j=0;$j<=3;$j++)
 678        {
 679         if ( !isset($Q[$ID]) ) { $Q[$ID] = ""; }
 680         if ( !isset($Q[$ID]["X"]) ) { $Q[$ID]["X"] = 0; }
 681         if ( !isset($Q[$ID]["Y"]) ) { $Q[$ID]["Y"] = 0; }
 682
 683         $Q[$ID]["X"] = $Q[$ID]["X"] + $P[$j]["X"] * $C[$j];
 684         $Q[$ID]["Y"] = $Q[$ID]["Y"] + $P[$j]["Y"] * $C[$j];
 685        }
 686       $ID++;
 687      }        
 688     $Q[$ID]["X"] = $X2; $Q[$ID]["Y"] = $Y2;
 689
 690     if ( !$NoDraw )
 691      {
 692       /* Display the control points */
 693       if ( $ShowC && !$PathOnly )
 694        {
 695         $Xv1 = floor($Xv1); $Yv1 = floor($Yv1); $Xv2 = floor($Xv2); $Yv2 = floor($Yv2);
 696
 697         $this->drawLine($X1,$Y1,$X2,$Y2,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>30));
 698
 699         $MyMarkerSettings = array("R"=>255,"G"=>0,"B"=>0,"BorderR"=>255,"BorderB"=>255,"BorderG"=>255,"Size"=>4);
 700         $this->drawRectangleMarker($Xv1,$Yv1,$MyMarkerSettings);
 701         $this->drawText($Xv1+4,$Yv1,"v1");
 702         $MyMarkerSettings = array("R"=>0,"G"=>0,"B"=>255,"BorderR"=>255,"BorderB"=>255,"BorderG"=>255,"Size"=>4);
 703         $this->drawRectangleMarker($Xv2,$Yv2,$MyMarkerSettings);
 704         $this->drawText($Xv2+4,$Yv2,"v2");
 705        }
 706
 707       /* Draw the bezier */
 708       $LastX = NULL; $LastY = NULL; $Cpt = NULL; $Mode = NULL; $ArrowS = NULL;
 709       foreach ($Q as $Key => $Point)
 710        {
 711         $X = $Point["X"]; $Y = $Point["Y"];
 712
 713         /* Get the first segment */
 714         if ( $ArrowS == NULL && $LastX != NULL && $LastY != NULL )
 715          { $ArrowS["X2"] = $LastX; $ArrowS["Y2"] = $LastY; $ArrowS["X1"] = $X; $ArrowS["Y1"] = $Y; }
 716
 717         if ( $LastX != NULL && $LastY != NULL && !$PathOnly)
 718          list($Cpt,$Mode) = $this->drawLine($LastX,$LastY,$X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Cpt"=>$Cpt,"Mode"=>$Mode,"Weight"=>$Weight));
 719
 720         /* Get the last segment */
 721         $ArrowE["X1"] = $LastX; $ArrowE["Y1"] = $LastY; $ArrowE["X2"] = $X; $ArrowE["Y2"] = $Y;
 722
 723         $LastX = $X; $LastY = $Y;
 724        }
 725
 726       if ( $DrawArrow && !$PathOnly )
 727        {
 728         $ArrowSettings = array("FillR"=>$R,"FillG"=>$G,"FillB"=>$B,"Alpha"=>$Alpha,"Size"=>$ArrowSize,"Ratio"=>$ArrowRatio);
 729         if ( $ArrowTwoHeads )
 730          $this->drawArrow($ArrowS["X1"],$ArrowS["Y1"],$ArrowS["X2"],$ArrowS["Y2"],$ArrowSettings);
 731
 732         $this->drawArrow($ArrowE["X1"],$ArrowE["Y1"],$ArrowE["X2"],$ArrowE["Y2"],$ArrowSettings);
 733        }
 734      }
 735     return($Q);
 736    }
 737
 738   /* Draw a line between two points */
 739   function drawLine($X1,$Y1,$X2,$Y2,$Format="")
 740    {
 741     $R		= isset($Format["R"]) ? $Format["R"] : 0;
 742     $G		= isset($Format["G"]) ? $Format["G"] : 0;
 743     $B		= isset($Format["B"]) ? $Format["B"] : 0;
 744     $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
 745     $Ticks	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
 746     $Cpt	= isset($Format["Cpt"]) ? $Format["Cpt"] : 1;
 747     $Mode	= isset($Format["Mode"]) ? $Format["Mode"] : 1;
 748     $Weight	= isset($Format["Weight"]) ? $Format["Weight"] : NULL;
 749     $Threshold	= isset($Format["Threshold"]) ? $Format["Threshold"] : NULL;
 750
 751     if ( $this->Antialias == FALSE && $Ticks == NULL )
 752      {
 753       if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
 754        {
 755         $ShadowColor = $this->allocateColor($this->Picture,$this->ShadowR,$this->ShadowG,$this->ShadowB,$this->Shadowa);
 756         imageline($this->Picture,$X1+$this->ShadowX,$Y1+$this->ShadowY,$X2+$this->ShadowX,$Y2+$this->ShadowY,$ShadowColor);
 757        }
 758
 759       $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
 760       imageline($this->Picture,$X1,$Y1,$X2,$Y2,$Color);
 761       return(0);
 762      }
 763
 764     $Distance = sqrt(($X2-$X1)*($X2-$X1)+($Y2-$Y1)*($Y2-$Y1));  
 765     if ( $Distance == 0 ) { return(-1); }
 766
 767     /* Derivative algorithm for overweighted lines, re-route to polygons primitives */
 768     if ( $Weight != NULL )
 769      {
 770       $Angle        = $this->getAngle($X1,$Y1,$X2,$Y2);
 771       $PolySettings = array ("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"BorderAlpha"=>$Alpha);
 772
 773       if ( $Ticks == NULL )
 774        {
 775         $Points   = ""; 
 776         $Points[] = cos(deg2rad($Angle-90)) * $Weight + $X1; $Points[] = sin(deg2rad($Angle-90)) * $Weight + $Y1;
 777         $Points[] = cos(deg2rad($Angle+90)) * $Weight + $X1; $Points[] = sin(deg2rad($Angle+90)) * $Weight + $Y1;
 778         $Points[] = cos(deg2rad($Angle+90)) * $Weight + $X2; $Points[] = sin(deg2rad($Angle+90)) * $Weight + $Y2;
 779         $Points[] = cos(deg2rad($Angle-90)) * $Weight + $X2; $Points[] = sin(deg2rad($Angle-90)) * $Weight + $Y2;
 780
 781         $this->drawPolygon($Points,$PolySettings);
 782        }
 783       else
 784        {
 785         for($i=0;$i<=$Distance;$i=$i+$Ticks*2)
 786          {
 787           $Xa = (($X2-$X1)/$Distance) * $i + $X1; $Ya = (($Y2-$Y1)/$Distance) * $i + $Y1;
 788           $Xb = (($X2-$X1)/$Distance) * ($i+$Ticks) + $X1; $Yb = (($Y2-$Y1)/$Distance) * ($i+$Ticks) + $Y1;
 789
 790           $Points   = ""; 
 791           $Points[] = cos(deg2rad($Angle-90)) * $Weight + $Xa; $Points[] = sin(deg2rad($Angle-90)) * $Weight + $Ya;
 792           $Points[] = cos(deg2rad($Angle+90)) * $Weight + $Xa; $Points[] = sin(deg2rad($Angle+90)) * $Weight + $Ya;
 793           $Points[] = cos(deg2rad($Angle+90)) * $Weight + $Xb; $Points[] = sin(deg2rad($Angle+90)) * $Weight + $Yb;
 794           $Points[] = cos(deg2rad($Angle-90)) * $Weight + $Xb; $Points[] = sin(deg2rad($Angle-90)) * $Weight 	+ $Yb;
 795
 796           $this->drawPolygon($Points,$PolySettings);
 797          }
 798        }
 799
 800       return(1);
 801      }
 802
 803     $XStep = ($X2-$X1) / $Distance;
 804     $YStep = ($Y2-$Y1) / $Distance;
 805
 806     for($i=0;$i<=$Distance;$i++)
 807      {
 808       $X = $i * $XStep + $X1;
 809       $Y = $i * $YStep + $Y1;
 810
 811       $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
 812
 813       if ( $Threshold != NULL )
 814        {
 815         foreach($Threshold as $Key => $Parameters)
 816          {
 817           if ( $Y <= $Parameters["MinX"] && $Y >= $Parameters["MaxX"])
 818            {
 819             if ( isset($Parameters["R"]) ) { $RT = $Parameters["R"]; } else { $RT = 0; }
 820             if ( isset($Parameters["G"]) ) { $GT = $Parameters["G"]; } else { $GT = 0; }
 821             if ( isset($Parameters["B"]) ) { $BT = $Parameters["B"]; } else { $BT = 0; }
 822             if ( isset($Parameters["Alpha"]) ) { $AlphaT = $Parameters["Alpha"]; } else { $AlphaT = 0; }
 823             $Color = array("R"=>$RT,"G"=>$GT,"B"=>$BT,"Alpha"=>$AlphaT);
 824            }
 825          }
 826        }
 827
 828       if ( $Ticks != NULL )
 829        {
 830         if ( $Cpt % $Ticks == 0 )
 831          { $Cpt = 0; if ( $Mode == 1 ) { $Mode = 0; } else { $Mode = 1; } }
 832
 833         if ( $Mode == 1 )
 834          $this->drawAntialiasPixel($X,$Y,$Color);
 835
 836         $Cpt++;
 837        }
 838       else
 839        $this->drawAntialiasPixel($X,$Y,$Color);
 840      }
 841
 842     return(array($Cpt,$Mode));
 843    }
 844
 845   /* Draw a circle */
 846   function drawCircle($Xc,$Yc,$Height,$Width,$Format="")
 847    {
 848     $R	    = isset($Format["R"]) ? $Format["R"] : 0;
 849     $G	    = isset($Format["G"]) ? $Format["G"] : 0;
 850     $B	    = isset($Format["B"]) ? $Format["B"] : 0;
 851     $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
 852     $Ticks = isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
 853
 854     $Height	= abs($Height);
 855     $Width	= abs($Width);
 856
 857     if ( $Height == 0 ) { $Height = 1; }
 858     if ( $Width == 0 )  { $Width = 1; }
 859     $Xc = floor($Xc); $Yc = floor($Yc);
 860
 861     $RestoreShadow = $this->Shadow;
 862     if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
 863      {
 864       $this->Shadow = FALSE;
 865       $this->drawCircle($Xc+$this->ShadowX,$Yc+$this->ShadowY,$Height,$Width,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa,"Ticks"=>$Ticks));
 866      }
 867
 868     if ( $Width == 0 ) { $Width = $Height; }
 869     if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
 870     if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
 871     if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }
 872
 873     $Step = 360 / (2 * PI * max($Width,$Height));
 874     $Mode = 1; $Cpt = 1;
 875     for($i=0;$i<=360;$i=$i+$Step)
 876      {
 877       $X = cos($i*PI/180) * $Height + $Xc;
 878       $Y = sin($i*PI/180) * $Width + $Yc;
 879
 880       if ( $Ticks != NULL )
 881        {
 882         if ( $Cpt % $Ticks == 0 )
 883          { $Cpt = 0; if ( $Mode == 1 ) { $Mode = 0; } else { $Mode = 1; } }
 884
 885         if ( $Mode == 1 )
 886          $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
 887
 888         $Cpt++;
 889        }
 890       else
 891        $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
 892
 893      }
 894     $this->Shadow = $RestoreShadow;
 895    }
 896
 897   /* Draw a filled circle */
 898   function drawFilledCircle($X,$Y,$Radius,$Format="")
 899    {
 900     $R			= isset($Format["R"]) ? $Format["R"] : 0;
 901     $G			= isset($Format["G"]) ? $Format["G"] : 0;
 902     $B			= isset($Format["B"]) ? $Format["B"] : 0;
 903     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
 904     $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
 905     $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
 906     $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
 907     $BorderAlpha	= isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : $Alpha;
 908     $Ticks     	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
 909     $Surrounding 	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
 910
 911     if ( $Radius == 0 ) { $Radius = 1; }
 912     if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
 913     $X = floor($X); $Y = floor($Y);
 914
 915     $Radius = abs($Radius);
 916
 917     $RestoreShadow = $this->Shadow;
 918     if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
 919      {
 920       $this->Shadow = FALSE;
 921       $this->drawFilledCircle($X+$this->ShadowX,$Y+$this->ShadowY,$Radius,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa,"Ticks"=>$Ticks));
 922      }
 923
 924     $this->Mask  = "";
 925     $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
 926     for ($i=0; $i<=$Radius*2; $i++)
 927      {
 928       $Slice  = sqrt($Radius * $Radius - ($Radius - $i) * ($Radius - $i));
 929       $XPos   = floor($Slice);
 930       $YPos   = $Y + $i - $Radius;
 931       $AAlias = $Slice - floor($Slice);
 932
 933       $this->Mask[$X-$XPos][$YPos] = TRUE;
 934       $this->Mask[$X+$XPos][$YPos] = TRUE;
 935       imageline($this->Picture,$X-$XPos,$YPos,$X+$XPos,$YPos,$Color);
 936      }
 937     if ( $this->Antialias )
 938      $this->drawCircle($X,$Y,$Radius,$Radius,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
 939
 940     $this->Mask = "";
 941
 942     if ( $BorderR != -1 )
 943      $this->drawCircle($X,$Y,$Radius,$Radius,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$Ticks));
 944
 945     $this->Shadow	= $RestoreShadow;
 946    }
 947
 948   /* Write text */
 949   function drawText($X,$Y,$Text,$Format="")
 950    {
 951     $R			= isset($Format["R"]) ? $Format["R"] : $this->FontColorR;
 952     $G			= isset($Format["G"]) ? $Format["G"] : $this->FontColorG;
 953     $B			= isset($Format["B"]) ? $Format["B"] : $this->FontColorB;
 954     $Angle		= isset($Format["Angle"]) ? $Format["Angle"] : 0;
 955     $Align		= isset($Format["Align"]) ? $Format["Align"] : TEXT_ALIGN_BOTTOMLEFT;
 956     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : $this->FontColorA;
 957     $FontName		= isset($Format["FontName"]) ? $Format["FontName"] : $this->FontName;
 958     $FontSize		= isset($Format["FontSize"]) ? $Format["FontSize"] : $this->FontSize;
 959     $ShowOrigine	= isset($Format["ShowOrigine"]) ? $Format["ShowOrigine"] : FALSE;
 960     $TOffset		= isset($Format["TOffset"]) ? $Format["TOffset"] : 2;
 961     $DrawBox		= isset($Format["DrawBox"]) ? $Format["DrawBox"] : FALSE;
 962     $DrawBoxBorder	= isset($Format["DrawBoxBorder"]) ? $Format["DrawBoxBorder"] : TRUE;
 963     $BorderOffset	= isset($Format["BorderOffset"]) ? $Format["BorderOffset"] : 6;
 964     $BoxRounded	= isset($Format["BoxRounded"]) ? $Format["BoxRounded"] : FALSE;
 965     $RoundedRadius	= isset($Format["RoundedRadius"]) ? $Format["RoundedRadius"] : 6;
 966     $BoxR		= isset($Format["BoxR"]) ? $Format["BoxR"] : 255;
 967     $BoxG		= isset($Format["BoxG"]) ? $Format["BoxG"] : 255;
 968     $BoxB		= isset($Format["BoxB"]) ? $Format["BoxB"] : 255;
 969     $BoxAlpha		= isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 50;
 970     $BoxSurrounding	= isset($Format["BoxSurrounding"]) ? $Format["BoxSurrounding"] : "";
 971     $BoxBorderR	= isset($Format["BoxR"]) ? $Format["BoxR"] : 0;
 972     $BoxBorderG	= isset($Format["BoxG"]) ? $Format["BoxG"] : 0;
 973     $BoxBorderB	= isset($Format["BoxB"]) ? $Format["BoxB"] : 0;
 974     $BoxBorderAlpha	= isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 50;
 975     $NoShadow		= isset($Format["NoShadow"]) ? $Format["NoShadow"] : FALSE;
 976
 977     $Shadow = $this->Shadow;
 978     if ( $NoShadow ) { $this->Shadow = FALSE; }
 979
 980     if ( $BoxSurrounding != "" ) { $BoxBorderR = $BoxR - $BoxSurrounding; $BoxBorderG = $BoxG - $BoxSurrounding; $BoxBorderB = $BoxB - $BoxSurrounding; $BoxBorderAlpha = $BoxAlpha; }
 981
 982     if ( $ShowOrigine )
 983      {
 984       $MyMarkerSettings = array("R"=>255,"G"=>0,"B"=>0,"BorderR"=>255,"BorderB"=>255,"BorderG"=>255,"Size"=>4);
 985       $this->drawRectangleMarker($X,$Y,$MyMarkerSettings);
 986      }
 987
 988     $TxtPos = $this->getTextBox($X,$Y,$FontName,$FontSize,$Angle,$Text);
 989
 990     if ( $DrawBox && ($Angle == 0 || $Angle == 90 || $Angle == 180 || $Angle == 270))
 991      {
 992       $T[0]["X"]=0;$T[0]["Y"]=0;$T[1]["X"]=0;$T[1]["Y"]=0;$T[2]["X"]=0;$T[2]["Y"]=0;$T[3]["X"]=0;$T[3]["Y"]=0;
 993       if ( $Angle == 0 ) { $T[0]["X"]=-$TOffset;$T[0]["Y"]=$TOffset;$T[1]["X"]=$TOffset;$T[1]["Y"]=$TOffset;$T[2]["X"]=$TOffset;$T[2]["Y"]=-$TOffset;$T[3]["X"]=-$TOffset;$T[3]["Y"]=-$TOffset; }
 994
 995       $X1 = min($TxtPos[0]["X"],$TxtPos[1]["X"],$TxtPos[2]["X"],$TxtPos[3]["X"]) - $BorderOffset + 3;
 996       $Y1 = min($TxtPos[0]["Y"],$TxtPos[1]["Y"],$TxtPos[2]["Y"],$TxtPos[3]["Y"]) - $BorderOffset;
 997       $X2 = max($TxtPos[0]["X"],$TxtPos[1]["X"],$TxtPos[2]["X"],$TxtPos[3]["X"]) + $BorderOffset + 3;
 998       $Y2 = max($TxtPos[0]["Y"],$TxtPos[1]["Y"],$TxtPos[2]["Y"],$TxtPos[3]["Y"]) + $BorderOffset - 3;
 999
1000       $X1 = $X1 - $TxtPos[$Align]["X"] + $X + $T[0]["X"];
1001       $Y1 = $Y1 - $TxtPos[$Align]["Y"] + $Y + $T[0]["Y"];
1002       $X2 = $X2 - $TxtPos[$Align]["X"] + $X + $T[0]["X"];
1003       $Y2 = $Y2 - $TxtPos[$Align]["Y"] + $Y + $T[0]["Y"];
1004
1005       $Settings = array("R"=>$BoxR,"G"=>$BoxG,"B"=>$BoxB,"Alpha"=>$BoxAlpha,"BorderR"=>$BoxBorderR,"BorderG"=>$BoxBorderG,"BorderB"=>$BoxBorderB,"BorderAlpha"=>$BoxBorderAlpha);
1006
1007       if ( $BoxRounded )
1008        { $this->drawRoundedFilledRectangle($X1,$Y1,$X2,$Y2,$RoundedRadius,$Settings); }
1009       else
1010        { $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,$Settings); }
1011      }
1012
1013     $X = $X - $TxtPos[$Align]["X"] + $X;
1014     $Y = $Y - $TxtPos[$Align]["Y"] + $Y;
1015
1016     if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
1017      {
1018       $C_ShadowColor = $this->allocateColor($this->Picture,$this->ShadowR,$this->ShadowG,$this->ShadowB,$this->Shadowa);
1019       imagettftext($this->Picture,$FontSize,$Angle,$X+$this->ShadowX,$Y+$this->ShadowY,$C_ShadowColor,$FontName,$this->getEncodedText($Text));
1020      }
1021
1022     $C_TextColor = $this->AllocateColor($this->Picture,$R,$G,$B,$Alpha);
1023     imagettftext($this->Picture,$FontSize,$Angle,$X,$Y,$C_TextColor,$FontName,$this->getEncodedText($Text));
1024
1025     $this->Shadow = $Shadow;
1026
1027     return($TxtPos);
1028    }
1029
1030     function getEncodedText($text)
1031     {
1032         $gdinfo = gd_info();
1033         if (!empty($gdinfo['JIS-mapped Japanese Font Support'])) {
1034             return mb_convert_encoding($text, "SJIS", "UTF-8");
1035         }
1036
1037         return $text;
1038     }
1039
1040   /* Draw a gradient within a defined area */
1041   function drawGradientArea($X1,$Y1,$X2,$Y2,$Direction,$Format="")
1042    {
1043     $StartR	= isset($Format["StartR"]) ? $Format["StartR"] : 90;
1044     $StartG	= isset($Format["StartG"]) ? $Format["StartG"] : 90;
1045     $StartB	= isset($Format["StartB"]) ? $Format["StartB"] : 90;
1046     $EndR	= isset($Format["EndR"]) ? $Format["EndR"] : 0;
1047     $EndG	= isset($Format["EndG"]) ? $Format["EndG"] : 0;
1048     $EndB	= isset($Format["EndB"]) ? $Format["EndB"] : 0;
1049     $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
1050     $Levels	= isset($Format["Levels"]) ? $Format["Levels"] : NULL;
1051
1052     $Shadow = $this->Shadow;
1053     $this->Shadow = FALSE;
1054
1055     if ( $StartR == $EndR && $StartG == $EndG && $StartB == $EndB )
1056      {
1057       $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,array("R"=>$StartR,"G"=>$StartG,"B"=>$StartB,"Alpha"=>$Alpha));
1058       return(0);
1059      }
1060
1061     if ( $Levels != NULL )
1062      { $EndR=$StartR+$Levels; $EndG=$StartG+$Levels; $EndB=$StartB+$Levels; }
1063
1064     if ($X1 > $X2) { list($X1, $X2) = array($X2, $X1); }
1065     if ($Y1 > $Y2) { list($Y1, $Y2) = array($Y2, $Y1); }
1066
1067     if ( $Direction == DIRECTION_VERTICAL )   { $Width = abs($Y2-$Y1); }
1068     if ( $Direction == DIRECTION_HORIZONTAL ) { $Width = abs($X2-$X1); }
1069
1070     $Step     = max(abs($EndR-$StartR),abs($EndG-$StartG),abs($EndB-$StartB));
1071     $StepSize = $Width/$Step;
1072     $RStep    = ($EndR-$StartR)/$Step;
1073     $GStep    = ($EndG-$StartG)/$Step;
1074     $BStep    = ($EndB-$StartB)/$Step;
1075
1076     $R=$StartR;$G=$StartG;$B=$StartB;
1077     switch($Direction)
1078      {
1079       case DIRECTION_VERTICAL:
1080        $StartY = $Y1; $EndY = floor($Y2)+1; $LastY2 = $StartY;
1081        for($i=0;$i<=$Step;$i++)
1082         {
1083          $Y2 = floor($StartY + ($i * $StepSize));
1084
1085          if ($Y2 > $EndY) { $Y2 = $EndY; }
1086          if (($Y1 != $Y2 && $Y1 < $Y2) || $Y2 == $EndY)
1087           {
1088            $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
1089            $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,$Color);
1090            $LastY2 = max($LastY2,$Y2);
1091            $Y1 = $Y2+1;
1092           }
1093          $R = $R + $RStep; $G = $G + $GStep; $B = $B + $BStep;
1094         }
1095        if ( $LastY2 < $EndY && isset($Color)) { for ($i=$LastY2+1;$i<=$EndY;$i++) { $this->drawLine($X1,$i,$X2,$i,$Color); } }
1096        break;
1097
1098       case DIRECTION_HORIZONTAL:
1099        $StartX = $X1; $EndX = $X2;
1100        for($i=0;$i<=$Step;$i++)
1101         {
1102          $X2 = floor($StartX + ($i * $StepSize));
1103
1104          if ($X2 > $EndX) { $X2 = $EndX; }
1105          if (($X1 != $X2 && $X1 < $X2) || $X2 == $EndX)
1106           {
1107            $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
1108            $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,$Color);
1109            $X1 = $X2+1;
1110           }
1111          $R = $R + $RStep; $G = $G + $GStep; $B = $B + $BStep; 
1112         }
1113        if ( $X2 < $EndX && isset($Color)) { $this->drawFilledRectangle($X2,$Y1,$EndX,$Y2,$Color); }
1114        break;
1115      }
1116
1117     $this->Shadow = $Shadow;
1118
1119    }
1120
1121   /* Draw an aliased pixel */
1122   function drawAntialiasPixel($X,$Y,$Format="")
1123    {
1124     $R     = isset($Format["R"]) ? $Format["R"] : 0;
1125     $G     = isset($Format["G"]) ? $Format["G"] : 0;
1126     $B     = isset($Format["B"]) ? $Format["B"] : 0;
1127     $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
1128
1129     if ( $X < 0 || $Y < 0 || $X >= $this->XSize || $Y >= $this->YSize )
1130      return(-1);
1131
1132     if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
1133     if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
1134     if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }
1135
1136     if ( !$this->Antialias )
1137      {
1138       if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
1139        {
1140         $ShadowColor = $this->allocateColor($this->Picture,$this->ShadowR,$this->ShadowG,$this->ShadowB,$this->Shadowa);
1141         imagesetpixel($this->Picture,$X+$this->ShadowX,$Y+$this->ShadowY,$ShadowColor);
1142        }
1143
1144       $PlotColor = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
1145       imagesetpixel($this->Picture,$X,$Y,$PlotColor);
1146
1147       return(0);
1148      }
1149
1150     $Plot = "";
1151     $Xi   = floor($X);
1152     $Yi   = floor($Y);
1153
1154     if ( $Xi == $X && $Yi == $Y)
1155      {
1156       if ( $Alpha == 100 )
1157        $this->drawAlphaPixel($X,$Y,100,$R,$G,$B);
1158       else
1159        $this->drawAlphaPixel($X,$Y,$Alpha,$R,$G,$B);
1160      }
1161     else
1162      {
1163       $Alpha1 = (((1 - ($X - floor($X))) * (1 - ($Y - floor($Y))) * 100) / 100) * $Alpha;
1164       if ( $Alpha1 > $this->AntialiasQuality ) { $this->drawAlphaPixel($Xi,$Yi,$Alpha1,$R,$G,$B); }
1165
1166       $Alpha2 = ((($X - floor($X)) * (1 - ($Y - floor($Y))) * 100) / 100) * $Alpha;
1167       if ( $Alpha2 > $this->AntialiasQuality ) { $this->drawAlphaPixel($Xi+1,$Yi,$Alpha2,$R,$G,$B); }
1168
1169       $Alpha3 = (((1 - ($X - floor($X))) * ($Y - floor($Y)) * 100) / 100) * $Alpha;
1170       if ( $Alpha3 > $this->AntialiasQuality ) { $this->drawAlphaPixel($Xi,$Yi+1,$Alpha3,$R,$G,$B); }
1171
1172       $Alpha4 = ((($X - floor($X)) * ($Y - floor($Y)) * 100) / 100) * $Alpha;
1173       if ( $Alpha4 > $this->AntialiasQuality ) { $this->drawAlphaPixel($Xi+1,$Yi+1,$Alpha4,$R,$G,$B); }
1174      }
1175    }
1176
1177   /* Draw a semi-transparent pixel */
1178   function drawAlphaPixel($X,$Y,$Alpha,$R,$G,$B)
1179    {
1180     if ( isset($this->Mask[$X])) { if ( isset($this->Mask[$X][$Y]) ) { return(0); } }
1181
1182     if ( $X < 0 || $Y < 0 || $X >= $this->XSize || $Y >= $this->YSize )
1183      return(-1);
1184
1185     if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
1186     if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
1187     if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }
1188
1189     if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
1190      {
1191       $AlphaFactor = floor(($Alpha / 100) * $this->Sha…

Large files files are truncated, but you can click here to view the full file