@@ -20,6 +20,7 @@ module Graphics.Vty.Image ( Image(..)
2020 , empty_image
2121 , translate
2222 , crop
23+ , pad
2324 -- | The possible display attributes used in constructing an `Image`.
2425 , module Graphics.Vty.Attributes
2526 )
@@ -102,6 +103,8 @@ data Image =
102103 | Translation (Int, Int) Image
103104 -- Crop an image to a size
104105 | ImageCrop (Int, Int) Image
106+ -- Pad an image up to a size
107+ | ImagePad (Int, Int) Image
105108 deriving Eq
106109
107110instance Show Image where
@@ -117,6 +120,8 @@ instance Show Image where
117120 = "Translation ( " ++ show offset ++ ", " ++ show i ++ " )"
118121 show ( ImageCrop size i )
119122 = "ImageCrop " ++ show size ++ " ( " ++ show i ++ " )"
123+ show ( ImagePad size i )
124+ = "ImagePad " ++ show size ++ " ( " ++ show i ++ " )"
120125 show ( EmptyImage ) = "EmptyImage"
121126
122127-- | Currently append in the Monoid instance is equivalent to <->. Future versions will just stack
@@ -209,6 +214,7 @@ image_width BGFill { output_width = w } = w
209214image_width EmptyImage = 0
210215image_width ( Translation _v i ) = image_width i
211216image_width ( ImageCrop _v i ) = min (image_width i) (toEnum $ fst _v)
217+image_width ( ImagePad _v i ) = max (image_width i) (toEnum $ fst _v)
212218
213219-- | The height of an Image. This is the number of display rows the image will occupy.
214220image_height :: Image -> Word
@@ -219,6 +225,7 @@ image_height BGFill { output_height = r } = r
219225image_height EmptyImage = 0
220226image_height ( Translation _v i ) = image_height i
221227image_height ( ImageCrop _v i ) = min (image_height i) (toEnum $ snd _v)
228+image_height ( ImagePad _v i ) = max (image_height i) (toEnum $ snd _v)
222229
223230-- | Combines two images side by side.
224231--
@@ -338,3 +345,5 @@ translate v i = Translation v i
338345crop :: (Int, Int) -> Image -> Image
339346crop v i = ImageCrop v i
340347
348+pad :: (Int, Int) -> Image -> Image
349+pad = ImagePad v i