Copyright | (c) Tim Docker 2014 |
---|---|
License | BSD-style (see chart/COPYRIGHT) |
Safe Haskell | None |
Language | Haskell98 |
This module provides the API for drawing operations abstracted to drive arbitrary Backend.
Synopsis
- type BackendProgram a = Program ChartBackendInstr a
- fillPath :: Path -> BackendProgram ()
- strokePath :: Path -> BackendProgram ()
- drawText :: Point -> String -> BackendProgram ()
- textSize :: String -> BackendProgram TextSize
- withTransform :: Matrix -> BackendProgram a -> BackendProgram a
- withClipRegion :: Rect -> BackendProgram a -> BackendProgram a
- withFontStyle :: FontStyle -> BackendProgram a -> BackendProgram a
- withFillStyle :: FillStyle -> BackendProgram a -> BackendProgram a
- withLineStyle :: LineStyle -> BackendProgram a -> BackendProgram a
- getPointAlignFn :: BackendProgram (Point -> Point)
- getCoordAlignFn :: BackendProgram (Point -> Point)
- data TextSize = TextSize {}
- data LineCap
- data LineJoin
- data LineStyle = LineStyle {}
- line_width :: Lens' LineStyle Double
- line_color :: Lens' LineStyle (AlphaColour Double)
- line_dashes :: Lens' LineStyle [Double]
- line_cap :: Lens' LineStyle LineCap
- line_join :: Lens' LineStyle LineJoin
- newtype FillStyle = FillStyleSolid {}
- data FontWeight
- data FontSlant
- data FontStyle = FontStyle {}
- data HTextAnchor
- data VTextAnchor
- font_name :: Lens' FontStyle String
- font_size :: Lens' FontStyle Double
- font_slant :: Lens' FontStyle FontSlant
- font_weight :: Lens' FontStyle FontWeight
- font_color :: Lens' FontStyle (AlphaColour Double)
- type AlignmentFn = Point -> Point
- data AlignmentFns
- vectorAlignmentFns :: AlignmentFns
- bitmapAlignmentFns :: AlignmentFns
The backend Monad
type BackendProgram a = Program ChartBackendInstr a Source #
A BackendProgram
provides the capability to render a chart somewhere.
The coordinate system of the backend has its initial origin (0,0) in the top left corner of the drawing plane. The x-axis points towards the top right corner and the y-axis points towards the bottom left corner. The unit used by coordinates, the font size, and lengths is the always the same, but depends on the backend. All angles are measured in radians.
The line, fill and font style are set to their default values initially.
Information about the semantics of the instructions can be
found in the documentation of ChartBackendInstr
.
Backend Operations
fillPath :: Path -> BackendProgram () Source #
strokePath :: Path -> BackendProgram () Source #
drawText :: Point -> String -> BackendProgram () Source #
Draw a single-line textual label anchored by the baseline (vertical)
left (horizontal) point. Uses the current FontStyle
for drawing.
textSize :: String -> BackendProgram TextSize Source #
Calculate a TextSize
object with rendering information
about the given string without actually rendering it.
withTransform :: Matrix -> BackendProgram a -> BackendProgram a Source #
Apply the given transformation in this local environment when drawing. The given transformation is applied after the current transformation. This means both are combined.
withClipRegion :: Rect -> BackendProgram a -> BackendProgram a Source #
Use the given clipping rectangle when drawing in this local environment. The new clipping region is intersected with the given clip region. You cannot escape the clip!
withFontStyle :: FontStyle -> BackendProgram a -> BackendProgram a Source #
Use the given font style in this local environment when drawing text.
An implementing backend is expected to guarentee
to support the following font families: serif
, sans-serif
and monospace
;
If the backend is not able to find or load a given font it is required to fall back to a custom fail-safe font and use it instead.
withFillStyle :: FillStyle -> BackendProgram a -> BackendProgram a Source #
Use the given fill style in this local environment when filling paths.
withLineStyle :: LineStyle -> BackendProgram a -> BackendProgram a Source #
Use the given line style in this local environment when stroking paths.
Backend Helpers
getPointAlignFn :: BackendProgram (Point -> Point) Source #
Get the point alignment function
getCoordAlignFn :: BackendProgram (Point -> Point) Source #
Get the coordinate alignment function
Text Metrics
Text metrics returned by textSize
.
TextSize | |
|
Line Types
The different supported line ends.
LineCapButt | Just cut the line straight. |
LineCapRound | Make a rounded line end. |
LineCapSquare | Make a square that ends the line. |
The different supported ways to join line ends.
LineJoinMiter | Extends the outline until they meet each other. |
LineJoinRound | Draw a circle fragment to connet line end. |
LineJoinBevel | Like miter, but cuts it off if a certain threshold is exceeded. |
Data type for the style of a line.
LineStyle | |
|
Fill Types
Abstract data type for a fill style.
The contained action sets the required fill style in the rendering state.
Font and Text Types
data FontWeight Source #
The possible weights of a font.
FontWeightNormal | Normal font style without weight. |
FontWeightBold | Bold font. |
Instances
Eq FontWeight Source # | |
Defined in Graphics.Rendering.Chart.Backend.Types (==) :: FontWeight -> FontWeight -> Bool # (/=) :: FontWeight -> FontWeight -> Bool # | |
Ord FontWeight Source # | |
Defined in Graphics.Rendering.Chart.Backend.Types compare :: FontWeight -> FontWeight -> Ordering # (<) :: FontWeight -> FontWeight -> Bool # (<=) :: FontWeight -> FontWeight -> Bool # (>) :: FontWeight -> FontWeight -> Bool # (>=) :: FontWeight -> FontWeight -> Bool # max :: FontWeight -> FontWeight -> FontWeight # min :: FontWeight -> FontWeight -> FontWeight # | |
Show FontWeight Source # | |
Defined in Graphics.Rendering.Chart.Backend.Types showsPrec :: Int -> FontWeight -> ShowS # show :: FontWeight -> String # showList :: [FontWeight] -> ShowS # | |
Default FontWeight Source # | The default font weight. |
Defined in Graphics.Rendering.Chart.Backend.Types def :: FontWeight # |
The possible slants of a font.
FontSlantNormal | Normal font style without slant. |
FontSlantItalic | With a slight slant. |
FontSlantOblique | With a greater slant. |
Data type for a font.
FontStyle | |
|
data HTextAnchor Source #
Possible horizontal anchor points for text.
Instances
Eq HTextAnchor Source # | |
Defined in Graphics.Rendering.Chart.Backend.Types (==) :: HTextAnchor -> HTextAnchor -> Bool # (/=) :: HTextAnchor -> HTextAnchor -> Bool # | |
Ord HTextAnchor Source # | |
Defined in Graphics.Rendering.Chart.Backend.Types compare :: HTextAnchor -> HTextAnchor -> Ordering # (<) :: HTextAnchor -> HTextAnchor -> Bool # (<=) :: HTextAnchor -> HTextAnchor -> Bool # (>) :: HTextAnchor -> HTextAnchor -> Bool # (>=) :: HTextAnchor -> HTextAnchor -> Bool # max :: HTextAnchor -> HTextAnchor -> HTextAnchor # min :: HTextAnchor -> HTextAnchor -> HTextAnchor # | |
Show HTextAnchor Source # | |
Defined in Graphics.Rendering.Chart.Backend.Types showsPrec :: Int -> HTextAnchor -> ShowS # show :: HTextAnchor -> String # showList :: [HTextAnchor] -> ShowS # |
data VTextAnchor Source #
Possible vertical anchor points for text.
Instances
Eq VTextAnchor Source # | |
Defined in Graphics.Rendering.Chart.Backend.Types (==) :: VTextAnchor -> VTextAnchor -> Bool # (/=) :: VTextAnchor -> VTextAnchor -> Bool # | |
Ord VTextAnchor Source # | |
Defined in Graphics.Rendering.Chart.Backend.Types compare :: VTextAnchor -> VTextAnchor -> Ordering # (<) :: VTextAnchor -> VTextAnchor -> Bool # (<=) :: VTextAnchor -> VTextAnchor -> Bool # (>) :: VTextAnchor -> VTextAnchor -> Bool # (>=) :: VTextAnchor -> VTextAnchor -> Bool # max :: VTextAnchor -> VTextAnchor -> VTextAnchor # min :: VTextAnchor -> VTextAnchor -> VTextAnchor # | |
Show VTextAnchor Source # | |
Defined in Graphics.Rendering.Chart.Backend.Types showsPrec :: Int -> VTextAnchor -> ShowS # show :: VTextAnchor -> String # showList :: [VTextAnchor] -> ShowS # |
type AlignmentFn = Point -> Point Source #
A function to align points for a certain rendering device.
data AlignmentFns Source #
Holds the point and coordinate alignment function.
vectorAlignmentFns :: AlignmentFns Source #
Alignment to render on vector based graphics.
bitmapAlignmentFns :: AlignmentFns Source #
Alignment to render on raster based graphics.