3 * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos
4 * <jiri.bluebear.dluhos@gmail.com>
5 * Copyright (C) 2009-2014 Cyril Hrubis <metan@ucw.cz>
8 #include "core/GP_GetPutPixel.h"
9 #include "core/GP_FnPerBpp.h"
10 #include "gfx/GP_HLine.h"
11 #include "gfx/GP_VLine.h"
12 #include "gfx/GP_Ellipse.h"
15 * A filled ellipse drawing algorithm.
17 * The algorithm is exactly the same as with GP_Ellipse() except that
18 * we draw a line between each two points at each side of the X axis;
19 * therefore, we don't need to draw any points during iterations of X,
20 * we just iterate X until Y reaches next line, and then draw the full line.
23 @ for ps in pixelsizes:
25 static void GP_FillEllipse_Raw_{{ ps.suffix }}(GP_Pixmap *pixmap, GP_Coord xcenter,
26 GP_Coord ycenter, GP_Size a, GP_Size b, GP_Pixel pixel)
28 /* Precompute quadratic terms. */
32 /* Handle special case */
34 GP_VLine_Raw_{{ ps.suffix }}(pixmap, xcenter, ycenter - b, ycenter + b, pixel);
39 for (x = 0, error = -b2*a, y = b; y >= 0; y--) {
41 error += b2 * (2*x + 1);
44 error += a2 * (-2*y + 1);
46 /* Draw two horizontal lines reflected across Y. */
47 GP_HLine_Raw_{{ ps.suffix }}(pixmap, xcenter-x+1, xcenter+x-1, ycenter-y, pixel);
48 GP_HLine_Raw_{{ ps.suffix }}(pixmap, xcenter-x+1, xcenter+x-1, ycenter+y, pixel);
54 void GP_FillEllipse_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter,
55 GP_Size a, GP_Size b, GP_Pixel pixel)
57 GP_CHECK_PIXMAP(pixmap);
59 GP_FN_PER_BPP_PIXMAP(GP_FillEllipse_Raw, pixmap, pixmap,
60 xcenter, ycenter, a, b, pixel);
63 void GP_FillEllipse(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter,
64 GP_Size a, GP_Size b, GP_Pixel pixel)
66 GP_CHECK_PIXMAP(pixmap);
68 GP_TRANSFORM_POINT(pixmap, xcenter, ycenter);
69 GP_TRANSFORM_SWAP(pixmap, a, b);
71 GP_FillEllipse_Raw(pixmap, xcenter, ycenter, a, b, pixel);