"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var getColorLuminance_1 = __importDefault(require("./getColorLuminance"));
var OFFSET = 0.05;
/**
* Get contrast ratio between two color.
* Smaller result means larger contrast.
* Reference: https://dev.to/alvaromontoro/building-your-own-color-contrast-checker-4j7o
* @param color1
* @param color2
* @category style
* @module getColorsContrastRatio
*/
var getColorsContrastRatio = function (color1, color2) {
var color1Luminance = (0, getColorLuminance_1.default)(color1);
var color2Luminance = (0, getColorLuminance_1.default)(color2);
return color1Luminance > color2Luminance
? ((color2Luminance + OFFSET) / (color1Luminance + OFFSET))
: ((color1Luminance + OFFSET) / (color2Luminance + OFFSET));
};
exports.default = getColorsContrastRatio;
Source