From 62f4f37f116e49850752d1c310087342ef970d71 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 6 Feb 2023 22:20:04 +0100 Subject: Rename rtgrpblib_draw_{circular => elliptical}_arc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 2 +- ...kensnittsglyfrasteriseringsprogrambiblioteket.h | 12 +++--- rtgrpblib_draw_circular_arc.c | 48 ---------------------- rtgrpblib_draw_elliptical_arc.c | 48 ++++++++++++++++++++++ 4 files changed, 55 insertions(+), 55 deletions(-) delete mode 100644 rtgrpblib_draw_circular_arc.c create mode 100644 rtgrpblib_draw_elliptical_arc.c diff --git a/Makefile b/Makefile index 300fb5f..f96c012 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ OBJ =\ rtgrpblib_set_draftness.o\ draw_linear_bezier_reference.o\ lines.o\ - rtgrpblib_draw_circular_arc.o\ + rtgrpblib_draw_elliptical_arc.o\ rtgrpblib_draw_linear_bezier.o\ rtgrpblib_draw_quadratic_bezier.o\ rtgrpblib_draw_cubic_bezier.o\ diff --git a/librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket.h b/librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket.h index dd75db3..2ba9065 100644 --- a/librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket.h +++ b/librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket.h @@ -121,14 +121,14 @@ void rtgrpblib_draw_quadratic_bezier(RTGRPBLIB_RASTER *restrict raster, * @param x3, y3 The second control point * @param x4, y4 The end point */ -void rtgrpblib_draw_cubic_bezier(RTGRPBLIB_RASTER *restrict raster, /* needed for OpenType */ +void rtgrpblib_draw_cubic_bezier(RTGRPBLIB_RASTER *restrict raster, double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4); /** - * Draw a circular arc + * Draw a elliptical arc * * @param raster The drawing buffer * @param x0, y0 The midpoint of the ellipse @@ -137,10 +137,10 @@ void rtgrpblib_draw_cubic_bezier(RTGRPBLIB_RASTER *restrict raster, /* needed fo * @param start The angular starting point of the arc, in radians * @param end The angular end point of the arc, in radians */ -void rtgrpblib_draw_circular_arc(RTGRPBLIB_RASTER *restrict raster, /* needed for outline stoking */ - double x0, double y0, - double semiwidth, double semiheight, - double start, double end); +void rtgrpblib_draw_elliptical_arc(RTGRPBLIB_RASTER *restrict raster, + double x0, double y0, + double semiwidth, double semiheight, + double start, double end); #if defined(__clang__) diff --git a/rtgrpblib_draw_circular_arc.c b/rtgrpblib_draw_circular_arc.c deleted file mode 100644 index f30fde7..0000000 --- a/rtgrpblib_draw_circular_arc.c +++ /dev/null @@ -1,48 +0,0 @@ -/* 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 diff --git a/rtgrpblib_draw_elliptical_arc.c b/rtgrpblib_draw_elliptical_arc.c new file mode 100644 index 0000000..514ea14 --- /dev/null +++ b/rtgrpblib_draw_elliptical_arc.c @@ -0,0 +1,48 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" +#ifndef TEST + + +void +rtgrpblib_draw_elliptical_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 -- cgit v1.2.3-70-g09d2