GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Algorithm::Line::Bresenham(3) User Contributed Perl Documentation Algorithm::Line::Bresenham(3)

Algorithm::Line::Bresenham - simple pixellated line-drawing algorithm

 use Algorithm::Line::Bresenham qw/line/;
 my @points = line(3,3 => 5,0);
    # returns the list: [3,3], [4,2], [4,1], [5,0]
 line(3,3 => 5,0,  \&draw_line);
    # calls draw_line on each point in turn

Bresenham is one of the canonical line drawing algorithms for pixellated grids. Given a start and an end-point, Bresenham calculates which points on the grid need to be filled to generate the line between them.

Googling for 'Bresenham', and 'line drawing algorithms' gives some good overview. The code here takes its starting point from Mark Feldman's Pascal code in his article Bresenham's Line and Circle Algorithms at <http://www.gamedev.net/reference/articles/article767.asp>.

 line ($from_y, $from_x => $to_y, $to_x);

Generates a list of all the intermediate points. This is returned as a list of array references.

 line ($from_y, $from_x => $to_y, $to_x,  \&callback);

Calls the referenced function on each point in turn. The callback could be used to actually draw the point. Returns the collated return values from the callback.

    my @points = circle ($y, $x, $radius)

Returns the points to draw a circle with

None currently.

Patches for the circle algorithm and a float value bug contributed by Richard Clamp, thanks!

osfameron, osfameron@cpan.org

Copyright (c) 2004-2006 osfameron. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html

2022-04-09 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.