@@ -37,6 +37,8 @@ import Codec.Binary.UTF8.Width
38import Codec.Binary.UTF8.String ( decode )
38import Codec.Binary.UTF8.String ( decode )
40+import Control.DeepSeq
40import qualified Data.ByteString as BS
42import qualified Data.ByteString as BS
41import Data.Monoid
43import Data.Monoid
42import qualified Data.Sequence as Seq
44import qualified Data.Sequence as Seq
@@ -69,7 +71,7 @@ type DisplayString = Seq.Seq (Char, Word)
70-- todo: increase the number of encoded bytestring formats supported.
72-- todo: increase the number of encoded bytestring formats supported.
71data Image =
73data Image =
72− -- A horizontal text span is always >= 1 column and has a row height of 1.
74+ -- | A horizontal text span is always >= 1 column and has a row height of 1.
74 { attr :: !Attr
76 { attr :: !Attr
75 -- All character data is stored as Char sequences with the ISO-10646 encoding.
77 -- All character data is stored as Char sequences with the ISO-10646 encoding.
@@ -77,7 +79,7 @@ data Image =
77 , output_width :: !Word -- >= 0
79 , output_width :: !Word -- >= 0
78 , char_width :: !Word -- >= 1
80 , char_width :: !Word -- >= 1
80− -- A horizontal join can be constructed between any two images. However a HorizJoin instance is
82+ -- | A horizontal join can be constructed between any two images. However a HorizJoin instance is
81 -- required to be between two images of equal height. The horiz_join constructor adds background
83 -- required to be between two images of equal height. The horiz_join constructor adds background
82 -- filles to the provided images that assure this is true for the HorizJoin value produced.
84 -- filles to the provided images that assure this is true for the HorizJoin value produced.
83 | HorizJoin
85 | HorizJoin
@@ -86,7 +88,7 @@ data Image =
86 , output_width :: !Word -- >= 1
88 , output_width :: !Word -- >= 1
87 , output_height :: !Word -- >= 1
89 , output_height :: !Word -- >= 1
89− -- A veritical join can be constructed between any two images. However a VertJoin instance is
91+ -- | A veritical join can be constructed between any two images. However a VertJoin instance is
90 -- required to be between two images of equal width. The vert_join constructor adds background
92 -- required to be between two images of equal width. The vert_join constructor adds background
91 -- fills to the provides images that assure this is true for the VertJoin value produced.
93 -- fills to the provides images that assure this is true for the VertJoin value produced.
92 | VertJoin
94 | VertJoin
@@ -95,13 +97,13 @@ data Image =
95 , output_width :: !Word -- >= 1
97 , output_width :: !Word -- >= 1
96 , output_height :: !Word -- >= 1
98 , output_height :: !Word -- >= 1
98− -- A background fill will be filled with the background pattern. The background pattern is
100+ -- | A background fill will be filled with the background pattern. The background pattern is
99 -- defined as a property of the Picture this Image is used to form.
101 -- defined as a property of the Picture this Image is used to form.
101 { output_width :: !Word -- >= 1
103 { output_width :: !Word -- >= 1
102 , output_height :: !Word -- >= 1
104 , output_height :: !Word -- >= 1
104− -- The combining operators identity constant.
106+ -- | The combining operators identity constant.
105 -- EmptyImage <|> a = a
107 -- EmptyImage <|> a = a
106 -- EmptyImage <-> a = a
108 -- EmptyImage <-> a = a
@@ -135,7 +137,17 @@ instance Show Image where
135instance Monoid Image where
137instance Monoid Image where
136 mempty = empty_image
138 mempty = empty_image
137 mappend = (<->)
139 mappend = (<->)
141+instance NFData Image where
143+ rnf (Translation s i) = s `deepseq` i `deepseq` ()
144+ rnf (ImagePad s i) = s `deepseq` i `deepseq` ()
145+ rnf (ImageCrop s i) = s `deepseq` i `deepseq` ()
146+ rnf (BGFill !w !h) = ()
147+ rnf (VertJoin t b !w !h) = t `deepseq` b `deepseq` ()
148+ rnf (HorizJoin l r !w !h) = l `deepseq` r `deepseq` ()
149+ rnf (HorizText !a s !w !cw) = s `deepseq` ()
139-- A horizontal text image of 0 characters in width simplifies to the EmptyImage
151-- A horizontal text image of 0 characters in width simplifies to the EmptyImage
140horiz_text :: Attr -> DisplayString -> Word -> Image
152horiz_text :: Attr -> DisplayString -> Word -> Image
141horiz_text a txt ow
153horiz_text a txt ow