Files
ee782b7d6e
QRun-IO/ci-policy: ci / fork-guard (push) Skipped
QRun-IO/ci-policy: ci / head-profile (push) Skipped
QRun-IO/ci-policy: ci / application-template-0 (push) Skipped
QRun-IO/ci-policy: ci / gradle-1 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3 (push) Skipped
QRun-IO/ci-policy: ci / java-docker-4 (push) Skipped
QRun-IO/ci-policy: ci / java-frontend-browser-5 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6 (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7 (push) Skipped
QRun-IO/ci-policy: ci / node-8 (push) Skipped
QRun-IO/ci-policy: ci / node-9 (push) Skipped
QRun-IO/ci-policy: ci / node-10 (push) Skipped
QRun-IO/ci-policy: ci / node-playwright-11 (push) Skipped
QRun-IO/ci-policy: ci / repository-policy-12 (push) Skipped
QRun-IO/ci-policy: ci / source-config-13 (push) Skipped
QRun-IO/ci-policy: ci / source-config-14 (push) Skipped
QRun-IO/ci-policy: ci / android-0 (push) Skipped
QRun-IO/ci-policy: ci / original-business (push) Skipped
QRun-IO/ci-policy: ci / original-mcp (push) Skipped
QRun-IO/ci-policy: ci / original-voyage (push) Skipped
QRun-IO/ci-policy: ci / original-cli (push) Skipped
QRun-IO/ci-policy: ci / not-enrolled (push) Failing after 7s
QRun-IO/ci-policy: native / fork-deny (push) Skipped
QRun-IO/ci-policy: native / dotnet-0 (push) Skipped
QRun-IO/ci-policy: ci / repository-policy (push) Skipped
QRun-IO/ci-policy: ci / java-core-2-head (push) Skipped
QRun-IO/ci-policy: ci / java-docker-3-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-6-head (push) Skipped
QRun-IO/ci-policy: ci / java-maven-7-head (push) Skipped
QRun-IO/ci-policy: ci / ci-result (push) Failing after 5s
QRun-IO/ci-policy: native / native-result (push) Successful in 6s
chore: preserve unfinished document generation source and status
Checkpoint implementation at user-requested stop; document known failures and incomplete release qualification.

Co-Authored-By: Claude <noreply@anthropic.com>

Co-Authored-By: GPT-6 Codex <noreply@openai.com>
2026-11-04 10:45:09 -06:00

74 lines
2.9 KiB
Diff

diff --git a/backend/raster.c b/backend/raster.c
index 5ab86838..96b6019e 100644
--- a/backend/raster.c
+++ b/backend/raster.c
@@ -30,6 +30,10 @@
*/
/* SPDX-License-Identifier: BSD-3-Clause */
+/* Contains routines adapted from https://zingl.github.io/bresenham.c
+ Copyright (c) 2020 zingl */
+/* SPDX-License-Identifier: MIT */
+
#include <assert.h>
#include <math.h>
@@ -580,31 +584,25 @@ static void draw_mp_circle_lines(unsigned char *pixelbuf, const int image_width,
/* Draw disc using Midpoint Circle Algorithm. Using this for MaxiCode rather than `draw_circle()` because it gives a
* flatter circumference with no single pixel peaks, similar to Figures J3 and J6 in ISO/IEC 16023:2000.
- * Taken from https://rosettacode.org/wiki/Bitmap/Midpoint_circle_algorithm#C
- * "Content is available under GNU Free Documentation License 1.2 unless otherwise noted."
- * https://www.gnu.org/licenses/old-licenses/fdl-1.2.html */
+ * Following adapted from `plotCircle()` in https://zingl.github.io/bresenham.c */
static void draw_mp_circle(unsigned char *pixelbuf, const int image_width, const int image_height,
- const int x0, const int y0, const int r, const int fill) {
- /* Using top RHS octant from (0, r) going clockwise, so fast direction is x (i.e. always incremented) */
- int f = 1 - r;
- int ddF_x = 0;
- int ddF_y = -2 * r;
- int x = 0;
- int y = r;
-
- draw_mp_circle_lines(pixelbuf, image_width, image_height, x0, y0, x, y, fill);
+ const int x0, const int y0, int r, const int fill) {
+ int x = -r;
+ int y = 0;
+ int err = 2 - 2 * r; /* Bottom left to top right */
- while (x < y) {
- if (f >= 0) {
- y--;
- ddF_y += 2;
- f += ddF_y;
- }
- x++;
- ddF_x += 2;
- f += ddF_x + 1;
+ do {
draw_mp_circle_lines(pixelbuf, image_width, image_height, x0, y0, x, y, fill);
- }
+ r = err;
+ if (r <= y) {
+ err += ++y * 2 + 1;
+ }
+ if (r > x || err > y) {
+ err += ++x * 2 + 1;
+ }
+ } while (x < 0);
+
+ draw_mp_circle_lines(pixelbuf, image_width, image_height, x0, y0, x, y, fill);
}
/* Draw central bullseye finder in Maxicode symbols */
@@ -651,8 +649,7 @@ static void draw_hexagon(unsigned char *pixelbuf, const int image_width, const i
}
/* Bresenham's line algorithm https://en.wikipedia.org/wiki/Bresenham's_line_algorithm
- * Creative Commons Attribution-ShareAlike License
- * https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License */
+ * Following adapted from `plotLine()` in https://zingl.github.io/bresenham.c */
static void plot_hexline(unsigned char *scaled_hexagon, const int hex_width, const int hex_height,
int start_x, int start_y, const int end_x, const int end_y) {
const int dx = abs(end_x - start_x);