<commit_before>import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import StartApp.Simple as StartApp
import String


main : Signal Html
main =
  StartApp.start { model = initialModel, view = view, update = update }


type alias Params =
  { frequency : Float
  , phase : Float
  , amplitude : Float
  , damp : Float
  }


type alias Model =
  { px1 : Params
  , px2 : Params
  , py1 : Params
  , py2 : Params
  }


initialModel =
  { px1 =
    { frequency = 0.7
    , phase = 0
    , amplitude = 200
    , damp = 0.002
    }
  , px2 =
    { frequency = 0.6
    , phase = 0
    , amplitude = 200
    , damp = 0.00012
    }
  , py1 =
    { frequency = 0.5
    , phase = 0
    , amplitude = 230
    , damp = 0.0000017
    }
  , py2 =
    { frequency = 0.7
    , phase = 0
    , amplitude = 200
    , damp = 0.0000013
    }
  }


update action model =
  case action of
    X1 f ->
      let
        p = f model.px1
      in
        { model | px1 = p }

    X2 f ->
      let
        p = f model.px2
      in
        { model | px2 = p }

    Y1 f ->
      let
        p = f model.py1
      in
        { model | py1 = p }

    Y2 f ->
      let
        p = f model.py1
      in
        { model | py2 = p }

type Action
  = X1 (Params -> Params)
  | X2 (Params -> Params)
  | Y1 (Params -> Params)
  | Y2 (Params -> Params)

view address model =
  div []
    [ fromElement <| collage 1000 1000
      [ trace model
      ]
    , paramControls (Signal.forwardTo address X1) model
    ]

paramControls address model =
  div []
    [ slider
      { title = "amplitude"
      , min = 0.0
      , max = 1000.0
      , step = 1.0
      , update = \x -> Signal.message address (\p -> { p | amplitude = x })
      } model.px1.amplitude
    , slider
      { title = "phase"
      , min = 0.0
      , max = 10.0
      , step = 0.001
      , update = \x -> Signal.message address (\p -> { p | phase = x })
      } model.px1.phase
    , slider
      { title = "frequency"
      , min = 0.0
      , max = 1.0
      , step = 0.001
      , update = \x -> Signal.message address (\p -> { p | frequency = x })
      } model.px1.frequency
    , slider
      { title = "damp"
      , min = 0.0
      , max = 0.001
      , step = 0.000001
      , update = \x -> Signal.message address (\p -> { p | damp = x })
      } model.px1.damp
    ]


type alias SliderAttributes =
  { title : String
  , min : Float
  , max : Float
  , step : Float
  , update : Float -> Signal.Message
  }


slider : SliderAttributes -> Float -> Html
slider attr v =
  div []<commit_msg>pages<commit_after>import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import StartApp.Simple as StartApp
import String


main : Signal Html
main =
  StartApp.start { model = initialModel, view = view, update = update }


type alias Params =
  { frequency : Float
  , phase : Float
  , amplitude : Float
  , damp : Float
  }


type alias Model =
  { px1 : Params
  , px2 : Params
  , py1 : Params
  , py2 : Params
  }


initialModel =
  { px1 =
    { frequency = 0.7
    , phase = 0
    , amplitude = 200
    , damp = 0.002
    }
  , px2 =
    { frequency = 0.6
    , phase = 0
    , amplitude = 200
    , damp = 0.00012
    }
  , py1 =
    { frequency = 0.5
    , phase = 0
    , amplitude = 230
    , damp = 0.0000017
    }
  , py2 =
    { frequency = 0.7
    , phase = 0
    , amplitude = 200
    , damp = 0.0000013
    }
  }


update action model =
  case action of
    X1 f ->
      let
        p = f model.px1
      in
        { model | px1 = p }

    X2 f ->
      let
        p = f model.px2
      in
        { model | px2 = p }

    Y1 f ->
      let
        p = f model.py1
      in
        { model | py1 = p }

    Y2 f ->
      let
        p = f model.py1
      in
        { model | py2 = p }

type Action
  = X1 (Params -> Params)
  | X2 (Params -> Params)
  | Y1 (Params -> Params)
  | Y2 (Params -> Params)

view address model =
  div []
    [ fromElement <| collage 1000 1000
      [ trace model
      ]
    , paramControls address model
    ]

paramControls address model =
  div []
    [ Html.text "x1"
    , controlBlock (Signal.forwardTo address X1) model.px1
    , Html.text "x2"
    , controlBlock (Signal.forwardTo address X2) model.px2
    , Html.text "y1"
    , controlBlock (Signal.forwardTo address Y1) model.py1
    , Html.text "y2"
    , controlBlock (Signal.forwardTo address Y2) model.py2
    ]


controlBlock : Signal.Address (Params -> Params) -> Params -> Html
controlBlock address p =
  div []
    [ slider
      { title = "amplitude"
      , min = 0.0
      , max = 1000.0
      , step = 1.0
      , update = \x -> Signal.message address (\p -> { p | amplitude = x })
      } p.amplitude
    , slider
      { title = "phase"
      , min = 0.0
      , max = 10.0
      , step = 0.001
      , update = \x -> Signal.message address (\p -> { p | phase = x })
      } p.phase
    , slider
      { title = "frequency"
      , min = 0.0
      , max = 1.0
      , step = 0.001
      , update = \x -> Signal.message address (\p -> { p | frequency = x })
      } p.frequency
    , slider
      { title = "damp"
      , min = 0.0
      , max = 0.001
      , step = 0.000001
      , update = \x -> Signal.message address (\p -> { p | damp = x })
      } p.damp
    ]

type alias SliderAttributes =
  { title : String
  , min : Float
  , max : Float
  , step : Float
  , update : Float -> Signal.Message
  }


slider : SliderAttributes -> Float -> Html
slider attr v =
  div []
{'fraction_non_alphanumeric': 0.1251745810055866, 'fraction_numerical': 0.04521648044692737, 'mean_word_length': 1.6303948576675849, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, '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': '7413603', 'n_tokens_mistral': 2177, 'n_tokens_neox': 1979, 'n_words': 570}