From c62f30a6acc144863b36f39724548ca6b2a0e8a6 Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Wed, 25 Oct 2023 08:36:50 +0530 Subject: [PATCH 01/36] Create DDA_line_drawing.py --- graphics/DDA_line_drawing.py | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 graphics/DDA_line_drawing.py diff --git a/graphics/DDA_line_drawing.py b/graphics/DDA_line_drawing.py new file mode 100644 index 000000000000..ff77b17415d1 --- /dev/null +++ b/graphics/DDA_line_drawing.py @@ -0,0 +1,46 @@ +import matplotlib.pyplot as plt + +def dda_line(x1, y1, x2, y2): + # Calculate the differences in x and y coordinates + dx = x2 - x1 + dy = y2 - y1 + + # Determine the number of steps to take + steps = max(abs(dx), abs(dy)) + + # Calculate the increments for x and y + x_increment = dx / steps + y_increment = dy / steps + + # Lists to store the x and y coordinates of the line + x_points = [x1] + y_points = [y1] + + # Calculate and store the intermediate points + x = x1 + y = y1 + for _ in range(steps): + x += x_increment + y += y_increment + x_points.append(round(x)) + y_points.append(round(y)) + + return x_points, y_points + +if __name__ == "__main__": + # Input the coordinates of the two endpoints of the line + x1 = int(input("Enter x1: ")) + y1 = int(input("Enter y1: ")) + x2 = int(input("Enter x2: ")) + y2 = int(input("Enter y2: ")) + + # Calculate the points using DDA algorithm + x_points, y_points = dda_line(x1, y1, x2, y2) + + # Plot the line using Matplotlib + plt.plot(x_points, y_points, marker='o') + plt.title('DDA Line Drawing Algorithm') + plt.xlabel('X-axis') + plt.ylabel('Y-axis') + plt.grid() + plt.show() From d08be9ab8eb689311b59c6a43372834350b18d2d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 03:08:39 +0000 Subject: [PATCH 02/36] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- graphics/DDA_line_drawing.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/graphics/DDA_line_drawing.py b/graphics/DDA_line_drawing.py index ff77b17415d1..db5eb1c0db6d 100644 --- a/graphics/DDA_line_drawing.py +++ b/graphics/DDA_line_drawing.py @@ -1,5 +1,6 @@ import matplotlib.pyplot as plt + def dda_line(x1, y1, x2, y2): # Calculate the differences in x and y coordinates dx = x2 - x1 @@ -27,6 +28,7 @@ def dda_line(x1, y1, x2, y2): return x_points, y_points + if __name__ == "__main__": # Input the coordinates of the two endpoints of the line x1 = int(input("Enter x1: ")) @@ -38,9 +40,9 @@ def dda_line(x1, y1, x2, y2): x_points, y_points = dda_line(x1, y1, x2, y2) # Plot the line using Matplotlib - plt.plot(x_points, y_points, marker='o') - plt.title('DDA Line Drawing Algorithm') - plt.xlabel('X-axis') - plt.ylabel('Y-axis') + plt.plot(x_points, y_points, marker="o") + plt.title("DDA Line Drawing Algorithm") + plt.xlabel("X-axis") + plt.ylabel("Y-axis") plt.grid() plt.show() From 220559aef6e2b653a3b39310c64fc835863eebc1 Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Thu, 26 Oct 2023 22:18:22 +0530 Subject: [PATCH 03/36] Rename DDA_line_drawing.py to digital differential analyzer_line_drawing.py From 5d4b127a6f2e8568e6caeedd9c1ea50cc3025176 Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Thu, 26 Oct 2023 22:20:15 +0530 Subject: [PATCH 04/36] Rename DDA_line_drawing.py to digital_differential_analyzer_line_drawing.py --- ...e_drawing.py => digital_differential_analyzer_line_drawing.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename graphics/{DDA_line_drawing.py => digital_differential_analyzer_line_drawing.py} (100%) diff --git a/graphics/DDA_line_drawing.py b/graphics/digital_differential_analyzer_line_drawing.py similarity index 100% rename from graphics/DDA_line_drawing.py rename to graphics/digital_differential_analyzer_line_drawing.py From e8a0ab71f8f34e422ea3623852d059ed98b81c91 Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Thu, 26 Oct 2023 22:31:32 +0530 Subject: [PATCH 05/36] Update digital_differential_analyzer_line_drawing.py From 1b621e1fd40adb557c7a0457cbf8b746438097ad Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Fri, 27 Oct 2023 10:59:44 +0530 Subject: [PATCH 06/36] Update digital_differential_analyzer_line_drawing.py --- ...ital_differential_analyzer_line_drawing.py | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/graphics/digital_differential_analyzer_line_drawing.py b/graphics/digital_differential_analyzer_line_drawing.py index db5eb1c0db6d..6ec9b3fa2261 100644 --- a/graphics/digital_differential_analyzer_line_drawing.py +++ b/graphics/digital_differential_analyzer_line_drawing.py @@ -1,7 +1,25 @@ import matplotlib.pyplot as plt +from typing import List, Tuple +def digital_differential_analyzer_line(x1: int, y1: int, x2: int, y2: int) -> Tuple[List[int], List[int]]: + """ + Draw a line using the Digital Differential Analyzer (DDA) algorithm. + + Parameters: + x1 (int): The x-coordinate of the starting point. + y1 (int): The y-coordinate of the starting point. + x2 (int): The x-coordinate of the ending point. + y2 (int): The y-coordinate of the ending point. + + Returns: + Tuple[List[int], List[int]]: A tuple of two lists, where the first list contains + the x-coordinates of the line points, and the second list contains the y-coordinates. + + Example: + >>> digital_differential_analyzer_line(0, 0, 3, 2) + ([0, 1, 2, 3], [0, 1, 1, 2]) + """ -def dda_line(x1, y1, x2, y2): # Calculate the differences in x and y coordinates dx = x2 - x1 dy = y2 - y1 @@ -28,20 +46,19 @@ def dda_line(x1, y1, x2, y2): return x_points, y_points - if __name__ == "__main__": # Input the coordinates of the two endpoints of the line - x1 = int(input("Enter x1: ")) - y1 = int(input("Enter y1: ")) - x2 = int(input("Enter x2: ")) - y2 = int(input("Enter y2: ")) + x1 = int(input("Enter the x-coordinate of the starting point: ")) + y1 = int(input("Enter the y-coordinate of the starting point: ")) + x2 = int(input("Enter the x-coordinate of the ending point: ")) + y2 = int(input("Enter the y-coordinate of the ending point: ")) - # Calculate the points using DDA algorithm - x_points, y_points = dda_line(x1, y1, x2, y2) + # Calculate the points using the Digital Differential Analyzer (DDA) algorithm + x_points, y_points = digital_differential_analyzer_line(x1, y1, x2, y2) # Plot the line using Matplotlib plt.plot(x_points, y_points, marker="o") - plt.title("DDA Line Drawing Algorithm") + plt.title("Digital Differential Analyzer Line Drawing Algorithm") plt.xlabel("X-axis") plt.ylabel("Y-axis") plt.grid() From 8391c5f70ba49f2cad84e064cf9dd8d6dfbf9507 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 27 Oct 2023 05:31:43 +0000 Subject: [PATCH 07/36] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- graphics/digital_differential_analyzer_line_drawing.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/graphics/digital_differential_analyzer_line_drawing.py b/graphics/digital_differential_analyzer_line_drawing.py index 6ec9b3fa2261..0fcf12a52ce0 100644 --- a/graphics/digital_differential_analyzer_line_drawing.py +++ b/graphics/digital_differential_analyzer_line_drawing.py @@ -1,7 +1,10 @@ import matplotlib.pyplot as plt from typing import List, Tuple -def digital_differential_analyzer_line(x1: int, y1: int, x2: int, y2: int) -> Tuple[List[int], List[int]]: + +def digital_differential_analyzer_line( + x1: int, y1: int, x2: int, y2: int +) -> Tuple[List[int], List[int]]: """ Draw a line using the Digital Differential Analyzer (DDA) algorithm. @@ -46,6 +49,7 @@ def digital_differential_analyzer_line(x1: int, y1: int, x2: int, y2: int) -> Tu return x_points, y_points + if __name__ == "__main__": # Input the coordinates of the two endpoints of the line x1 = int(input("Enter the x-coordinate of the starting point: ")) From 70764bbe91404c15113c85d41af68618a7b87e6f Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Fri, 27 Oct 2023 11:07:34 +0530 Subject: [PATCH 08/36] Update digital_differential_analyzer_line_drawing.py --- .../digital_differential_analyzer_line_drawing.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/graphics/digital_differential_analyzer_line_drawing.py b/graphics/digital_differential_analyzer_line_drawing.py index 0fcf12a52ce0..e8291a01f1b0 100644 --- a/graphics/digital_differential_analyzer_line_drawing.py +++ b/graphics/digital_differential_analyzer_line_drawing.py @@ -1,10 +1,7 @@ import matplotlib.pyplot as plt from typing import List, Tuple - -def digital_differential_analyzer_line( - x1: int, y1: int, x2: int, y2: int -) -> Tuple[List[int], List[int]]: +def digital_differential_analyzer_line(x1: int, y1: int, x2: int, y2: int) -> Tuple[List[int], List[int]]: """ Draw a line using the Digital Differential Analyzer (DDA) algorithm. @@ -15,8 +12,8 @@ def digital_differential_analyzer_line( y2 (int): The y-coordinate of the ending point. Returns: - Tuple[List[int], List[int]]: A tuple of two lists, where the first list contains - the x-coordinates of the line points, and the second list contains the y-coordinates. + Tuple of two lists, where the first list contains the x-coordinates of the line points, + and the second list contains the y-coordinates. Example: >>> digital_differential_analyzer_line(0, 0, 3, 2) @@ -44,12 +41,11 @@ def digital_differential_analyzer_line( for _ in range(steps): x += x_increment y += y_increment - x_points.append(round(x)) - y_points.append(round(y)) + x_points.append(int(round(x))) + y_points.append(int(round(y))) return x_points, y_points - if __name__ == "__main__": # Input the coordinates of the two endpoints of the line x1 = int(input("Enter the x-coordinate of the starting point: ")) From d84e4ec476e763864fe8ebc30996ecb6b6ab292a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 27 Oct 2023 05:38:09 +0000 Subject: [PATCH 09/36] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- graphics/digital_differential_analyzer_line_drawing.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/graphics/digital_differential_analyzer_line_drawing.py b/graphics/digital_differential_analyzer_line_drawing.py index e8291a01f1b0..9bc15283b9d4 100644 --- a/graphics/digital_differential_analyzer_line_drawing.py +++ b/graphics/digital_differential_analyzer_line_drawing.py @@ -1,7 +1,10 @@ import matplotlib.pyplot as plt from typing import List, Tuple -def digital_differential_analyzer_line(x1: int, y1: int, x2: int, y2: int) -> Tuple[List[int], List[int]]: + +def digital_differential_analyzer_line( + x1: int, y1: int, x2: int, y2: int +) -> Tuple[List[int], List[int]]: """ Draw a line using the Digital Differential Analyzer (DDA) algorithm. @@ -46,6 +49,7 @@ def digital_differential_analyzer_line(x1: int, y1: int, x2: int, y2: int) -> Tu return x_points, y_points + if __name__ == "__main__": # Input the coordinates of the two endpoints of the line x1 = int(input("Enter the x-coordinate of the starting point: ")) From a6b452fd09e581d6436cdd562305a4f8302f75f9 Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Fri, 27 Oct 2023 11:14:05 +0530 Subject: [PATCH 10/36] Update digital_differential_analyzer_line_drawing.py --- graphics/digital_differential_analyzer_line_drawing.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/graphics/digital_differential_analyzer_line_drawing.py b/graphics/digital_differential_analyzer_line_drawing.py index 9bc15283b9d4..e8291a01f1b0 100644 --- a/graphics/digital_differential_analyzer_line_drawing.py +++ b/graphics/digital_differential_analyzer_line_drawing.py @@ -1,10 +1,7 @@ import matplotlib.pyplot as plt from typing import List, Tuple - -def digital_differential_analyzer_line( - x1: int, y1: int, x2: int, y2: int -) -> Tuple[List[int], List[int]]: +def digital_differential_analyzer_line(x1: int, y1: int, x2: int, y2: int) -> Tuple[List[int], List[int]]: """ Draw a line using the Digital Differential Analyzer (DDA) algorithm. @@ -49,7 +46,6 @@ def digital_differential_analyzer_line( return x_points, y_points - if __name__ == "__main__": # Input the coordinates of the two endpoints of the line x1 = int(input("Enter the x-coordinate of the starting point: ")) From 06f87eb28b406d18ffcc931f324945a647ce0e56 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 27 Oct 2023 05:44:40 +0000 Subject: [PATCH 11/36] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- graphics/digital_differential_analyzer_line_drawing.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/graphics/digital_differential_analyzer_line_drawing.py b/graphics/digital_differential_analyzer_line_drawing.py index e8291a01f1b0..9bc15283b9d4 100644 --- a/graphics/digital_differential_analyzer_line_drawing.py +++ b/graphics/digital_differential_analyzer_line_drawing.py @@ -1,7 +1,10 @@ import matplotlib.pyplot as plt from typing import List, Tuple -def digital_differential_analyzer_line(x1: int, y1: int, x2: int, y2: int) -> Tuple[List[int], List[int]]: + +def digital_differential_analyzer_line( + x1: int, y1: int, x2: int, y2: int +) -> Tuple[List[int], List[int]]: """ Draw a line using the Digital Differential Analyzer (DDA) algorithm. @@ -46,6 +49,7 @@ def digital_differential_analyzer_line(x1: int, y1: int, x2: int, y2: int) -> Tu return x_points, y_points + if __name__ == "__main__": # Input the coordinates of the two endpoints of the line x1 = int(input("Enter the x-coordinate of the starting point: ")) From 7f2ee3c3b3d2bc42458ffc0f6dbf804c3b23533b Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Fri, 27 Oct 2023 12:10:22 +0530 Subject: [PATCH 12/36] Update digital_differential_analyzer_line_drawing.py From f41532856394a8f1fca7c20540e0fbc2dfa20adc Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Fri, 27 Oct 2023 12:27:24 +0530 Subject: [PATCH 13/36] Update digital_differential_analyzer_line_drawing.py --- graphics/digital_differential_analyzer_line_drawing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphics/digital_differential_analyzer_line_drawing.py b/graphics/digital_differential_analyzer_line_drawing.py index 9bc15283b9d4..569aba5b441a 100644 --- a/graphics/digital_differential_analyzer_line_drawing.py +++ b/graphics/digital_differential_analyzer_line_drawing.py @@ -4,7 +4,7 @@ def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int -) -> Tuple[List[int], List[int]]: +) -> tuple[list[int], list[int]]: """ Draw a line using the Digital Differential Analyzer (DDA) algorithm. From 5cae2156b3e66dab5cd9bd8f8bc58c82ae8f9ed1 Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Fri, 27 Oct 2023 12:30:18 +0530 Subject: [PATCH 14/36] Update digital_differential_analyzer_line_drawing.py --- graphics/digital_differential_analyzer_line_drawing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphics/digital_differential_analyzer_line_drawing.py b/graphics/digital_differential_analyzer_line_drawing.py index 569aba5b441a..512ea12b2c83 100644 --- a/graphics/digital_differential_analyzer_line_drawing.py +++ b/graphics/digital_differential_analyzer_line_drawing.py @@ -1,5 +1,5 @@ import matplotlib.pyplot as plt -from typing import List, Tuple +from typing import list, tuple def digital_differential_analyzer_line( From 5234d02fc055ffa425d2815ae9fc17c0486cd33d Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Fri, 27 Oct 2023 12:34:02 +0530 Subject: [PATCH 15/36] Update digital_differential_analyzer_line_drawing.py --- graphics/digital_differential_analyzer_line_drawing.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/graphics/digital_differential_analyzer_line_drawing.py b/graphics/digital_differential_analyzer_line_drawing.py index 512ea12b2c83..50712382581d 100644 --- a/graphics/digital_differential_analyzer_line_drawing.py +++ b/graphics/digital_differential_analyzer_line_drawing.py @@ -1,7 +1,6 @@ import matplotlib.pyplot as plt from typing import list, tuple - def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int ) -> tuple[list[int], list[int]]: @@ -15,7 +14,7 @@ def digital_differential_analyzer_line( y2 (int): The y-coordinate of the ending point. Returns: - Tuple of two lists, where the first list contains the x-coordinates of the line points, + tuple of two lists, where the first list contains the x-coordinates of the line points, and the second list contains the y-coordinates. Example: @@ -49,7 +48,6 @@ def digital_differential_analyzer_line( return x_points, y_points - if __name__ == "__main__": # Input the coordinates of the two endpoints of the line x1 = int(input("Enter the x-coordinate of the starting point: ")) From f34960f83bcdaad84d0eb208d44aa9ae7848adbf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 27 Oct 2023 07:04:37 +0000 Subject: [PATCH 16/36] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- graphics/digital_differential_analyzer_line_drawing.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/graphics/digital_differential_analyzer_line_drawing.py b/graphics/digital_differential_analyzer_line_drawing.py index 50712382581d..30a801244b96 100644 --- a/graphics/digital_differential_analyzer_line_drawing.py +++ b/graphics/digital_differential_analyzer_line_drawing.py @@ -1,6 +1,7 @@ import matplotlib.pyplot as plt from typing import list, tuple + def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int ) -> tuple[list[int], list[int]]: @@ -48,6 +49,7 @@ def digital_differential_analyzer_line( return x_points, y_points + if __name__ == "__main__": # Input the coordinates of the two endpoints of the line x1 = int(input("Enter the x-coordinate of the starting point: ")) From 842ad9ead5d544d605fa7a16555b7d76285eb878 Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Sat, 28 Oct 2023 06:21:16 +0530 Subject: [PATCH 17/36] Apply suggestions from code review Co-authored-by: Tianyi Zheng --- graphics/digital_differential_analyzer_line_drawing.py | 1 - 1 file changed, 1 deletion(-) diff --git a/graphics/digital_differential_analyzer_line_drawing.py b/graphics/digital_differential_analyzer_line_drawing.py index 30a801244b96..7f84cc7f2968 100644 --- a/graphics/digital_differential_analyzer_line_drawing.py +++ b/graphics/digital_differential_analyzer_line_drawing.py @@ -1,5 +1,4 @@ import matplotlib.pyplot as plt -from typing import list, tuple def digital_differential_analyzer_line( From 74b5dd18ebdd94b5eb8e0ff4912836c390cd9939 Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Sat, 28 Oct 2023 06:41:37 +0530 Subject: [PATCH 18/36] Update and rename digital_differential_analyzer_line_drawing.py to digital_differential_analyzer_line.py --- ... => digital_differential_analyzer_line.py} | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) rename graphics/{digital_differential_analyzer_line_drawing.py => digital_differential_analyzer_line.py} (76%) diff --git a/graphics/digital_differential_analyzer_line_drawing.py b/graphics/digital_differential_analyzer_line.py similarity index 76% rename from graphics/digital_differential_analyzer_line_drawing.py rename to graphics/digital_differential_analyzer_line.py index 7f84cc7f2968..ed3acabb44a2 100644 --- a/graphics/digital_differential_analyzer_line_drawing.py +++ b/graphics/digital_differential_analyzer_line.py @@ -1,9 +1,8 @@ import matplotlib.pyplot as plt - def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int -) -> tuple[list[int], list[int]]: +) -> list[tuple[int, int]]: """ Draw a line using the Digital Differential Analyzer (DDA) algorithm. @@ -14,12 +13,11 @@ def digital_differential_analyzer_line( y2 (int): The y-coordinate of the ending point. Returns: - tuple of two lists, where the first list contains the x-coordinates of the line points, - and the second list contains the y-coordinates. + list of coordinate pairs (x, y). Example: >>> digital_differential_analyzer_line(0, 0, 3, 2) - ([0, 1, 2, 3], [0, 1, 1, 2]) + [(0, 0), (1, 1), (2, 1), (3, 2)] """ # Calculate the differences in x and y coordinates @@ -33,9 +31,8 @@ def digital_differential_analyzer_line( x_increment = dx / steps y_increment = dy / steps - # Lists to store the x and y coordinates of the line - x_points = [x1] - y_points = [y1] + # List to store the coordinate pairs + coordinates = [] # Calculate and store the intermediate points x = x1 @@ -43,11 +40,9 @@ def digital_differential_analyzer_line( for _ in range(steps): x += x_increment y += y_increment - x_points.append(int(round(x))) - y_points.append(int(round(y))) - - return x_points, y_points + coordinates.append((int(round(x)), int(round(y)))) + return coordinates if __name__ == "__main__": # Input the coordinates of the two endpoints of the line @@ -57,9 +52,10 @@ def digital_differential_analyzer_line( y2 = int(input("Enter the y-coordinate of the ending point: ")) # Calculate the points using the Digital Differential Analyzer (DDA) algorithm - x_points, y_points = digital_differential_analyzer_line(x1, y1, x2, y2) + coordinates = digital_differential_analyzer_line(x1, y1, x2, y2) # Plot the line using Matplotlib + x_points, y_points = zip(*coordinates) plt.plot(x_points, y_points, marker="o") plt.title("Digital Differential Analyzer Line Drawing Algorithm") plt.xlabel("X-axis") From dc1f4b2eea59d36cd70746db85cec9f3120ac351 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 28 Oct 2023 01:13:38 +0000 Subject: [PATCH 19/36] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- graphics/digital_differential_analyzer_line.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index ed3acabb44a2..83bfc9c576ee 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -1,5 +1,6 @@ import matplotlib.pyplot as plt + def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int ) -> list[tuple[int, int]]: @@ -44,6 +45,7 @@ def digital_differential_analyzer_line( return coordinates + if __name__ == "__main__": # Input the coordinates of the two endpoints of the line x1 = int(input("Enter the x-coordinate of the starting point: ")) From 836ce487162549440c24ab5aed0b434fe3d60ef0 Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Sat, 28 Oct 2023 06:47:54 +0530 Subject: [PATCH 20/36] Update digital_differential_analyzer_line.py --- graphics/digital_differential_analyzer_line.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index 83bfc9c576ee..ed3acabb44a2 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -1,6 +1,5 @@ import matplotlib.pyplot as plt - def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int ) -> list[tuple[int, int]]: @@ -45,7 +44,6 @@ def digital_differential_analyzer_line( return coordinates - if __name__ == "__main__": # Input the coordinates of the two endpoints of the line x1 = int(input("Enter the x-coordinate of the starting point: ")) From 3aa73ba7a3b28bdd8bc16441c1d95d8a42444e2a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 28 Oct 2023 01:18:28 +0000 Subject: [PATCH 21/36] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- graphics/digital_differential_analyzer_line.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index ed3acabb44a2..83bfc9c576ee 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -1,5 +1,6 @@ import matplotlib.pyplot as plt + def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int ) -> list[tuple[int, int]]: @@ -44,6 +45,7 @@ def digital_differential_analyzer_line( return coordinates + if __name__ == "__main__": # Input the coordinates of the two endpoints of the line x1 = int(input("Enter the x-coordinate of the starting point: ")) From d9f2d33fab00806b43b9116c124927cd3adfe71d Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Sat, 28 Oct 2023 06:53:33 +0530 Subject: [PATCH 22/36] Update digital_differential_analyzer_line.py --- graphics/digital_differential_analyzer_line.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index 83bfc9c576ee..f6071ee878e9 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -1,6 +1,5 @@ import matplotlib.pyplot as plt - def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int ) -> list[tuple[int, int]]: @@ -42,10 +41,10 @@ def digital_differential_analyzer_line( x += x_increment y += y_increment coordinates.append((int(round(x)), int(round(y)))) + return coordinates - if __name__ == "__main__": # Input the coordinates of the two endpoints of the line x1 = int(input("Enter the x-coordinate of the starting point: ")) From a4dcebfd6f09fbf8351c437cae2c3a3765ea3392 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 28 Oct 2023 01:24:59 +0000 Subject: [PATCH 23/36] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- graphics/digital_differential_analyzer_line.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index f6071ee878e9..83bfc9c576ee 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -1,5 +1,6 @@ import matplotlib.pyplot as plt + def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int ) -> list[tuple[int, int]]: @@ -41,10 +42,10 @@ def digital_differential_analyzer_line( x += x_increment y += y_increment coordinates.append((int(round(x)), int(round(y)))) - return coordinates + if __name__ == "__main__": # Input the coordinates of the two endpoints of the line x1 = int(input("Enter the x-coordinate of the starting point: ")) From 6d1844abc19851839f6a10fb35c3d8587e0df1fe Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Sat, 28 Oct 2023 06:56:50 +0530 Subject: [PATCH 24/36] Update digital_differential_analyzer_line.py --- graphics/digital_differential_analyzer_line.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index 83bfc9c576ee..89ed0be42d15 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -1,6 +1,5 @@ import matplotlib.pyplot as plt - def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int ) -> list[tuple[int, int]]: @@ -26,7 +25,7 @@ def digital_differential_analyzer_line( dy = y2 - y1 # Determine the number of steps to take - steps = max(abs(dx), abs(dy)) + steps = max(abs(dx), abs(dy) # Calculate the increments for x and y x_increment = dx / steps @@ -41,11 +40,9 @@ def digital_differential_analyzer_line( for _ in range(steps): x += x_increment y += y_increment - coordinates.append((int(round(x)), int(round(y)))) - + coordinates.append((int(round(x)), int(round(y))) return coordinates - if __name__ == "__main__": # Input the coordinates of the two endpoints of the line x1 = int(input("Enter the x-coordinate of the starting point: ")) From 67ca0e64a614e12e87c103a60687bcc8853990b7 Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Sat, 28 Oct 2023 07:01:02 +0530 Subject: [PATCH 25/36] Update digital_differential_analyzer_line.py --- graphics/digital_differential_analyzer_line.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index 89ed0be42d15..659f98941f04 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -25,7 +25,7 @@ def digital_differential_analyzer_line( dy = y2 - y1 # Determine the number of steps to take - steps = max(abs(dx), abs(dy) + steps = max(abs(dx), abs(dy)) # Calculate the increments for x and y x_increment = dx / steps @@ -40,7 +40,7 @@ def digital_differential_analyzer_line( for _ in range(steps): x += x_increment y += y_increment - coordinates.append((int(round(x)), int(round(y))) + coordinates.append((int(round(x)), int(round(y)))) return coordinates if __name__ == "__main__": From 94972ae239192b25ab3480041ed3aa9e1823dd0b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 28 Oct 2023 01:31:38 +0000 Subject: [PATCH 26/36] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- graphics/digital_differential_analyzer_line.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index 659f98941f04..77f2046082cd 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -1,5 +1,6 @@ import matplotlib.pyplot as plt + def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int ) -> list[tuple[int, int]]: @@ -43,6 +44,7 @@ def digital_differential_analyzer_line( coordinates.append((int(round(x)), int(round(y)))) return coordinates + if __name__ == "__main__": # Input the coordinates of the two endpoints of the line x1 = int(input("Enter the x-coordinate of the starting point: ")) From 92877252d82f5a415c19fe1c35b74158fc1accc3 Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Sat, 28 Oct 2023 12:02:18 +0530 Subject: [PATCH 27/36] Update digital_differential_analyzer_line.py --- .../digital_differential_analyzer_line.py | 37 +------------------ 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index 77f2046082cd..432e7721a0e7 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -1,41 +1,14 @@ import matplotlib.pyplot as plt - def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int ) -> list[tuple[int, int]]: - """ - Draw a line using the Digital Differential Analyzer (DDA) algorithm. - - Parameters: - x1 (int): The x-coordinate of the starting point. - y1 (int): The y-coordinate of the starting point. - x2 (int): The x-coordinate of the ending point. - y2 (int): The y-coordinate of the ending point. - - Returns: - list of coordinate pairs (x, y). - - Example: - >>> digital_differential_analyzer_line(0, 0, 3, 2) - [(0, 0), (1, 1), (2, 1), (3, 2)] - """ - - # Calculate the differences in x and y coordinates dx = x2 - x1 dy = y2 - y1 - - # Determine the number of steps to take steps = max(abs(dx), abs(dy)) - - # Calculate the increments for x and y - x_increment = dx / steps - y_increment = dy / steps - - # List to store the coordinate pairs + x_increment = dx / float(steps) + y_increment = dy / float(steps) coordinates = [] - - # Calculate and store the intermediate points x = x1 y = y1 for _ in range(steps): @@ -44,18 +17,12 @@ def digital_differential_analyzer_line( coordinates.append((int(round(x)), int(round(y)))) return coordinates - if __name__ == "__main__": - # Input the coordinates of the two endpoints of the line x1 = int(input("Enter the x-coordinate of the starting point: ")) y1 = int(input("Enter the y-coordinate of the starting point: ")) x2 = int(input("Enter the x-coordinate of the ending point: ")) y2 = int(input("Enter the y-coordinate of the ending point: ")) - - # Calculate the points using the Digital Differential Analyzer (DDA) algorithm coordinates = digital_differential_analyzer_line(x1, y1, x2, y2) - - # Plot the line using Matplotlib x_points, y_points = zip(*coordinates) plt.plot(x_points, y_points, marker="o") plt.title("Digital Differential Analyzer Line Drawing Algorithm") From b4b89ca3b99243f787ab57491126d32981bbaf11 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 28 Oct 2023 06:33:12 +0000 Subject: [PATCH 28/36] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- graphics/digital_differential_analyzer_line.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index 432e7721a0e7..268d21d652aa 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -1,5 +1,6 @@ import matplotlib.pyplot as plt + def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int ) -> list[tuple[int, int]]: @@ -17,6 +18,7 @@ def digital_differential_analyzer_line( coordinates.append((int(round(x)), int(round(y)))) return coordinates + if __name__ == "__main__": x1 = int(input("Enter the x-coordinate of the starting point: ")) y1 = int(input("Enter the y-coordinate of the starting point: ")) From 6f0540d5a78e05590667e41dfdba8a8d779b5423 Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Sat, 28 Oct 2023 12:13:44 +0530 Subject: [PATCH 29/36] Update digital_differential_analyzer_line.py --- .../digital_differential_analyzer_line.py | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index 268d21d652aa..8a54c2e408f7 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -1,25 +1,40 @@ import matplotlib.pyplot as plt - def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int ) -> list[tuple[int, int]]: + """ + Draws a line between two points using the Digital Differential Analyzer (DDA) algorithm. + + Args: + - x1, y1: Coordinates of the starting point. + - x2, y2: Coordinates of the ending point. + + Returns: + - List of coordinate points that form the line. + + >>> digital_differential_analyzer_line(1, 1, 4, 4) + [(2, 2), (3, 3), (4, 4)] + """ + dx = x2 - x1 dy = y2 - y1 steps = max(abs(dx), abs(dy)) x_increment = dx / float(steps) y_increment = dy / float(steps) coordinates = [] - x = x1 - y = y1 + x: float = x1 + y: float = y1 for _ in range(steps): x += x_increment y += y_increment coordinates.append((int(round(x)), int(round(y)))) return coordinates - if __name__ == "__main__": + import doctest + doctest.testmod() + x1 = int(input("Enter the x-coordinate of the starting point: ")) y1 = int(input("Enter the y-coordinate of the starting point: ")) x2 = int(input("Enter the x-coordinate of the ending point: ")) From 11e93159e601e8c7f3fc163d631d83057798dc17 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 28 Oct 2023 06:44:24 +0000 Subject: [PATCH 30/36] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- graphics/digital_differential_analyzer_line.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index 8a54c2e408f7..9280731bb886 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -1,11 +1,12 @@ import matplotlib.pyplot as plt + def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int ) -> list[tuple[int, int]]: """ Draws a line between two points using the Digital Differential Analyzer (DDA) algorithm. - + Args: - x1, y1: Coordinates of the starting point. - x2, y2: Coordinates of the ending point. @@ -16,7 +17,7 @@ def digital_differential_analyzer_line( >>> digital_differential_analyzer_line(1, 1, 4, 4) [(2, 2), (3, 3), (4, 4)] """ - + dx = x2 - x1 dy = y2 - y1 steps = max(abs(dx), abs(dy)) @@ -31,10 +32,12 @@ def digital_differential_analyzer_line( coordinates.append((int(round(x)), int(round(y)))) return coordinates + if __name__ == "__main__": import doctest + doctest.testmod() - + x1 = int(input("Enter the x-coordinate of the starting point: ")) y1 = int(input("Enter the y-coordinate of the starting point: ")) x2 = int(input("Enter the x-coordinate of the ending point: ")) From 93ed88bc563c69e7143233792ff2ad764a0f6629 Mon Sep 17 00:00:00 2001 From: SEIKH NABAB UDDIN <93948993+nababuddin@users.noreply.github.com> Date: Sat, 28 Oct 2023 12:20:40 +0530 Subject: [PATCH 31/36] Update digital_differential_analyzer_line.py --- graphics/digital_differential_analyzer_line.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index 9280731bb886..f0c38837a128 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -1,12 +1,11 @@ import matplotlib.pyplot as plt - def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int ) -> list[tuple[int, int]]: """ - Draws a line between two points using the Digital Differential Analyzer (DDA) algorithm. - + Draws a line between two points using the DDA algorithm. + Args: - x1, y1: Coordinates of the starting point. - x2, y2: Coordinates of the ending point. @@ -17,7 +16,7 @@ def digital_differential_analyzer_line( >>> digital_differential_analyzer_line(1, 1, 4, 4) [(2, 2), (3, 3), (4, 4)] """ - + dx = x2 - x1 dy = y2 - y1 steps = max(abs(dx), abs(dy)) @@ -32,12 +31,10 @@ def digital_differential_analyzer_line( coordinates.append((int(round(x)), int(round(y)))) return coordinates - if __name__ == "__main__": import doctest - doctest.testmod() - + x1 = int(input("Enter the x-coordinate of the starting point: ")) y1 = int(input("Enter the y-coordinate of the starting point: ")) x2 = int(input("Enter the x-coordinate of the ending point: ")) From ac7607e325f67b3cf53d201fd06ab0959b162c4e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 28 Oct 2023 06:51:16 +0000 Subject: [PATCH 32/36] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- graphics/digital_differential_analyzer_line.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index f0c38837a128..60461e6006e4 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -1,11 +1,12 @@ import matplotlib.pyplot as plt + def digital_differential_analyzer_line( x1: int, y1: int, x2: int, y2: int ) -> list[tuple[int, int]]: """ Draws a line between two points using the DDA algorithm. - + Args: - x1, y1: Coordinates of the starting point. - x2, y2: Coordinates of the ending point. @@ -16,7 +17,7 @@ def digital_differential_analyzer_line( >>> digital_differential_analyzer_line(1, 1, 4, 4) [(2, 2), (3, 3), (4, 4)] """ - + dx = x2 - x1 dy = y2 - y1 steps = max(abs(dx), abs(dy)) @@ -31,10 +32,12 @@ def digital_differential_analyzer_line( coordinates.append((int(round(x)), int(round(y)))) return coordinates + if __name__ == "__main__": import doctest + doctest.testmod() - + x1 = int(input("Enter the x-coordinate of the starting point: ")) y1 = int(input("Enter the y-coordinate of the starting point: ")) x2 = int(input("Enter the x-coordinate of the ending point: ")) From 7ce5261f02032eaafc36329198c791eb72a2cf05 Mon Sep 17 00:00:00 2001 From: Tianyi Zheng Date: Mon, 30 Dec 2024 17:17:35 -0800 Subject: [PATCH 33/36] Apply suggestions from code review --- graphics/digital_differential_analyzer_line.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index 60461e6006e4..64b2c38b7740 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -2,22 +2,22 @@ def digital_differential_analyzer_line( - x1: int, y1: int, x2: int, y2: int + p1: tuple[int, int], p2: tuple[int, int] ) -> list[tuple[int, int]]: """ Draws a line between two points using the DDA algorithm. Args: - - x1, y1: Coordinates of the starting point. - - x2, y2: Coordinates of the ending point. - + - p1: Coordinates of the starting point. + - p2: Coordinates of the ending point. Returns: - List of coordinate points that form the line. >>> digital_differential_analyzer_line(1, 1, 4, 4) [(2, 2), (3, 3), (4, 4)] """ - + x1, y1 = p1 + x2, y2 = p2 dx = x2 - x1 dy = y2 - y1 steps = max(abs(dx), abs(dy)) From 8dab7f44b50130e1ecca40961061b7925096efb5 Mon Sep 17 00:00:00 2001 From: Tianyi Zheng Date: Mon, 30 Dec 2024 17:18:07 -0800 Subject: [PATCH 34/36] Fix doctest --- graphics/digital_differential_analyzer_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index 64b2c38b7740..9f5fdd920987 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -13,7 +13,7 @@ def digital_differential_analyzer_line( Returns: - List of coordinate points that form the line. - >>> digital_differential_analyzer_line(1, 1, 4, 4) + >>> digital_differential_analyzer_line((1, 1), (4, 4)) [(2, 2), (3, 3), (4, 4)] """ x1, y1 = p1 From 4a91773266c1ae919dadc3dc0725cac0b8d7fc70 Mon Sep 17 00:00:00 2001 From: Tianyi Zheng Date: Mon, 30 Dec 2024 17:26:38 -0800 Subject: [PATCH 35/36] Trigger GH workflows From 6f381df49d5ef3cd5aa51272fac4c729c6547d8f Mon Sep 17 00:00:00 2001 From: Tianyi Zheng Date: Mon, 30 Dec 2024 17:28:11 -0800 Subject: [PATCH 36/36] Fix function call in main block --- graphics/digital_differential_analyzer_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphics/digital_differential_analyzer_line.py b/graphics/digital_differential_analyzer_line.py index 9f5fdd920987..a51cb0b8dc37 100644 --- a/graphics/digital_differential_analyzer_line.py +++ b/graphics/digital_differential_analyzer_line.py @@ -42,7 +42,7 @@ def digital_differential_analyzer_line( y1 = int(input("Enter the y-coordinate of the starting point: ")) x2 = int(input("Enter the x-coordinate of the ending point: ")) y2 = int(input("Enter the y-coordinate of the ending point: ")) - coordinates = digital_differential_analyzer_line(x1, y1, x2, y2) + coordinates = digital_differential_analyzer_line((x1, y1), (x2, y2)) x_points, y_points = zip(*coordinates) plt.plot(x_points, y_points, marker="o") plt.title("Digital Differential Analyzer Line Drawing Algorithm")