DEV Community

Samandar Ravshanov
Samandar Ravshanov

Posted on

📦 Generates inverted (opposite) version of the given color

from functorflow import f

print(f('invert-color', '#000')) 
#ffffff

print(f('invert-color', '#282b35'))
# '#d7d4ca'

# input color as RGB array or object

print(f('invert-color', [69, 191, 189]))
# '#ba4042'

print(f('invert-color', { 'r': 249, 'g': 119, 'b': 121 })) 
# '#068886'


# amplify to black or white
print(f('invert-color', '#282b35', bw=True))
# '#ffffff'


# amplify to custom black or white color
print(f('invert-color', '#282b35', bw={ 'black': '#3a3a3a', 'white': '#fafafa' }))     # —> #fafafa

# amplify with custom luminance threshold (default is invert.defaultThreshold = ~0.179)
print(f('invert-color', '#282b35', bw={ 'black': '#3a3a3a', 'white': '#fafafa', 'threshold': 0.01 }))     
# #3a3a3a
Enter fullscreen mode Exit fullscreen mode

Top comments (0)