<commit_before>module Purple
  ( Purple
  , initPurple
  , updatePurple
  ) where

import Data.Bits (bit, testBit)
import Data.List (intersperse)
import Data.Word (Word8)

import Time
import Segment
import State
import Activity
import Blinker

frac :: RealFrac a => a -> a
frac = (snd :: (Integer, a) -> a) . properFraction

hue :: Float -> Color
hue h
  | x <= 1 = RGB 1 y 0
  | x <= 2 = RGB z 1 0
  | x <= 3 = RGB 0 1 y
  | x <= 4 = RGB 0 z 1
  | x <= 5 = RGB y 0 1
  | otherwise = RGB 1 0 z
  where
    x = 6*frac h
    y = frac x
    z = 1 - y

color :: Word8 -> Color
color w = b * hue (fromIntegral w / fromIntegral (pred (bit highBit) :: Word8)) where
  b = if testBit w highBit then 0.5 else 0.25

duration :: Interval
duration = 0.5

flash :: Color -> Segment<commit_msg>Tweak purple color map for new alertcount updates<commit_after>module Purple
  ( Purple
  , initPurple
  , updatePurple
  ) where

import Data.Bits (bit, testBit, clearBit)
import Data.List (intersperse)
import Data.Word (Word8)

import Time
import Segment
import State
import Activity
import Blinker

hue :: Float -> Color
hue h = case x :: Word8 of
  0 -> RGB 1 y 0
  1 -> RGB z 1 0
  2 -> RGB 0 1 y
  3 -> RGB 0 z 1
  4 -> RGB y 0 1
  5 -> RGB 1 0 z
  _ -> RGB 1 1 1
  where
    (x, y) = properFraction (6*h)
    z = 1 - y

color :: Word8 -> Color
color w = b * hue (fromIntegral (clearBit w highBit) / fromIntegral (pred (bit highBit) :: Word8)) where
  b = if testBit w highBit then 0.5 else 0.25

duration :: Interval
duration = 0.5

flash :: Color -> Segment
{'fraction_non_alphanumeric': 0.1080906148867314, 'fraction_numerical': 0.040776699029126215, 'mean_word_length': 2.6376470588235295, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '579736', 'n_tokens_mistral': 625, 'n_tokens_neox': 554, 'n_words': 235}