@glassware/core 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -57,10 +57,12 @@ var TEXT_COLORS = {
57
57
  function textModeForTone(tone) {
58
58
  return tone === "light" ? "dark" : "light";
59
59
  }
60
- function pickTextMode(luminance, threshold = 0.5) {
60
+ var DEFAULT_THRESHOLD = 0.19;
61
+ var HYSTERESIS_MARGIN = 0.03;
62
+ function pickTextMode(luminance, threshold = DEFAULT_THRESHOLD) {
61
63
  return luminance > threshold ? "dark" : "light";
62
64
  }
63
- function pickTextModeSticky(luminance, previous, threshold = 0.5, margin = 0.04) {
65
+ function pickTextModeSticky(luminance, previous, threshold = DEFAULT_THRESHOLD, margin = HYSTERESIS_MARGIN) {
64
66
  if (previous === "dark") return luminance > threshold - margin ? "dark" : "light";
65
67
  if (previous === "light") return luminance > threshold + margin ? "dark" : "light";
66
68
  return pickTextMode(luminance, threshold);