@@ -216,9 +216,9 @@ image_width HorizJoin { output_width = w } = w
216image_width VertJoin { output_width = w } = w
216image_width VertJoin { output_width = w } = w
217image_width BGFill { output_width = w } = w
217image_width BGFill { output_width = w } = w
218image_width EmptyImage = 0
218image_width EmptyImage = 0
219−image_width ( Translation _v i ) = toEnum $ max 0 $ (fst _v +) $ fromEnum $ image_width i
219+image_width ( Translation v i ) = toEnum $ max 0 $ (fst v +) $ fromEnum $ image_width i
220−image_width ( ImageCrop _v i ) = min (image_width i) $ fst _v
220+image_width ( ImageCrop v i ) = min (image_width i) $ fst v
221−image_width ( ImagePad _v i ) = max (image_width i) $ fst _v
221+image_width ( ImagePad v i ) = max (image_width i) $ fst v
223-- | The height of an Image. This is the number of display rows the image will occupy.
223-- | The height of an Image. This is the number of display rows the image will occupy.
224image_height :: Image -> Word
224image_height :: Image -> Word
@@ -227,9 +227,9 @@ image_height HorizJoin { output_height = r } = r
227image_height VertJoin { output_height = r } = r
227image_height VertJoin { output_height = r } = r
228image_height BGFill { output_height = r } = r
228image_height BGFill { output_height = r } = r
229image_height EmptyImage = 0
229image_height EmptyImage = 0
230−image_height ( Translation _v i ) = toEnum $ max 0 $ (snd _v +) $ fromEnum $ image_height i
230+image_height ( Translation v i ) = toEnum $ max 0 $ (snd v +) $ fromEnum $ image_height i
231−image_height ( ImageCrop _v i ) = min (image_height i) $ snd _v
231+image_height ( ImageCrop v i ) = min (image_height i) $ snd v
232−image_height ( ImagePad _v i ) = max (image_height i) $ snd _v
232+image_height ( ImagePad v i ) = max (image_height i) $ snd v
234-- | Combines two images side by side.
234-- | Combines two images side by side.
@@ -343,9 +343,11 @@ char_fill !a !c w h =
343empty_image :: Image
343empty_image :: Image
344empty_image = EmptyImage
344empty_image = EmptyImage
346+-- | Apply the given offset to the image.
346translate :: (Int, Int) -> Image -> Image
347translate :: (Int, Int) -> Image -> Image
347translate v i = Translation v i
348translate v i = Translation v i
350+-- | Ensure an image is no larger than the provided size. If the image is larger then crop.
349crop :: (Word, Word) -> Image -> Image
351crop :: (Word, Word) -> Image -> Image
350crop (0,_) _ = EmptyImage
352crop (0,_) _ = EmptyImage
351crop (_,0) _ = EmptyImage
353crop (_,0) _ = EmptyImage
@@ -353,8 +355,10 @@ crop v (ImageCrop _size i) = ImagePad (min (fst v) (fst _size), min (snd v) (snd
353crop v (ImagePad _size i) = ImagePad (min (fst v) (fst _size), min (snd v) (snd _size)) i
355crop v (ImagePad _size i) = ImagePad (min (fst v) (fst _size), min (snd v) (snd _size)) i
354crop v i = ImagePad v i
356crop v i = ImagePad v i
358+-- | Ensure an image is at least the provided size. If the image is smaler then pad.
356pad :: (Word, Word) -> Image -> Image
359pad :: (Word, Word) -> Image -> Image
357pad (0,_) _ = EmptyImage
360pad (0,_) _ = EmptyImage
358pad (_,0) _ = EmptyImage
361pad (_,0) _ = EmptyImage
359pad v (ImagePad _size i) = ImagePad (max (fst v) (fst _size), max (snd v) (snd _size)) i
362pad v (ImagePad _size i) = ImagePad (max (fst v) (fst _size), max (snd v) (snd _size)) i
360pad v i = ImagePad v i
363pad v i = ImagePad v i