summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2015-12-17 23:05:18 -0500
committerAndrew Cady <d@jerkface.net>2015-12-17 23:05:18 -0500
commit4cde742b99fe000cf0bb7b0a0f28900a40ce140f (patch)
tree1a1702a0d3b659d6c42b9ca8db2d14af80a2fe0a
parent11bc93662f77a13f4842066fcf40f83b3d3e2ece (diff)
non-semantic HLint fixes
-rw-r--r--axis.hs23
1 files 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 =
249 -- pixelFormat or the faked one, so fuck it. See colorToPixel let pixelFormat = 249 -- pixelFormat or the faked one, so fuck it. See colorToPixel let pixelFormat =
250 -- SDL.surfaceGetPixelFormat videoSurface pixelFormat <- SDL.surfaceGetPixelFormat <$> 250 -- SDL.surfaceGetPixelFormat videoSurface pixelFormat <- SDL.surfaceGetPixelFormat <$>
251 -- SDL.createRGBSurfaceEndian [] 1 1 24 251 -- SDL.createRGBSurfaceEndian [] 1 1 24
252 void $ shutUp 252 void shutUp
253 putStrLn "Initialized." 253 putStrLn "Initialized."
254 254
255 (_, ()) <- execRWST mainLoop 255 (_, ()) <- execRWST mainLoop
@@ -258,8 +258,8 @@ main =
258 return () 258 return ()
259 259
260setFont :: (MonadIO m, MonadState LoopState m) => (Int, Int) -> m () 260setFont :: (MonadIO m, MonadState LoopState m) => (Int, Int) -> m ()
261setFont resolution' = do 261setFont resolution = do
262 let (w, h) = resolution' 262 let (w, h) = resolution
263 fontSize = chooseFontSize w h 263 fontSize = chooseFontSize w h
264 font' <- liftIO $ SDL.TTF.openFont "LiberationMono-Bold.ttf" fontSize 264 font' <- liftIO $ SDL.TTF.openFont "LiberationMono-Bold.ttf" fontSize
265 modify $ \s -> s { _sdlFont = font' } 265 modify $ \s -> s { _sdlFont = font' }
@@ -321,10 +321,11 @@ mainLoop = do
321 chanPitches = Map.fromListWith (++) $ map (\(c, p) -> (c, [p])) $ Set.toList nowKeys 321 chanPitches = Map.fromListWith (++) $ map (\(c, p) -> (c, [p])) $ Set.toList nowKeys
322 322
323 when (midiKeysDown' /= midiKeysDown) $ do 323 when (midiKeysDown' /= midiKeysDown) $ do
324 -- let chord = showChord midiKeysDown' 324 when False $ do
325 -- let chord = show $ pitchList midiKeysDown' 325 let chord = showChord midiKeysDown'
326 -- let chord = show $ map (\i->elemIndices i pitchIndex) $ pitchList midiKeysDown' 326 let chord = show $ pitchList midiKeysDown'
327 -- textBand videoSurface videoClipRect (SDL.Rect 0 70 0 70) font chord 327 let chord = show $ map (`elemIndices` pitchIndex colsRepeat) $ pitchList midiKeysDown'
328 liftIO $ textBand videoSurface videoClipRect (SDL.Rect 0 70 0 70) font chord
328 liftIO $ smartDrawKeys colsRepeat False midiKeysDown midiKeysDown' videoSurface font axis_key_locations axis_key_size 329 liftIO $ smartDrawKeys colsRepeat False midiKeysDown midiKeysDown' videoSurface font axis_key_locations axis_key_size
329 330
330 when restartVideo $ do 331 when restartVideo $ do
@@ -366,9 +367,7 @@ drawFilledHexagonSDL = _drawHexagonSDL True
366_drawHexagonSDL :: Integral a => Bool -> SDL.Surface -> Int16 -> Int16 -> a -> SDL.Pixel -> IO Bool 367_drawHexagonSDL :: Integral a => Bool -> SDL.Surface -> Int16 -> Int16 -> a -> SDL.Pixel -> IO Bool
367_drawHexagonSDL filled videoSurface centerx centery radius pixel = do 368_drawHexagonSDL filled videoSurface centerx centery radius pixel = do
368 let r = fromIntegral radius 369 let r = fromIntegral radius
369 let points = map (\(x, y) -> (centerx + x, centery + y)) $ 370 let points = map ((((+) centerx *** (+) centery) . (round *** round)) . (\i -> (r * cos(pi/3 * i), r * sin(pi/3 * i)))) [0 .. 5]
370 map (\(x, y) -> (round x, round y)) $
371 map (\i -> (r * cos(pi/3 * (i)), r * sin(pi/3 * (i)))) [0 .. 5]
372 (if not filled then SDL.Primitive.polygon else SDL.Primitive.filledPolygon) videoSurface points pixel 371 (if not filled then SDL.Primitive.polygon else SDL.Primitive.filledPolygon) videoSurface points pixel
373 372
374centerText :: (Integral a, Integral a1) => SDL.Surface -> a -> a1 -> SDL.TTF.Font -> SDL.Color -> t -> String -> IO () 373centerText :: (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
378 fontSurface <- SDL.TTF.renderUTF8Blended font text fgColor 377 fontSurface <- SDL.TTF.renderUTF8Blended font text fgColor
379 fontClipRect <- SDL.getClipRect fontSurface 378 fontClipRect <- SDL.getClipRect fontSurface
380 let (SDL.Rect _ _ w h) = fontClipRect 379 let (SDL.Rect _ _ w h) = fontClipRect
381 _ <- SDL.blitSurface fontSurface (Just fontClipRect) videoSurface (Just (SDL.Rect (fromIntegral(x) - w `div` 2) (fromIntegral(y) - h `div` 2) w h)) 380 _ <- SDL.blitSurface fontSurface (Just fontClipRect) videoSurface (Just (SDL.Rect (fromIntegral x - w `div` 2) (fromIntegral y - h `div` 2) w h))
382 return () 381 return ()
383 382
384pitchIndex :: (Enum b, Num b) => b -> [Word8] 383pitchIndex :: (Enum b, Num b) => b -> [Word8]
@@ -444,7 +443,7 @@ getKeyLocationsAbs colsRepeat =
444 (kh, kw, xys) 443 (kh, kw, xys)
445 444
446-- clear a band the width of the videoClipRect and print the text within it, centered 445-- clear a band the width of the videoClipRect and print the text within it, centered
447textBand :: SDL.Surface -> SDL.Rect -> SDL.Rect -> SDL.TTF.Font -> [Char] -> IO () 446textBand :: SDL.Surface -> SDL.Rect -> SDL.Rect -> SDL.TTF.Font -> String -> IO ()
448textBand videoSurface videoClipRect (SDL.Rect _ y _ h) font text = do 447textBand videoSurface videoClipRect (SDL.Rect _ y _ h) font text = do
449 let (SDL.Rect vx _ vw _) = videoClipRect 448 let (SDL.Rect vx _ vw _) = videoClipRect
450 _ <- SDL.fillRect videoSurface (Just (SDL.Rect 0 y vw h)) (SDL.Pixel 0) 449 _ <- SDL.fillRect videoSurface (Just (SDL.Rect 0 y vw h)) (SDL.Pixel 0)