Skip to content
This repository was archived by the owner on Jul 26, 2025. It is now read-only.

Commit 0263139

Browse files
committed
docs: add comments to the function
1 parent 88cecdc commit 0263139

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/draw/drawCircleOnImage.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,12 @@ export function drawCircleOnImage(
9090
{ strokeColor: fill, out: newImage },
9191
);
9292
}
93-
// The bresenham algorithm is drawing the circle in 4 parts. We are filling the top and bottom part of the circle. Therefore we check whether the point belongs to top or bottom part through indexes. Index must be 1 or 3 to fill the circle.
94-
// Filling bottom half of the circle.
95-
if ((index - 1) % 4 === 0 && prevRow !== row) {
93+
// The algorithm used is Bresenham's circle algorithm (@link https://www.geeksforgeeks.org/bresenhams-circle-drawing-algorithm/) to find points that constitute the circle outline. However, in this algorithm The circle is divided in 4 parts instead of 8: top, right, bottom and left.
94+
// The algorithm draws a point per quadrant until the circle is complete.
95+
// We use bottom (index % 4 === 1, quadrant 2) point of the outline to fill the circle with color.
96+
// Filling half of the circle.
97+
if (index % 4 === 1 && prevRow !== row) {
98+
// For quadrant 2, column < center.column
9699
newImage.drawLine(
97100
{ row, column: column + 1 },
98101
{

0 commit comments

Comments
 (0)