| <head> |
| <title>addpt(3) - Plan 9 from User Space</title> |
| <meta content="text/html; charset=utf-8" http-equiv=Content-Type> |
| </head> |
| <body bgcolor=#ffffff> |
| <table border=0 cellpadding=0 cellspacing=0 width=100%> |
| <tr height=10><td> |
| <tr><td width=20><td> |
| <tr><td width=20><td><b>ADDPT(3)</b><td align=right><b>ADDPT(3)</b> |
| <tr><td width=20><td colspan=2> |
| <br> |
| <p><font size=+1><b>NAME </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| addpt, subpt, mulpt, divpt, rectaddpt, rectsubpt, insetrect, canonrect, |
| eqpt, eqrect, ptinrect, rectinrect, rectXrect, rectclip, combinerect, |
| Dx, Dy, Pt, Rect, Rpt – arithmetic on points and rectangles<br> |
| |
| </table> |
| <p><font size=+1><b>SYNOPSIS </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>#include <u.h><br> |
| #include <libc.h><br> |
| #include <draw.h> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Point addpt(Point p, Point q) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Point subpt(Point p, Point q) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Point mulpt(Point p, int a) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Point divpt(Point p, int a) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Rectangle rectaddpt(Rectangle r, Point p) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Rectangle rectsubpt(Rectangle r, Point p) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Rectangle insetrect(Rectangle r, int n) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Rectangle canonrect(Rectangle r) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int eqpt(Point p, Point q) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int eqrect(Rectangle r, Rectangle s) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int ptinrect(Point p, Rectangle r) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int rectinrect(Rectangle r, Rectangle s) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int rectXrect(Rectangle r, Rectangle s) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int rectclip(Rectangle *rp, Rectangle b) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>void combinerect(Rectangle *rp, Rectangle b) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int Dx(Rectangle r) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int Dy(Rectangle r) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Point Pt(int x, int y) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Rectangle Rect(int x0, int y0, int x1, int y1) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Rectangle Rpt(Point p, Point q)<br> |
| </font></tt> |
| </table> |
| <p><font size=+1><b>DESCRIPTION </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| The functions <i>Pt</i>, <i>Rect</i> and <i>Rpt</i> construct geometrical data types |
| from their components. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Addpt</i> returns the Point sum of its arguments: <tt><font size=+1>Pt(</font></tt><i>p</i><tt><font size=+1>.x+</font></tt><i>q</i><tt><font size=+1>.x,</font></tt> <i>p</i><tt><font size=+1>.y+</font></tt><i>q</i><tt><font size=+1>.y)</font></tt>. |
| <i>Subpt</i> returns the Point difference of its arguments: <tt><font size=+1>Pt(</font></tt><i>p</i><tt><font size=+1>.x−</font></tt><i>q</i><tt><font size=+1>.x,</font></tt> |
| <i>p</i><tt><font size=+1>.y−</font></tt><i>q</i><tt><font size=+1>.y)</font></tt>. <i>Mulpt</i> returns the Point <tt><font size=+1>Pt(</font></tt><i>p</i><tt><font size=+1>.x*</font></tt><i>a</i><tt><font size=+1>,</font></tt> <i>p</i><tt><font size=+1>.y*</font></tt><i>a</i><tt><font size=+1>)</font></tt>. <i>Divpt</i> returns |
| the Point <tt><font size=+1>Pt(</font></tt><i>p</i><tt><font size=+1>.x/</font></tt><i>a</i><tt><font size=+1>,</font></tt> <i>p</i><tt><font size=+1>.y/</font></tt><i>a</i><tt><font size=+1>)</font></tt>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Rectaddpt</i> returns the Rectangle <tt><font size=+1>Rect(add(</font></tt><i>r</i><tt><font size=+1>.min,</font></tt> <i>p</i><tt><font size=+1>)</font></tt>, <tt><font size=+1>add(</font></tt><i>r</i><tt><font size=+1>.max,</font></tt> |
| <i>p</i><tt><font size=+1>))</font></tt>; <i>rectsubpt</i> returns the Rectangle <tt><font size=+1>Rpt(sub(</font></tt><i>r</i><tt><font size=+1>.min,</font></tt> <i>p</i><tt><font size=+1>), sub(</font></tt><i>r</i><tt><font size=+1>.max,</font></tt> |
| <i>p</i><tt><font size=+1>))</font></tt>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Insetrect</i> returns the Rectangle <tt><font size=+1>Rect(</font></tt><i>r</i><tt><font size=+1>.min.x+</font></tt><i>n</i>, <i>r</i><tt><font size=+1>.min.y+</font></tt><i>n</i>, <i>r</i><tt><font size=+1>.max.x−</font></tt><i>n</i>, |
| <i>r</i><tt><font size=+1>.max.y−</font></tt><i>n</i><tt><font size=+1>)</font></tt>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Canonrect</i> returns a rectangle with the same extent as <i>r</i>, canonicalized |
| so that <tt><font size=+1>min.x </font></tt>≤ <tt><font size=+1>max.x</font></tt>, and <tt><font size=+1>min.y </font></tt>≤ <tt><font size=+1>max.y</font></tt>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Eqpt</i> compares its argument Points and returns 0 if unequal, 1 |
| if equal. <i>Eqrect</i> does the same for its argument Rectangles. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Ptinrect</i> returns 1 if <i>p</i> is a point within <i>r</i>, and 0 otherwise. |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Rectinrect</i> returns 1 if all the pixels in <i>r</i> are also in <i>s</i>, and |
| 0 otherwise. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>RectXrect</i> returns 1 if <i>r</i> and <i>s</i> share any point, and 0 otherwise. |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Rectclip</i> clips in place the Rectangle pointed to by <i>rp</i> so that |
| it is completely contained within <i>b</i>. The return value is 1 if |
| any part of *<i>rp</i> is within <i>b</i>. Otherwise, the return value is 0 |
| and *<i>rp</i> is unchanged. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Combinerect</i> overwrites <tt><font size=+1>*rp</font></tt> with the smallest rectangle sufficient |
| to cover all the pixels of <tt><font size=+1>*rp</font></tt> and <tt><font size=+1>b</font></tt>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| The functions <i>Dx</i> and <i>Dy</i> give the width (Δx) and height (Δy) of |
| a Rectangle. They are implemented as macros.<br> |
| |
| </table> |
| <p><font size=+1><b>SOURCE </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>/usr/local/plan9/src/libdraw<br> |
| </font></tt> |
| </table> |
| <p><font size=+1><b>SEE ALSO </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <a href="../man3/graphics.html"><i>graphics</i>(3)</a><br> |
| |
| </table> |
| |
| <td width=20> |
| <tr height=20><td> |
| </table> |
| <!-- TRAILER --> |
| <table border=0 cellpadding=0 cellspacing=0 width=100%> |
| <tr height=15><td width=10><td><td width=10> |
| <tr><td><td> |
| <center> |
| <a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a> |
| </center> |
| </table> |
| <!-- TRAILER --> |
| </body></html> |