@@ -102,9 +102,9 @@ data Image =
102 | EmptyImage
102 | EmptyImage
103 | Translation (Int, Int) Image
103 | Translation (Int, Int) Image
104 -- Crop an image to a size
104 -- Crop an image to a size
105− | ImageCrop (Int, Int) Image
105+ | ImageCrop (Word, Word) Image
106 -- Pad an image up to a size
106 -- Pad an image up to a size
107− | ImagePad (Int, Int) Image
107+ | ImagePad (Word, Word) Image
108 deriving Eq
108 deriving Eq
110instance Show Image where
110instance Show Image where
@@ -213,8 +213,8 @@ image_width VertJoin { output_width = w } = w
213image_width BGFill { output_width = w } = w
213image_width BGFill { output_width = w } = w
214image_width EmptyImage = 0
214image_width EmptyImage = 0
215image_width ( Translation _v i ) = image_width i
215image_width ( Translation _v i ) = image_width i
216−image_width ( ImageCrop _v i ) = min (image_width i) (toEnum $ fst _v)
216+image_width ( ImageCrop _v i ) = min (image_width i) $ fst _v
217−image_width ( ImagePad _v i ) = max (image_width i) (toEnum $ fst _v)
217+image_width ( ImagePad _v i ) = max (image_width i) $ fst _v
219-- | 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.
220image_height :: Image -> Word
220image_height :: Image -> Word
@@ -224,8 +224,8 @@ image_height VertJoin { output_height = r } = r
224image_height BGFill { output_height = r } = r
224image_height BGFill { output_height = r } = r
225image_height EmptyImage = 0
225image_height EmptyImage = 0
226image_height ( Translation _v i ) = image_height i
226image_height ( Translation _v i ) = image_height i
227−image_height ( ImageCrop _v i ) = min (image_height i) (toEnum $ snd _v)
227+image_height ( ImageCrop _v i ) = min (image_height i) $ snd _v
228−image_height ( ImagePad _v i ) = max (image_height i) (toEnum $ snd _v)
228+image_height ( ImagePad _v i ) = max (image_height i) $ snd _v
230-- | Combines two images side by side.
230-- | Combines two images side by side.
@@ -342,8 +342,14 @@ empty_image = EmptyImage
342translate :: (Int, Int) -> Image -> Image
342translate :: (Int, Int) -> Image -> Image
343translate v i = Translation v i
343translate v i = Translation v i
345−crop :: (Int, Int) -> Image -> Image
345+crop :: (Word, Word) -> Image -> Image
346−crop v i = ImageCrop v i
346+crop v@(w,h) i
347+ | w == 0 = EmptyImage
348+ | h == 0 = EmptyImage
349+ | otherwise = ImagePad v i
348−pad :: (Int, Int) -> Image -> Image
351+pad :: (Word, Word) -> Image -> Image
353+ | w == 0 = EmptyImage
354+ | h == 0 = EmptyImage
349−pad = ImagePad v i
355+ | otherwise = ImagePad v i