Algorithm-Line-Bresenham
view release on metacpan or search on metacpan
lib/Algorithm/Line/Bresenham.pm view on Meta::CPAN
Draws a line thickened using Murphy's modication of Bresenham'salgorithm
between two points of x,y pairs. This routine was further enahnced to
provide variable thickness lines and uses multiple helper subroutines.
=head2 C<varthick_line>
my @points= varthick_line($x0,$y0,$x1,$y1,$leftFn,$argL,$rightFn,$argR)
Variable thickness lines are implemented as described in
http://kt8216.unixcab.org/murphy/index.html ; This allows passing of
two subroutine references (so the left side and the right sides of the
line can have differently varying thicknesses) along with a
user originated parameter. The subroutine reference example is shown below:
my $leftFn=sub{
my ($arg,$p,$l)=@_;
# C<$arg> is passed by calling routine,
# C<$p> is point on line
# C<$l> is length of line
return $p % $arg;
};
=cut
## Variable thickness lines using Murphy's Modification of Bresenham Line Algorithm**
## Codes ported from C in http://kt8216.unixcab.org/murphy/index.html
#* X BASED LINES *
sub x_perpendicular{
my ($x0,$y0,$dx,$dy,$xstep,$ystep,$einit,$w_left,$w_right,$winit)=@_;
my @pts;
my $threshold = $dx - 2*$dy;
my $E_diag= -2*$dx;
( run in 1.520 second using v1.01-cache-2.11-cpan-df04353d9ac )