XDrawRectangle(3)
β¨ NAME β¨
okay so this is the XLIB FUNCTIONS page for XDrawRectangle(3), and it's bringing XDrawRectangle, XDrawRectangles, and XRectangle together to draw rectangles and explain the rectangles structure. lowkey iconic trio behavior π
π SYNTAX π
int XDrawRectangle(Display *display, Drawable d, GC gc, int x, int y,
unsigned int width, unsigned int height);
int XDrawRectangles(Display *display, Drawable d, GC gc, XRectangle
rectangles[], int nrectangles);
π§Ύ ARGUMENTS π§Ύ
dβ tells it which drawable we're working with.displayβ the connection to the X server, aka the group chat line to the server.gcβ says whichGCto use.nrectanglesβ how many rectangles are in the array.rectanglesβ an array of rectangles, bestie.width,heightβ the width and the height, which specify the dimensions of the rectangle.x,yβ the x and y coordinates, which specify the upper-left corner of the rectangle.
π« DESCRIPTION π«
so XDrawRectangle and XDrawRectangles draw the outlines of the rectangle or rectangles you specify, as if a five-point PolyLine protocol request were specified for each rectangle:
[x,y] [x+width,y] [x+width,y+height] [x,y+height] [x,y]
for the rectangle or rectangles you named, these functions do not draw a pixel more than once. no cap. XDrawRectangles draws the rectangles in the order listed in the array. and if rectangles intersect, the intersecting pixels are drawn multiple times β that's just the vibe, okay? π
both functions use these GC components: function, plane-mask, line-width, line-style, cap-style, join-style, fill-style, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask. they also use these GC mode-dependent components: foreground, background, tile, stipple, tile-stipple-x-origin, tile-stipple-y-origin, dash-offset, and dash-list. periodt β¨
XDrawRectangle and XDrawRectangles can generate BadDrawable, BadGC, and BadMatch errors. yes, those are the drama alarms to watch for π
ποΈ STRUCTURES ποΈ
the XRectangle structure contains:
typedef struct {
short x, y;
unsigned short width, height;
} XRectangle;
all x and y members are signed integers. the width and height members are 16-bit unsigned integers. you should be careful not to generate coordinates and sizes out of the 16-bit ranges, because the protocol only has 16-bit fields for these values.
bestie please respect the 16-bit range π this is not a "we'll fix it later" situation, the protocol literally only has 16-bit fields for these values π
π¨ DIAGNOSTICS π¨
BadDrawableβ a value for aDrawableargument does not name a definedWindoworPixmap.BadGCβ a value for aGContextargument does not name a definedGContext.BadMatchβ anInputOnlywindow is used as aDrawable.BadMatchβ some argument or pair of arguments has the correct type and range but fails to match in some other way required by the request.
π SEE ALSO π
XDrawArc(3)XDrawLine(3)XDrawPoint(3)Xlib - C Language X Interface
okay that's the whole page, bestie π signed, sealed, and slayed by X Version 11 and libX11 1.8.14 β mwah πβ¨
π¦ where this page comes from
- alpine 3.24: libx11-doc 1.8.14-r0 Β· X11
- arch rolling: libx11 1.8.14-1 Β· MIT AND X11
- nixos 26.05: libx11 1.8.14
- nixpkgs unstable: libx11 1.8.14
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms