UNPKG

661 BJavaScriptView Raw
1import { __read } from "tslib";
2import colorUtil from '@antv/color-util';
3// 内置的一些特殊设置
4var preset = {
5 '#5B8FF9': true,
6};
7// 根据YIQ亮度判断指定颜色取反色是不是白色
8// http://24ways.org/2010/calculating-color-contrast
9// http://www.w3.org/TR/AERT#color-contrast
10export var isContrastColorWhite = function (color) {
11 var rgb = colorUtil.toRGB(color).toUpperCase();
12 if (preset[rgb]) {
13 return preset[rgb];
14 }
15 var _a = __read(colorUtil.rgb2arr(rgb), 3), r = _a[0], g = _a[1], b = _a[2];
16 var isDark = (r * 299 + g * 587 + b * 114) / 1000 < 128;
17 return isDark;
18};
19//# sourceMappingURL=color.js.map
\No newline at end of file