ColorE, an extension to Roblox's Color3!

Hello all!
I have made an open-source module with the intent of extending Color3’s lacking functions. I have also made documentation for the module.

You can find all of that on my github:
ColorE_module_and_documentation

This module includes:

  • Color initialization constants
  • Color math
  • Color inversion
  • Color luminance (3 ways)
  • And color clamping

I’m relatively new to this sort of stuff so if there’s anything I could improve on, let me know!
Enjoy!

2 Likes

The methods are written very strangely. For example:

function colorE.new(R:number,G:number,B:number)
	local color = {}
	setmetatable(color, colorE)
	
	if typeof(R) == "Color3" then
		color.R = R.R
		color.G = R.G
		color.B = R.B
		color.color = R
	elseif typeof(R) == "number" then
		color.R = R
		color.G = G
		color.B = B
		color.color = Color3.new(R,G,B)
	elseif typeof(R) == "Vector3" then
		color.R = R.X
		color.G = R.Y
		color.B = R.Z
		color.color = Color3.new(R.X,R.Y,R.Z)
	else
		return error("Color input is not valid!") -- Throw an error if it isn't a color
	end
	
	return color
end

The constructor’s type analysis only displays R, G, and B as numbers, however the script shows that R can also be a Vector3 and Color3.

I get that this is probably meant to be an overload function, but the type analysis should be written like this:

function colorE.new(R: number | Vector3 | Color3, G: number?, B: number?)

This should be the case for the other methods as well

4 Likes