Skip to content
Snippets Groups Projects
Commit eace3b29 authored by Raphael's avatar Raphael
Browse files

small fix for bresenham algorithm

parent cbf3f309
No related branches found
No related tags found
2 merge requests!12version 0.2a,!10Resolve "Image creation bugs with 0 size windows"
......@@ -8,10 +8,8 @@ def bresenham(x1, y1, x2, y2):
if dy < 0:
sy = -1
x = x1
y = y1
pixels = [(x1, y1)]
pixels = []
if abs(dx) > abs(dy): # slope < 1
if x1 > x2:
tmp = x2
......@@ -21,7 +19,11 @@ def bresenham(x1, y1, x2, y2):
tmp = y2
y2 = y1
y1 = tmp
sy *= -1
y = y1
p = (2 * abs(dy)) - abs(dx)
pixels.append((x1, y1))
for x in range(x1 + 1, x2 + 1):
if p < 0:
......@@ -39,6 +41,10 @@ def bresenham(x1, y1, x2, y2):
tmp = y2
y2 = y1
y1 = tmp
sx *= -1
x = x1
pixels.append((x1, y1))
p = (2 * abs(dx)) - abs(dy)
for y in range(y1 + 1, y2 + 1):
if p < 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment