@@ -20,6 +20,7 @@ module Graphics.Vty.Image ( Image(..)
20 , empty_image
20 , empty_image
21 , translate
21 , translate
23 -- | The possible display attributes used in constructing an `Image`.
24 -- | The possible display attributes used in constructing an `Image`.
24 , module Graphics.Vty.Attributes
25 , module Graphics.Vty.Attributes
@@ -102,6 +103,8 @@ data Image =
102 | Translation (Int, Int) Image
103 | Translation (Int, Int) Image
103 -- Crop an image to a size
104 -- Crop an image to a size
104 | ImageCrop (Int, Int) Image
105 | ImageCrop (Int, Int) Image
106+ -- Pad an image up to a size
107+ | ImagePad (Int, Int) Image
105 deriving Eq
108 deriving Eq
107instance Show Image where
110instance Show Image where
@@ -117,6 +120,8 @@ instance Show Image where
117 = "Translation ( " ++ show offset ++ ", " ++ show i ++ " )"
120 = "Translation ( " ++ show offset ++ ", " ++ show i ++ " )"
118 show ( ImageCrop size i )
121 show ( ImageCrop size i )
119 = "ImageCrop " ++ show size ++ " ( " ++ show i ++ " )"
122 = "ImageCrop " ++ show size ++ " ( " ++ show i ++ " )"
123+ show ( ImagePad size i )
124+ = "ImagePad " ++ show size ++ " ( " ++ show i ++ " )"
120 show ( EmptyImage ) = "EmptyImage"
125 show ( EmptyImage ) = "EmptyImage"
122-- | Currently append in the Monoid instance is equivalent to <->. Future versions will just stack
127-- | 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
209image_width EmptyImage = 0
214image_width EmptyImage = 0
210image_width ( Translation _v i ) = image_width i
215image_width ( Translation _v i ) = image_width i
211image_width ( ImageCrop _v i ) = min (image_width i) (toEnum $ fst _v)
216image_width ( ImageCrop _v i ) = min (image_width i) (toEnum $ fst _v)
217+image_width ( ImagePad _v i ) = max (image_width i) (toEnum $ fst _v)
213-- | The height of an Image. This is the number of display rows the image will occupy.
219-- | The height of an Image. This is the number of display rows the image will occupy.
214image_height :: Image -> Word
220image_height :: Image -> Word
@@ -219,6 +225,7 @@ image_height BGFill { output_height = r } = r
219image_height EmptyImage = 0
225image_height EmptyImage = 0
220image_height ( Translation _v i ) = image_height i
226image_height ( Translation _v i ) = image_height i
221image_height ( ImageCrop _v i ) = min (image_height i) (toEnum $ snd _v)
227image_height ( ImageCrop _v i ) = min (image_height i) (toEnum $ snd _v)
228+image_height ( ImagePad _v i ) = max (image_height i) (toEnum $ snd _v)
223-- | Combines two images side by side.
230-- | Combines two images side by side.
@@ -338,3 +345,5 @@ translate v i = Translation v i
338crop :: (Int, Int) -> Image -> Image
345crop :: (Int, Int) -> Image -> Image
339crop v i = ImageCrop v i
346crop v i = ImageCrop v i
348+pad :: (Int, Int) -> Image -> Image