UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) 389 B
const i=150,s="#1a1a1a",c="#ffffff",a=/^[0-9A-Fa-f]{6}$/,f=/^[0-9A-Fa-f]{3}$/;function u(t){const n=t.replace("#","");return a.test(n)?n:f.test(n)?n[0]+n[0]+n[1]+n[1]+n[2]+n[2]:null}export function getContrastTextColor(t){const n=u(t);if(!n)return s;const r=parseInt(n.substring(0,2),16),e=parseInt(n.substring(2,4),16),o=parseInt(n.substring(4,6),16);return .299*r+.587*e+.114*o>150?s:c}