> For the complete documentation index, see [llms.txt](https://junkeh.gitbook.io/eb/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://junkeh.gitbook.io/eb/features/palettes.md).

# Palettes

You can create Palettes for blocks in Palette.yml

***

Palettes can set a blocks color into a specific color, So if you set your brush to use that block, then the color that it comes with in palette.yml will also be defined, For example:\
if you set the color to be this in the palette:

```yaml
blocks:
  STONE: "#808080"
  DIRT: "#8B4513"
  GRASS_BLOCK: "#567D46"
```

and you do `/eb set brush block STONE`  Then the brush will automatically make the brushs color to `#808080`

## Want to generate a palette for EVERY block from a texture pack?

{% stepper %}
{% step %}

### Folder Structure

Create a folder, and add a folder called "Blocks" that contains every block texture (either yours or from a texturepack)
{% endstep %}

{% step %}

### Adding the code

In the root folder, create a Python script file and add this code:

Make sure you have the Pillow and NumPy libraries installed (you can install them via `pip install Pillow numpy`).

```python
import os
from PIL import Image
import numpy as np

def compute_average_color(image_path):
    """Compute the average color of an image."""
    with Image.open(image_path) as img:
        # Ensure the image is in RGB mode.
        img = img.convert('RGB')
        # Convert the image to a NumPy array.
        np_img = np.array(img)
        # Calculate the mean of each color channel.
        avg = np.mean(np_img.reshape(-1, 3), axis=0)
        return tuple(avg.astype(int))

def rgb_to_hex(rgb):
    """Convert an (R, G, B) tuple to a hex string."""
    return '#{:02X}{:02X}{:02X}'.format(*rgb)

def main():
    # Set the directory containing the block texture images to "blocks".
    input_dir = "blocks"  # Images should be placed in this folder.
    output_file = "blocks_colors.txt"

    blocks = {}

    # Iterate over all image files in the input directory.
    for filename in os.listdir(input_dir):
        if filename.lower().endswith(('.png', '.jpg', '.jpeg')):
            # Use the filename (without extension) as the block name, in uppercase.
            block_name = os.path.splitext(filename)[0].upper()
            image_path = os.path.join(input_dir, filename)
            # Compute the average color.
            avg_color = compute_average_color(image_path)
            # Convert the average color to a hex string.
            hex_color = rgb_to_hex(avg_color)
            blocks[block_name] = hex_color

    # Write the results in the desired YAML-like format.
    with open(output_file, "w") as file:
        file.write("blocks:\n")
        for block, color in blocks.items():
            file.write(f"  {block}: \"{color}\"\n")

    print(f"Block colors written to {output_file}")

if __name__ == "__main__":
    main()

```

{% endstep %}

{% step %}

### Final Steps

Run the Python Script and boom! You're done! Copy the text inside the newly created file and add it to Palette.yml
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
The python script also adds the TOP, SIDE, and other textures to the file so you may need to manually change these.
{% endhint %}
