@libgranite/contrast-color
v1.0.0
Published
Contrast color calculator
Downloads
8
Maintainers
Readme
SCSS Contrast Color
This package provides a contrast color calculator for scss and js. The library will calculate if the color has a higher contrast against white or black.
Using the library
The package provides a js module and a scss mixing for the calculation of the contrast color.
The library functions will return either 'black' or 'white', based upon the input color.
JavaScript
The js module provides two functions. The first, get_contrast_color_rgb takes an
RGB color while get_contrast_color_hex takes a hex color string.
import {get_contrast_color_rgb, get_contrast_color_hex} form '@grante/contrast-color'
var best_color = get_contrast_color_rgb({red: 100, green: 100, blue: 100});
// or
var best_color_2 = get_contrast_color_hex('#123456');
SCSS
The scss project provides one mixin. It can be used with any css color (Hex, RGB, or RBGa);
@import '@grante/contrast-color/_mixin';
div.example {
background-color: #123456;
color: @import(#123456);
}