|
/* Write text */
function drawText($X,$Y,$Text,$Format="")
{
$R = isset($Format["R"]) ? $Format["R"] : $this->FontColorR;
$G = isset($Format["G"]) ? $Format["G"] : $this->FontColorG;
$B = isset($Format["B"]) ? $Format["B"] : $this->FontColorB;
$Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0;
$Align = isset($Format["Align"]) ? $Format["Align"] : TEXT_ALIGN_BOTTOMLEFT;
$Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : $this->FontColorA;
$FontName = isset($Format["FontName"]) ? $Format["FontName"] : $this->FontName;
$FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : $this->FontSize;
$ShowOrigine = isset($Format["ShowOrigine"]) ? $Format["ShowOrigine"] : FALSE;
$TOffset = isset($Format["TOffset"]) ? $Format["TOffset"] : 2;
$DrawBox = isset($Format["DrawBox"]) ? $Format["DrawBox"] : FALSE;
$DrawBoxBorder = isset($Format["DrawBoxBorder"]) ? $Format["DrawBoxBorder"] : TRUE;
$BorderOffset = isset($Format["BorderOffset"]) ? $Format["BorderOffset"] : 6;
$BoxRounded = isset($Format["BoxRounded"]) ? $Format["BoxRounded"] : FALSE;
$RoundedRadius = isset($Format["RoundedRadius"]) ? $Format["RoundedRadius"] : 6;
$BoxR = isset($Format["BoxR"]) ? $Format["BoxR"] : 255;
$BoxG = isset($Format["BoxG"]) ? $Format["BoxG"] : 255;
$BoxB = isset($Format["BoxB"]) ? $Format["BoxB"] : 255;
$BoxAlpha = isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 50;
$BoxSurrounding = isset($Format["BoxSurrounding"]) ? $Format["BoxSurrounding"] : "";
$BoxBorderR = isset($Format["BoxR"]) ? $Format["BoxR"] : 0;
$BoxBorderG = isset($Format["BoxG"]) ? $Format["BoxG"] : 0;
$BoxBorderB = isset($Format["BoxB"]) ? $Format["BoxB"] : 0;
$BoxBorderAlpha = isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 50;
$NoShadow = isset($Format["NoShadow"]) ? $Format["NoShadow"] : FALSE;
$Shadow = $this->Shadow;
if ( $NoShadow ) { $this->Shadow = FALSE; }
if ( $BoxSurrounding != "" ) { $BoxBorderR = $BoxR - $BoxSurrounding; $BoxBorderG = $BoxG - $BoxSurrounding; $BoxBorderB = $BoxB - $BoxSurrounding; $BoxBorderAlpha = $BoxAlpha; }
if ( $ShowOrigine )
{
$MyMarkerSettings = array("R"=>255,"G"=>0,"B"=>0,"BorderR"=>255,"BorderB"=>255,"BorderG"=>255,"Size"=>4);
$this->drawRectangleMarker($X,$Y,$MyMarkerSettings);
}
$TxtPos = $this->getTextBox($X,$Y,$FontName,$FontSize,$Angle,$Text);
if ( $DrawBox && ($Angle == 0 || $Angle == 90 || $Angle == 180 || $Angle == 270))
{
$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;
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; }
$X1 = min($TxtPos[0]["X"],$TxtPos[1]["X"],$TxtPos[2]["X"],$TxtPos[3]["X"]) - $BorderOffset + 3;
$Y1 = min($TxtPos[0]["Y"],$TxtPos[1]["Y"],$TxtPos[2]["Y"],$TxtPos[3]["Y"]) - $BorderOffset;
$X2 = max($TxtPos[0]["X"],$TxtPos[1]["X"],$TxtPos[2]["X"],$TxtPos[3]["X"]) + $BorderOffset + 3;
$Y2 = max($TxtPos[0]["Y"],$TxtPos[1]["Y"],$TxtPos[2]["Y"],$TxtPos[3]["Y"]) + $BorderOffset - 3;
$X1 = $X1 - $TxtPos[$Align]["X"] + $X + $T[0]["X"];
$Y1 = $Y1 - $TxtPos[$Align]["Y"] + $Y + $T[0]["Y"];
$X2 = $X2 - $TxtPos[$Align]["X"] + $X + $T[0]["X"];
$Y2 = $Y2 - $TxtPos[$Align]["Y"] + $Y + $T[0]["Y"];
$Settings = array("R"=>$BoxR,"G"=>$BoxG,"B"=>$BoxB,"Alpha"=>$BoxAlpha,"BorderR"=>$BoxBorderR,"BorderG"=>$BoxBorderG,"BorderB"=>$BoxBorderB,"BorderAlpha"=>$BoxBorderAlpha);
if ( $BoxRounded )
{ $this->drawRoundedFilledRectangle($X1,$Y1,$X2,$Y2,$RoundedRadius,$Settings); }
else
{ $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,$Settings); }
}
$X = $X - $TxtPos[$Align]["X"] + $X;
$Y = $Y - $TxtPos[$Align]["Y"] + $Y;
if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
{
$C_ShadowColor = $this->allocateColor($this->Picture,$this->ShadowR,$this->ShadowG,$this->ShadowB,$this->Shadowa);
imagettftext($this->Picture,$FontSize,$Angle,$X+$this->ShadowX,$Y+$this->ShadowY,$C_ShadowColor,$FontName,$Text);
}
$C_TextColor = $this->AllocateColor($this->Picture,$R,$G,$B,$Alpha);
imagettftext($this->Picture,$FontSize,$Angle,$X,$Y,$C_TextColor,$FontName,$Text);
$this->Shadow = $Shadow;
return($TxtPos);
}
|
|