# Wrap

Introduction

The Wrap value controls whether the sprite wraps its image when rendering portions beyond the right and bottom image bounds. If this value is true then wrapping occurs. Otherwise, areas beyond the texture extend the last pixel - also known as "clamping" the value.

The Wrap variable applies when dealing with a **Texture Address** of **Custom** or **DimensionsBased**. Wrapping is not available when using a **Texture Address** value of **Entire Texture.**

### Wrap and Custom Texture Address

If Texture Address is set to Custom then wrapping is available. All examples in the Custom Texture Address section use the following values:

* Width = 100
* Width Units = Percentage of File Width
* Height = 100
* Height Units = Percentage of File Height

For more information, see the [Width Unit](https://docs.flatredball.com/gum/gum-tool/gum-elements/general-properties/width-units) and [Height Unit](https://docs.flatredball.com/gum/gum-tool/gum-elements/general-properties/height-units) pages.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-e37f152fc454b70e6b15968ebcc8b3077cf22fca%2Fimage.png?alt=media" alt=""><figcaption><p>Default Sprite width and height values are used in this section</p></figcaption></figure>

Toggling wrapping adjusts whether the Sprite wraps or clamps the area defined by the Texture Left, Texture Top, Texture Width, and Texture Height values.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-9225bfb0936cc39811e0b5eafbdb2a2c761a7ba0%2F22_06%2056%2055.gif?alt=media" alt=""><figcaption><p>A Sprite can wrap or clamp the area outside of the right and bottom bounds of its source</p></figcaption></figure>

A texture is wrapped if its Texture Right or Texture Bottom values are set to be larger than the source texture. For example, the following image shows a Sprite which is using an image that is 200x200. Its Texture Width is set to 500 and Texture Height is set to 300 so the sprite displays wrapping.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-51bdc9ae4f10221df80ef5746b0cae64ac4d6e59%2Fimage.png?alt=media" alt=""><figcaption><p>Sprite wrapping its image</p></figcaption></figure>

If the Texture Width or Texture Height values are adjusted, then the Sprite's wrapping also adjusts.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-9045be6115c44b5a3273b0f17e094fd4446379db%2F22_06%2055%2013.gif?alt=media" alt=""><figcaption><p>Adjusting Texture Width and Texture Heigh changes wrapping</p></figcaption></figure>

If Wrap is set to true, then wrapping happens for any area to the right or bottom of the bounds of the source. The following shows the bounds of a sprite moved in the Texture Coordinate tab resulting in the area that is being displayed wrapping and repeating.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-668df91dc88e0c0728ef949752f0ed3ba5d3d172%2F22_07%2002%2010.gif?alt=media" alt=""><figcaption><p>Sprite repeating the image as its texture address is moved to the right</p></figcaption></figure>

{% hint style="info" %}
If a Sprite's Texture Left or Texture Top are set to less than 0 then the Sprite clamps this area. This may change to wrap in future versions of Gum so this behavior should not be relied upon.

<img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-8bfebb880b8817a60650268387c02af87b68eda1%2Fimage.png?alt=media" alt="" data-size="original">
{% endhint %}

### Wrap and DimensionsBased

If a Sprite sets DimensionsBased for its Texture Address, then its source file can wrap if its dimensions are large enough to result in the texture width or texture height set to a value larger than the source dimensions.

All examples in the DimensionsBased Texture Address section use the following values:

* Width Units = Absolute
* Height Units = Absolute

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-6c11ad8448c443876ea4c679f6d82a60580ce355%2Fimage.png?alt=media" alt=""><figcaption><p>Sprite width and height values used in this section</p></figcaption></figure>

Toggling wrapping adjusts whether the Sprite wraps or clamps the area defined by the Texture Left, Texture Top, and its size.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-1aadd2e2a6689df93a30dd7afe14eddb4c2c0751%2F22_09%2023%2041.gif?alt=media" alt=""><figcaption><p>A Sprite can wrap or clamp the area outside of the right and bottom bounds of its source</p></figcaption></figure>

If a Sprite's width or height are adjusted, this results in its texture coordinate values also being modified. If Wrap is true then areas outside of the source file wrap.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-382f5d9ea0eac280e3af3cf4a9d31a61e25f63b3%2F22_09%2025%2042.gif?alt=media" alt=""><figcaption><p>The source image wraps if the width or height are adjusted Texture Address is DimensionsBased</p></figcaption></figure>

Wrapping can also be affected by changing the Texture Width Scale or Texture Height Scale. Smaller values result in image being drawn smaller, making it wrap more.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-fe8152b98c4876974d5421593fbe5957b2881671%2F22_09%2040%2021.gif?alt=media" alt=""><figcaption></figcaption></figure>
