Get pixel from GradientTexture

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

I have a GradientTexture. I want to get a color from a position in it (not just the colors in the array, but the final texture).

For example, if i have the default GradientTexture (Black to white, width 2048), getting the pixel at position 1024 should return Color(0.5,0.5,0.5)

Gradient.get_color(point) does not work

droc101 | 2021-01-07 19:07

:bust_in_silhouette: Reply From: Andrea

Counter intuitively, the function to get color from a gradient is not get_color but gradient.interpolate(x) with x being a value between 0 and 1. In your case x=1024/texture_gradient.width