xref: /inferno-os/libdraw/border.c (revision 37da2899f40661e3e9631e497da8dc59b971cbd0)
1 #include "lib9.h"
2 #include "draw.h"
3 
4 void
borderop(Image * im,Rectangle r,int i,Image * color,Point sp,Drawop op)5 borderop(Image *im, Rectangle r, int i, Image *color, Point sp, Drawop op)
6 {
7 	if(i < 0){
8 		r = insetrect(r, i);
9 		sp = addpt(sp, Pt(i,i));
10 		i = -i;
11 	}
12 	drawop(im, Rect(r.min.x, r.min.y, r.max.x, r.min.y+i),
13 		color, nil, sp, op);
14 	drawop(im, Rect(r.min.x, r.max.y-i, r.max.x, r.max.y),
15 		color, nil, Pt(sp.x, sp.y+Dy(r)-i), op);
16 	drawop(im, Rect(r.min.x, r.min.y+i, r.min.x+i, r.max.y-i),
17 		color, nil, Pt(sp.x, sp.y+i), op);
18 	drawop(im, Rect(r.max.x-i, r.min.y+i, r.max.x, r.max.y-i),
19 		color, nil, Pt(sp.x+Dx(r)-i, sp.y+i), op);
20 }
21 
22 void
border(Image * im,Rectangle r,int i,Image * color,Point sp)23 border(Image *im, Rectangle r, int i, Image *color, Point sp)
24 {
25 	borderop(im, r, i, color, sp, SoverD);
26 }
27