🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.micro.mac
Article #6847

Re: How to draw a Region around a random Line?

#6847
From: The Doctor
Date: Tue, 19 Aug 1986 14:22
43 lines
2202 bytes
> Given that I  have a random line going from StartPt to EndPt (any 
> orientation), what is a  good  way to create a rectangular Region 
> around it, perhaps 2 pixels  out from the line (ie a Region which 
> encloses the line but is slightly larger than the line itself, to 
> make for  easier  mouse capture).  (My problem is not in actually 
> creating the Region,  but  making it come out in the shape that I 
> want around the line...)
>

I haven't actually tried this, but you might want to try this routine

/* this is for a c system */

surround_line(x1, y1, x2, y2, region)
int x1, y1, x2, y3;
RgnHandle region;

/* this should do it.  Note that this routine doesn't define the region
 * itself.  You must do that with a call to NewRgn() before trying to
 * manipulate the contents.
 */

{
	Rect temprect;
/* You may wish to set the rectangle differently than I do.
 * This case allows for what may be "improper" rectangles, that is , those
 * whose bottom is above their top, and left before there right.
 * it may be neccessary to sort the points accordingly, ie, if x1 is greater
 * than x2, swap them, and if y1 is greater than y2, swap them. This will
 * generate an equivalent rectangle, but not the specific one.
 * If a slash is a diagonal line,   \  and  /  could be fit in the same
 * rectangle, but the routine generates spceific ones, not generalizations.
 */
	SetRect(&temprect, x1, y1, x2, y2);
	InsetRect(&temprect, -2, -2); /* don't like the magic numbers */
	
	RectRgn(region, &temprect);
}
 

Hope this helps.

Steve Hawley
Technical Details
Message-ID: <244@joevax.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!magic!joevax!sdh
References: <4848@decwrl.DEC.COM>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site joevax.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!magic!joevax!sdh
From: sdh@joevax.UUCP (The Doctor)
Newsgroups: net.micro.mac
Subject: Re: How to draw a Region around a random Line?
Message-ID: <244@joevax.UUCP>
Date: Tue, 19-Aug-86 10:22:05 EDT
Article-I.D.: joevax.244
Posted: Tue Aug 19 10:22:05 1986
Date-Received: Wed, 20-Aug-86 05:18:23 EDT
References: <4848@decwrl.DEC.COM>
Organization: Bell Communications Research Inc., Morristown, NJ
Lines: 43