dots

Personal dotfiles
git clone git://git.gormless.xyz/dots.git
Log | Files | Refs

addpt.3 (2963B)


      1 .TH ADDPT 3
      2 .SH NAME
      3 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
      4 .SH SYNOPSIS
      5 .B #include <u.h>
      6 .br
      7 .B #include <libc.h>
      8 .br
      9 .B #include <draw.h>
     10 .PP
     11 .B
     12 Point	addpt(Point p, Point q)
     13 .PP
     14 .B
     15 Point	subpt(Point p, Point q)
     16 .PP
     17 .B
     18 Point	mulpt(Point p, int a)
     19 .PP
     20 .B
     21 Point	divpt(Point p, int a)
     22 .PP
     23 .B
     24 Rectangle	rectaddpt(Rectangle r, Point p)
     25 .PP
     26 .B
     27 Rectangle	rectsubpt(Rectangle r, Point p)
     28 .PP
     29 .B
     30 Rectangle	insetrect(Rectangle r, int n)
     31 .PP
     32 .B
     33 Rectangle	canonrect(Rectangle r)
     34 .PP
     35 .B
     36 int		eqpt(Point p, Point q)
     37 .PP
     38 .B
     39 int		eqrect(Rectangle r, Rectangle s)
     40 .PP
     41 .B
     42 int		ptinrect(Point p, Rectangle r)
     43 .PP
     44 .B
     45 int		rectinrect(Rectangle r, Rectangle s)
     46 .PP
     47 .B
     48 int		rectXrect(Rectangle r, Rectangle s)
     49 .PP
     50 .B
     51 int		rectclip(Rectangle *rp, Rectangle b)
     52 .PP
     53 .B
     54 void		combinerect(Rectangle *rp, Rectangle b)
     55 .PP
     56 .B
     57 int		Dx(Rectangle r)
     58 .PP
     59 .B
     60 int		Dy(Rectangle r)
     61 .PP
     62 .B
     63 Point	Pt(int x, int y)
     64 .PP
     65 .B
     66 Rectangle	Rect(int x0, int y0, int x1, int y1)
     67 .PP
     68 .B
     69 Rectangle	Rpt(Point p, Point q)
     70 .SH DESCRIPTION
     71 The functions
     72 .IR Pt ,
     73 .I Rect
     74 and
     75 .I Rpt
     76 construct geometrical data types from their components.
     77 .PP
     78 .I Addpt
     79 returns the Point
     80 sum of its arguments:
     81 .BI Pt( p .x+ q .x,
     82 .IB p .y+ q .y) \f1.
     83 .I Subpt
     84 returns the Point
     85 difference of its arguments:
     86 .BI Pt( p .x- q .x,
     87 .IB p .y- q .y) \f1.
     88 .I Mulpt
     89 returns the Point
     90 .BI Pt( p .x* a ,
     91 .IB p .y* a ) \f1.
     92 .I Divpt
     93 returns the Point
     94 .BI Pt( p .x/ a ,
     95 .IB p .y/ a ) \f1.
     96 .PP
     97 .I Rectaddpt
     98 returns the Rectangle
     99 .BI Rect(add( r .min,
    100 .IB p ) \f1,
    101 .BI add( r .max,
    102 .IB p )) \f1;
    103 .I rectsubpt
    104 returns the Rectangle
    105 .BI Rpt(sub( r .min,
    106 .IB p ),
    107 .BI sub( r .max,
    108 .IB p ))\fR.
    109 .PP
    110 .I Insetrect
    111 returns the Rectangle
    112 .BI Rect( r .min.x+ n \f1,
    113 .IB r .min.y+ n \f1,
    114 .IB r .max.x- n \f1,
    115 .IB r .max.y- n ) \f1.
    116 .PP
    117 .I Canonrect
    118 returns a rectangle with the same extent as
    119 .IR r ,
    120 canonicalized so that
    121 .B min.x
    122    123 .BR max.x ,
    124 and
    125 .B min.y
    126    127 .BR max.y .
    128 .PP
    129 .I Eqpt
    130 compares its argument Points and returns
    131 0 if unequal,
    132 1 if equal.
    133 .I Eqrect
    134 does the same for its argument Rectangles.
    135 .PP
    136 .I Ptinrect
    137 returns 1 if
    138 .I p
    139 is a point within
    140 .IR r ,
    141 and 0 otherwise.
    142 .PP
    143 .I Rectinrect
    144 returns 1 if all the pixels in
    145 .I r
    146 are also in
    147 .IR s ,
    148 and 0 otherwise.
    149 .PP
    150 .I RectXrect
    151 returns 1 if
    152 .I r
    153 and
    154 .I s
    155 share any point, and 0 otherwise.
    156 .PP
    157 .I Rectclip
    158 clips in place
    159 the Rectangle pointed to by
    160 .I rp
    161 so that it is completely contained within
    162 .IR b .
    163 The return value is 1 if any part of
    164 .RI * rp
    165 is within
    166 .IR b .
    167 Otherwise, the return value is 0 and
    168 .RI * rp
    169 is unchanged.
    170 .PP
    171 .I Combinerect
    172 overwrites
    173 .B *rp
    174 with the smallest rectangle sufficient to cover all the pixels of
    175 .B *rp
    176 and
    177 .BR b .
    178 .PP
    179 The functions
    180 .I Dx
    181 and
    182 .I Dy
    183 give the width (Δx) and height (Δy) of a Rectangle.
    184 They are implemented as macros.
    185 .SH SOURCE
    186 .B \*9/src/libdraw
    187 .SH SEE ALSO
    188 .MR graphics (3)