1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
\modName{HGL.Graphics.Core} % accurate 16/1/2000
\begin{verbatim}
> type Title = String
> type Point = (Int,Int)
> type Size = (Int,Int)
> type Angle = Double
> type Time = Word32 -- milliseconds
> data RGB = RGB Word8 Word8 Word8
> data BkMode = Opaque | Transparent
>
> type Alignment = (HAlign, VAlign)
> -- names have a tick to distinguish them from Prelude names (blech!)
> data HAlign = Left' | Center | Right'
> deriving (Enum, Eq, Ord, Ix, Show)
> data VAlign = Top | Baseline | Bottom
> deriving (Enum, Eq, Ord, Ix, Show)
>
> data Style
> = Solid
> | Dash -- "-------"
> | Dot -- "......."
> | DashDot -- "_._._._"
> | DashDotDot -- "_.._.._"
> | Null
> | InsideFrame
>
> runGraphics :: IO () -> IO ()
> getTime :: IO Time
>
> data Window
> openWindowEx :: Title -> Maybe Point -> Size ->
> RedrawMode -> Maybe T.Time -> IO Window
>
> closeWindow :: Window -> IO ()
> getWindowRect :: Window -> IO (Point,Point)
> getWindowEvent :: Window -> IO Event
> getWindowTick :: Window -> IO ()
> maybeGetWindowEvent :: Window -> IO (Maybe Event)
>
> type Graphic = Draw ()
> setGraphic :: Window -> Graphic -> IO ()
> getGraphic :: Window -> IO Graphic
> modGraphic :: Window -> (Graphic -> Graphic) -> IO ()
> directDraw :: Window -> Graphic -> IO ()
>
> selectFont :: Font -> Draw Font
> setTextColor :: RGB -> Draw RGB
> setTextAlignment :: Alignment -> Draw Alignment
> setBkColor :: RGB -> Draw RGB
> setBkMode :: BkMode -> Draw BkMode
> selectPen :: Pen -> Draw Pen
> selectBrush :: Brush -> Draw Brush
>
> bracket :: Draw a -> (a -> Draw b) -> (a -> Draw c) -> Draw c
> bracket_ :: Draw a -> (a -> Draw b) -> Draw c -> Draw c
>
> data Font
> createFont :: Point -> Angle -> Bool -> Bool -> String -> IO Font
> deleteFont :: Font -> IO ()
>
> data Brush
> mkBrush :: RGB -> (Brush -> Draw a) -> Draw a
>
> data Pen
> mkPen :: Style -> Int -> RGB -> (Pen -> Draw a) -> Draw a
> createPen :: Style -> Int -> RGB -> IO Pen
>
> arc :: Point -> Point -> Angle -> Angle -> Graphic -- unfilled
> line :: Point -> Point -> Graphic -- unfilled
> polyline :: [Point] -> Graphic -- unfilled
> ellipse :: Point -> Point -> Graphic -- filled
> shearEllipse :: Point -> Point -> Point -> Graphic -- filled
> polygon :: [Point] -> Graphic -- filled
> text :: Point -> String -> Graphic -- filled
>
> data Region
> emptyRegion :: Region
> rectangleRegion :: Point -> Point -> Region
> ellipseRegion :: Point -> Point -> Region
> polygonRegion :: [Point] -> Region
> intersectRegion :: Region -> Region -> Region
> unionRegion :: Region -> Region -> Region
> subtractRegion :: Region -> Region -> Region
> xorRegion :: Region -> Region -> Region
> regionToGraphic :: Region -> Graphic
>
> data Event
> = Key { char :: Char, isDown :: Bool }
> | Button { pt :: Point, isLeft, isDown :: Bool }
> | MouseMove { pt :: Point }
> | Resize
> | Closed
> deriving Show
\end{verbatim}
\modName{HGL.Graphics.Utils} % accurate 16/1/2000
Note that this document repeats the definitions of all the functions
defined in \module{HGL.Graphics.Utils}.
\begin{verbatim}
> -- Reexports HGL.Graphics.Core
>
> openWindow :: Title -> Size -> IO Window
> clearWindow :: Window -> IO ()
> drawInWindow :: Window -> Graphic -> IO ()
>
> getWindowSize :: Window -> IO Size
> getLBP :: Window -> IO Point
> getRBP :: Window -> IO Point
> getButton :: Window -> Bool -> Bool -> IO Point
> getKey :: Window -> IO Char
> getKeyEx :: Window -> Bool -> IO Char
>
> emptyGraphic :: Graphic
> overGraphic :: Graphic -> Graphic -> Graphic
> overGraphics :: [Graphic] -> Graphic
>
> withFont :: Font -> Graphic -> Graphic
> withTextColor :: RGB -> Graphic -> Graphic
> withTextAlignment :: Alignment -> Graphic -> Graphic
> withBkColor :: RGB -> Graphic -> Graphic
> withBkMode :: BkMode -> Graphic -> Graphic
> withPen :: Pen -> Graphic -> Graphic
> withBrush :: Brush -> Graphic -> Graphic
> withRGB :: RGB -> Graphic -> Graphic
>
> data Color
> = Black
> | Blue
> | Green
> | Cyan
> | Red
> | Magenta
> | Yellow
> | White
> deriving (Eq, Ord, Bounded, Enum, Ix, Show, Read)
>
> colorList :: [(Color, RGB)]
> colorTable :: Array Color RGB
> withColor :: Color -> Graphic -> Graphic
>
> par :: IO a -> IO b -> IO (a,b)
> par_ :: IO a -> IO b -> IO ()
> parMany :: [IO ()] -> IO ()
\end{verbatim}
\subsection{Portability notes}
\begin{itemize}
\item \NotInX{\fun{polyBezier}}
\item \fun{shearEllipse} is implemented by polygons on both Win32 and X11.
\item X11 does not directly support font rotation so \fun{mkFont}
always ignores the rotation angle argument in the X11 implementation
of this library.
\item Many of the font families typically available on Win32 are not
available on X11 (and {\it vice-versa\/}). In our experience, the
font families ``courier,'' ``helvetica'' and ``times'' are somewhat
portable.
\item
On Win32, the pen is also used to draw a line round all
the filled shapes --- so the pen color also affects how
polygons, ellipses and regions are drawn.
\item
One of the Win32 ``gotchas'' is that the choice of \type{Style}
only applies if the width is 1 or less. With greater widths,
the pen style will always be \fun{Solid} no matter what you try to
select. This problem does not apply to X11.
\item The Bitmap functions are not currently provided in the X11
implementation of this library.
\item \fun{shearBitmap} is supported on Win'NT but not Win'95.
\item \NotInWin{\fun{emptyRegion}}
It is possible to use an empty rectangle region instead
\item \fun{ellipseRegion} is implemented using polygons in the X11
implementation of the library.
\item
Programmers should assume that the \type{Event} datatype will be extended in the
not-too-distant future and that individual events may change slightly.
As a minimum, you should add a ``match anything'' alternative to
any function which pattern matches against \type{Event}s.
\item
X11 systems typically have three button mice. Button 1 is used as the
left button, button 3 as the right button and button 2 (the middle
button) is ignored.
\end{itemize}
|