Geek Culture
Published in

Geek Culture

Bresenham’s Line Drawing Algorithm

Explanation of Bresenham’s Line Drawing Algorithm with examples

Finding the next pixel in Bresenham’s algorithm

Similar to the DDA algorithm, we need two endpoints, P and Q, to draw a line using Bresengham’s algorithm.

  1. Right side pixel (East — E)
  2. Upper right pixel (North East — NE)

Bresenham’s Algorithm

Assume starting point is (x1, y1) and the ending point is (x2, y2)

Example

I am going to take the same example I used in the DDA algorithm tutorial so that we can compare the results.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store