Skip to content

Commit db1eb28

Browse files
authored
added Color:Contrast(smooth)
1 parent 9dcee29 commit db1eb28

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

init.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,15 @@ do -- converters rgb > X
159159
function Color:ToVector()
160160
return Vector(self.r / 255, self.g / 255, self.b / 255)
161161
end
162+
163+
function Color:Contrast(smooth)
164+
if smooth then
165+
local c = 255 - self:ToHexDeciminal() / 0xffffff * 255
166+
return Color(c, c, c)
167+
else
168+
return self:ToHexDeciminal() > 0xffffff / 2 and Color(0, 0, 0) or Color(255, 255, 255)
169+
end
170+
end
162171
end
163172

164173
do -- constructors X > rgb

0 commit comments

Comments
 (0)