+1 vote

From a script, I'd like to get the color values at specific positions of a sprite. Is this possible somehow? In my case, the sprite is not drawn but only contains data for an algorithm. Is there another way to just load an image an get its color values?

in Engine by (40 points)

1 Answer

+4 votes
Best answer

Yes, you don't have to create a sprite for this.

# This gives you an ImageTexture
var image_texture_resource = preload("my_image.png")

# This gives you an Image
var image = image_texture_resource.get_data()

# This gives you a pixel (check the doc)
image.get_pixel(x, y)
by (29,088 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.