Rotating and Scaling Clipped Contents
Last updated
Was this helpful?
The Clips Children and Is Render Target properties clip their children to an axis-aligned rectangle. Because the clip region stays aligned to the screen, rotating a container that clips its children leaves the clip region unrotated, so the result looks broken.
To rotate (or scale) a container and keep its contents clipped, you render the container to a render target and display that render target through a Sprite. The Sprite can then be rotated, scaled, positioned, and stacked like any other Gum object, and the clipping rotates along with it.

This effect uses two objects:
A Container with Is Render Target set to true. This container holds the content you want to clip, and it clips its children automatically.
A Sprite with its Render Target Texture Source set to the container above. The Sprite displays the container's render target and can be freely rotated and scaled.

The source container (which has Use Render Terget set to true) can even be made invisible:

Create a Container and add the children you want to clip and rotate.
Select the Container and set its Is Render Target value to true. Its children are now clipped to the container's bounds.
Create a Sprite.
Select the Sprite and set its Render Target Texture Source value to the container created in step 1. The dropdown lists all containers in the current element that have Is Render Target set to true.
Set the Sprite's Rotation (and optionally its Width and Height) to rotate and scale the clipped contents.

A container with Is Render Target set to true performs its layout and rendering even when its Visible value is false. Set the source container's Visible to false to hide the original while still displaying it through the Sprite.
Children inside the render target container are not interactive while displayed through the Sprite, because input is handled by the original (invisible) container rather than the rotated Sprite.
RenderTargetTextureSource — the same pattern in code
Last updated
Was this helpful?
Was this helpful?

