I’m trying to recreate an CAD application that I wrote years ago in Delphi for Windows. I want to duplicate it’s capabilities in Mac OSx. One thing I’m stuck on is a routine to draw a pattern on a rectangle and use the Windows CreatePolygonRgn API to create a pattern cropped to the polygonal shape.
So there would be a polygon shape with bricks or siding within those boundaries.
Does anyone have any idea how we could do such a thing in Xojo?
You have given me hope. It’s a new concept to me, though.
Can you point me to some source of information on how to make a mask and combine it with a picture? Are we talking about two pictures?
I searched in the Language Reference for “Mask” and looked in the sample programs, but can’t find much.
Right. That looks good in a test program. Thanks.
Will there be a problem with the big rectangular picture overwriting other drawings when it’s put in the main drawing?
No… because the picture that you tiled the pattern into is temporary, and is discarded after the fill
That is the reason for the &c010101 pixel… they are the ONLY ones on your main image that will be changed.
note one drawback is your filled area will alway be opaque… but in 99.9% of the situations that should not be an issue
Hmm. I’m trying to wrap my brain around the concept. Rather than create two new pictures and put the doctored one on the main drawing, I should draw the &c010101 filled pixel polygon directly onto the full drawing and then replace it’s pixels directly? If the main drawing is very large, would it slow things down to scan the large image just to alter a much smaller polygon?
I guess the RGBSurface would be big but we only need to scan and replace the part that has the &c010101 polygon?
You are not putting a doctored picture on the main one.
You do draw the &c010101 polygon directly on the full drawing and replace the pixels based on your pattern
The size of the pattern picture does not exceed the size of the polygon area… it does not need to be the same size as your main picture… As a matter of fact if you are filling with Hatch Patterns or something like that… you only need enough of a tile to represent the repeating parts of the pattern… Of course that means the above code gets a bit more complex… but not overly so.
As a matter of fact… I use 32x32 bit pattern tiles… then it is just a matter of using (x and &H1f) on the pattern pic to return the right pixel.
Right. I thank you for putting me on this track. It is working on my tests. The pixel replacement is quite fast. The fills are construction stuff. Some such as siding and tiles use repeating patterns. They are vector drawings that have to scale exactly. An 8 x 2 brick needs to be 8x2 no matter the zoom used, so we can’t use bitmaps. We have to draw it every time.
Thanks again. I may be back during implementation, but I think this will work.