Runtime Revolution
   Home  |   Revolution News  |   Revolution Blogs  |   Revolution Wiki  |   Revolution Forums  |   Revolution

Soft clipping, in 10 easy steps

Clipping - the ability to limit what region of a particular object or objects is drawn - is a fundamental graphics operation and at first sight, Revolution provides limited options in this regard. Indeed one would be forgiven for thinking that rectangular clipping was your only option - employed by putting objects in a group with its lockLocation set to true. In fact, the new graphics features introduced in 2.7 allow you to clip to arbitrary anti-aliased polygons in just 10 easy steps…

  1. Create a fresh new stack
  2. Import an image as a control, position and lock its location - call this “Background”
  3. Create a polygon graphic using the freehand polygon tool, call it “Mask”
  4. set the lineSize of graphic “Mask” to 0
  5. set the dontResize of graphic “Mask” to true
  6. get the points of graphic “Mask”; set the rect of graphic “Mask” to the rect of image “Background”; set the points of graphic “Mask” to it
  7. group image “Background” and graphic “Mask”
  8. set the ink of group 1 to “blendSrcOver”
  9. set the ink of graphic “Mask” to “blendDstIn”
  10. Enjoy!

One Response to “Soft clipping, in 10 easy steps”

  1. Trevor DeVore Says:

    You are batting 2 for 2 with blog entries :-) This is great information.

Leave a Reply