on master help sign in
Proper image size of a translation

Negative translation moves the image "up" and "left", decreasing the height and width. Vice versa for positive translation.

commit2cfe630a7b81ea5d907b0f4179494a3ef1cc4037 authorBen Boeckel <MathStuf@gmail.com> dateThu 31 Mar 2011, 00:06 (16 years ago) parent4fae8bf
1 file changed+2−2
src/Graphics/Vty/Image.hs+2−2
src/Graphics/Vty/Image.hs+2−2
@@ -202,7 +202,7 @@ image_width HorizJoin { output_width = w } = w
202202image_width VertJoin { output_width = w } = w
203203image_width BGFill { output_width = w } = w
204204image_width EmptyImage = 0
205−image_width ( Translation _v i ) = image_width i
205+image_width ( Translation _v i ) = toEnum $ max 0 $ (fst _v +) $ fromEnum $ image_width i
206206
207207-- | The height of an Image. This is the number of display rows the image will occupy.
208208image_height :: Image -> Word
@@ -211,7 +211,7 @@ image_height HorizJoin { output_height = r } = r
211211image_height VertJoin { output_height = r } = r
212212image_height BGFill { output_height = r } = r
213213image_height EmptyImage = 0
214−image_height ( Translation _v i ) = image_height i
214+image_height ( Translation _v i ) = toEnum $ max 0 $ (snd _v +) $ fromEnum $ image_height i
215215
216216-- | Combines two images side by side.
217217--