Hi Jim, Thanks for your suggestion/insight to use a combination of Stroke and Area for expanding and contracting Shapes. It looks like this will work well.
A follow up question: I will also occasionally need to expand/contract my simple closed polygons by a different amount in X and Y. For example, add 2 units in the x dimension and add 1 unit in the y dimension. Is it possible to create a Stroke that is thicker in one dimension than in the other? If so, it would seem that I could use Strokes and Areas to expand and contract by different amounts in x and y. Thank you, Ted Hill ----- Original Message ----- From: "Jim Graham" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, November 26, 2002 4:37 PM Subject: [JAVA2D] Path fun (in Re: to both STROKE_CONTROL and GeneralPath expansion) > Ted and Ram�n, > > Using the Area and BasicStroke classes, you can achieve any of the effects > that you two have been asking for. Assuming a source Shape object "S", and > wanting to outsideline, insideline, expand or contract it by N pixels... > > First get all your variables set up: > > BasicStroke bs = new BasicStroke(N*2); > Shape outline = bs.createStrokedShape(S); > Area a1 = new Area(outline); > Area a2 = new Area(S); > > Then plug in the appropriate Area operation depending on what you want to do: > > - Outline N pixels outside of a shape (S): > > Area result = a1.subtract(a2); > > - Outline N pixels inside of a shape (S): > > Area result = a1.intersect(a2); > > - Expand a shape (S) by N pixels: > > Area result = a1.union(a2); > > - Contract a shape (S) by N pixels: > > Area result = a2.subtract(a1); > > I've left out the various attributes on constructing the BasicStroke above > since it depends on the "look" that you are going for. I would imagine that > the expand/contract operations would want to specify a MITER join so that > it doesn't cause the corners to get rounded or chopped off, but the inside > and outside outlines could probably use all sorts of variations depending > on personal taste... > > ...jim > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > of the message "signoff JAVA2D-INTEREST". For general help, send email to > [EMAIL PROTECTED] and include in the body of the message "help". =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
