Shaping an image to fit in a polygon

J. Landman Gay jacque at hyperactivesw.com
Sat Oct 16 18:05:36 EDT 2021


On 10/16/21 2:17 PM, David Epstein via use-livecode wrote:
> I am trying to create an image that will appear to have the shape of some arbitrary polygon.  The idea is to set the image's alphaData so that pixels within the polygon are opaque, and those outside the polygon are transparent.  The scripts below create a rectangular image of whatever is under the polygon's enclosing rectangle, and then adjust the alphaData of that new image.  But while the new image gets trimmed a bit, the result does not match the shape of the designated polygon.  Any thoughts?

If it's acceptable to make the polygon and the image the same size, you can just set the 
backgroundPattern of graphic to the ID of the image and it will appear the way you want. The 
down side is that the pattern is drawn from the top left of the graphic rather than centered 
within it, so that may be an issue.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list