I'm trying to generate a sprite filled with random data created from a noise function. I have a script that I found here which can make some noise values (such as simplex noise), and so I've been trying to turn that into a sprite of some kind. What I do is preload that other script, create an Image
object, assign that to an ImageTexture
object, set that to a texture, create the data, set the color of the pixels in the Image
object, and finally set that data to the texture. It's suppose to take the array data and map the colors to the sprite based on the values of each cell in the array. So if some cell (which corresponds to a pixel in the Image
object) has a value between 0 and 0.3, it's suppose to make the pixel a bluish color.
Unfortunately, all this does is create a window that has different colored tiles in it.

I can't figure out where the problem is. Is it in the Image
object? Or the ImageTexture
object? Does it lie somewhere else? I don't know.
My scene is set up like this:
some_tilemap (a tilemap node) -> some_sprite (obviously, a sprite node)
Btw, here's the code that I'm using:
extends TileMap
onready var preScript = preload("res://scripts/softnoise.gd")
onready var softNoise
func _ready():
randomize()
# Create a vector to set the size of the image.
var imageSize = Vector2(256,256)
# Create an image
var noisey_image = Image(imageSize.x, imageSize.y, false, Image.FORMAT_RGBA)
# Create an ImageTexture
var le_texture = ImageTexture.new()
le_texture.create(imageSize.x, imageSize.y, Image.FORMAT_RGBA, 0)
le_texture.set_data(noisey_image)
# Get the node of the sprite
var le_sprite = get_node("some_sprite")
# Set the texure in the sprite
le_sprite.set_texture(le_texture)
# Make some random number
var num = randi()%1000
# Hold the noise data here.
var noise_data = {}
# Some other variables
var b = 0
var thing = 0
var color = {}
# Random
softNoise = preScript.SoftNoise.new(num)
for i in range(0, imageSize.x):
for j in range(0, imageSize.y):
thing = softNoise.openSimplex2D(i,j)
# For each pixel, if the resulting noise lies within a certain
# range, assign a certain color to that pixel.
if -0.5 <= thing <= 0:
# Brown
color = Color(250, 58, 20)
elif 0 <= thing <= 0.3:
# Blue
color = Color(37, 134, 187)
elif 0.3 <= thing <= 0.6:
# Green
color = Color(54, 194, 85)
elif 0.6 <= thing <= 1.0:
# Pale color
color = Color(227, 207, 168)
noisey_image.put_pixel(i,j, color)
le_texture.set_data(noisey_image)