0 votes

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)

Godot version 3.1.1
in Engine by (157 points)

Gradient.get_color(point) does not work

1 Answer

0 votes

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

by (1,500 points)
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.