How can I calculate a color spectrum with `Color(r,g,b,a)`?

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

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.

:bust_in_silhouette: Reply From: PeterA

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

image =
image.create(width, height, false, Image.FORMAT_RGB8)
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

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 | 2021-08-08 18:24