Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you make a smooth rainbow effect in Frame?

Asked by 6 years ago

I'm a noob at scripting but i'm trying to make a Frame that will switch between the rainbow colors smoothly, not like just flashing the colors of the rainbow. Do I have to script all of the RGB colors manually or is there a more efficient way of doing it. Are there any references I can use?

0
Try looking at the forums next time. Look what I did https://forum.scriptinghelpers.org/topic/188/screen-saver hiimgoodpack 2009 — 6y

1 answer

Log in to vote
0
Answered by
2eggnog 981 Moderation Voter
6 years ago

Color3 has a function called fromHSV which takes the hue, saturation, and value as arguments, and converts them to a Color3. You can use a for loop to rotate through all the hues of the rainbow with as much precision as you want.

for hue=0, 1, 1/30 do
frame.BackgroundColor3 = Color3.fromHSV(hue, 1, 1)
wait()
end

Another useful method of Color3s is the lerp method, which lets you smoothly transition between two colors. Unfortunately this will not necessarily retain the saturation and value along the way, but it can still be useful.

local color1 = Color3.new(1, 0, 0) --red
local color2 = Color3.new(0, 1, 1) --cyan
for t = 0, 1, 1/30 do
whatever.BackgroundColor3 = color1:lerp(color2, t)
end
0
Why not Color3.fromRGB? You can easily get red, green, and blue values without looking them up. hiimgoodpack 2009 — 6y
Ad

Answer this question