-- SOLVED --
The last flag in Image.create needed to be 4 so that the channel for colors exists.

I'm working on a pixel based world map for my game. To make it, I need to create an image and set it to the texture of a textureRect. To start it, I was going to use the Image.fill() function to set a base blue background. But the only colors I can get are blank white or black, no matter the color I set it to fill.

Here's my code

extends Control

@onready var texture = $TextureRect

func _ready():
	var map = Image.create(50, 50, false, 0)
	map.fill(Color.CORNFLOWER_BLUE)
	texture.texture.set_image(map)

I've set the color to be the RGBA value for cornflower blue, other blues, and to Color(0, 0, 0, 1), and the only one that made it anything other then white was Color(0, 0, 0, 1), or pure black.

To be clear, texture is a TextureRect with the texture set to be a blank, default ImageRect.

Thanks for the help!

    Figgity texture.texture.set_image(map)

    Try this instead:
    texture.texture = ImageTexture.create_from_image(map)

      I may experiment with it. I've created polygonal shapes with solid colors in code, and that works correctly. However, I'm using Polygon2D, not TextureRect.

        Actually, if your objective is to have a solid color rectangle, you could use a ColorRect.

          DaveTheCoder Okay. Thank you for your help!

          It needs to be an image because its a pixel map, so ColorRect won't work

          DaveTheCoder I figured it out. I needed to change the last flag when making the Image object, as that controls what channels the pixels in the image can have. Thanks for the help!

          Figgity changed the title to Image.fill always gives a white texture - Solved - .