lippin@sizzlean.berkeley.edu (The Apathist) (08/18/88)
About a week ago, I posted a short routine, LineRgn, which converts a
line to a region enclosing the bits Quickdraw would affect when
drawing the line. Since then, I've realized that the version I posted
doesn't handle the ends of the line correctly, particularly when the
pen size is large. So here's the corrected version:
void LineRgn(line,start,finish)
RgnHandle line;
Point start,finish;
{
RgnHandle cap;
Point start2,finish2;
start2=start;
finish2=finish;
AddPt(thePort->penSize,&start2);
AddPt(thePort->penSize,&finish2);
OpenRgn();
MoveTo(start.h,start.v);
LineTo(finish.h,finish.v);
LineTo(finish2.h,finish2.v);
LineTo(start2.h,start2.v);
LineTo(start.h,start.v);
CloseRgn(line);
cap=NewRgn();
SetRectRgn(cap,start.h,start.v,start2.h,start2.v);
UnionRgn(line,cap,line);
SetRectRgn(cap,finish.h,finish.v,finish2.h,finish2.v);
UnionRgn(line,cap,line);
DisposRgn(cap);
}
--Tom Lippincott
..ucbvax!math!lippin
"Those are line *segments*, sir."
--Second City,
"Football Comes to the University of Chicago"