module SWPict( Number, PictTrans, PColor, PLabel, Pict(..), BPict(..), BBox(..), Face(..), PPoint(..), RPoint(..), FrameType(..), t, tt, btt, it, bt, bit, rt, rbt, rit, sy, frame, fill, scale, blank, spacing, superimpose, ppara, colorize, append, find, ghost, label, lineWidth, inset, offset, bitmap, scalep, turn, setLength, polygon, polyline, oval, ovalFrame, HV(..), Hpos(..), Vpos(..) ) where import Char type Number = Double type PictTrans = Pict -> Pict -- abstract public data Pict = Text Face String | Frame FrameType Pict | Scale Number Pict | Append HV [Pict] | Para Hpos Number [Pict] | Spacing Number | Superimpose Hpos Vpos [Pict] | Colorize PColor Pict | Blank Number Number | LineWidth Number Pict | Next | Ghost Pict | Label PLabel Pict | Line Bool Bool PPoint PPoint | Inset Number Number Number Number Pict | BitMapFile FilePath | Polygon Bool [PPoint] -- | Many [BPict] -- after boxing | DLine Bool Bool RPoint RPoint | DPolygon Bool [RPoint] deriving (Show) type PColor = String type PLabel = String data PPoint = Find Hpos Vpos PLabel Pict | Offset Number Number PPoint | Turn BasePPoint Number PPoint -- Turn p1 a p2, turns p2 around p1 | ScaleP BasePPoint Number PPoint | SetLength BasePPoint Number PPoint deriving (Show) type BasePPoint = PPoint data RPoint = RPoint Number Number deriving (Show) data FrameType = FRectFrame | FRectFill | FOvalFill | FOvalFrame deriving (Show) data BBox = BBox { bbTop :: Number, -- relative in containing box bbLeft :: Number, -- relative in containing box bbHeight :: Number, bbWidth :: Number, bbTopLine :: Number, -- offset from top of first baseline bbBottomLine :: Number -- offset from top of last baseline } deriving (Show) bbNone = BBox 0 0 0 0 0 0 data BPict = Box BBox Pict deriving (Show) noBox p = Box bbNone p data Face = F_N | F_B | F_I | F_BI | F_TT | F_BTT | F_RT | F_RBT | F_RIT | F_SY deriving (Show, Eq) data HV = H Vpos | V Hpos deriving (Show, Eq) data Hpos = Hl | Hr | Hc deriving (Show, Eq) data Vpos = Vt | Vb | Vc | Vbl | Vtl deriving (Show, Eq) -- public t :: String -> Pict t = Text F_N -- public tt :: String -> Pict tt = Text F_TT -- public btt :: String -> Pict btt = Text F_BTT -- public it :: String -> Pict it = Text F_I -- public bt :: String -> Pict bt = Text F_B -- public bit :: String -> Pict bit = Text F_BI -- public rt :: String -> Pict rt = Text F_RT -- public rbt :: String -> Pict rbt = Text F_RBT -- public rit :: String -> Pict rit = Text F_RIT -- public sy :: String -> Pict sy = Text F_SY -- public frame :: PictTrans frame = Frame FRectFrame -- public fill :: PictTrans fill = Frame FRectFill -- public oval :: PictTrans oval = Frame FOvalFill -- public ovalFrame :: PictTrans ovalFrame = Frame FOvalFrame -- public scale :: Number -> PictTrans scale = Scale -- public blank :: Number -> Number -> Pict blank = Blank -- public spacing :: Number -> Pict spacing = Spacing -- public append :: HV -> [Pict] -> Pict append hv ps = Append hv ps -- public colorize :: PColor -> PictTrans colorize = Colorize -- public superimpose :: Hpos -> Vpos -> [Pict] -> Pict superimpose s1 s2 ps = Superimpose s1 s2 ps -- public ppara :: Hpos -> Number -> [Pict] -> Pict ppara a s ps = Para a s ps -- public lineWidth :: Number -> PictTrans lineWidth w p = LineWidth w p -- public ghost :: PictTrans ghost p@(Spacing _) = p ghost p = Ghost p -- public label :: PLabel -> PictTrans label s p = Label s p -- public inset :: (Number, Number, Number, Number) -> PictTrans inset (l, t, r, b) p = Inset l t r b p -- public bitmap :: String -> Pict bitmap s = BitMapFile s -- public offset :: (Number, Number) -> PPoint -> PPoint offset (x, y) p = Offset x y p -- public turn :: BasePPoint -> Number -> PPoint -> PPoint turn p1 a p2 = Turn p1 a p2 -- public scalep :: BasePPoint -> Number -> PPoint -> PPoint scalep p1 a p2 = ScaleP p1 a p2 -- public setLength :: BasePPoint -> Number -> PPoint -> PPoint setLength p1 a p2 = SetLength p1 a p2 -- public polygon :: [PPoint] -> Pict polygon ps = Polygon True ps -- public polyline :: [PPoint] -> Pict polyline ps = Polygon False ps -- public find :: Hpos -> Vpos -> PLabel ->Pict -> PPoint find = Find