Skip to content

Commit ac7607e

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 93ed88b commit ac7607e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

graphics/digital_differential_analyzer_line.py

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

3+
34
def digital_differential_analyzer_line(
45
x1: int, y1: int, x2: int, y2: int
56
) -> list[tuple[int, int]]:
67
"""
78
Draws a line between two points using the DDA algorithm.
8-
9+
910
Args:
1011
- x1, y1: Coordinates of the starting point.
1112
- x2, y2: Coordinates of the ending point.
@@ -16,7 +17,7 @@ def digital_differential_analyzer_line(
1617
>>> digital_differential_analyzer_line(1, 1, 4, 4)
1718
[(2, 2), (3, 3), (4, 4)]
1819
"""
19-
20+
2021
dx = x2 - x1
2122
dy = y2 - y1
2223
steps = max(abs(dx), abs(dy))
@@ -31,10 +32,12 @@ def digital_differential_analyzer_line(
3132
coordinates.append((int(round(x)), int(round(y))))
3233
return coordinates
3334

35+
3436
if __name__ == "__main__":
3537
import doctest
38+
3639
doctest.testmod()
37-
40+
3841
x1 = int(input("Enter the x-coordinate of the starting point: "))
3942
y1 = int(input("Enter the y-coordinate of the starting point: "))
4043
x2 = int(input("Enter the x-coordinate of the ending point: "))

0 commit comments

Comments
 (0)