# Image

{% hint style="info" %}
Your GameObject which contains Image component, need to be the a child of GameObject which contains a Canvas component
{% endhint %}

## Introduction

Your image gonna get the size of your GameObject world scale and image position gonna set at your GameObject world position.

### Change color

You can see the [color definition](/kap-engine-wiki/user-manual/tools/color.md)

```cpp
KapEngine::Tools::Color col(10, 10, 10);

myImage.setColor(col);
```

## No Images

If you do not set a path for an image, you component will be set only for color. There is no code to write to set it without image.

{% hint style="success" %}
If your image conatins an image and you want only a color, you just have to set path to nothing ("").
{% endhint %}

## Image

To set an image path in your Image component, there is 2 things to do :&#x20;

* First one : set the path

```cpp
myImage.setPathSprite("my/path.png");
```

* Second one : set the [rectangle](/kap-engine-wiki/user-manual/tools/rectangle.md) of your image :&#x20;

```cpp
//way 1
myImage.setRectangle({0, 0, 100, 100});
//way 2
KapEngine::Tools::Rectangle rect;
rect.setPos({0, 0});
rect.setSize({100, 100});
myImage.setRectangle(rect);
```

here, your image have a size of 100x100 and your want to get all image.


---

# Agent Instructions: 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:

```
GET https://kap35.gitbook.io/kap-engine-wiki/user-manual/ui/image.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
