note 36236 added to function.imageline

From: Date: Thu, 02 Oct 2003 01:33:35 +0000
Subject: note 36236 added to function.imageline
Groups: php.notes 
Request: Send a blank email to php-notes+get-57574@lists.php.net to get a copy of this message
# antialiased lines with true-type-fonts !? # yip, it works - not very good - but faster # (below 3 sec) than other routines (~7 sec) # i saw here. # the antialiased effect is minimal and only # at the top of the line - but, as better as # nothing ;) # here is a drawLine routine from Logan Gunthorpe # (logang@deltatee.com) posted by nanobot@chipx86.com # on php.net and enhanced/optimized by myself :) function drawSoftLine ($image, $x1, $y1, $x2, $y2, $r,$g,$b) { $fontfile="arial.ttf"; # the font for the dot $str="·" ; # the point_char for the dot $size=12; # the point for the dot_size $color = ImageColorAllocate ($image, $r,$g,$b); if ($x2 == $x1) { $tmp = $x1; $x1 = $y1; $y1 = $tmp; $tmp = $x2; $x2 = $y2; $y2 = $tmp; $swapx = true; } $m = (float)(( $y2 - $y1 ) / ( $x2 - $x1 )); $b = (float)($y1 - $m*$x1); $strx = min ( $x1 , $x2 ); $endx = max ( $x1 , $x2 ); $x=(int)0; # the original loop was based on one for_loop # with the if_swap inside. to speed up this loop # i double it, to keep off the permanent if_call's. if (!$swapx) { for ($x = $strx; $x <= $endx; $x++) { $y = (int)($m*$x + $b); imagettftext($image, $size, 0, $x, $y, $color, $fontfile,$str); } } else { for ($x = $strx; $x <= $endx; $x++) { $y = (int)($m*$x + $b); imagettftext($image, $size, 0, $y, $x, $color, $fontfile,$str); } } } ---- Manual Page -- http://www.php.net/manual/en/function.imageline.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36236 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36236&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36236&report=yes

« previous php.notes (#57574) next »