HGL-3.2.3.1: A simple graphics library based on X11 or Win32

Copyright(c) Alastair Reid, 1999-2003
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityprovisional
Portabilitynon-portable (requires concurrency)
Safe HaskellNone
LanguageHaskell98

Graphics.HGL.Utils

Contents

Description

Utility functions for a simple graphics library.

Synopsis

Windows

openWindow :: Title -> Size -> IO Window Source

Create a window with the given title and size.

clearWindow :: Window -> IO () Source

Erase all drawing in the window. (That is, set the Graphic held by the window to emptyGraphic.)

drawInWindow :: Window -> Graphic -> IO () Source

Draw the given graphic on the window, on top of anything that is already there. (That is, combine the given Graphic and the one held by the window using overGraphic, store the result in the window, and display it.)

withWindow :: Title -> Size -> (Window -> IO a) -> IO a Source

Run an action inside a new window, ensuring that the window is destroyed on exit.

withWindow_ :: Title -> Size -> (Window -> IO a) -> IO () Source

A variant of withWindow that ignores the result of the action.

runWindow :: Title -> Size -> (Window -> IO a) -> IO () Source

A combination of runGraphics and withWindow_.

getWindowSize :: Window -> IO Size Source

The current size of the window.

Specific events

Mouse events

getLBP :: Window -> IO Point Source

Wait for a press of the left mouse button, and return the position of the mouse cursor.

getRBP :: Window -> IO Point Source

Wait for a press of the right mouse button, and return the position of the mouse cursor.

getButton Source

Arguments

:: Window 
-> Bool

if True, wait for the left button

-> Bool

if True, wait for a press; otherwise wait for a release.

-> IO Point 

Wait for a mouse button to be pressed or released, and return the position of the mouse cursor.

Keyboard events

getKey :: Window -> IO Key Source

Wait until a key is pressed and released.

getKeyEx :: Window -> Bool -> IO Key Source

Wait until a key is pressed (if the second argument is True) or released (otherwise).

wGetChar :: Window -> IO Char Source

Wait for a translated character (from a key press). Use in preference to getKey if the aim is to read text.

Graphics

Combining Graphics

emptyGraphic :: Graphic Source

An empty drawing.

overGraphic :: Graphic -> Graphic -> Graphic Source

A composite drawing made by overlaying the first argument on the second.

overGraphics :: [Graphic] -> Graphic Source

Overlay a list of drawings.

Graphic modifiers

withFont :: Font -> Graphic -> Graphic Source

Set the default font for a drawing.

withTextColor :: RGB -> Graphic -> Graphic Source

Set the default color for drawing text.

withTextAlignment :: Alignment -> Graphic -> Graphic Source

Set the default alignment of text in a drawing.

withBkColor :: RGB -> Graphic -> Graphic Source

Set the default background color for drawing text with background mode Opaque. The background color is ignored when the mode is Transparent.

withBkMode :: BkMode -> Graphic -> Graphic Source

Set the default background mode for drawing text.

withPen :: Pen -> Graphic -> Graphic Source

Set the default pen for drawing lines.

withBrush :: Brush -> Graphic -> Graphic Source

Set the default brush for filling shapes.

withRGB :: RGB -> Graphic -> Graphic Source

A convenience function that sets the brush, pen and text colors to the same value.

Named colors

colorList :: [(Color, RGB)] Source

A mapping of Color names to RGB triples.

colorTable :: Array Color RGB Source

A mapping of Color names to RGB triples.

withColor :: Color -> Graphic -> Graphic Source

Set the default drawing color for a Graphic.

Concurrency

par :: IO a -> IO b -> IO (a, b) Source

Run two IO actions in parallel and terminate when both actions terminate.

par_ :: IO a -> IO b -> IO () Source

Run two IO actions in parallel and terminate when both actions terminate, discarding the results of the actions.

parMany :: [IO ()] -> IO () Source

Run several IO actions in parallel and terminate when all actions terminate, discarding the results of the actions.