Replace Color3.toHSV with toHSV method

I propose to add a toHSV method to Color3, and deprecate the Color3.toHSV function.

Instead of doing this:

local color = Color3.new()
local h, s, v = Color3.toHSV(color)

Users do this:

local color = Color3.new()
local h, s, v = color:toHSV()

Arguments for

  • The DevHub indicates that toHSV is “static”, but offers no explanation as to what this means.
  • toHSV is the only such function of its kind. The concept of static functions has no precedent; they are not a regular pattern found in the Lua API.
  • toHSV, receiving a Color3 as its first and only argument, might as well be a method; a well-established pattern in the Lua API with plenty of precedent.
  • First-time users will expect it to be a method. They will be confused when they find that it isn’t.
  • Not having to introduce an entire concept for the sake of a single static function that might as well be a method is a lot easier for documentation writers.

Arguments against

  • The Color3.toHSV function is the reverse of the Color3.fromHSV constructor, so that means they have to have matching APIs. Established patterns be damned.
36 Likes

Just now had a confusing time with this function.

For the record, this has been implemented a while ago as Color3:ToHSV.

3 Likes