GRASS 8 Programmer's Manual
8.5.0(2026)-8d6ceba290
Toggle main menu visibility
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
*/
23
void
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
}
PNG_Box
void PNG_Box(double fx1, double fy1, double fx2, double fy2)
Draw a (filled) rectangle.
Definition
pngdriver/box.c:23
png
struct png_state png
Definition
pngdriver/graph_set.c:32
pngdriver.h
GRASS png display driver - header file.
png_state::clip_left
double clip_left
Definition
pngdriver.h:41
png_state::clip_bot
double clip_bot
Definition
pngdriver.h:41
png_state::clip_top
double clip_top
Definition
pngdriver.h:41
png_state::current_color
int current_color
Definition
pngdriver.h:33
png_state::height
int height
Definition
pngdriver.h:42
png_state::grid
unsigned int * grid
Definition
pngdriver.h:43
png_state::width
int width
Definition
pngdriver.h:42
png_state::clip_rite
double clip_rite
Definition
pngdriver.h:41
png_state::modified
int modified
Definition
pngdriver.h:46
x
#define x
pngdriver
box.c
Generated on
for GRASS 8 Programmer's Manual by
1.18.0