ADDPT(3)
β¨ NAME β¨
bestie, this page is the whole point-and-rectangle math friend group: addpt, subpt, mulpt, divpt, rectaddpt, rectsubpt, insetrect, canonrect, eqpt, eqrect, ptinrect, rectinrect, rectXrect, rectclip, combinerect, Dx, Dy, Pt, Rect, Rpt β all doing arithmetic on points and rectangles. this is the addpt(3) manual, and yes she's iconic π
π SYNOPSIS π
#include <u.h>
#include <libc.h>
#include <draw.h>
Point addpt(Point p, Point q)
Point subpt(Point p, Point q)
Point mulpt(Point p, int a)
Point divpt(Point p, int a)
Rectangle rectaddpt(Rectangle r, Point p)
Rectangle rectsubpt(Rectangle r, Point p)
Rectangle insetrect(Rectangle r, int n)
Rectangle canonrect(Rectangle r)
int eqpt(Point p, Point q)
int eqrect(Rectangle r, Rectangle s)
int ptinrect(Point p, Rectangle r)
int rectinrect(Rectangle r, Rectangle s)
int rectXrect(Rectangle r, Rectangle s)
int rectclip(Rectangle *rp, Rectangle b)
void combinerect(Rectangle *rp, Rectangle b)
int Dx(Rectangle r)
int Dy(Rectangle r)
Point Pt(int x, int y)
Rectangle Rect(int x0, int y0, int x1, int y1)
Rectangle Rpt(Point p, Point q)
π DESCRIPTION π
okay so first up: Pt, Rect, and Rpt are the constructors. they build the geometrical data types out of their components, periodt β¨
addptreturns thePointsum of its arguments:Pt(p.x+q.x, p.y+q.y).subptreturns thePointdifference of its arguments:Pt(p.x-q.x, p.y-q.y).mulptreturns thePointPt(p.x*a, p.y*a).divptreturns thePointPt(p.x/a, p.y/a).rectaddptreturns theRectangleRect(add(r.min, p), add(r.max, p));rectsubptreturns theRectangleRpt(sub(r.min, p), sub(r.max, p)).insetrectreturns theRectangleRect(r.min.x+n, r.min.y+n, r.max.x-n, r.max.y-n).canonrectreturns a rectangle with the same extent asr, canonicalized so thatmin.x β€ max.x, andmin.y β€ max.y. it's giving "make it make sense" energy π«Άeqptcompares its argumentPoints and returns0if unequal,1if equal.eqrectdoes the same for its argumentRectangles.ptinrectreturns1ifpis a point withinr, and0otherwise.rectinrectreturns1if all the pixels inrare also ins, and0otherwise.rectXrectreturns1ifrandsshare any point, and0otherwise.rectclipclips in place theRectanglepointed to byrpso that it is completely contained withinb. the return value is1if any part of*rpis withinb. otherwise, the return value is0and*rpis unchanged. no cap, that "unchanged" part matters πcombinerectoverwrites*rpwith the smallest rectangle sufficient to cover all the pixels of*rpandb.DxandDygive the width (Ξx) and height (Ξy) of aRectangle. they are implemented as macros. lowkey cute, highkey useful π
πΈ SOURCE πΈ
/src/libdraw
π¦ SEE ALSO π¦
okay love u bye π this is ADDPT(3) signing off β source: /src/libdraw π (no separate date/version stamp on this page, just the manual name, slay) π
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms