You are here

function pBarcode39::getSize in Visitors 7

Same name and namespace in other branches
  1. 7.2 pChart/class/pBarcode39.class.php \pBarcode39::getSize()

File

pChart/class/pBarcode39.class.php, line 50

Class

pBarcode39

Code

function getSize($TextString, $Format = "") {
  $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0;
  $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE;
  $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5;
  $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE;
  $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : 12;
  $Height = isset($Format["Height"]) ? $Format["Height"] : 30;
  $TextString = $this
    ->encode39($TextString);
  $BarcodeLength = strlen($this->Result);
  if ($DrawArea) {
    $WOffset = 20;
  }
  else {
    $WOffset = 0;
  }
  if ($ShowLegend) {
    $HOffset = $FontSize + $LegendOffset + $WOffset;
  }
  else {
    $HOffset = 0;
  }
  $X1 = cos($Angle * PI / 180) * ($WOffset + $BarcodeLength);
  $Y1 = sin($Angle * PI / 180) * ($WOffset + $BarcodeLength);
  $X2 = $X1 + cos(($Angle + 90) * PI / 180) * ($HOffset + $Height);
  $Y2 = $Y1 + sin(($Angle + 90) * PI / 180) * ($HOffset + $Height);
  $AreaWidth = max(abs($X1), abs($X2));
  $AreaHeight = max(abs($Y1), abs($Y2));
  return array(
    "Width" => $AreaWidth,
    "Height" => $AreaHeight,
  );
}