|
Graphics.UI.GIO.Canvas | Portability | portable | Stability | provisional | Maintainer | ka2_mail@yahoo.com |
|
|
|
|
Contents |
- Canvas
- Drawing primitives
- Transform
- Font metrics
- Internal
|
|
Description |
Widgets that can be (re)painted are an instance of the Paint class. By
setting the paint attribute, a custom paint function can be specified.
For example: do w <- window [paint =: mypaint]
...
where
mypaint canvas updateFrame updateAreas
= do setCanvasPen canvas [color =: red]
fillRect (rect (pt 10 10) (pt 20 20)) canvas
setCanvasPen canvas [color =: blue, thickness =: 10]
drawLine (pt 20 20) (pt 30 30) canvas A paint function (of type PaintFunction) takes three arguments, the canvas
(of type Canvas), the bounding rectangle of the update frame and all areas that
need to be repainted.
|
|
Synopsis |
|
|
|
|
Canvas |
|
data Canvas |
A canvas is an area on which you can draw objects. |
|
|
data CanvasPen |
|
|
setCanvasPen :: Canvas -> [Prop CanvasPen] -> IO () |
|
getCanvasPen :: Canvas -> Attr CanvasPen a -> IO a |
|
paintInBitmap :: Bitmap -> Pen -> (Canvas -> IO a) -> IO a |
The paintInBitmap executes the given function with canvas
associated with given Bitmap. |
|
Drawing primitives |
|
drawPoint :: Point -> Canvas -> IO () |
Draws a point at the specified location. |
|
drawString :: Point -> String -> Canvas -> IO () |
Draws the specified text string at the specified location. |
|
drawLine :: Point -> Point -> Canvas -> IO () |
Draws a line connecting the two points specified by coordinate pairs. |
|
drawPolyline :: [Point] -> Canvas -> IO () |
Draws a series of line segments that connect an list of points. |
|
drawRect :: Rect -> Canvas -> IO () |
Draws a rectangle specified by a Rect. |
|
fillRect :: Rect -> Canvas -> IO () |
Fills the interior of a rectangle specified by a Rect. |
|
drawOval :: Rect -> Canvas -> IO () |
Draws an ellipse specified by a bounding rectangle. |
|
drawEllipse :: Point -> Int -> Int -> Canvas -> IO () |
Draw an ellipse specified by a center point and the x- and y radius. |
|
drawCircle :: Point -> Int -> Canvas -> IO () |
Draw an circle specified by a center point and the radius. |
|
fillOval :: Rect -> Canvas -> IO () |
Fills the interior of an ellipse defined by a bounding rectangle specified by a Rect. |
|
fillEllipse :: Point -> Int -> Int -> Canvas -> IO () |
Fills the interior of an ellipse specified by a center point and the x- and y radius. |
|
fillCircle :: Point -> Int -> Canvas -> IO () |
Fills the interior of a circle specified by a center point and the radius. |
|
drawCurve :: Rect -> Float -> Float -> Canvas -> IO () |
Draws an curve representing a portion of an ellipse specified by a Rect. The Float type
arguments specifies start and end angles in radians. The curve starts at an angle start
continuing in clockwise direction to the ending angle end. |
|
drawArc :: Point -> Int -> Int -> Float -> Float -> Canvas -> IO () |
Draw an arc. The expression (arc c rx ry start end [] canvas) draws a curve on the oval
defined by the center point c, the x radius rx and the y radius ry. The curve starts
at an angle start (in radians) continuing in clockwise direction
to the ending angle end (in radians). |
|
fillPie :: Point -> Int -> Int -> Float -> Float -> Canvas -> IO () |
Fills the interior of a pie section defined by an ellipse specified by a by a center point and the x- and y radius
and two radial lines at angles start and end. The Float arguments specifies the angles. |
|
drawPolygon :: [Point] -> Canvas -> IO () |
Draws a polygon defined by an list of points |
|
drawBitmap :: Point -> Bitmap -> Canvas -> IO () |
Draws the specified Bitmap at the specified location. |
|
Transform |
|
rotateCanvas :: Double -> Canvas -> IO () |
Rotate the canvas clockwise with an angle in radians. |
|
scaleCanvas :: Double -> Double -> Canvas -> IO () |
Scale the canvas with a horizontal and vertical factor. |
|
shearCanvas :: Double -> Double -> Canvas -> IO () |
Shear the canvas in a horizontal and vertical direction. |
|
translateCanvas :: Double -> Double -> Canvas -> IO () |
Translate (or move) the canvas in a horizontal and vertical direction. |
|
Font metrics |
|
fontMetrics :: Font -> Attr Canvas FontMetrics |
The font metrics (read-only). do metrics <- get canvas (fontMetrics defaultFont)
|
|
fontCharWidth :: Font -> Char -> Attr Canvas Int |
The width of a character in a certain font (read-only). |
|
fontStringWidth :: Font -> String -> Attr Canvas Int |
The width of a string in a certain font (read-only). |
|
canvasFontMetrics :: Attr Canvas FontMetrics |
The font metrics of the current drawing pencil (read-only). |
|
canvasFontCharWidth :: Char -> Attr Canvas Int |
The character width in the current pen font on a canvas (read-only). do em <- get canvas (canvasFontCharWidth 'm') |
|
canvasFontStringWidth :: String -> Attr Canvas Int |
The string width in the current pen font on a canvas (read-only). |
|
Internal |
|
withCanvas :: BufferMode -> Pen -> CanvasHandle -> (Canvas -> IO a) -> IO a |
|
Produced by Haddock version 0.4 |