> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/gum/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/gum/gum-tool/tutorials-and-examples/examples/rotating-and-scaling-clipped-contents.md).

# Rotating and Scaling Clipped Contents

## Introduction

The [Clips Children](/gum/gum-tool/gum-elements/general-properties/clips-children.md) and [Is Render Target](/gum/gum-tool/gum-elements/container/is-render-target.md) 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.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2FsFgZ1FOqCgOlGxyU4Ggm%2F13_07%2043%2045.gif?alt=media&amp;token=a739498a-cf7f-4f2d-bcf7-2ea0482816e2" alt=""><figcaption><p>Clipping doesn't support rotation</p></figcaption></figure>

## The Two-Object Pattern

This effect uses two objects:

1. A **Container** with **Is Render Target** set to `true`. This container holds the content you want to clip, and it clips its children automatically.
2. 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.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2FSAmUDEQqeacJiSi1BWeF%2F13_07%2045%2056.gif?alt=media&amp;token=4a2ee54e-85a0-4565-b2fb-b1cc93e0e696" alt=""><figcaption><p>Sprite rotating while referencing a render target container</p></figcaption></figure>

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

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2FvqXr3JrHbplEicg19Y5x%2F13_07%2047%2054.gif?alt=media&amp;token=e93b96a3-362b-4593-a9b0-705136a065d9" alt=""><figcaption><p>Invisible container still used as a source render target</p></figcaption></figure>

## Step by Step

1. Create a **Container** and add the children you want to clip and rotate.
2. Select the **Container** and set its **Is Render Target** value to `true`. Its children are now clipped to the container's bounds.
3. Create a **Sprite**.
4. 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`.
5. Set the **Sprite**'s [Rotation](/gum/gum-tool/gum-elements/general-properties/rotation.md) (and optionally its `Width` and `Height`) to rotate and scale the clipped contents.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2F8YowOsAmRw0wEmlCucpZ%2F13_07%2049%2025.gif?alt=media&amp;token=082a18e9-7f23-444c-961a-7ab12cc136bf" alt=""><figcaption><p>Sprite with a Render Target Texture Source</p></figcaption></figure>

## Notes

* 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`.

## See Also

* [Clips Children](/gum/gum-tool/gum-elements/general-properties/clips-children.md)
* [Rotation](/gum/gum-tool/gum-elements/general-properties/rotation.md)
* [Is Render Target](/gum/gum-tool/gum-elements/container/is-render-target.md)
* [RenderTargetTextureSource](/gum/code/standard-visuals/spriteruntime/rendertargettexturesource.md) — the same pattern in code


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flatredball.com/gum/gum-tool/tutorials-and-examples/examples/rotating-and-scaling-clipped-contents.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
