Difference of Rectangles

Dan Ingalls Dan at SqueakLand.org
Mon May 7 03:41:26 UTC 2007


>Consider two rectangles, a and b. The only constraint I will put on them is that neither contains the other. I wish to create a PolygonMorph programmatically consisting of a merge: b with b removed but all of a retained in the case a and b overlap. I think I see my way to how to do this, but if anyone knows of any code I can look at where something like this is already implemented I'd be much obliged.
>
>My idea for how to go about this is to use "turtle logic" more or less as follows: Start with the first vertex of a merge: b which is not inside of b. Proceed clockwise along the bounds of a merge: b; if you hit b turn left, if you hit a turn right. But this may be doing things the hard way.
>
>-Thanks, Jim

Hi, Jim -

While it does not produce a polygon, you might well find <Rectangle>areasOutside: <Rectangle> to be a useful first step.

I wrote the original version and should probably apologize for not calling it something closer to "difference".

	- Dan



More information about the Squeak-dev mailing list