Picture Cut-Out

Take a bite out of the picture

Comments

There are a number of interesting ideas involved in this application, besides the obvious dynamic masking. Dealing with curves can be fairly complicated. Two specialized techniques are used here:

  1. Figuring out whether a curve (given as a sequence of points) goes clockwise or counterclockwise. This is done by checking the angle between each segment of the curve and the next segment (wrapping around to the first segment at the end). Summing all these small angles will give some multiple of 360 degrees, indicating the net rotation of the curve. When setting up a mask, you need to keep track of the direction.
  2. Rectifying curves that cross themselves—that is, "untwisting" them so that they enclose the same region, but no longer cross themselves. I have not yet solved this problem completely. Ordinary figure-eight type crossings are dealt with correctly, but very complicated self-intersecting curves still lead to problems.
Try tracing a self-intersecting curve, and then press "Show Clipping Path." You will see a small red dot trace out the curve in its rectified form.

Note that there is no obviously correct way to deal with the area that is in a loop within a loop. Should it be considered cut out, or not?

Code

No code yet, since this is not yet working correctly in all respects.


© 1/2005 Michael Kantor FlashGizmo.com