Proposal to add a Color3Curve Instance

As a Roblox developer, it is currently too hard to gradually change the color of a BasePart into more than one color, as the most convenient way to do so is by using a ColorSequence Data Type which requires the use of a function as shown below in order to interpolate between each Color3 value

local function colorSequenceLerp(colorSequence: ColorSequence, time: number): Color3
	if time == 0 then return colorSequence.Keypoints[1].Value end
	if time == 1 then return colorSequence.Keypoints[#colorSequence.Keypoints].Value end

	for i = 1, #colorSequence.Keypoints - 1 do
		local currentKeypoint = colorSequence.Keypoints[i]
		local nextKeypoint = colorSequence.Keypoints[i + 1]

		if time >= currentKeypoint.Time and time < nextKeypoint.Time then
			return currentKeypoint.Value:Lerp(nextKeypoint.Value, (time - currentKeypoint.Time) / (nextKeypoint.Time - currentKeypoint.Time))
		end
	end
end

And while this does achieve the desired effect, this does have some drawbacks namely:

  • It requires good math knowledge if you wish to use a non-linear interpolation method
  • You must remember to either write and store the function somewhere (ideally inside a ModuleScript), use a ModuleScript provided by a player than includes this function, or copy the function from a free resource or tutorial
  • The function will take up a small bit of memory (Admittedly if you’re storing it in a module, this isn’t that much of a problem although it will still take up a small bit of memory)
  • Most of the calculations are done using Luau, and while Luau is fast, using a function like FloatCurve:GetValueAtTime() has the advantage of calculating in C

If this issue is addressed, it would improve my development experience because it will be much simpler to create a custom health Gui that gradually shifts colors depending on how hurt a Humanoid is for example

Do you agree with my proposal?
  • Yes
  • No
  • Indifferent

0 voters

Honestly, Roblox should implement spawnable-through-studio curve objects, just like they do for values.

The could then be fetched like any other object, then the expect :GetValueAtTime() could be called against them, and provide a properly typed result.

A benefit to this would be to leverage the already existing curve / gradient GUIs present in the studio for modifying similar curves that exist under the hood such as FloatCurve.

These would be a great middle-ground between the Tween service and full animations, and would be an ideal implementation method for myself.

It’s 100% useless.
Attributes can do that, and this instances is de facto deprecated, and attributes replace them

TIL we have FloatCurves in code, and NumberSequences in Attributes ( wonderful naming, no wonder I hadn’t heard of the latter ) and ColorSequences to boot. Fancy that.

Thanks for the tip :+1:

Vector3Curve exists which should give you what you need if you map X->R, Y->G and Z->B, I know colors aren’t vectors, but they’re both 3-dimensional data types.