Refactor window size, update selection cursor on new screen

This commit is contained in:
2023-03-25 09:27:27 +00:00
parent 20c05be23f
commit ea0c942887
57 changed files with 346 additions and 310 deletions
+12 -7
View File
@@ -25,6 +25,7 @@ module Picture.Base (
line,
lineCol,
text,
drawText,
centerText,
stackText,
pictures,
@@ -200,10 +201,14 @@ stackText = mconcat . zipWith (\y s -> translate 0 y $ centerText s) [0, 100 ..]
text :: String -> Picture
{-# INLINE text #-}
text = map f . stringToList
text = translate (-50) (-100) . drawText (-10)
drawText :: Float -> String -> [Verx]
drawText gap = map f . stringToList gap
where
f (pos, col, V3 a b c) = Verx pos col [a, b, c, 1] BottomLayer textNum
line :: [Point2] -> Picture
{-# INLINE line #-}
line = thickLine 1
@@ -291,18 +296,18 @@ overCol :: (Point4 -> Point4) -> Verx -> Verx
overCol f vx = vx{_vxCol = f (_vxCol vx)}
-- no premature optimisation, consider changing to use texture arrays
stringToList :: String -> [(Point3, Point4, Point3)]
stringToList :: Float -> String -> [(Point3, Point4, Point3)]
{-# INLINE stringToList #-}
stringToList = concatMap (uncurry charToTuple) . zip [0, 0.9 * dimText ..]
where
dimText = 100
stringToList gap = concatMap (uncurry charToTuple) . zip [0, 100 + gap ..]
charToTuple :: Float -> Char -> [(Point3, Point4, Point3)]
{-# INLINE charToTuple #-}
charToTuple xoff c = [f 0 0, f 1 0, f 1 1, f 0 0, f 1 1, f 0 1]
where
f x y = (V3 (xoff - 50 + x * 100) (100 - y * 200) 0, white, V3 x y offset)
offset = fromIntegral (fromEnum c) - 32
f x y = (V3 (xoff + x * 100) (y * 200) 0, white, V3 x (1 - y) charnum)
-- textures in opengl have origins at the lower left, my char array has its
-- origin at the upper left
charnum = fromIntegral (fromEnum c) - 32
--charToTuple' :: Float -> Char -> [(Point3, Point4, Point3)]
--{-# INLINE charToTuple' #-}