Can I change color index through script?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Weexer

I’m using aseprite for my 2d graphics. Right now I am working on user interface, and I wonder if I can control color Index from script, it would be pretty usefull

:bust_in_silhouette: Reply From: SQBX

Not quite sure if this is what you’re asking for, but you can get a pixel via x and y:

var image = texture_normal.get_data()
Image.lock()
for row in image.get_height():
    for column in image.get_width():
        print(image.get_pixel(column, row))

image.unlock()

At this point, you have an Image with your edited pixels. If you want to draw it on screen using a sprite or a mesh instance, you can create an ImageTexture from it:

texture_normal = ImageTexture.new()
texture_normal.create_from_image(image)