> For the complete documentation index, see [llms.txt](https://frinn.gitbook.io/custom-machinery-1.21/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://frinn.gitbook.io/custom-machinery-1.21/creating-custom-machines/machine-gui/background-element.md).

# Background element

The background gui element work mostly the same way as the [texture gui element](/custom-machinery-1.21/creating-custom-machines/machine-gui/texture-element.md).

It is used to display a background texture for the machine gui.

{% hint style="warning" %}
By default the machine gui doesn't have a background texture, meaning that the gui will be transparent if no background element are specified.
{% endhint %}

It can also be used to change the size of the gui.

The default machine gui size is 256x192px and the maximum size is 3840x2160px.

If a texture is specified the width/height of the gui will use the width/height of that texture (unless these properties are specified in the background element).

Background elements are defined in json with `"type": "custommachinery:background"`.

{% hint style="warning" %}
You can only define 1 background element for a machine gui, if more than 1 background elements are added only the first will be used and the other ignored.
{% endhint %}

### Properties

The background element has 1 mandatory property and 3 optional properties :&#x20;

#### Mandatory property

```json5
"type": "custommachinery:background" //Mandatory to define a background element.
```

#### Optional properties

<details>

<summary>Texture</summary>

#### Name : `texture`

#### Description :&#x20;

The location of the texture that will be rendered into the GUI.&#x20;

The location must be referenced by : `namespace:path/file.png` The texture loader will search for textures in the `assets/namespace` folder, the .png extension is required or the file will not be found.

The texture can be any size, if the texture size is different from the default size the width and height properties of the element will be automatically changed to fit the texture size if not provided.&#x20;

If the width and/or height properties of the element are provided, the texture will be stretched to fit the dimensions of the element (it can render weirdly in that case).

#### Default :&#x20;

```json
"texture": "custommachinery:textures/gui/base_background.png"
```

#### Example :&#x20;

The file `assets/textures/my_background_texture.png` will be used for the slot element.

```json5
"texture": "namespace:textures/my_background_texture.png"
```

</details>

<details>

<summary>Width</summary>

#### Name : `width`

#### Description :&#x20;

A positive integer that define the width of the machine gui.

Maximum allowed value : 3840

#### Default : `256`

#### Example :&#x20;

```json5
"width": 512 //The machine gui will be 512px wide.
```

</details>

<details>

<summary>Height</summary>

#### Name : `height`

#### Description :&#x20;

A positive integer that define the height of the machine gui.

Maximum allowed value : 2160

#### Default : `192`

#### Example :&#x20;

```json5
"height": 512 //The machine gui will be 512px high.
```

</details>

### Example :&#x20;

The most basic background gui element that will fix 99% of your use-cases :&#x20;

```json
{
    "type": "custommachinery:background"
}
```

A background gui element that resize the machine gui to 192x256px

```json5
{
    "type": "custommachinery:background",
    "width": 192,
    "height": 256
}
```

A background gui element that change the default texture (size will be handled automatically) :&#x20;

```json
{
    "type": "custommachinery:background",
    "texture": "custommachinery:textures/custom_machine_gui_background.png"
}
```


---

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

```
GET https://frinn.gitbook.io/custom-machinery-1.21/creating-custom-machines/machine-gui/background-element.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.
