<commit_before>module Scorched.View.Widget.BorderBox where

import List

import Graphics.Element (color, size, empty)
import Graphics.Collage (..)

import Scorched.Model.World (Dimension)
import Scorched.Model.Window (transformCoordinates)

import Scorched.View.Palette (..)

build : Dimension -> Bool -> Form
build {width, height} invert = group
  [ backdrop width height
  , border (toFloat width) (toFloat height) invert
  ]

backdrop : Int -> Int -> Form
backdrop width height = toForm (color background (size width height empty))

border : Float -> Float -> Bool -> Form
border width height invert =
  (group >> (transformCoordinates width -height))
    (highlights width height invert)

highlights : Float -> Float -> Bool -> List Form
highlights width height invert =
  if invert then invertedLines width height else lines width height

lines : Float -> Float -> List Form
lines width height =
  [ filled shadowDark (leftLine width height)
  , filled highlightLight (rightLine width height)

  , filled shadowLight (bottomLine width height)
  , filled highlightDark (topLine width height)
  ]

invertedLines : Float -> Float -> List Form
invertedLines width height =
  [ filled shadowDark (rightLine width height)
  , filled highlightLight (leftLine width height)

  , filled shadowLight (topLine width height)
  , filled highlightDark (bottomLine width height)
  ]

leftLine : Float -> Float -> Shape
leftLine width height =
  polygon [(width - 3.0, 0.0), (width, 0.0), (width, height), ((width - 3.0), height)]

rightLine : Float -> Float -> Shape
rightLine width height =
  polygon [(0.0, 0.0), (2.0, 0.0), (2.0, height), (0.0, height)]

bottomLine : Float -> Float -> Shape
bottomLine width height =
  polygon [(0.0, 0.0), (2.0, 2.0), (width - 3.0, 2.0), (width, 0.0)]

topLine : Float -> Float -> Shape
topLine width height =
  polygon [(0.0, height - 1.0), (2.0, height - 3.0), (width - 3.0, height - 3.0), (width, height)]<commit_msg>remove translation on border box<commit_after>module Scorched.View.Widget.BorderBox where

import List

import Graphics.Element (color, size, empty)
import Graphics.Collage (..)

import Scorched.Model.World (Dimension)

import Scorched.View.Palette (..)

build : Dimension -> Bool -> Form
build {width, height} invert = group
  [ backdrop width height
  , border (toFloat width) (toFloat height) invert
  ]

backdrop : Int -> Int -> Form
backdrop width height = toForm (color background (size width height empty))

border : Float -> Float -> Bool -> Form
border width height invert =
  group (highlights width height invert)

highlights : Float -> Float -> Bool -> List Form
highlights width height invert =
  let
    halfWidth = width / 2
    halfHeight = height /2
  in
    if invert then invertedLines halfWidth halfHeight else lines halfWidth halfHeight

lines : Float -> Float -> List Form
lines x y =
  [ filled shadowDark (rightLine x y)
  , filled highlightLight (leftLine x y)

  , filled shadowLight (bottomLine x y)
  , filled highlightDark (topLine x y)
  ]

invertedLines : Float -> Float -> List Form
invertedLines x y =
  [ filled shadowDark (leftLine x y)
  , filled highlightLight (rightLine x y)

  , filled shadowLight (topLine x y)
  , filled highlightDark (bottomLine x y)
  ]

leftLine : Float -> Float -> Shape
leftLine x y =
  polygon
    [ (-x, -y)
    , (-x + 2.0, -y)
    , (-x + 2.0, y)
    , (-x, y)
    ]

rightLine : Float -> Float -> Shape
rightLine x y =
  polygon
    [ (x - 3.0, -y)
    , (x, -y)
    , (x, y)
    , ((x - 3.0), y)
    ]

topLine : Float -> Float -> Shape
topLine x y =
  polygon
    [ (-x, y)
    , (-x + 2.0, y - 3.0)
    , (x - 3.0, y - 3.0)
    , (x, y)]

bottomLine : Float -> Float -> Shape
bottomLine x y =
  polygon
    [ (-x, -y)
    , (-x + 2.0, -y + 3.0)
    , (x - 3.0, -y + 3.0)
    , (x, -y)
    ]
{'fraction_non_alphanumeric': 0.1283464566929134, 'fraction_numerical': 0.01889763779527559, 'mean_word_length': 3.0585729499467518, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 49, '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': '5430087', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1231, 'n_words': 442}