Cleanup rendering

This commit is contained in:
2023-05-10 21:26:17 +01:00
parent 5f238a65d0
commit 6081f90f90
3 changed files with 28 additions and 67 deletions
+22 -7
View File
@@ -25,7 +25,10 @@ module Picture.Base (
line,
lineCol,
text,
textRight,
textJustifyLeft,
textJustifyRight,
textJustifyCenter,
textVMirror,
drawText,
centerText,
@@ -90,7 +93,6 @@ poly3Col = map f . polyToTris
where
f (pos, col) = Verx pos col [] BottomLayer polyNum
---- given a one and two zeros of a linear function over x and y,
---- determine the function
---- so if f(ox,oy) = 1 and f(ax,ay) = f(bx,by) = 0, determines f
@@ -201,15 +203,28 @@ stackText :: [String] -> Picture
{-# INLINE stackText #-}
stackText = mconcat . zipWith (\y s -> translate 0 y $ centerText s) [0, 100 ..]
textJustifyRight :: String -> Picture
{-# INLINE textJustifyRight #-}
textJustifyRight str = translate ((-100) * fromIntegral (length str)) 0 $ text str
text :: String -> Picture
{-# INLINE text #-}
--text = translate (-50) (-100) . drawText (-10)
text = drawText 0
--text = drawText (-10)
-- lines up the rightmost part of the last character with 0
textJustifyRight :: String -> Picture
{-# INLINE textJustifyRight #-}
textJustifyRight str = translate (12.5 + (-100) * fromIntegral (length str)) 0 $ text str
-- translate the text so its bottom right coordinate is at (0,0)
textRight :: String -> Picture
{-# INLINE textRight #-}
textRight str = translate ((-100) * fromIntegral (length str)) 0 $ text str
-- lines up the leftmost part of the first character with 0
textJustifyLeft :: String -> Picture
{-# INLINE textJustifyLeft #-}
textJustifyLeft = translate (-12.5) 0 . text
textJustifyCenter :: String -> Picture
{-# INLINE textJustifyCenter #-}
textJustifyCenter str = translate ((-50) * fromIntegral (length str)) 0 $ text str
textVMirror :: String -> Picture
{-# INLINE textVMirror #-}