<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY % local.common.attrib "xmlns:xi  CDATA  #FIXED 'http://www.w3.org/2003/XInclude'">
<!ENTITY version SYSTEM "version.xml">
]>
<refentry id="gdk4-Points-Rectangles-and-Regions">
<refmeta>
<refentrytitle role="top_of_page" id="gdk4-Points-Rectangles-and-Regions.top_of_page">Points and Rectangles</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GDK4 Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Points and Rectangles</refname>
<refpurpose>Simple graphical data types</refpurpose>
</refnamediv>

<refsect1 id="gdk4-Points-Rectangles-and-Regions.functions" role="functions_proto">
<title role="functions_proto.title">Functions</title>
<informaltable pgwide="1" frame="none">
<tgroup cols="2">
<colspec colname="functions_proto_type" colwidth="150px"/>
<colspec colname="functions_proto_name"/>
<tbody>
<row><entry role="function_type"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
</entry><entry role="function_name"><link linkend="gdk-rectangle-intersect">gdk_rectangle_intersect</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="gdk-rectangle-union">gdk_rectangle_union</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
</entry><entry role="function_name"><link linkend="gdk-rectangle-equal">gdk_rectangle_equal</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
</entry><entry role="function_name"><link linkend="gdk-rectangle-contains-point">gdk_rectangle_contains_point</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<anchor id="GdkRectangle"/><refsect1 id="gdk4-Points-Rectangles-and-Regions.other" role="other_proto">
<title role="other_proto.title">Types and Values</title>
<informaltable pgwide="1" frame="none">
<tgroup cols="2">
<colspec colname="other_proto_type" colwidth="150px"/>
<colspec colname="other_proto_name"/>
<tbody>
<row><entry role="datatype_keyword"></entry><entry role="function_name"><link linkend="GdkPoint">GdkPoint</link></entry></row>

<row><entry role="datatype_keyword"></entry><entry role="function_name"><link linkend="GdkRectangle-struct">GdkRectangle</link></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 id="gdk4-Points-Rectangles-and-Regions.object-hierarchy" role="object_hierarchy">
<title role="object_hierarchy.title">Object Hierarchy</title>
<screen>    <link linkend="GBoxed">GBoxed</link>
    <phrase role="lineart">&#9584;&#9472;&#9472;</phrase> GdkRectangle
</screen>
</refsect1>

<refsect1 id="gdk4-Points-Rectangles-and-Regions.includes"><title>Includes</title><synopsis>#include &lt;gdk/gdk.h&gt;
</synopsis></refsect1>

<refsect1 id="gdk4-Points-Rectangles-and-Regions.description" role="desc">
<title role="desc.title">Description</title>
<para>GDK provides the <link linkend="GdkPoint"><type>GdkPoint</type></link> and <link linkend="GdkRectangle"><type>GdkRectangle</type></link> data types for representing pixels
and sets of pixels on the screen. Together with Cairo’s <link linkend="cairo-region-t"><type>cairo_region_t</type></link> data
type, they make up the central types for representing graphical data.</para>
<para>A <link linkend="GdkPoint"><type>GdkPoint</type></link> represents an x and y coordinate of a point.</para>
<para>A <link linkend="GdkRectangle"><type>GdkRectangle</type></link> represents the position and size of a rectangle.
The intersection of two rectangles can be computed with
<link linkend="gdk-rectangle-intersect"><function>gdk_rectangle_intersect()</function></link>. To find the union of two rectangles use
<link linkend="gdk-rectangle-union"><function>gdk_rectangle_union()</function></link>.</para>
<para><link linkend="cairo-region-t"><type>cairo_region_t</type></link> is usually used for managing clipping of graphical operations.</para>

</refsect1>
<refsect1 id="gdk4-Points-Rectangles-and-Regions.functions_details" role="details">
<title role="details.title">Functions</title>
<refsect2 id="gdk-rectangle-intersect" role="function">
<title>gdk_rectangle_intersect&#160;()</title>
<indexterm zone="gdk-rectangle-intersect"><primary>gdk_rectangle_intersect</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
gdk_rectangle_intersect (<parameter>const <link linkend="GdkRectangle"><type>GdkRectangle</type></link> *src1</parameter>,
                         <parameter>const <link linkend="GdkRectangle"><type>GdkRectangle</type></link> *src2</parameter>,
                         <parameter><link linkend="GdkRectangle"><type>GdkRectangle</type></link> *dest</parameter>);</programlisting>
<para>Calculates the intersection of two rectangles. It is allowed for
<parameter>dest</parameter>
 to be the same as either <parameter>src1</parameter>
 or <parameter>src2</parameter>
. If the rectangles 
do not intersect, <parameter>dest</parameter>
’s width and height is set to 0 and its x 
and y values are undefined. If you are only interested in whether
the rectangles intersect, but not in the intersecting area itself,
pass <link linkend="NULL:CAPS"><literal>NULL</literal></link> for <parameter>dest</parameter>
.</para>
<refsect3 id="gdk-rectangle-intersect.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>src1</para></entry>
<entry role="parameter_description"><para>a <link linkend="GdkRectangle"><type>GdkRectangle</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>src2</para></entry>
<entry role="parameter_description"><para>a <link linkend="GdkRectangle"><type>GdkRectangle</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>dest</para></entry>
<entry role="parameter_description"><para>return location for the
intersection of <parameter>src1</parameter>
and <parameter>src2</parameter>
, or <link linkend="NULL:CAPS"><literal>NULL</literal></link>. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>out caller-allocates</acronym>][<acronym>allow-none</acronym>]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gdk-rectangle-intersect.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if the rectangles intersect.</para>
</refsect3></refsect2>
<refsect2 id="gdk-rectangle-union" role="function">
<title>gdk_rectangle_union&#160;()</title>
<indexterm zone="gdk-rectangle-union"><primary>gdk_rectangle_union</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
gdk_rectangle_union (<parameter>const <link linkend="GdkRectangle"><type>GdkRectangle</type></link> *src1</parameter>,
                     <parameter>const <link linkend="GdkRectangle"><type>GdkRectangle</type></link> *src2</parameter>,
                     <parameter><link linkend="GdkRectangle"><type>GdkRectangle</type></link> *dest</parameter>);</programlisting>
<para>Calculates the union of two rectangles.
The union of rectangles <parameter>src1</parameter>
 and <parameter>src2</parameter>
 is the smallest rectangle which
includes both <parameter>src1</parameter>
 and <parameter>src2</parameter>
 within it.
It is allowed for <parameter>dest</parameter>
 to be the same as either <parameter>src1</parameter>
 or <parameter>src2</parameter>
.</para>
<para>Note that this function does not ignore 'empty' rectangles (ie. with
zero width or height).</para>
<refsect3 id="gdk-rectangle-union.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>src1</para></entry>
<entry role="parameter_description"><para>a <link linkend="GdkRectangle"><type>GdkRectangle</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>src2</para></entry>
<entry role="parameter_description"><para>a <link linkend="GdkRectangle"><type>GdkRectangle</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>dest</para></entry>
<entry role="parameter_description"><para>return location for the union of <parameter>src1</parameter>
and <parameter>src2</parameter>
. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>out</acronym>]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="gdk-rectangle-equal" role="function">
<title>gdk_rectangle_equal&#160;()</title>
<indexterm zone="gdk-rectangle-equal"><primary>gdk_rectangle_equal</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
gdk_rectangle_equal (<parameter>const <link linkend="GdkRectangle"><type>GdkRectangle</type></link> *rect1</parameter>,
                     <parameter>const <link linkend="GdkRectangle"><type>GdkRectangle</type></link> *rect2</parameter>);</programlisting>
<para>Checks if the two given rectangles are equal.</para>
<refsect3 id="gdk-rectangle-equal.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>rect1</para></entry>
<entry role="parameter_description"><para>a <link linkend="GdkRectangle"><type>GdkRectangle</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>rect2</para></entry>
<entry role="parameter_description"><para>a <link linkend="GdkRectangle"><type>GdkRectangle</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gdk-rectangle-equal.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if the rectangles are equal.</para>
</refsect3></refsect2>
<refsect2 id="gdk-rectangle-contains-point" role="function">
<title>gdk_rectangle_contains_point&#160;()</title>
<indexterm zone="gdk-rectangle-contains-point"><primary>gdk_rectangle_contains_point</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
gdk_rectangle_contains_point (<parameter>const <link linkend="GdkRectangle"><type>GdkRectangle</type></link> *rect</parameter>,
                              <parameter><link linkend="int"><type>int</type></link> x</parameter>,
                              <parameter><link linkend="int"><type>int</type></link> y</parameter>);</programlisting>
<para>Returns <link linkend="TRUE:CAPS"><type>TRUE</type></link> if <parameter>rect</parameter>
 contains the point described by <parameter>x</parameter>
 and <parameter>y</parameter>
.</para>
<refsect3 id="gdk-rectangle-contains-point.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>rect</para></entry>
<entry role="parameter_description"><para>a <link linkend="GdkRectangle"><type>GdkRectangle</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>x</para></entry>
<entry role="parameter_description"><para>X coordinate</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>y</para></entry>
<entry role="parameter_description"><para>Y coordinate</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gdk-rectangle-contains-point.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><type>TRUE</type></link> if <parameter>rect</parameter>
contains the point</para>
</refsect3></refsect2>

</refsect1>
<refsect1 id="gdk4-Points-Rectangles-and-Regions.other_details" role="details">
<title role="details.title">Types and Values</title>
<refsect2 id="GdkPoint" role="struct">
<title>GdkPoint</title>
<indexterm zone="GdkPoint"><primary>GdkPoint</primary></indexterm>
<programlisting language="C">typedef struct {
  int x;
  int y;
} GdkPoint;
</programlisting>
<para>Defines the x and y coordinates of a point.</para>
<refsect3 id="GdkPoint.members" role="struct_members">
<title>Members</title>
<informaltable role="struct_members_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="struct_members_name" colwidth="300px"/>
<colspec colname="struct_members_description"/>
<colspec colname="struct_members_annotations" colwidth="200px"/>
<tbody>
<row role="member"><entry role="struct_member_name"><para><link linkend="int"><type>int</type></link>&#160;<structfield id="GdkPoint.x">x</structfield>;</para></entry>
<entry role="struct_member_description"><para>the x coordinate of the point</para></entry>
<entry role="struct_member_annotations"></entry>
</row>
<row role="member"><entry role="struct_member_name"><para><link linkend="int"><type>int</type></link>&#160;<structfield id="GdkPoint.y">y</structfield>;</para></entry>
<entry role="struct_member_description"><para>the y coordinate of the point</para></entry>
<entry role="struct_member_annotations"></entry>
</row>
</tbody></tgroup></informaltable>
</refsect3>
</refsect2>
<refsect2 id="GdkRectangle-struct" role="struct">
<title>GdkRectangle</title>
<indexterm zone="GdkRectangle-struct"><primary>GdkRectangle</primary></indexterm>
<programlisting language="C">typedef struct {
    int x, y;
    int width, height;
} GdkRectangle;
</programlisting>
<para>Defines the position and size of a rectangle. It is identical to
<link linkend="cairo-rectangle-int-t"><type>cairo_rectangle_int_t</type></link>.</para>
<refsect3 id="GdkRectangle.members" role="struct_members">
<title>Members</title>
<informaltable role="struct_members_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="struct_members_name" colwidth="300px"/>
<colspec colname="struct_members_description"/>
<colspec colname="struct_members_annotations" colwidth="200px"/>
<tbody>
<row role="member"><entry role="struct_member_name"><para><link linkend="int"><type>int</type></link>&#160;<structfield id="GdkRectangle-struct.x">x</structfield>;</para></entry>
<entry role="struct_member_description"><para>the x coordinate of the top left corner</para></entry>
<entry role="struct_member_annotations"></entry>
</row>
<row role="member"><entry role="struct_member_name"><para><link linkend="int"><type>int</type></link>&#160;<structfield id="GdkRectangle-struct.y">y</structfield>;</para></entry>
<entry role="struct_member_description"><para>the y coordinate of the top left corner</para></entry>
<entry role="struct_member_annotations"></entry>
</row>
<row role="member"><entry role="struct_member_name"><para><link linkend="int"><type>int</type></link>&#160;<structfield id="GdkRectangle-struct.width">width</structfield>;</para></entry>
<entry role="struct_member_description"><para>the width of the rectangle</para></entry>
<entry role="struct_member_annotations"></entry>
</row>
<row role="member"><entry role="struct_member_name"><para><link linkend="int"><type>int</type></link>&#160;<structfield id="GdkRectangle-struct.height">height</structfield>;</para></entry>
<entry role="struct_member_description"><para>the height of the rectangle</para></entry>
<entry role="struct_member_annotations"></entry>
</row>
</tbody></tgroup></informaltable>
</refsect3>
</refsect2>

</refsect1>

</refentry>
