function Stroke(Image $aImg, $x = null, $y = null) { if ($x !== null) { $this->x = round($x); } if ($y !== null) { $this->y = round($y); } // Insert newlines if ($this->iWordwrap > 0) { $this->t = wordwrap($this->t, $this->iWordwrap, "\n"); } // If position been given as a fraction of the image size // calculate the absolute position if ($this->x < 1 && $this->x > 0) { $this->x *= $aImg->width; } if ($this->y < 1 && $this->y > 0) { $this->y *= $aImg->height; } $aImg->PushColor($this->color); $aImg->SetFont($this->font_family, $this->font_style, $this->raw_font_size); $aImg->SetTextAlign($this->halign, $this->valign); if ($this->boxed) { if ($this->fcolor == "nofill") { $this->fcolor = false; } $oldweight = $aImg->SetLineWeight(1); if ($this->iBoxType == 2 && $this->font_family > FF_FONT2 + 2) { $bbox = $aImg->StrokeBoxedText2($this->x, $this->y, $this->t, $this->dir, $this->fcolor, $this->bcolor, $this->shadow, $this->paragraph_align, 2, 4, $this->icornerradius, $this->ishadowwidth); } else { $bbox = $aImg->StrokeBoxedText($this->x, $this->y, $this->t, $this->dir, $this->fcolor, $this->bcolor, $this->shadow, $this->paragraph_align, 3, 3, $this->icornerradius, $this->ishadowwidth); } $aImg->SetLineWeight($oldweight); } else { $debug = false; $bbox = $aImg->StrokeText($this->x, $this->y, $this->t, $this->dir, $this->paragraph_align, $debug); } // Create CSIM targets $coords = $bbox[0] . ',' . $bbox[1] . ',' . $bbox[2] . ',' . $bbox[3] . ',' . $bbox[4] . ',' . $bbox[5] . ',' . $bbox[6] . ',' . $bbox[7]; $this->iCSIMarea = "<area shape=\"poly\" coords=\"{$coords}\" href=\"" . htmlentities($this->iCSIMtarget) . "\" "; if (trim($this->iCSIMalt) != '') { $this->iCSIMarea .= " alt=\"" . $this->iCSIMalt . "\" "; $this->iCSIMarea .= " title=\"" . $this->iCSIMalt . "\" "; } if (trim($this->iCSIMWinTarget) != '') { $this->iCSIMarea .= " target=\"" . $this->iCSIMWinTarget . "\" "; } $this->iCSIMarea .= " />\n"; $aImg->PopColor($this->color); }
function _StrokeTicks(Image $aImg, LinearScale $aScale, $aPos) { $hor = $aScale->type == 'x'; $aImg->SetLineWeight($this->weight); // We need to make this an int since comparing it below // with the result from round() can give wrong result, such that // (40 < 40) == TRUE !!! $limit = (int) $aScale->scale_abs[1]; // A text scale doesn't have any minor ticks if (!$aScale->textscale) { // Stroke minor ticks $yu = $aPos - $this->direction * $this->GetMinTickAbsSize(); $xr = $aPos + $this->direction * $this->GetMinTickAbsSize(); $n = count($this->ticks_pos); for ($i = 0; $i < $n; ++$i) { if (!$this->supress_tickmarks && !$this->supress_minor_tickmarks) { if ($this->mincolor != '') { $aImg->PushColor($this->mincolor); } if ($hor) { //if( $this->ticks_pos[$i] <= $limit ) $aImg->Line($this->ticks_pos[$i], $aPos, $this->ticks_pos[$i], $yu); } else { //if( $this->ticks_pos[$i] >= $limit ) $aImg->Line($aPos, $this->ticks_pos[$i], $xr, $this->ticks_pos[$i]); } if ($this->mincolor != '') { $aImg->PopColor(); } } } } // Stroke major ticks $yu = $aPos - $this->direction * $this->GetMajTickAbsSize(); $xr = $aPos + $this->direction * $this->GetMajTickAbsSize(); $nbrmajticks = round(($aScale->GetMaxVal() - $aScale->GetMinVal() - $this->text_label_start) / $this->major_step) + 1; $n = count($this->maj_ticks_pos); for ($i = 0; $i < $n; ++$i) { if (!($this->xtick_offset > 0 && $i == $nbrmajticks - 1) && !$this->supress_tickmarks) { if ($this->majcolor != '') { $aImg->PushColor($this->majcolor); } if ($hor) { //if( $this->maj_ticks_pos[$i] <= $limit ) $aImg->Line($this->maj_ticks_pos[$i], $aPos, $this->maj_ticks_pos[$i], $yu); } else { //if( $this->maj_ticks_pos[$i] >= $limit ) $aImg->Line($aPos, $this->maj_ticks_pos[$i], $xr, $this->maj_ticks_pos[$i]); } if ($this->majcolor != '') { $aImg->PopColor(); } } } }