tlibdraw: add borderop - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 41305b23558a51c5a6fa33bc7476df1ed6221667
 (DIR) parent f4d56d7218169816fcbc304c7848d48ab78315a4
 (HTM) Author: Jeff Sickel <jas@corpus-callosum.com>
       Date:   Wed,  3 Dec 2008 02:13:38 -0600
       
       libdraw: add borderop
       
       Diffstat:
         M man/man3/draw.3                     |       5 ++++-
         M src/libdraw/border.c                |      24 +++++++++++++++---------
       
       2 files changed, 19 insertions(+), 10 deletions(-)
       ---
 (DIR) diff --git a/man/man3/draw.3 b/man/man3/draw.3
       t@@ -5,7 +5,7 @@ replclipr, line, lineop, poly, polyop, fillpoly, fillpolyop, bezier, bezierop,
        bezspline, bezsplineop, bezsplinepts, fillbezier, fillbezierop, 
        fillbezspline, fillbezsplineop, ellipse, ellipseop, 
        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, 
        stringbgop, stringnbg, stringnbgop, runestringbg, runestringbgop,
        runestringnbg, runestringnbgop, _string, ARROW, drawsetdebug \- graphics functions
       t@@ -156,6 +156,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 *im, Rectangle r, int i, Image *color, Point sp,
       +                Drawop op)
        .br
        .PB
        Point        string(Image *dst, Point p, Image *src, Point sp,
 (DIR) diff --git a/src/libdraw/border.c b/src/libdraw/border.c
       t@@ -3,19 +3,25 @@
        #include <draw.h>
        
        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);
        }