diff --git a/src/Emphasise.lua b/src/Emphasise.lua index f56f295..694db16 100644 --- a/src/Emphasise.lua +++ b/src/Emphasise.lua @@ -2,6 +2,7 @@ local GetLuminance = require(script.Parent.GetLuminance) local Lighten = require(script.Parent.Lighten) local Darken = require(script.Parent.Darken) -return function(colour: Color3, coefficient: number): Color3 - return GetLuminance(colour) > .5 and Darken(colour, coefficient) or Lighten(colour, coefficient) +return function(colour: Color3, coefficient: number, threshold: number?): Color3 + threshold = type(threshold) == "number" and threshold or .5 + return GetLuminance(colour) > threshold and Darken(colour, coefficient) or Lighten(colour, coefficient) end diff --git a/src/Emphasise.spec.lua b/src/Emphasise.spec.lua index 74ea284..badc2bd 100644 --- a/src/Emphasise.spec.lua +++ b/src/Emphasise.spec.lua @@ -12,4 +12,14 @@ return function() local colour = Color3.fromRGB(250, 240, 230) expect(Emphasise(colour, .3)).to.equal(Darken(colour, .3)) end) + + it("lightens a light colour with a high threshold", function() + local colour = Color3.fromRGB(230, 220, 210) + expect(Emphasise(colour, .1, .9)).to.equal(Lighten(colour, .1)) + end) + + it("darkens a dark colour with a low threshold", function() + local colour = Color3.new(.2, .2, .2) + expect(Emphasise(colour, .1, .01)).to.equal(Darken(colour, .1)) + end) end