Skip to content

An implementation of Bresenham's line drawing algorithm

License

Notifications You must be signed in to change notification settings

baibaidj/bresenham

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The bresenham module

An implementation of Bresenham's line drawing algorithm.

See the Wikipedia entry for details on what that is.

Installation

In a Python virtual environment, do:

python -m pip install bresenham

To install an editable from a Git checkout:

python -m pip install -e.

To install without a virtual envitonment, add the --user option.

Usage

The bresenham(x0, y0, x1, y1) function, which returns a generator of the coordinates of the line from (x0, y0) to (x1, y1).

For example, the coordinates of a line from, say, (-1, -4) to (3, 2), are:

>>> from bresenham import bresenham

>>> list(bresenham(-1, -4, 3, 2))
[(-1, -4), (0, -3), (0, -2), (1, -1), (2, 0), (2, 1), (3, 2)]

Development

You're welcome to join this project!

If you spot an issue, please report it at the Issues page on Github.

If you'd like to start changing the code or documentation, check out the code locally using:

git clone https://github.com/encukou/bresenham

If you're new to this, please read the this guide about collaborating on Github-hosted projects like this one.

If that doesn't make sense, please e-mail the author for clarification. I'd be happy to help you get started.

About

An implementation of Bresenham's line drawing algorithm

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%