From 4cde742b99fe000cf0bb7b0a0f28900a40ce140f Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Thu, 17 Dec 2015 23:05:18 -0500 Subject: non-semantic HLint fixes --- axis.hs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/axis.hs b/axis.hs index bd57573..711fb9c 100644 --- a/axis.hs +++ b/axis.hs @@ -249,7 +249,7 @@ main = -- pixelFormat or the faked one, so fuck it. See colorToPixel let pixelFormat = -- SDL.surfaceGetPixelFormat videoSurface pixelFormat <- SDL.surfaceGetPixelFormat <$> -- SDL.createRGBSurfaceEndian [] 1 1 24 - void $ shutUp + void shutUp putStrLn "Initialized." (_, ()) <- execRWST mainLoop @@ -258,8 +258,8 @@ main = return () setFont :: (MonadIO m, MonadState LoopState m) => (Int, Int) -> m () -setFont resolution' = do - let (w, h) = resolution' +setFont resolution = do + let (w, h) = resolution fontSize = chooseFontSize w h font' <- liftIO $ SDL.TTF.openFont "LiberationMono-Bold.ttf" fontSize modify $ \s -> s { _sdlFont = font' } @@ -321,10 +321,11 @@ mainLoop = do chanPitches = Map.fromListWith (++) $ map (\(c, p) -> (c, [p])) $ Set.toList nowKeys when (midiKeysDown' /= midiKeysDown) $ do - -- let chord = showChord midiKeysDown' - -- let chord = show $ pitchList midiKeysDown' - -- let chord = show $ map (\i->elemIndices i pitchIndex) $ pitchList midiKeysDown' - -- textBand videoSurface videoClipRect (SDL.Rect 0 70 0 70) font chord + when False $ do + let chord = showChord midiKeysDown' + let chord = show $ pitchList midiKeysDown' + let chord = show $ map (`elemIndices` pitchIndex colsRepeat) $ pitchList midiKeysDown' + liftIO $ textBand videoSurface videoClipRect (SDL.Rect 0 70 0 70) font chord liftIO $ smartDrawKeys colsRepeat False midiKeysDown midiKeysDown' videoSurface font axis_key_locations axis_key_size when restartVideo $ do @@ -366,9 +367,7 @@ drawFilledHexagonSDL = _drawHexagonSDL True _drawHexagonSDL :: Integral a => Bool -> SDL.Surface -> Int16 -> Int16 -> a -> SDL.Pixel -> IO Bool _drawHexagonSDL filled videoSurface centerx centery radius pixel = do let r = fromIntegral radius - let points = map (\(x, y) -> (centerx + x, centery + y)) $ - map (\(x, y) -> (round x, round y)) $ - map (\i -> (r * cos(pi/3 * (i)), r * sin(pi/3 * (i)))) [0 .. 5] + let points = map ((((+) centerx *** (+) centery) . (round *** round)) . (\i -> (r * cos(pi/3 * i), r * sin(pi/3 * i)))) [0 .. 5] (if not filled then SDL.Primitive.polygon else SDL.Primitive.filledPolygon) videoSurface points pixel centerText :: (Integral a, Integral a1) => SDL.Surface -> a -> a1 -> SDL.TTF.Font -> SDL.Color -> t -> String -> IO () @@ -378,7 +377,7 @@ centerText videoSurface x y font fgColor bgColor text = do fontSurface <- SDL.TTF.renderUTF8Blended font text fgColor fontClipRect <- SDL.getClipRect fontSurface let (SDL.Rect _ _ w h) = fontClipRect - _ <- SDL.blitSurface fontSurface (Just fontClipRect) videoSurface (Just (SDL.Rect (fromIntegral(x) - w `div` 2) (fromIntegral(y) - h `div` 2) w h)) + _ <- SDL.blitSurface fontSurface (Just fontClipRect) videoSurface (Just (SDL.Rect (fromIntegral x - w `div` 2) (fromIntegral y - h `div` 2) w h)) return () pitchIndex :: (Enum b, Num b) => b -> [Word8] @@ -444,7 +443,7 @@ getKeyLocationsAbs colsRepeat = (kh, kw, xys) -- clear a band the width of the videoClipRect and print the text within it, centered -textBand :: SDL.Surface -> SDL.Rect -> SDL.Rect -> SDL.TTF.Font -> [Char] -> IO () +textBand :: SDL.Surface -> SDL.Rect -> SDL.Rect -> SDL.TTF.Font -> String -> IO () textBand videoSurface videoClipRect (SDL.Rect _ y _ h) font text = do let (SDL.Rect vx _ vw _) = videoClipRect _ <- SDL.fillRect videoSurface (Just (SDL.Rect 0 y vw h)) (SDL.Pixel 0) -- cgit v1.2.3