Skip to content

Commit 9b836da

Browse files
committed
refactor: reorganize internal class declaration
1 parent 610c7c6 commit 9b836da

File tree

1 file changed

+17
-25
lines changed

1 file changed

+17
-25
lines changed

src/main/java/com/thealgorithms/geometry/WusLine.java

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,30 @@ public Pixel(int x, int y, double intensity) {
5454
}
5555
}
5656

57+
/**
58+
* Internal class to hold processed endpoint data.
59+
*/
60+
private static class EndpointData {
61+
final int xPixel;
62+
final int yPixel;
63+
final double yEnd;
64+
final double xGap;
65+
66+
EndpointData(int xPixel, int yPixel, double yEnd, double xGap) {
67+
this.xPixel = xPixel;
68+
this.yPixel = yPixel;
69+
this.yEnd = yEnd;
70+
this.xGap = xGap;
71+
}
72+
}
73+
5774
/**
5875
* Draws an anti-aliased line using Wu's algorithm.
5976
*
6077
* The algorithm produces smooth lines by drawing pairs of pixels at each
6178
* x-coordinate (or y-coordinate for steep lines), with intensities based on
6279
* the line's distance from pixel centers.
6380
*
64-
* Example usage:
65-
* {@code
66-
* List<Pixel> linePixels = WusLine.drawLine(10, 20, 100, 80);
67-
* for (Pixel p : linePixels) {
68-
* drawPixel(p.point.x, p.point.y, p.intensity);
69-
* }
70-
* }
71-
*
7281
* @param x0 the x-coordinate of the line's start point
7382
* @param y0 the y-coordinate of the line's start point
7483
* @param x1 the x-coordinate of the line's end point
@@ -223,21 +232,4 @@ private static double rfpart(double x) {
223232
private static double round(double x) {
224233
return Math.floor(x + 0.5);
225234
}
226-
227-
/**
228-
* Internal class to hold processed endpoint data.
229-
*/
230-
private static class EndpointData {
231-
final int xPixel;
232-
final int yPixel;
233-
final double yEnd;
234-
final double xGap;
235-
236-
EndpointData(int xPixel, int yPixel, double yEnd, double xGap) {
237-
this.xPixel = xPixel;
238-
this.yPixel = yPixel;
239-
this.yEnd = yEnd;
240-
this.xGap = xGap;
241-
}
242-
}
243235
}

0 commit comments

Comments
 (0)