From 168b9f3de4088ed08987e62da3c593e98bdaab29 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Mon, 21 Jul 2014 18:10:58 +0200 Subject: [PATCH] libdraw: add missing borderop() (thanks aiju) --- sys/man/2/draw | 3 +++ sys/src/libdraw/border.c | 24 +++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/sys/man/2/draw b/sys/man/2/draw index e6f23a968..f517bc5c1 100644 --- a/sys/man/2/draw +++ b/sys/man/2/draw @@ -152,6 +152,9 @@ int icossin(int deg, int *cosp, int *sinp) int icossin2(int x, int y, int *cosp, int *sinp) .PB void border(Image *dst, Rectangle r, int i, Image *color, Point sp) +.PB +void borderop(Image *dst, Rectangle r, int i, Image *color, Point sp, + Drawop op) .br .PB Point string(Image *dst, Point p, Image *src, Point sp, diff --git a/sys/src/libdraw/border.c b/sys/src/libdraw/border.c index 22637dfad..52eaa1524 100644 --- a/sys/src/libdraw/border.c +++ b/sys/src/libdraw/border.c @@ -3,19 +3,25 @@ #include void -border(Image *im, Rectangle r, int i, Image *color, Point sp) +borderop(Image *im, Rectangle r, int i, Image *color, Point sp, Drawop op) { if(i < 0){ r = insetrect(r, i); sp = addpt(sp, Pt(i,i)); i = -i; } - draw(im, Rect(r.min.x, r.min.y, r.max.x, r.min.y+i), - color, nil, sp); - draw(im, Rect(r.min.x, r.max.y-i, r.max.x, r.max.y), - color, nil, Pt(sp.x, sp.y+Dy(r)-i)); - draw(im, Rect(r.min.x, r.min.y+i, r.min.x+i, r.max.y-i), - color, nil, Pt(sp.x, sp.y+i)); - draw(im, Rect(r.max.x-i, r.min.y+i, r.max.x, r.max.y-i), - color, nil, Pt(sp.x+Dx(r)-i, sp.y+i)); + drawop(im, Rect(r.min.x, r.min.y, r.max.x, r.min.y+i), + color, nil, sp, op); + drawop(im, Rect(r.min.x, r.max.y-i, r.max.x, r.max.y), + color, nil, Pt(sp.x, sp.y+Dy(r)-i), op); + drawop(im, Rect(r.min.x, r.min.y+i, r.min.x+i, r.max.y-i), + color, nil, Pt(sp.x, sp.y+i), op); + drawop(im, Rect(r.max.x-i, r.min.y+i, r.max.x, r.max.y-i), + color, nil, Pt(sp.x+Dx(r)-i, sp.y+i), op); +} + +void +border(Image *im, Rectangle r, int i, Image *color, Point sp) +{ + borderop(im, r, i, color, sp, SoverD); }