GRASS 8 Programmer's Manual 8.6.0dev(2026)-ddeab64dbf
Loading...
Searching...
No Matches
pngdriver/box.c
Go to the documentation of this file.
1/*!
2 \file lib/pngdriver/box.c
3
4 \brief GRASS png display driver - draw box
5
6 (C) 2003-2014 by Per Henrik Johansen and the GRASS Development Team
7
8 This program is free software under the GNU General Public License
9 (>=v2). Read the file COPYING that comes with GRASS for details.
10
11 \author Per Henrik Johansen (original contributor)
12 \author Glynn Clements
13 */
14
15#include <math.h>
16#include "pngdriver.h"
17
18/*!
19 \brief Draw a (filled) rectangle
20
21 \param fx1,fy1,fx2,fy2 rectangle coordinates
22 */
23void PNG_Box(double fx1, double fy1, double fx2, double fy2)
24{
25 int x1 = (int)floor(fx1 + 0.5);
26 int y1 = (int)floor(fy1 + 0.5);
27 int x2 = (int)floor(fx2 + 0.5);
28 int y2 = (int)floor(fy2 + 0.5);
29 int tmp;
30 int x, y;
31
32 if (x1 > x2)
33 tmp = x1, x1 = x2, x2 = tmp;
34
35 if (y1 > y2)
36 tmp = y1, y1 = y2, y2 = tmp;
37
38 if (x2 < 0 || x1 > png.width)
39 return;
40
41 if (y2 < 0 || y1 > png.height)
42 return;
43
44 if (x1 < png.clip_left)
45 x1 = png.clip_left;
46
47 if (x2 > png.clip_rite)
48 x2 = png.clip_rite;
49
50 if (y1 < png.clip_top)
51 y1 = png.clip_top;
52
53 if (y2 > png.clip_bot)
54 y2 = png.clip_bot;
55
56 for (y = y1; y < y2; y++) {
57 unsigned int *p = &png.grid[y * png.width + x1];
58
59 for (x = x1; x < x2; x++)
60 *p++ = png.current_color;
61 }
62
63 png.modified = 1;
64}
void PNG_Box(double fx1, double fy1, double fx2, double fy2)
Draw a (filled) rectangle.
struct png_state png
GRASS png display driver - header file.
#define x