Partial inventory display update

This commit is contained in:
2023-01-27 22:47:45 +00:00
parent ce25157738
commit 5f7d662454
6 changed files with 179 additions and 16 deletions
+29
View File
@@ -0,0 +1,29 @@
module Picture.Text where
import Geometry.Data
import Picture.Data
import Color
textGrad :: Color -> Color -> String -> Picture
{-# INLINE textGrad #-}
textGrad topc botc = map f . stringToListGrad topc botc
where
f (pos, col, V2 a b) = Verx pos col [a, b] BottomLayer textNum
-- no premature optimisation, consider changing to use texture arrays
stringToListGrad :: Color -> Color -> String -> [(Point3, Point4, Point2)]
{-# INLINE stringToListGrad #-}
stringToListGrad topc botc = concatMap (uncurry (charToTupleGrad topc botc)) . zip [0, 0.9 * dimText ..]
where
dimText = 100
charToTupleGrad :: Color -> Color -> Float -> Char -> [(Point3, Point4, Point2)]
{-# INLINE charToTupleGrad #-}
charToTupleGrad topc botc x c =
[ (V3 (x -50) (-100) 0, botc, V2 offset 1)
, (V3 (x -50) 100 0, topc, V2 offset 0)
, (V3 (x + 50) 100 0, topc, V2 (offset + 1) 0)
, (V3 (x -50) (-100) 0, botc, V2 offset 1)
, (V3 (x + 50) (-100) 0, botc, V2 (offset + 1) 1)
, (V3 (x + 50) 100 0, topc, V2 (offset + 1) 0)
]
where
offset = fromIntegral (fromEnum c) - 32