libdraw: add borderop

This commit is contained in:
Jeff Sickel 2008-12-03 02:13:38 -06:00
parent f4d56d7218
commit 41305b2355
2 changed files with 19 additions and 10 deletions

View file

@ -5,7 +5,7 @@ replclipr, line, lineop, poly, polyop, fillpoly, fillpolyop, bezier, bezierop,
bezspline, bezsplineop, bezsplinepts, fillbezier, fillbezierop, bezspline, bezsplineop, bezsplinepts, fillbezier, fillbezierop,
fillbezspline, fillbezsplineop, ellipse, ellipseop, fillbezspline, fillbezsplineop, ellipse, ellipseop,
fillellipse, fillellipseop, arc, arcop, fillarc, fillarcop, fillellipse, fillellipseop, arc, arcop, fillarc, fillarcop,
icossin, icossin2, border, string, stringop, stringn, stringnop, icossin, icossin2, border, borderop, string, stringop, stringn, stringnop,
runestring, runestringop, runestringn, runestringnop, stringbg, runestring, runestringop, runestringn, runestringnop, stringbg,
stringbgop, stringnbg, stringnbgop, runestringbg, runestringbgop, stringbgop, stringnbg, stringnbgop, runestringbg, runestringbgop,
runestringnbg, runestringnbgop, _string, ARROW, drawsetdebug \- graphics functions runestringnbg, runestringnbgop, _string, ARROW, drawsetdebug \- graphics functions
@ -156,6 +156,9 @@ int icossin(int deg, int *cosp, int *sinp)
int icossin2(int x, int y, int *cosp, int *sinp) int icossin2(int x, int y, int *cosp, int *sinp)
.PB .PB
void border(Image *dst, Rectangle r, int i, Image *color, Point sp) void border(Image *dst, Rectangle r, int i, Image *color, Point sp)
.PB
void borderop(Image *im, Rectangle r, int i, Image *color, Point sp,
Drawop op)
.br .br
.PB .PB
Point string(Image *dst, Point p, Image *src, Point sp, Point string(Image *dst, Point p, Image *src, Point sp,

View file

@ -3,19 +3,25 @@
#include <draw.h> #include <draw.h>
void 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){ if(i < 0){
r = insetrect(r, i); r = insetrect(r, i);
sp = addpt(sp, Pt(i,i)); sp = addpt(sp, Pt(i,i));
i = -i; i = -i;
} }
draw(im, Rect(r.min.x, r.min.y, r.max.x, r.min.y+i), drawop(im, Rect(r.min.x, r.min.y, r.max.x, r.min.y+i),
color, nil, sp); color, nil, sp, op);
draw(im, Rect(r.min.x, r.max.y-i, r.max.x, r.max.y), 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)); color, nil, Pt(sp.x, sp.y+Dy(r)-i), op);
draw(im, Rect(r.min.x, r.min.y+i, r.min.x+i, r.max.y-i), 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)); color, nil, Pt(sp.x, sp.y+i), op);
draw(im, Rect(r.max.x-i, r.min.y+i, r.max.x, r.max.y-i), 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)); 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);
} }