# Y Units

The `Y Units` variable controls how a unit is vertically positioned relative to its parent. By default an object is positioned relative to the top of its parent, where each unit represents 1 pixel downward.

## Pixels From Top

The following image shows a child [ColoredRectangle](https://docs.flatredball.com/gum/gum-tool/gum-elements/coloredrectangle) positioned 50 `Pixels From Top` relative to its parent:

![Rectangle with Y Units of Pixels From Top](https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-8bd9f13907dea07d64c786e51bdec9bf87488850%2F05_07%2050%2042.png?alt=media)

## Pixels From Center

The following image shows a child ColoredRectangle positioned 50 `Pixels From Center` relative to its parent:

![ColoredRectangle with Y Units of Pixels From Center](https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-633861c28480dc76d7ee53ddd164c89730b00d0c%2F05_08%2042%2017.png?alt=media)

## Pixels From Bottom

The following image shows a child ColoredRectangle positioned 50 `Pixels From Bottom` relative to its parent:

![ColoredRectangle with Y Units of Pixels From Bottom](https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-207ae99b62b9b25df1dd99a6d83e630f7655a353%2F05_08%2051%2054.png?alt=media)

## Percentage Parent Height

The following image shows a child ColoredRectangle positioned 50 `Percentage Parent Height` relative to its parent:

![ColoredRectangle with Y Units of Percentage Parent Height](https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-3d0c35b5e6f7be683f62ad45be837a334dcf3ce7%2F05_08%2054%2017.png?alt=media)

## Pixels From Baseline

`Pixels From Baseline` positions a child relative to the parent's baseline. If the parent is a Text instance, the baseline is the Y position of the bottom of letters which do not have descenders. For more information on the concept of text baseline, see the baseline Wikipedia page <https://en.wikipedia.org/wiki/Baseline_(typography)>

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-48a9119244887910922c3109245c790913bbbcd3%2FBaseline2.png?alt=media" alt=""><figcaption><p>Baseline Example</p></figcaption></figure>

The following image shows a child ColoredRectangle positioned 0 pixels relative to a Text instance's baseline.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-a329ca2766867c05016e257b2584ca99811b62aa%2F09_06%2040%2034.png?alt=media" alt=""><figcaption><p>ColoredRectangle with <code>Y Units</code> of <code>Pixels From Baseline</code></p></figcaption></figure>

When using `Pixels From Baseline`, the position depends on the font size, baseline definition in the .fnt, and whether the text wraps. For example, changing the `Width` of the Text causes line wrapping which shifts the baseline.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-765c733ddc719a0e9c8962eec743165dbb8dce8f%2F09_06%2042%2005.gif?alt=media" alt=""><figcaption><p>Baseline Shifts when the parent Width changes</p></figcaption></figure>

A text instance's baseline is defined by its `Font` and `Font Scale` values. These values ultimately create a .fnt file with a `base` value indicating the distance from the top of the text instance to the baseline. For example, an Arial font with Font Size 40 has a `base` value of 36 and a lineHeight of 45.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-ad0899ff2eb090aac90e3893ac50fee92451dabb%2F05_20%2048%2034.png?alt=media" alt=""><figcaption><p>Arial with Font Size 40 has a base value of 36</p></figcaption></figure>

This means that 36 pixels fall above the baseline, and 9 pixels (45 - 36) below.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-0190a0115a50d8bfa2f01c8a513357e2e911effe%2F05_20%2051%2013.png?alt=media" alt=""><figcaption><p>Base defines the distance from the top of the Text instance to the baseline</p></figcaption></figure>

Note that if the parent is not a Text instance, then the bottom of the parent is used as the baseline. The following image shows a Colored Rectangle using a `Y Units` of `Pixels From Baseline` with a Container parent.

<figure><img src="https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-4c69d3f6b669c8743cb5a86f1b05d9239cbe6429%2F05_09%2018%2028.png?alt=media" alt=""><figcaption><p><code>Pixels from Baseline</code> uses the bottom of the parent if it is not a Text instance</p></figcaption></figure>
