realbasic-nug
[Top] [All Lists]

Re: QuickDraw InsetRgn algorithm

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: QuickDraw InsetRgn algorithm
From: Don Jungk <rb at flippingdades dot com>
Date: Fri, 31 Aug 2007 18:44:18 -0500
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <77124270708311617w6c578fa5gdd53735c4586eca4 at mail dot gmail dot com>
On Friday 31 August 2007 6:17 pm, Peter K. Stys wrote:
> Can anyone point me to an algorithm (with source preferably, C is
> fine) that "insets" a polygon (defined by a set of vertices as x,y
> coordinates).  By inset I mean "shrink" towards its "center" (or
> expand if the dx,dy params are negative).

> Thanks,
> Peter.

Would something like this work?
f is your scale factor
Pick any new point, Px, Py
new x1 = Px + (Px - x1)*f
new y1 = Py + (Py - y1)*f
etc.

If you can define the "center" of your polygon and choose that point as your 
new point, the polygon should appear to shrink in on itself. If the point is 
somewhere else, the polygon will move, but shrink. I think the visual center 
will be a point half way between the points (smallest x value, smallest y 
value) and (largest x value, largest y value) from your list of vertices.

This is off the top of my head and entirely untested.

Don
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>