1 /* Simple rectangle algebra.
2  */
3 
4 /*
5 
6     This file is part of VIPS.
7 
8     VIPS is free software; you can redistribute it and/or modify
9     it under the terms of the GNU Lesser General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any later version.
12 
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU Lesser General Public License for more details.
17 
18     You should have received a copy of the GNU Lesser General Public License
19     along with this program; if not, write to the Free Software
20     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21     02110-1301  USA
22 
23  */
24 
25 /*
26 
27     These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
28 
29  */
30 
31 #ifndef VIPS_RECT_H
32 #define VIPS_RECT_H
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif /*__cplusplus*/
37 
38 typedef struct _VipsRect {
39 	/*< public >*/
40 	int left;
41 	int top;
42 	int width;
43 	int height;
44 } VipsRect;
45 
46 #define VIPS_RECT_RIGHT(R) ((R)->left + (R)->width)
47 #define VIPS_RECT_BOTTOM(R) ((R)->top + (R)->height)
48 #define VIPS_RECT_HCENTRE(R) ((R)->left + (R)->width / 2)
49 #define VIPS_RECT_VCENTRE(R) ((R)->top + (R)->height / 2)
50 
51 gboolean vips_rect_isempty( const VipsRect *r );
52 gboolean vips_rect_includespoint( const VipsRect *r, int x, int y );
53 gboolean vips_rect_includesrect( const VipsRect *r1, const VipsRect *r2 );
54 gboolean vips_rect_equalsrect( const VipsRect *r1, const VipsRect *r2 );
55 gboolean vips_rect_overlapsrect( const VipsRect *r1, const VipsRect *r2 );
56 void vips_rect_marginadjust( VipsRect *r, int n );
57 void vips_rect_intersectrect( const VipsRect *r1, const VipsRect *r2,
58 	VipsRect *out );
59 void vips_rect_unionrect( const VipsRect *r1, const VipsRect *r2,
60 	VipsRect *out );
61 VipsRect *vips_rect_dup( const VipsRect *r );
62 void vips_rect_normalise( VipsRect *r );
63 
64 #ifdef __cplusplus
65 }
66 #endif /*__cplusplus*/
67 
68 #endif /*VIPS_RECT_H*/
69