.\" Copyright (c) 2008 Hypertriton, Inc.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
.\" (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd October 12, 2008
.Dt AG_RECT 3
.Os
.ds vT Agar API Reference
.ds oS Agar 1.3.3
.Sh NAME
.Nm AG_Rect
.Nd agar rectangle structure
.Sh SYNOPSIS
.Bd -literal
#include
#include
.Ed
.Sh DESCRIPTION
Many functions in Agar accept
.Fa AG_Rect
parameters.
This structure describes a rectangle in terms of position and dimensions:
.Bd -literal
typedef struct ag_rect {
int x, y;
int w, h;
} AG_Rect;
.Ed
.Pp
Agar also defines an
.Ft AG_Rect2
structure, which describes a rectangle in terms of two endpoints:
.Bd -literal
typedef struct ag_rect2 {
int x1, y1;
int w, h;
int x2, y2;
} AG_Rect2;
.Ed
.Pp
For operations which involve intersection tests, it is more efficient to
use
.Ft AG_Rect2
over
.Ft AG_Rect .
.Sh INTERFACE
.nr nS 1
.Ft AG_Rect
.Fn AG_RECT "int x" "int y" "int w" "int h"
.Pp
.Ft AG_Rect2
.Fn AG_RECT2 "int x" "int y" "int w" "int h"
.Pp
.Ft AG_Rect
.Fn AG_Rect2ToRect "AG_Rect2 r"
.Pp
.Ft AG_Rect2
.Fn AG_RectToRect2 "AG_Rect r"
.Pp
.Ft AG_Rect
.Fn AG_RectIntersect "const AG_Rect *a" "const AG_Rect *b"
.Pp
.Ft AG_Rect2
.Fn AG_RectIntersect2 "const AG_Rect2 *a" "const AG_Rect2 *b"
.Pp
.Ft int
.Fn AG_RectInside "const AG_Rect *r" "int x" "int y"
.Pp
.Ft int
.Fn AG_RectInside2 "const AG_Rect2 *r" "int x" "int y"
.Pp
.Ft SDL_Rect
.Fn AG_RectToSDL "const AG_Rect *r"
.Pp
.Ft AG_Rect
.Fn AG_RectFromSDL "const SDL_Rect *r"
.Pp
.Ft int
.Fn AG_RectCompare "const AG_Rect *a" "const AG_Rect *b"
.Pp
.Ft int
.Fn AG_RectCompare2 "const AG_Rect2 *a" "const AG_Rect2 *b"
.Pp
.Ft void
.Fn AG_RectSize "AG_Rect *r" "int w" "int h"
.Pp
.Ft void
.Fn AG_RectSize2 "AG_Rect2 *r" "int w" "int h"
.Pp
.nr nS 0
.Pp
The
.Fn AG_RECT
routine returns an
.Ft AG_Rect
from the given coordinates
.Fa x ,
.Fa y
and dimensions
.Fa w ,
.Fa h .
The
.Fn AG_RECT2
variant returns an
.Ft AG_Rect2 .
.Pp
The
.Fn AG_RectToRect2
and
.Fn AG_Rect2ToRect
routines convert between the
.Ft AG_Rect
and
.Ft AG_Rect2
formats.
.Pp
If Agar is compiled with support for SDL, the
.Fn AG_RectToSDL
and
.Fn AG_RectFromSDL
routines are available for converting between
.Ft AG_Rect
and
.Ft SDL_Rect .
.Pp
.Fn AG_RectIntersect
and
.Fn AG_RectIntersect2
return intersection of rectangles
.Fa a
and
.Fa b .
.Pp
.Fn AG_RectInside
and
.Fn AG_RectInside
return 1 if the point
.Fa x ,
.Fa y
lies inside of rectangle
.Fa r .
.Pp
The
.Fn AG_RectCompare
and
.Fn AG_RectCompare2
routines return 0 if both rectangles possess the same coordinates and
dimensions.
.Pp
The
.Fn AG_RectSize
and
.Fn AG_RectSize2
routines resize a rectangle to the specified dimensions.
.Sh SEE ALSO
.Xr AG_Intro 3 ,
.Xr AG_Widget 3 .
.Sh HISTORY
The
.Nm
structure first appeared in Agar 1.3.