From e7b56841561f9a8bc40d8cebd9dae23b3c5951a2 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 7 Feb 2023 22:48:46 +0100 Subject: Change back the name of rtgrpblib_draw_elliptical_arc to rtgrpblib_draw_circular_arc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 4 +- README | 9 ++-- ...kensnittsglyfrasteriseringsprogrambiblioteket.7 | 9 ++-- ...kensnittsglyfrasteriseringsprogrambiblioteket.h | 26 ++++++++---- rtgrpblib_draw_circular_arc.c | 48 ++++++++++++++++++++++ rtgrpblib_draw_elliptical_arc.c | 48 ---------------------- rtgrpblib_draw_linear_bezier.3 | 4 +- rtgrpblib_fill_shapes.3 | 2 +- 8 files changed, 77 insertions(+), 73 deletions(-) create mode 100644 rtgrpblib_draw_circular_arc.c delete mode 100644 rtgrpblib_draw_elliptical_arc.c diff --git a/Makefile b/Makefile index 96cd2da..3a8befe 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ OBJ =\ rtgrpblib_set_draftness.o\ draw_linear_bezier_reference.o\ lines.o\ - rtgrpblib_draw_elliptical_arc.o\ + rtgrpblib_draw_circular_arc.o\ rtgrpblib_draw_linear_bezier.o\ rtgrpblib_draw_quadratic_bezier.o\ rtgrpblib_draw_cubic_bezier.o\ @@ -42,7 +42,7 @@ MAN3 =\ rtgrpblib_create_raster.3\ rtgrpblib_reset_raster.3\ rtgrpblib_set_draftness.3\ - rtgrpblib_draw_elliptical_arc.3\ + rtgrpblib_draw_circular_arc.3\ rtgrpblib_draw_linear_bezier.3\ rtgrpblib_draw_quadratic_bezier.3\ rtgrpblib_draw_cubic_bezier.3\ diff --git a/README b/README index 4f8d93a..d297047 100644 --- a/README +++ b/README @@ -10,17 +10,14 @@ DESCRIPTION library only supports curve types that are used for drawing glyphs; specifically this means that lines and quadratic Bézier curves are supported by cause this is what is required to draw vectorised bitmap fonts and TrueType fonts, but also - cubic Bézier curves as this is required for OpenType fonts and elliptical arcs - (elliptical rather than circular because it may be need required to strech the - circle to support outputs with different vertical and horizontal dot density - and to support subpixel antialiasing) as this is commonly used for corners when - stroking the outline of a glyph. + cubic Bézier curves as this is required for OpenType fonts and circular arcs + as this is commonly used for corners when stroking the outline of a glyph. The create an image, first create a buffer using rtgrpblib_create_raster(3) (if you already have one that is large enough, you can reinitialise it with rtgrpblib_reset_raster(3)), and than using the drawing functions (rtgrpblib_draw_linear_bezier(3), rtgrpblib_draw_quadratic_bezier(3), - rtgrpblib_draw_cubic_bezier(3), and rtgrpblib_draw_elliptical_arc(3)) to + rtgrpblib_draw_cubic_bezier(3), and rtgrpblib_draw_circular_arc(3)) to draw the components of each shape's outline. When done, create an image using the rtgrpblib_fill_shapes(3) function: you will receive a ink-level map, where the value 0 means background, and 1 means foreground, and values diff --git a/librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket.7 b/librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket.7 index a0fe3d0..aff9ec4 100644 --- a/librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket.7 +++ b/librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket.7 @@ -14,11 +14,8 @@ for drawing glyphs; specifically this means that lines and quadratic Bézier curves are supported by cause this is what is required to draw vectorised bitmap fonts and TrueType fonts, but also cubic Bézier curves as this is required for OpenType -fonts and elliptical arcs (elliptical rather than circular -because it may be need required to strech the circle to support -outputs with different vertical and horizontal dot density and -to support subpixel antialiasing) as this is commonly used for -corners when stroking the outline of a glyph. +fonts and circular arcs as this is commonly used for corners +when stroking the outline of a glyph. .PP The create an image, first create a buffer using .BR rtgrpblib_create_raster (3) @@ -30,7 +27,7 @@ and than using the drawing functions .BR rtgrpblib_draw_quadratic_bezier (3), .BR rtgrpblib_draw_cubic_bezier (3), and -.BR rtgrpblib_draw_elliptical_arc (3)) +.BR rtgrpblib_draw_circular_arc (3)) to draw the components of each shape's outline. When done, create an image using the .BR rtgrpblib_fill_shapes (3) diff --git a/librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket.h b/librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket.h index aa6f4ce..ef53fea 100644 --- a/librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket.h +++ b/librifunktionsteckensnittsglyfrasteriseringsprogrambiblioteket.h @@ -128,19 +128,29 @@ void rtgrpblib_draw_cubic_bezier(RTGRPBLIB_RASTER *restrict raster, double x4, double y4); /** - * Draw a elliptical arc + * Draw a circular arc * * @param raster The drawing buffer - * @param x0, y0 The midpoint of the ellipse - * @param semiwidth Half the width of the ellipse - * @param semiheight Half the height of the ellipse + * @param x0, y0 The midpoint of the circle + * @param semiwidth Half the width of the circle + * @param semiheight Half the height of the circle * @param start The angular starting point of the arc, in radians * @param end The angular end point of the arc, in radians + * + * Rather than specify a radius, a semimajor and semiminor is + * specified, despite this, the shape is called a circular rather + * than elliptical, this is because the function is indented to + * draw a circular arc on a image with different horizontal + * and vertical cell densities; note an elliptical arc on an image + * with the same horizontal as vertical cell density. This is + * why the function doesn't provide a way to rotate the ellipse: + * it's a circle, not an ellipse, and circles are perfectly + * symmetrical */ -void rtgrpblib_draw_elliptical_arc(RTGRPBLIB_RASTER *restrict raster, - double x0, double y0, - double semiwidth, double semiheight, - double start, double end); +void rtgrpblib_draw_circular_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 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 diff --git a/rtgrpblib_draw_elliptical_arc.c b/rtgrpblib_draw_elliptical_arc.c deleted file mode 100644 index 514ea14..0000000 --- a/rtgrpblib_draw_elliptical_arc.c +++ /dev/null @@ -1,48 +0,0 @@ -/* 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 diff --git a/rtgrpblib_draw_linear_bezier.3 b/rtgrpblib_draw_linear_bezier.3 index 7cc67c9..05b12f9 100644 --- a/rtgrpblib_draw_linear_bezier.3 +++ b/rtgrpblib_draw_linear_bezier.3 @@ -20,7 +20,7 @@ The .BR rtgrpblib_draw_linear_bezier () function draws onto .I raster -a line segment from +a line segment, as part a contour, from .RI ( x1 , .IR y1 ) to @@ -39,4 +39,4 @@ None. .BR rtgrpblib_fill_shapes (3), .BR rtgrpblib_draw_quadratic_bezier (3), .BR rtgrpblib_draw_cubic_bezier (3), -.BR rtgrpblib_draw_elliptical_arc (3) +.BR rtgrpblib_draw_circular_arc (3) diff --git a/rtgrpblib_fill_shapes.3 b/rtgrpblib_fill_shapes.3 index 7bd58b5..8c01995 100644 --- a/rtgrpblib_fill_shapes.3 +++ b/rtgrpblib_fill_shapes.3 @@ -82,4 +82,4 @@ has the index .BR rtgrpblib_draw_linear_bezier (3), .BR rtgrpblib_draw_quadratic_bezier (3), .BR rtgrpblib_draw_cubic_bezier (3), -.BR rtgrpblib_draw_elliptical_arc (3) +.BR rtgrpblib_draw_circular_arc (3) -- cgit v1.2.3-70-g09d2