# Canvas

{% hint style="info" %}
Canvas is mandatory in a parent of GameObject which contains Image or Text
{% endhint %}

## Why ?

Canvas is a component really useful for your UIs game. This component is made to do some calculations to render your images and texts. To make this render, it uses an enum called : ResizyngType.

## ResizyngType

This enum contains 2 differents type of resizing :&#x20;

* PIXEL\_CONSTANT : if your windows is resized, all things in your canvas gonna keep the same size (even they go outside the screen)
* RESIZE\_WITH\_SCREEN : if your windows is resized, all things in your canvas gonna be recalculated to feat with your screen



## Create a canvas

```cpp
// here scene is already defined
// canvas = std::shared_ptr<GameObject>
auto canvas = KapEngine::UI::UiFactory::createCanvas(scene, "Canvas Name In Scene");
```

{% content-ref url="uifactory" %}
[uifactory](uifactory)
{% endcontent-ref %}
