From c5738de01d3c8adccaf87842cd6efceafd795d98 Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Sun, 13 Nov 2022 18:17:50 -0700 Subject: sticky patches and exit script --- drw.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'drw.c') diff --git a/drw.c b/drw.c index 2feea7e..54602d7 100644 --- a/drw.c +++ b/drw.c @@ -249,6 +249,26 @@ drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1); } +void +drw_polygon(Drw *drw, int x, int y, int ow, int oh, int sw, int sh, const XPoint *points, int npoints, int shape, int filled) /* wrapper function to scale and draw a polygon with X11 */ +{ + if (!drw || !drw->scheme) + return; + XSetForeground(drw->dpy, drw->gc, drw->scheme[ColFg].pixel); + if (!filled) { /* reduces the scaled width and height by 1 when drawing the outline to compensate for X11 drawing the line 1 pixel over */ + sw -= 1; + sh -= 1; + } + XPoint scaledpoints[npoints]; + memcpy(scaledpoints, points, npoints); + for (int v = 0; v < npoints; v++) + scaledpoints[v] = (XPoint){ .x = points[v].x * sw / ow + x, .y = points[v].y * sh / oh + y }; + if (filled) + XFillPolygon(drw->dpy, drw->drawable, drw->gc, scaledpoints, npoints, shape, CoordModeOrigin); /* Change shape to 'Convex' or 'Complex' in dwm.c if the shape is not 'Nonconvex' */ + else + XDrawLines(drw->dpy, drw->drawable, drw->gc, scaledpoints, npoints, CoordModeOrigin); +} + int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert) { -- cgit v1.2.3