xcb_poly_line(3)
π xcb_poly_line β draw lines
okay bestie, welcome to xcb_poly_line(3), a page from the XCB Requests corner of the libxcb universe. it draws lines. that's the whole vibe. but the way it draws them?? lowkey iconic. let's get into it π
β¨ NAME β¨
xcb_poly_line β draw lines
πΈ SYNOPSIS πΈ
first things first, you gotta pull in the header:
#include <xcb/xproto.h>
π¦ Request function
xcb_void_cookie_t xcb_poly_line(xcb_connection_t *conn,
uint8_t coordinate_mode, xcb_drawable_t drawable,
xcb_gcontext_t gc, uint32_t points_len, const
xcb_point_t *points);
that's the whole signature, no cap. β¨
π REQUEST ARGUMENTS π
here's what you're feeding her, one by one:
connβ The XCB connection to X11. your lil hotline to the server, fr.coordinate_modeβ One of the following values:XCB_COORD_MODE_ORIGINβ Treats all coordinates as relative to the origin. every point is measured from the same starting spot, main character energy for the origin.XCB_COORD_MODE_PREVIOUSβ Treats all coordinates after the first as relative to the previous coordinate. so each point is like "i'm this far from the last one" π«Ά
drawableβ The drawable to draw the line(s) on. this is the canvas, the stage, the moment.gcβ The graphics context to use. your whole aesthetic config, pens and colors and all.points_lenβ The number ofxcb_point_tstructures inpoints.pointsβ An array of points. literally just a lil lineup of coordinates, standing there, waiting to be connected π
π DESCRIPTION π
so what does it actually do. okay so:
Draws points_len-1 lines between each pair of points (point[i], point[i+1]) in the points array. The lines are drawn in the order listed in the array. They join correctly at all intermediate points, and if the first and last points coincide, the first and last lines also join correctly.
no gaps, no awkward corners, everything connects like it was always meant to be. β¨
For any given line, a pixel is not drawn more than once. If thin (zero line-width) lines intersect, the intersecting pixels are drawn multiple times. If wide lines intersect, the intersecting pixels are drawn only once, as though the entire request were a single, filled shape.
so basically: thin lines that cross over each other re-draw the overlap (they're each doing their own thing, independent girlies), but wide lines get treated like one single filled shape, so the overlap only gets painted once. no double-dipping. periodt.
β RETURN VALUE β
Returns an xcb_void_cookie_t. Errors (if any) have to be handled in the event loop.
If you want to handle errors directly with xcb_request_check instead, use xcb_poly_line_checked. See xcb-requests(3) for details.
so like, you got a cookie πͺ and you gotta check on it later. that's just how the event loop works bestie.
π ERRORS π
here's the roster of things that can go wrong, and yes, the docs are still a WIP:
xcb_drawable_error_tβ TODO: reasons?xcb_g_context_error_tβ TODO: reasons?xcb_match_error_tβ TODO: reasons?xcb_value_error_tβ TODO: reasons?
(they literally left the reasons as TODO in the source, we're not making anything up here π)
π EXAMPLE π
okay here's a whole actual example, verbatim, go off:
/*
* Draw a straight line.
*
*/
void my_example(xcb_connection_t *conn, xcb_drawable_t drawable, xcb_gcontext_t gc) {
xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, drawable, gc, 2,
(xcb_point_t[]) { {10, 10}, {100, 10} });
xcb_flush(conn);
}
two points, one horizontal line, one xcb_flush(conn) to actually make it show up. ate. π
π SEE ALSO π
go read these next, i'm obsessed:
π§ AUTHOR π§
Generated from xproto.xml. Contact xcb@lists.freedesktop.org for corrections and improvements.
and that's the page!! this beauty ships with X Version 11 as part of libxcb 1.17.0, and yeah, it really is called xcb_poly_line(3) β iykyk π¦β¨ stay slay, draw responsibly, and may all your pixels land exactly where you meant them to ππ
π¦ where this page comes from
- alpine 3.22: libxcb-doc 1.17.0-r0 Β· MIT
- alpine 3.23: libxcb-doc 1.17.0-r1 Β· MIT
- alpine 3.24: libxcb-doc 1.17.0-r2 Β· MIT
- arch rolling: libxcb 1.17.0-1 Β· X11
- centos-stream 10: libxcb-devel 1.17.0-3.el10 Β· X11
- debian trixie: libxcb-doc 1.17.0-2
- fedora 43: libxcb-devel 1.17.0-6.fc43 Β· X11
- fedora 43: libxcb-devel 1.17.0-6.fc43 Β· X11
- fedora 44: libxcb-devel 1.17.0-7.fc44 Β· X11
- fedora 44: libxcb-devel 1.17.0-7.fc44 Β· X11
- nixpkgs unstable: libxcb 1.17.0
- opensuse-leap 16.0: libxcb-devel-doc 1.17.0-160000.2.2 Β· MIT
- ubuntu questing: libxcb-doc 1.17.0-2build1
- ubuntu resolute: libxcb-doc 1.17.0-2ubuntu1
- ubuntu stonking: libxcb-doc 1.17.0-2ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms