aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-04-15 23:11:17 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-04-15 23:11:17 +0100
commit9ac5ca2ad326667a182686aa48c4a4da45f4f5ce (patch)
tree5615af954065cfc7bec86653d600878763529c7d
parent7b3aa61462dc5a1135e01beedcbc98efe47ffb13 (diff)
downloadspace-plat-hs-9ac5ca2ad326667a182686aa48c4a4da45f4f5ce.tar.gz
space-plat-hs-9ac5ca2ad326667a182686aa48c4a4da45f4f5ce.zip
Make the solid frame partially transparent
-rw-r--r--src/Game/BitmapFont.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Game/BitmapFont.hs b/src/Game/BitmapFont.hs
index e68ee26..66b9b5d 100644
--- a/src/Game/BitmapFont.hs
+++ b/src/Game/BitmapFont.hs
@@ -6,6 +6,7 @@ import qualified Data.Map as Map
import Data.Maybe (fromMaybe)
import Foreign.C.Types (CInt)
import qualified Game.Utils as U
+import SDL (($=))
import qualified SDL
import Text.JSON
@@ -51,6 +52,11 @@ renderText renderer (BitmapFont (FontDesc w h m) tex) x y text = mapM_ renderOne
-- | Render a string like renderText but with a translucid background.
renderTextSolid :: SDL.Renderer -> BitmapFont -> Int -> Int -> String -> IO ()
renderTextSolid renderer font@(BitmapFont (FontDesc w h _) _) x y text = do
- -- TODO: make the rect transparent
+ oldBlend <- SDL.get $ SDL.rendererDrawBlendMode renderer
+ SDL.rendererDrawBlendMode renderer $= SDL.BlendAlphaBlend
+ oldColor <- SDL.get $ SDL.rendererDrawColor renderer
+ SDL.rendererDrawColor renderer $= SDL.V4 32 32 32 192
_ <- SDL.fillRect renderer (Just (U.rect (x - 5) (y - 5) (length text * w + 10) (h + 10)))
+ SDL.rendererDrawColor renderer $= oldColor
+ SDL.rendererDrawBlendMode renderer $= oldBlend
renderText renderer font x y text