<commit_before>module Scorched.View.Transition exposing (build)

import Svg exposing (Svg)
import Svg.Attributes as Attr

import Scorched.View.Palette as Palette exposing (Color)
import Scorched.Model.Types exposing (Model, Msg)

build : Model -> Svg Msg
build {dimensions, ticks} =
  Svg.g
    [ Attr.id "transition" ]
    (List.indexedMap (band ticks dimensions.height) (bands dimensions.width))

bands : Int -> List Color
bands width =
  List.repeat (round (toFloat (repeats width) / 2)) colors
    |> List.intersperse (List.reverse colors)
    |> List.concat

band : Int -> Int -> Int -> Color -> Svg Msg
band ticks height offset color =
  Svg.rect
    [ Attr.x (String.fromInt (offset * bandWidth + (timeOffset ticks)))
    , Attr.y "0"
    , Attr.width (String.fromInt bandWidth)
    , Attr.height (String.fromInt height)
    , Attr.fill (Palette.toString color)
    ]
    []

timeOffset : Int -> Int<commit_msg>do not render invisible elements<commit_after>module Scorched.View.Transition exposing (build)

import Svg exposing (Svg)
import Svg.Attributes as Attr

import Scorched.View.Palette as Palette exposing (Color)
import Scorched.Model.Types exposing (Model, Msg, Dimension)

build : Model -> Svg Msg
build {dimensions, ticks} =
  Svg.g
    [ Attr.id "transition" ]
    (List.indexedMap (band ticks dimensions) (bands dimensions.width))

bands : Int -> List Color
bands width =
  List.repeat (round (toFloat (repeats width) / 2)) colors
    |> List.intersperse (List.reverse colors)
    |> List.concat

band : Int -> Dimension -> Int -> Color -> Svg Msg
band ticks {width, height} n color =
  let
    offset = (n * bandWidth + (timeOffset ticks))
  in
    if offset < 0 - bandWidth || offset > width then
      Svg.g [ ] [ ]
    else
      Svg.rect
        [ Attr.x (String.fromInt offset)
        , Attr.y "0"
        , Attr.width (String.fromInt bandWidth)
        , Attr.height (String.fromInt height)
        , Attr.fill (Palette.toString color)
        ]
        []

timeOffset : Int -> Int
{'fraction_non_alphanumeric': 0.11548033847685416, 'fraction_numerical': 0.0024888003982080635, 'mean_word_length': 3.0524193548387095, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 22, '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': '2248108', 'n_tokens_mistral': 675, 'n_tokens_neox': 649, 'n_words': 196}