aboutsummaryrefslogtreecommitdiff
path: root/drw.c
diff options
context:
space:
mode:
authorBryson Steck <brysonsteck@protonmail.com>2022-11-13 18:17:50 -0700
committerBryson Steck <brysonsteck@protonmail.com>2022-11-13 18:17:50 -0700
commitc5738de01d3c8adccaf87842cd6efceafd795d98 (patch)
treea4e6eaf064b3881e62e66d16f63aac3adce63896 /drw.c
parent7516b03d7d3c7844ebdab69cf731d59ea2b3c84d (diff)
downloaddwm-c5738de01d3c8adccaf87842cd6efceafd795d98.tar
dwm-c5738de01d3c8adccaf87842cd6efceafd795d98.tar.gz
dwm-c5738de01d3c8adccaf87842cd6efceafd795d98.tar.bz2
sticky patches and exit script
Diffstat (limited to 'drw.c')
-rw-r--r--drw.c20
1 files changed, 20 insertions, 0 deletions
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)
{