diff options
Diffstat (limited to 'src/Chelleport/Draw.hs')
| -rw-r--r-- | src/Chelleport/Draw.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Chelleport/Draw.hs b/src/Chelleport/Draw.hs index 3f67848..3720ba0 100644 --- a/src/Chelleport/Draw.hs +++ b/src/Chelleport/Draw.hs @@ -14,6 +14,7 @@ class (Monad m) => MonadDraw m where drawLine :: (CInt, CInt) -> (CInt, CInt) -> m () drawText :: (CInt, CInt) -> Color -> Text -> m (CInt, CInt) drawCircle :: Int -> (CInt, CInt) -> m () + fillRect :: (CInt, CInt) -> (CInt, CInt) -> m () setDrawColor :: Color -> m () windowSize :: m (CInt, CInt) windowPosition :: m (CInt, CInt) @@ -27,6 +28,11 @@ instance (MonadIO m) => MonadDraw (AppM m) where renderer <- asks ctxRenderer SDL.rendererDrawColor renderer $= color + fillRect (x, y) (w, h) = do + renderer <- asks ctxRenderer + let rect = SDL.Rectangle (SDL.P $ SDL.V2 x y) (SDL.V2 w h) + SDL.fillRect renderer (Just rect) + drawText (x, y) color text = do DrawContext {ctxRenderer = renderer, ctxFont = font} <- ask surface <- TTF.blended font color text @@ -65,6 +71,9 @@ instance (MonadIO m) => MonadDraw (AppM m) where SDL.V2 x y <- asks ctxWindow >>= SDL.getWindowAbsolutePosition pure (x, y) +fillRectVertices :: (MonadDraw m) => (CInt, CInt) -> (CInt, CInt) -> m () +fillRectVertices (x1, y1) (x2, y2) = fillRect (x1, y1) (x2 - x1, y2 - y1) + cellSize :: (MonadDraw m) => State -> m (CInt, CInt) cellSize (State {stateGrid}) = do (width, height) <- windowSize |
