<commit_before>module Main (main) where

import Chess()
import Config
import Data.List
import System.IO (stderr)
import System.Log.Formatter
import System.Log.Handler as H
import System.Log.Handler.Simple
import System.Log.Logger as L
import UI.Colors
import UI.Render
import UI.TextureCache

import Graphics.UI.GLUT

-- | Initializes all the loggers' states to what was defined in the config file.
configLogger :: IO ()
configLogger = do root <- getRootLogger

                  let formatter' = simpleLogFormatter logFormat

                  consoleOutput <- streamHandler stderr logLevel

                  let log' = foldl' (flip ($)) root
                        [ L.setLevel logLevel
                        , setHandlers $ map (flip H.setFormatter formatter')
                              [ consoleOutput ]
                        ]

                  -- Apply the changes to the global logger.
                  saveGlobalLogger log'

                  -- Set up all our custom logger levels.
                  mapM_ (\(logName, prio) -> updateGlobalLogger logName $ L.setLevel prio) customLogLevels

display :: Window -> TextureCache -> DisplayCallback
display w tc = do let rectangle = (rectangleRenderer 10 10 red)
                                    { vAlign = Just (TopAlign $ -10)
                                    , hAlign = Just (LeftAlign 10)
                                    , rotation = pi/4
                                    , rotateAround = (5, 5)
                                    }

                  yellowDot <- textureRenderer tc "yellow-dot.png"

                  updateWindow w $ yellowDot { vAlign = Just (VCenterAlign 0)
                                             , hAlign = Just (HCenterAlign 0)
                                             , children = [rectangle]
                                             }

myInit :: Window -> IO ()
myInit w = do currentWindow $= Just w
              -- select clearing color
              clearColor $= Color4 0 0 0 0

              Size windowWidth windowHeight <- get windowSize

              infoM "Main.myInit" $ "Window dimensions: " ++ show windowWidth ++ "x" ++ show windowHeight

              -- Get some nice-looking graphics goin'!
              mapM_ (\hnt -> hint hnt $= Nicest) [ PointSmooth
                                                , LineSmooth
                                                , PolygonSmooth
                                                ]

              -- initialize viewing values
              matrixMode $= Projection
              loadIdentity
              ortho2D 0 (fromIntegral windowWidth) 0 (fromIntegral windowHeight)

-- Declare initial window size, position, and display mode (single buffer and
-- RGBA). Open window with "hello" in its title bar. Call initialization<commit_msg>Turned on antialiasing and assorted polish.<commit_after>module Main (main) where

import Chess()
import Config
import Data.List
import System.IO (stderr)
import System.Log.Formatter
import System.Log.Handler as H
import System.Log.Handler.Simple
import System.Log.Logger as L
import UI.Colors
import UI.Render
import UI.TextureCache

import Graphics.UI.GLUT

-- | Initializes all the loggers' states to what was defined in the config file.
configLogger :: IO ()
configLogger = do root <- getRootLogger

                  let formatter' = simpleLogFormatter logFormat

                  consoleOutput <- streamHandler stderr logLevel

                  let log' = foldl' (flip ($)) root
                        [ L.setLevel logLevel
                        , setHandlers $ map (flip H.setFormatter formatter')
                              [ consoleOutput ]
                        ]

                  -- Apply the changes to the global logger.
                  saveGlobalLogger log'

                  -- Set up all our custom logger levels.
                  mapM_ (\(logName, prio) -> updateGlobalLogger logName $ L.setLevel prio) customLogLevels

display :: Window -> TextureCache -> DisplayCallback
display w tc = do let rectangle = (rectangleRenderer 10 10 red)
                                    { vAlign = Just (TopAlign $ -10)
                                    , hAlign = Just (LeftAlign 10)
                                    , rotation = pi/4
                                    , rotateAround = (5, 5)
                                    }

                  yellowDot <- textureRenderer tc "yellow-dot.png"

                  updateWindow w $ yellowDot { vAlign = Just (VCenterAlign 0)
                                             , hAlign = Just (HCenterAlign 0)
                                             , children = [rectangle]
                                             }

myInit :: Window -> IO ()
myInit w = do currentWindow $= Just w
              -- select clearing color
              clearColor $= Color4 0 0 0 0

              Size windowWidth windowHeight <- get windowSize

              infoM "Main.myInit" $ "Window dimensions: " ++ show windowWidth ++ "x" ++ show windowHeight

              -- Enable antialiasing, and general graphical nicities.
              lineSmooth $= Enabled
              pointSmooth $= Enabled
              polygonSmooth $= Enabled
              blend $= Enabled
              blendFunc $= (SrcAlpha, OneMinusSrcAlpha)
              lineWidth $= 1.5

              mapM_ (\ty -> hint ty $= Nicest) [ PointSmooth
                                              , LineSmooth
                                              , PolygonSmooth
                                              ]

              -- initialize viewing values
              matrixMode $= Projection
              loadIdentity
              ortho2D 0 (fromIntegral windowWidth) 0 (fromIntegral windowHeight)

-- Declare initial window size, position, and display mode (single buffer and
-- RGBA). Open window with "hello" in its title bar. Call initialization
{'fraction_non_alphanumeric': 0.06763611768684477, 'fraction_numerical': 0.0074399729455529254, 'mean_word_length': 1.3132577238951897, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2425051', 'n_tokens_mistral': 1404, 'n_tokens_neox': 1286, 'n_words': 460}