Challenge: How can we set the rect of a polygon to its visual rect?

Scott Rossi scott at tactilemedia.com
Fri Aug 14 14:34:50 EDT 2009


Recently, Wilhelm Sanke wrote:

> Triangles, pentagons, and hexagons (three-, five-, and six-sided
> polygons) have rects that are different from their visual rects, i.e.
> their opaque areas when the fillcolor is set to true.
> 
> As an example, a hexagon with a height of 200 possesses a "visual"
> height of only 172.
> 
> A snapshot taken from the graphic has the same dimensions, but the
> resulting image can be cropped to the real visual height.
> 
> Cropping however is possible only with images, so how do we proceed to
> set the rect of a hexagon (or triangle and pentagon) to its visual rect?
> 
> Any ideas?

You can crop a snapshot image of the graphic by looking at the alphaData of
the snapshot and cropping into the image only where the alphaData is 100%
transparent (or some other threshold you prefer).  I posted a stack that
does this, which is based on an alphaData checking routine originally
written by Trevor DeVore.  In your message box:

 go url "http://www.tactilemedia.com/download/crop2alphaRect.rev"

The stack generates a random regular polygon and then creates a matching
image cropped to the extents of the original graphic.

Hope this helps.

Regards,

Scott Rossi
Creative Director
Tactile Media, Multimedia & Design





More information about the use-livecode mailing list