Rename GP_Context -> GP_Pixmap
[gfxprim.git] / libs / gfx / GP_CircleSeg.c
blob8b51797609ff28b9066554de7587ac7b02628dd9
1 /*****************************************************************************
2 * This file is part of gfxprim library. *
3 * *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
8 * *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
18 * *
19 * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
20 * <jiri.bluebear.dluhos@gmail.com> *
21 * *
22 * Copyright (C) 2009-2012 Cyril Hrubis <metan@ucw.cz> *
23 * *
24 *****************************************************************************/
26 #include "core/GP_GetPutPixel.h"
27 #include "core/GP_FnPerBpp.h"
29 #include "gfx/GP_CircleSeg.h"
30 #include "gfx/GP_HLine.h"
32 #include "algo/CircleSeg.algo.h"
34 static uint8_t transform_segments(GP_Pixmap *pixmap, uint8_t seg_flags)
36 uint8_t seg1 = seg_flags & GP_CIRCLE_SEG1;
37 uint8_t seg2 = seg_flags & GP_CIRCLE_SEG2;
38 uint8_t seg3 = seg_flags & GP_CIRCLE_SEG3;
39 uint8_t seg4 = seg_flags & GP_CIRCLE_SEG4;
41 if (pixmap->axes_swap)
42 GP_SWAP(seg1, seg3);
44 if (pixmap->x_swap) {
45 GP_SWAP(seg1, seg2);
46 GP_SWAP(seg3, seg4);
49 if (pixmap->y_swap) {
50 GP_SWAP(seg1, seg4);
51 GP_SWAP(seg2, seg3);
54 seg1 = seg1 ? GP_CIRCLE_SEG1 : 0;
55 seg2 = seg2 ? GP_CIRCLE_SEG2 : 0;
56 seg3 = seg3 ? GP_CIRCLE_SEG3 : 0;
57 seg4 = seg4 ? GP_CIRCLE_SEG4 : 0;
59 return seg1|seg2|seg3|seg4;
62 /* Generate drawing functions for various bit depths. */
63 GP_DEF_DRAW_FN_PER_BPP(GP_CircleSeg_Raw, DEF_CIRCLE_SEG_FN)
65 void GP_CircleSeg_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter,
66 GP_Size r, uint8_t seg_flag, GP_Pixel pixel)
68 GP_CHECK_PIXMAP(pixmap);
70 GP_FN_PER_BPP_PIXMAP(GP_CircleSeg_Raw, pixmap, pixmap,
71 xcenter, ycenter, r, seg_flag, pixel);
74 void GP_CircleSeg(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter,
75 GP_Size r, uint8_t seg_flag, GP_Pixel pixel)
77 GP_CHECK_PIXMAP(pixmap);
79 GP_TRANSFORM_POINT(pixmap, xcenter, ycenter);
81 GP_CircleSeg_Raw(pixmap, xcenter, ycenter, r,
82 transform_segments(pixmap, seg_flag), pixel);
86 #include "algo/FillCircle.algo.h"
88 GP_DEF_FILL_FN_PER_BPP(GP_FillCircle_Raw, DEF_FILLCIRCLE_FN)
90 void GP_FillCircle_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter,
91 GP_Size r, GP_Pixel pixel)
93 GP_CHECK_PIXMAP(pixmap);
95 GP_FN_PER_BPP_PIXMAP(GP_FillCircle_Raw, pixmap, pixmap,
96 xcenter, ycenter, r, pixel);
99 void GP_FillCircle(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter,
100 GP_Size r, GP_Pixel pixel)
102 GP_CHECK_PIXMAP(pixmap);
104 GP_TRANSFORM_POINT(pixmap, xcenter, ycenter);
106 GP_FillCircle_Raw(pixmap, xcenter, ycenter, r, pixel);