> 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="/files/yeIdsQHG78WDkklFt6DZ" 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="/files/KckKHAgtE25JFPeNf2qG" 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="/files/v180CM5IPTTANMI5CIhs" 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="/files/8YAdMskyRAQTlebhS496" 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
