Skip to content

Commit 93ed88b

Browse files
authored
Update digital_differential_analyzer_line.py
1 parent 11e9315 commit 93ed88b

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

graphics/digital_differential_analyzer_line.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import matplotlib.pyplot as plt
22

3-
43
def digital_differential_analyzer_line(
54
x1: int, y1: int, x2: int, y2: int
65
) -> list[tuple[int, int]]:
76
"""
8-
Draws a line between two points using the Digital Differential Analyzer (DDA) algorithm.
9-
7+
Draws a line between two points using the DDA algorithm.
8+
109
Args:
1110
- x1, y1: Coordinates of the starting point.
1211
- x2, y2: Coordinates of the ending point.
@@ -17,7 +16,7 @@ def digital_differential_analyzer_line(
1716
>>> digital_differential_analyzer_line(1, 1, 4, 4)
1817
[(2, 2), (3, 3), (4, 4)]
1918
"""
20-
19+
2120
dx = x2 - x1
2221
dy = y2 - y1
2322
steps = max(abs(dx), abs(dy))
@@ -32,12 +31,10 @@ def digital_differential_analyzer_line(
3231
coordinates.append((int(round(x)), int(round(y))))
3332
return coordinates
3433

35-
3634
if __name__ == "__main__":
3735
import doctest
38-
3936
doctest.testmod()
40-
37+
4138
x1 = int(input("Enter the x-coordinate of the starting point: "))
4239
y1 = int(input("Enter the y-coordinate of the starting point: "))
4340
x2 = int(input("Enter the x-coordinate of the ending point: "))

0 commit comments

Comments
 (0)