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

Color3 lerp like a ramp?

Asked by 5 years ago

So far I have this but it just sets it to the b color. I don't know what to do.. if color3 doesn't have an alpha. How would I achieve this?

Basicly trying to ramp white to red base off t

local GUI = game.StarterGui.ScreenGui
local frame = GUI:WaitForChild("Frame")

function lerp(a, b, t)
    t = math.clamp(0, 1, 1)
    return Color3.new(
        a.r + (b.r - a.r) * t,
        a.g + (b.g - a.g) * t,
        a.b + (b.b - a.b) * t
    )
end

frame.BackgroundColor3 = lerp(Color3.fromRGB(255,255,255), Color3.fromRGB(255,35,35), 0.5)
0
I forgot that clamp rounds your number.. :P wantsome555 0 — 5y
0
it doesn't, Color3.new just takes values from 0 to 1 but you're lerping it from 0 to 255 thebayou 441 — 5y
0
nope, it works just as it should, the math.clamp round 0.5 to 1 wantsome555 0 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

Answer: Just remove t = math.clamp(0, 1, 1), and make sure t is from 0 - 1

Ad

Answer this question