0 votes

How can I calculate such a color spectrum with Color(r,g,b,a) to save it as an Image?
I know how to store the pixels in an image, but I can't figure out how to change the RGB values to create such a spectrum.

color spectrum

in Engine by (226 points)

1 Answer

0 votes

You can create an image and then you can set the color of every individual pixel in an image

image = Image.new()
image.create(width, height, false, Image.FORMAT_RGB8)
image.lock()
image.set_pixelv(v2, Color(r,g,b))

You can iterate through different values for the v2 and paint the image accordingly.

The best solution though is to do it with shaders
It's faster to compute, and way more flexible if you know how to use them.
They are kind of time-consuming to first learn, but if you have the time go ahead and give it a shot

by (120 points)

Is it possible to save a color spectrum programmed by the shader as an image?
Do you have any idea how I have to calculate the RGB values to get a spectrum like on the picture ( this picture is from the internet)?

Thank you for your help!
Gamemap

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.