With Graphics 2.0, one of the things we’re aiming for is to unify graphics features in a seamless manner. We’re doing that in many different ways, and this week, I want to mention one small, but powerful feature we call “snapshots.”

Snapshots allow you to apply filter effects on a group of objects, just like you would an individual object.

We could have added this functionality to groups, but groups have always been lightweight, so we wanted to maintain that philosophy. So instead, we created snapshot objects. These are basically image objects with group-like features. You can manipulate them in the same way you would any rectangle, including 2.5D distortion effects, but you can also add children to them just like groups.

Here’s an example of what snapshots let you do. Below, we take Fishies and apply the “pixelate” filter to get a retro-look. On the left, we apply the filter to just the fish. On the right, we insert all the objects into a special kind of object called a snapshot object and apply the filter to the snapshot.

Effectively, the difference boils down to:



So snapshots are a way for you to render a group of objects into a live texture. It’s almost like a screen capture, but you bypass saving to a file, so you can get better performance. When you create a snapshot, you specify the dimensions of that texture, render children into the texture, and then apply filter effects on that texture just like you would a normal image.

Although snapshots behave like groups (i.e. you can call ‘insert’ on them), there are some key differences. The most notable is what happens when you modify the ‘alpha’ property. For a group, the alpha is propagated to each individual child separately. The result is that overlapping children will cumulatively blend. In contrast, children in snapshots are rendered to a single texture, so the alpha is applied on the entire texture, not on individual children:



Graphics 2.0: Render to texture with snapshot objects