FB II Compiler
I just discovered something that surprised me. If I record two rectangles into a region:
myRgn& = FN NEWRGN...the region ends up with only the non-overlapping portions of the rects. The overlap, if any, is missing from the region. This gave me fits for days until I finally figured out what was happening. Would someone please confirm for me that this is indeed normal behavior? I don't see it anywhere in the documentation, although I admit I've not dug into IM. I had expected I would get the same result as with this (which is what I'm using as a workaround):
myRgn& = FN NEWRGNIs there a more efficient or more direct way to accomplish this?
myOtherRgn& = FN NEWRGN
CALL RECTRGN(myRgn&, oldRect)
CALL RECTRGN(myOtherRgn&, newRect)
CALL UNIONRGN(myRgn&, myOtherRgn&, myRgn&)
I don't think the region calls like working with mere outlines of things. Try changing your FRAMERECT calls to PAINTRECT; I think that'll make it work as you originally expected.
There's a story in Silicon Valley that Bill Atkinson was in some sort of a crash during the development of Macintosh and had to be taken to the hospital. Jobs apparently buzzed over to the hospital in a panic. The first question out of his mouth was, "Do you remember how to do regions?" no idea if it's true or not, but *I* certainly wouldn't want to rewrite the Region Manager...
Thanks for your quick reply. But can that be right? I haven't tried it, because the Regions section of the FB Handbook says: "A region is a set of pixels representing a shape constructed with one or more of the following QuickDraw procedures."
CALL FRAMERECTChernicoff's "Inside Macintosh" says the same. Neither mentions whether the areas recorded are added with an OR or an XOR operation. Is it possible the current pen mode affects this?
A related question: once a region has been closed, is there a way to reopen it to add more data? (I'm guessing you have to create a new region and merge the two.)
As it happens, my answer was completely off target. According to Inside Mac: Quickdraw, "while a region is open, all calls to Line, LineTo, and the procedures that draw framed shapes (except arcs) affect the outline of the region. Only the line endpoints and shape boundaries affect the region definition - the pattern mode, pattern, and size do not affect it."
Oh well. Guess I should check in Inside Mac *before* answering instead of afterward.
<< Chernicoff's "Inside Macintosh" says the same. Neither mentions whether the areas recorded are added with an OR or an XOR operation. Is it possible the current pen mode affects this? >>
Each item drawn is added to the region with OR.
I could not find anything in Inside Mac which explicitly describes this behavior; the closest hint I could find was a statement that every closed loop you draw "affects" the region's outline. From "Inside Mac": "While a region is open, all calls to Line, LineTo, and the procedures that draw framed shapes (except arcs) affect the outline of the region...The outline of a region...separates the bit or pixel image into two groups of pixels: those within the region and those outside it." This is not as clear as it could be, but I take it to mean that _every_ part of every closed loop added to the region definition becomes part of the region's outline, and therefore if you cross over any piece of any of those loops, you are crossing from "region" to "non-region", or vice-versa. That's consistent with the behavior you're seeing.
Hey, as long as we're going into everything-but-the-kitchen sink mode on this topic, here's something I recently learned about QuickDraw. Consider the statements
CALL MOVETO(0,0)Two ways of getting exactly the same shape onto the screen, right? Wrong. The first form--and any rectangle-based statement such as PAINTOVAL--draws everything _inside_ the specified rect: set your pen to 8,8 and you'll end up with 84*84 pixels of blank space inside the rectangle. But the second form, and any polygon-based drawing, positions the pen _below_ and to the _right_ of the specified area: set your pen to 8,8 and you'll have the equivalent of a (0,0,108,108) rect with a 92*92 blank interior. Worth keeping in mind, especially when you're using wide penstrokes.