Rename GP_Context -> GP_Pixmap
[gfxprim.git] / libs / gfx / GP_Rect.c
blobcbaf5f2b6a1984acca4b7bfbdd335dce1ab8793e
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_Transform.h"
28 #include "gfx/GP_HLine.h"
29 #include "gfx/GP_VLine.h"
30 #include "gfx/GP_Rect.h"
32 void GP_RectXYXY_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0,
33 GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
35 GP_HLine_Raw(pixmap, x0, x1, y0, pixel);
36 GP_HLine_Raw(pixmap, x0, x1, y1, pixel);
37 GP_VLine_Raw(pixmap, x0, y0, y1, pixel);
38 GP_VLine_Raw(pixmap, x1, y0, y1, pixel);
41 void GP_RectXYWH_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y,
42 GP_Size w, GP_Size h, GP_Pixel pixel)
44 if (w == 0 || h == 0)
45 return;
47 GP_RectXYXY_Raw(pixmap, x, y, x + w - 1, y + h - 1, pixel);
50 void GP_RectXYXY(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0,
51 GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
53 GP_CHECK_PIXMAP(pixmap);
55 GP_TRANSFORM_POINT(pixmap, x0, y0);
56 GP_TRANSFORM_POINT(pixmap, x1, y1);
58 GP_RectXYXY_Raw(pixmap, x0, y0, x1, y1, pixel);
61 void GP_RectXYWH(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y,
62 GP_Size w, GP_Size h, GP_Pixel pixel)
64 if (w == 0 || h == 0)
65 return;
67 GP_RectXYXY(pixmap, x, y, x + w - 1, y + h - 1, pixel);
70 void GP_FillRectXYXY_Raw(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0,
71 GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
73 GP_CHECK_PIXMAP(pixmap);
75 if (y0 > y1)
76 GP_SWAP(y0, y1);
78 y0 = GP_MAX(0, y0);
79 y1 = GP_MIN(y1, (GP_Coord)pixmap->h - 1);
81 GP_Coord y;
82 for (y = y0; y <= y1; y++)
83 GP_HLine_Raw(pixmap, x0, x1, y, pixel);
86 void GP_FillRectXYWH_Raw(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y,
87 GP_Size w, GP_Size h, GP_Pixel pixel)
89 if (w == 0 || h == 0)
90 return;
92 GP_FillRectXYXY_Raw(pixmap, x, y, x + w - 1, y + h - 1, pixel);
95 void GP_FillRectXYXY(GP_Pixmap *pixmap, GP_Coord x0, GP_Coord y0,
96 GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
98 GP_CHECK_PIXMAP(pixmap);
100 GP_TRANSFORM_POINT(pixmap, x0, y0);
101 GP_TRANSFORM_POINT(pixmap, x1, y1);
103 GP_FillRectXYXY_Raw(pixmap, x0, y0, x1, y1, pixel);
106 void GP_FillRectXYWH(GP_Pixmap *pixmap, GP_Coord x, GP_Coord y,
107 GP_Size w, GP_Size h, GP_Pixel pixel)
109 if (w == 0 || h == 0)
110 return;
112 GP_FillRectXYXY(pixmap, x, y, x + w - 1, y + h - 1, pixel);