Invert Color Module

Backstory

I recently needed a way to invert a few Color3 values so I decided to create this module.


Documentation

invert(color: string | Color3, bw: boolean)

color - HEX string or Color3 to invert
bw - whether to return a black/white Color3


Example Code

local invert = require(7199428060) -- or require(path.to.module)

-- Hex to Inverted RGB
invert('#ABCDEF') -- Color3.new(0.329412, 0.196078, 0.0627451)

-- RGB to Inverted RGB
invert(Color3.fromRGB(255,0,0)) -- Color3.new(0, 1, 1)

-- Hex to Inverted BW
invert('#FFFFFF', true) -- Color3.new(0,0,0)

-- RGB to Inverted BW
invert(Color3.fromRGB(0,0,0), true) -- Color3.new(1,1,1)

Source

You can view the source here.
You can download the module here.


Happy color-inverting!

5 Likes

Mind including some documentation about the function?

All I can guess is that the first one id the color and second is black and white.

1 Like

It is pretty self-explanatory from the examples, but I’ll include a basic overview of the one function.

2 Likes

idk whats the use for this, if you wanted all colors to be inverted in the work space there is already a trick for it

Actually, there are many use cases for this.

  1. Player input
  2. Creating procedurally-generated patterns
  3. Individual part color inversion
  4. GUI Light/Dark mode
2 Likes

Inverting a color is pretty easy, but a hex-string-to-Color3 would be useful. You should add a standalone hex-to-color3 function.

1 Like

Good idea, I’ll release an overall Color3 module soon that combines a bunch of Color3 functions.

1 Like

Here you go!

2 Likes