<commit_before>module Colors exposing
    ( black
    , darkGray
    , darkText
    , gray
    , highlightPink
    , icon
    , inputBackground
    , leftBarHeader
    , leftStripeIconSelected
    , lightGray
    , lightText
    , mainSvgBackground
    , menuBackground
    , menuBorder
    , menuBorderOnMouseOver
    , mouseOveredItem
    , orange
    , rectAroundSelectedVertices
    , red
    , rightBarHeader
    , selectBlue
    , selectedItem
    , selectorStroke
    , sliderThumb
    , svgLine
    , toString
    , transition
    , vertexAndEdgeColors
    , white
    , yellow
    )

import Element as El exposing (Color, Element)


toString : Color -> String
toString color =
    let
        o =
            El.toRgb color
    in
    "rgba("
        ++ String.fromInt (round (o.red * 255))
        ++ ("," ++ String.fromInt (round (o.green * 255)))
        ++ ("," ++ String.fromInt (round (o.blue * 255)))
        ++ ("," ++ String.fromFloat o.alpha)
        ++ ")"


transition : Float -> Color -> Color -> Color
transition k start end =
    let
        ( s, e ) =
            ( El.toRgb start, El.toRgb end )

        tr s_ e_ =
            s_ + k * (e_ - s_)
    in
    El.rgba
        (tr s.red e.red)
        (tr s.green e.green)
        (tr s.blue e.blue)
        (tr s.alpha e.alpha)


rectAroundSelectedVertices =
    El.rgb255 40 127 230

<commit_msg>added decoder and encoder to Colors<commit_after>module Colors exposing
    ( black
    , darkGray
    , darkText
    , decoder
    , encode
    , gray
    , highlightPink
    , icon
    , inputBackground
    , leftBarHeader
    , leftStripeIconSelected
    , lightGray
    , lightText
    , mainSvgBackground
    , menuBackground
    , menuBorder
    , menuBorderOnMouseOver
    , mouseOveredItem
    , orange
    , rectAroundSelectedVertices
    , red
    , rightBarHeader
    , selectBlue
    , selectedItem
    , selectorStroke
    , sliderThumb
    , svgLine
    , toString
    , transition
    , vertexAndEdgeColors
    , white
    , yellow
    )

import Element as El exposing (Color, Element)
import Json.Decode as JD exposing (Decoder, Value)
import Json.Encode as JE exposing (Value)


toString : Color -> String
toString color =
    let
        o =
            El.toRgb color
    in
    "rgba("
        ++ String.fromInt (round (o.red * 255))
        ++ ("," ++ String.fromInt (round (o.green * 255)))
        ++ ("," ++ String.fromInt (round (o.blue * 255)))
        ++ ("," ++ String.fromFloat o.alpha)
        ++ ")"



-------------
-- Encoder --
-------------


encode : Color -> Value
encode color =
    let
        o =
            El.toRgb color
    in
    JE.object
        [ ( "red", JE.float o.red )
        , ( "green", JE.float o.green )
        , ( "blue", JE.float o.blue )
        , ( "alpha", JE.float o.alpha )
        ]



-------------
-- Decoder --
-------------


decoder : Decoder Color
decoder =
    JD.map4 El.rgba
        JD.float
        JD.float
        JD.float
        JD.float



--


transition : Float -> Color -> Color -> Color
transition k start end =
    let
        ( s, e ) =
            ( El.toRgb start, El.toRgb end )

        tr s_ e_ =
            s_ + k * (e_ - s_)
    in
    El.rgba
        (tr s.red e.red)
        (tr s.green e.green)
        (tr s.blue e.blue)
        (tr s.alpha e.alpha)


rectAroundSelectedVertices =
    El.rgb255 40 127 230


{'fraction_non_alphanumeric': 0.1211134142730234, 'fraction_numerical': 0.012140953509031684, 'mean_word_length': 1.6431924882629108, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '6133629', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1069, 'n_words': 269}