note 25650 added to function.pdf-lineto

From: Date: Tue, 01 Oct 2002 15:32:02 +0000
Subject: note 25650 added to function.pdf-lineto
Groups: php.notes 
Request: Send a blank email to php-notes+get-37470@lists.php.net to get a copy of this message
function pdf_arrow ($pdfobj, $x1, $y1, $x2, $y2, $dashed) { // This function will draw, stroke, and fill a line // from (x1,y1) to (x2,y2) with an arrowhead defined // by $headangle (in degrees) and $arrowlength. // If $dashed is nonzero, a dashed line is drawn. // REQUIRES: find_angle $headangle = 20; $arrowlength = 20; list ($angle, $slope) = find_angle($x1, $y1, $x2, $y2); pdf_moveto($pdfobj, $x2, $y2); // Find the two other points of the arrowhead // using $headangle and $arrowlength. $xarrow1 = $x2+cos(deg2rad(180+$angle+$headangle/2))*$arrowlength; $yarrow1 = $y2+sin(deg2rad(180+$angle+$headangle/2))*$arrowlength; $xarrow2 = $x2+cos(deg2rad(180+$angle-$headangle/2))*$arrowlength; $yarrow2 = $y2+sin(deg2rad(180+$angle-$headangle/2))*$arrowlength; // Draw two legs of the arrowhead, close and fill pdf_lineto($pdfobj, $xarrow1, $yarrow1); pdf_lineto($pdfobj, $xarrow2, $yarrow2); pdf_closepath($pdfobj); pdf_fill($pdfobj); // Find the point bisecting the short side // of the arrowhead. This is necessary so // the end of the line doesn't poke out the // beyond the arrow point. $x2line = ($xarrow1+$xarrow2)/2; $y2line = ($yarrow1+$yarrow2)/2; // Now draw the "body" line of the arrow if ($dashed != 0) { pdf_setdash($pdfobj,5,5); } pdf_moveto($pdfobj, $x1, $y1); pdf_lineto($pdfobj, $x2line, $y2line); pdf_stroke($pdfobj); } -- http://www.php.net/manual/en/function.pdf-lineto.php http://master.php.net/manage/user-notes.php?action=edit+25650 http://master.php.net/manage/user-notes.php?action=delete+25650 http://master.php.net/manage/user-notes.php?action=reject+25650

« previous php.notes (#37470) next »