1 /*****************************************************************************
2 * This file is part of gfxprim library. *
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. *
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. *
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 *
19 * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
20 * <jiri.bluebear.dluhos@gmail.com> *
22 * Copyright (C) 2009-2012 Cyril Hrubis <metan@ucw.cz> *
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_Context
*context
, GP_Coord x0
, GP_Coord y0
,
33 GP_Coord x1
, GP_Coord y1
, GP_Pixel pixel
)
35 GP_HLine_Raw(context
, x0
, x1
, y0
, pixel
);
36 GP_HLine_Raw(context
, x0
, x1
, y1
, pixel
);
37 GP_VLine_Raw(context
, x0
, y0
, y1
, pixel
);
38 GP_VLine_Raw(context
, x1
, y0
, y1
, pixel
);
41 void GP_RectXYWH_Raw(GP_Context
*context
, GP_Coord x
, GP_Coord y
,
42 GP_Size w
, GP_Size h
, GP_Pixel pixel
)
47 GP_RectXYXY_Raw(context
, x
, y
, x
+ w
- 1, y
+ h
- 1, pixel
);
50 void GP_RectXYXY(GP_Context
*context
, GP_Coord x0
, GP_Coord y0
,
51 GP_Coord x1
, GP_Coord y1
, GP_Pixel pixel
)
53 GP_CHECK_CONTEXT(context
);
55 GP_TRANSFORM_POINT(context
, x0
, y0
);
56 GP_TRANSFORM_POINT(context
, x1
, y1
);
58 GP_RectXYXY_Raw(context
, x0
, y0
, x1
, y1
, pixel
);
61 void GP_RectXYWH(GP_Context
*context
, GP_Coord x
, GP_Coord y
,
62 GP_Size w
, GP_Size h
, GP_Pixel pixel
)
67 GP_RectXYXY(context
, x
, y
, x
+ w
- 1, y
+ h
- 1, pixel
);
70 void GP_FillRectXYXY_Raw(GP_Context
*context
, GP_Coord x0
, GP_Coord y0
,
71 GP_Coord x1
, GP_Coord y1
, GP_Pixel pixel
)
73 GP_CHECK_CONTEXT(context
);
79 for (y
= y0
; y
<= y1
; y
++)
80 GP_HLine_Raw(context
, x0
, x1
, y
, pixel
);
83 void GP_FillRectXYWH_Raw(GP_Context
*context
, GP_Coord x
, GP_Coord y
,
84 GP_Size w
, GP_Size h
, GP_Pixel pixel
)
89 GP_FillRectXYXY_Raw(context
, x
, y
, x
+ w
- 1, y
+ h
- 1, pixel
);
92 void GP_FillRectXYXY(GP_Context
*context
, GP_Coord x0
, GP_Coord y0
,
93 GP_Coord x1
, GP_Coord y1
, GP_Pixel pixel
)
95 GP_CHECK_CONTEXT(context
);
97 GP_TRANSFORM_POINT(context
, x0
, y0
);
98 GP_TRANSFORM_POINT(context
, x1
, y1
);
100 GP_FillRect_Raw(context
, x0
, y0
, x1
, y1
, pixel
);
103 void GP_FillRectXYWH(GP_Context
*context
, GP_Coord x
, GP_Coord y
,
104 GP_Size w
, GP_Size h
, GP_Pixel pixel
)
106 if (w
== 0 || h
== 0)
109 GP_FillRectXYXY(context
, x
, y
, x
+ w
- 1, y
+ h
- 1, pixel
);