aboutsummaryrefslogtreecommitdiffstats
path: root/rtgrpblib_draw_circular_arc.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-02-07 22:48:46 +0100
committerMattias Andrée <maandree@kth.se>2023-02-07 22:48:46 +0100
commite7b56841561f9a8bc40d8cebd9dae23b3c5951a2 (patch)
tree87b5e109a7c92fec341ad4096c315929dbb3979d /rtgrpblib_draw_circular_arc.c
parentAdd man pages (diff)
downloadlibrifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket-e7b56841561f9a8bc40d8cebd9dae23b3c5951a2.tar.gz
librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket-e7b56841561f9a8bc40d8cebd9dae23b3c5951a2.tar.bz2
librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket-e7b56841561f9a8bc40d8cebd9dae23b3c5951a2.tar.xz
Change back the name of rtgrpblib_draw_elliptical_arc to rtgrpblib_draw_circular_arc
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'rtgrpblib_draw_circular_arc.c')
-rw-r--r--rtgrpblib_draw_circular_arc.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/rtgrpblib_draw_circular_arc.c b/rtgrpblib_draw_circular_arc.c
new file mode 100644
index 0000000..f30fde7
--- /dev/null
+++ b/rtgrpblib_draw_circular_arc.c
@@ -0,0 +1,48 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifndef TEST
+
+
+void
+rtgrpblib_draw_circular_arc(RASTER *restrict raster, double x0, double y0,
+ double semiwidth, double semiheight, double start, double end)
+{
+ double inc, v, x, y, prevX, prevY;
+
+ if (start == end)
+ return;
+
+ /* TODO precalculate intersection with raster box */
+
+ inc = fmax(semiwidth, semiheight);
+ inc *= 2 * M_PI;
+ inc *= end - start;
+ inc = raster->draftness / inc;
+
+ v = start;
+ prevX = x0 + semiwidth * cos(start);
+ prevY = y0 + semiheight * sin(start);
+
+ for (; (v += inc) < end; prevX = x, prevY = y) {
+ x = x0 + semiwidth * cos(v);
+ y = y0 + semiheight * sin(v);
+ rtgrpblib_draw_linear_bezier(raster, prevX, prevY, x, y);
+ }
+
+ x = x0 + semiwidth * cos(end);
+ y = y0 + semiheight * sin(end);
+ rtgrpblib_draw_linear_bezier(raster, prevX, prevY, x, y);
+}
+
+
+#else
+
+
+int
+main(void)
+{
+ return 0; /* TODO add test */
+}
+
+
+#endif