Path: utzoo!attcan!uunet!zephyr.ens.tek.com!tektronix!reed!orpheus From: orpheus@reed.UUCP (P. Hawthorne) Newsgroups: comp.graphics Subject: Re: Hexagonal bit maps Keywords: masks, regions, Z-Buffer Message-ID: <15869@reed.UUCP> Date: 13 Jan 91 00:13:21 GMT References: <26275@uflorida.cis.ufl.EDU> Reply-To: orpheus@reed.UUCP (P. Hawthorne) Organization: Reed College Lines: 44 jdb@reef.cis.ufl.edu (Brian K. W. Hook) writes: | I am running into the problem of how to use the Borland Graphics interface | (actually, ANY graphics library with a getimage/putimage type function set) | to write the hex bit map on the screen without writing into the area of the | rectangular bit map outside of the hex....e.g. | | 0011111100 | 0111111110 | 1111111111 | 0111111110 | 0011111100 QuickDraw on the Macintosh has a procedure to allow you to copy one bitmap or pixmap to another, through a mask. It's a lot like a stencil, in that you can use a region to stop an image from being transfered outside that region. If I was going to try to do the same thing as the procedure I mentioned, without using it, I might try two methods first off. 1 Copy each pixel, from left to right and top to bottom, only if it is inside the area that you want to obliterate. Given that you are working with hexes, you might be able to develop an efficient algorithm to determine whether a given point is in or out of the hex. Alternately, if your graphics interface has the ability to define regions, you could define a hex at the appropriate scale when you began writing hexes, and use the mod operator and the interface call to see if the point was in the region. 2 Save the areas that you do not want to be obliterated, and replace them when you are done filling in the hex. If memory is an important consideration, you might be able to store the areas outside of the hex in a rectangle, by placing the upper left first, the lower right second, the lower left third, and the upper right fourth. Of course, that leave you in the position of having to solve the problem again.... I was implementing a Z Buffer the other day, which is a problem a lot like this one. The idea being that you step through each point on a surface, and only write the color of the surface onto pixels that are inside the area of the surface, and are closest to the eye. I had no problem determining if the point was closest to the eye. I had to use regions the determine if the point was inside the area of the surface. It was fortunate that the inside/outside test for regions in QuickDraw seems relatively quick. I'd be very interest to see any other solutions that are posted.