Chart-1.9.3: A library for generating 2D Charts and Plots

Copyright | (c) Tim Docker 2006 2014
License | BSD-style (see chart/COPYRIGHT)
Safe Haskell | None
Language | Haskell98

Graphics.Rendering.Chart.Drawing

Contents

- Point Types and Drawing
- Alignments and Paths
- Transformation and Style Helpers
- Text Drawing
- Style Helpers
- Backend and general Types
- Accessors

Description

This module contains basic types and functions used for drawing.

Note that Template Haskell is used to derive accessor functions (see `Lens`) for each field of the following data types:

- `PointStyle`

These accessors are not shown in this API documentation. They have the same name as the field, but with the trailing underscore dropped. Hence for data field `f_::F` in type `D`, they have type

      f :: Control.Lens.Lens' D F

Synopsis

- data PointShape
  - = PointShapeCircle
  - | PointShapePolygon Int Bool
  - | PointShapePlus
  - | PointShapeCross
  - | PointShapeStar
  - | PointShapeArrowHead Double
  - | PointShapeEllipse Double Double
- data PointStyle = PointStyle {
  - _point_color :: AlphaColour Double
  - _point_border_color :: AlphaColour Double
  - _point_border_width :: Double
  - _point_radius :: Double
  - _point_shape :: PointShape
  }
- drawPoint :: PointStyle -> Point -> BackendProgram ()
- alignPath :: (Point -> Point) -> Path -> Path
- alignFillPath :: Path -> BackendProgram Path
- alignStrokePath :: Path -> BackendProgram Path
- alignFillPoints :: [Point] -> BackendProgram [Point]
- alignStrokePoints :: [Point] -> BackendProgram [Point]
- alignFillPoint :: Point -> BackendProgram Point
- alignStrokePoint :: Point -> BackendProgram Point
- strokePointPath :: [Point] -> BackendProgram ()
- fillPointPath :: [Point] -> BackendProgram ()
- withRotation :: Double -> BackendProgram a -> BackendProgram a
- withTranslation :: Point -> BackendProgram a -> BackendProgram a
- withScale :: Vector -> BackendProgram a -> BackendProgram a
- withScaleX :: Double -> BackendProgram a -> BackendProgram a
- withScaleY :: Double -> BackendProgram a -> BackendProgram a
- withPointStyle :: PointStyle -> BackendProgram a -> BackendProgram a
- withDefaultStyle :: BackendProgram a -> BackendProgram a
- drawTextA :: HTextAnchor -> VTextAnchor -> Point -> String -> BackendProgram ()
- drawTextR :: HTextAnchor -> VTextAnchor -> Double -> Point -> String -> BackendProgram ()
- drawTextsR :: HTextAnchor -> VTextAnchor -> Double -> Point -> String -> BackendProgram ()
- textDrawRect :: HTextAnchor -> VTextAnchor -> Point -> String -> BackendProgram Rect
- textDimension :: String -> BackendProgram RectSize
- defaultColorSeq :: [AlphaColour Double]
- solidLine :: Double -> AlphaColour Double -> LineStyle
- dashedLine :: Double -> [Double] -> AlphaColour Double -> LineStyle
- filledCircles :: Double -> AlphaColour Double -> PointStyle
- hollowCircles :: Double -> Double -> AlphaColour Double -> PointStyle
- filledPolygon :: Double -> Int -> Bool -> AlphaColour Double -> PointStyle
- hollowPolygon :: Double -> Double -> Int -> Bool -> AlphaColour Double -> PointStyle
- plusses :: Double -> Double -> AlphaColour Double -> PointStyle
- exes :: Double -> Double -> AlphaColour Double -> PointStyle
- stars :: Double -> Double -> AlphaColour Double -> PointStyle
- arrows :: Double -> Double -> Double -> AlphaColour Double -> PointStyle
- solidFillStyle :: AlphaColour Double -> FillStyle
- module Graphics.Rendering.Chart.Backend
- point_color :: Lens' PointStyle (AlphaColour Double)
- point_border_color :: Lens' PointStyle (AlphaColour Double)
- point_border_width :: Lens' PointStyle Double
- point_radius :: Lens' PointStyle Double
- point_shape :: Lens' PointStyle PointShape

# Point Types and Drawing

data PointShape Source #

The different shapes a point can have.

Constructors

PointShapeCircle | A circle.
PointShapePolygon Int Bool | Number of vertices and is right-side-up?
PointShapePlus | A plus sign.
PointShapeCross | A cross.
PointShapeStar | Combination of a cross and a plus.
PointShapeArrowHead Double |
PointShapeEllipse Double Double | Ratio of minor to major axis and rotation

data PointStyle Source #

Abstract data type for the style of a plotted point.

Constructors

PointStyle |

Fields

- _point_color :: AlphaColour Double

  The color to fill the point with.

- _point_border_color :: AlphaColour Double

  The color to stroke the outline with.

- _point_border_width :: Double

  The width of the outline.

- _point_radius :: Double

  The radius of the tightest surrounding circle of the point.

- _point_shape :: PointShape

  The shape.

#### Instances

Instances details

Default PointStyle Source # | Default style to use for points.
Instance details Defined in Graphics.Rendering.Chart.Drawing Methods def :: PointStyle Source #

drawPoint Source #

Arguments

:: PointStyle | Style to use when rendering the point.
-> Point | Position of the point to render.
-> BackendProgram () |

Draw a single point at the given location.

# Alignments and Paths

alignPath :: (Point -> Point) -> Path -> Path Source #

Align the path by applying the given function on all points.

alignFillPath :: Path -> BackendProgram Path Source #

Align the path using the environment's alignment function for coordinates. This is generally useful when filling. See `alignPath` and `getCoordAlignFn`.

alignStrokePath :: Path -> BackendProgram Path Source #

Align the path using the environment's alignment function for points. This is generally useful when stroking. See `alignPath` and `getPointAlignFn`.

alignFillPoints :: [Point] -> BackendProgram [Point] Source #

The points will be aligned by the `getCoordAlignFn`, so that when drawing bitmaps, the edges of the region will fall between pixels.

alignStrokePoints :: [Point] -> BackendProgram [Point] Source #

The points will be aligned by the `getPointAlignFn`, so that when drawing bitmaps, 1 pixel wide lines will be centred on the pixels.

alignFillPoint :: Point -> BackendProgram Point Source #

Align the point using the environment's alignment function for coordinates. See `getCoordAlignFn`.

alignStrokePoint :: Point -> BackendProgram Point Source #

Align the point using the environment's alignment function for points. See `getPointAlignFn`.

strokePointPath :: [Point] -> BackendProgram () Source #

Draw lines between the specified points.

fillPointPath :: [Point] -> BackendProgram () Source #

Fill the region with the given corners.

# Transformation and Style Helpers

withRotation :: Double -> BackendProgram a -> BackendProgram a Source #

Apply a local rotation. The angle is given in radians.

withTranslation :: Point -> BackendProgram a -> BackendProgram a Source #

Apply a local translation.

withScale :: Vector -> BackendProgram a -> BackendProgram a Source #

Apply a local scale.

withScaleX :: Double -> BackendProgram a -> BackendProgram a Source #

Apply a local scale on the x-axis.

withScaleY :: Double -> BackendProgram a -> BackendProgram a Source #

Apply a local scale on the y-axis.

withPointStyle :: PointStyle -> BackendProgram a -> BackendProgram a Source #

Changes the `LineStyle` and `FillStyle` to comply with the given `PointStyle`.

withDefaultStyle :: BackendProgram a -> BackendProgram a Source #

# Text Drawing

drawTextA :: HTextAnchor -> VTextAnchor -> Point -> String -> BackendProgram () Source #

Draw a line of text that is aligned at a different anchor point. See `drawText`.

drawTextR :: HTextAnchor -> VTextAnchor -> Double -> Point -> String -> BackendProgram () Source #

Draw a textual label anchored by one of its corners or edges, with rotation. Rotation angle is given in degrees, rotation is performed around anchor point. See `drawText`.

drawTextsR :: HTextAnchor -> VTextAnchor -> Double -> Point -> String -> BackendProgram () Source #

Draw a multi-line textual label anchored by one of its corners or edges, with rotation. Rotation angle is given in degrees, rotation is performed around anchor point. See `drawText`.

textDrawRect :: HTextAnchor -> VTextAnchor -> Point -> String -> BackendProgram Rect Source #

Return the bounding rectangle for a text string positioned where it would be drawn by `drawText`. See `textSize`.

textDimension :: String -> BackendProgram RectSize Source #

Get the width and height of the string when rendered. See `textSize`.

# Style Helpers

defaultColorSeq :: [AlphaColour Double] Source #

The default sequence of colours to use when plotings different data sets in a graph.

solidLine Source #

Arguments

:: Double | Width of line.
-> AlphaColour Double | Colour of line.
-> LineStyle |

Create a solid line style (not dashed).

dashedLine Source #

Arguments

:: Double | Width of line.
-> [Double] | The dash pattern in device coordinates.
-> AlphaColour Double | Colour of line.
-> LineStyle |

Create a dashed line style.

filledCircles Source #

Arguments

:: Double | Radius of circle.
-> AlphaColour Double | Fill colour.
-> PointStyle |

Style for filled circle points.

hollowCircles Source #

Arguments

:: Double | Radius of circle.
-> Double | Thickness of line.
-> AlphaColour Double |
-> PointStyle |

Style for stroked circle points.

filledPolygon Source #

Arguments

:: Double | Radius of circle.
-> Int | Number of vertices.
-> Bool | Is right-side-up?
-> AlphaColour Double | Fill color.
-> PointStyle |

Style for filled polygon points.

hollowPolygon Source #

Arguments

:: Double | Radius of circle.
-> Double | Thickness of line.
-> Int | Number of vertices.
-> Bool | Is right-side-up?
-> AlphaColour Double | Colour of line.
-> PointStyle |

Style for stroked polygon points.

plusses Source #

Arguments

:: Double | Radius of tightest surrounding circle.
-> Double | Thickness of line.
-> AlphaColour Double | Color of line.
-> PointStyle |

Plus sign point style.

exes Source #

Arguments

:: Double | Radius of circle.
-> Double | Thickness of line.
-> AlphaColour Double | Color of line.
-> PointStyle |

Cross point style.

stars Source #

Arguments

:: Double | Radius of circle.
-> Double | Thickness of line.
-> AlphaColour Double | Color of line.
-> PointStyle |

Combination of plus and cross point style.

arrows Source #

Arguments

:: Double | Radius of circle.
-> Double | Rotation (Tau)
-> Double | Thickness of line.
-> AlphaColour Double | Color of line.
-> PointStyle |

solidFillStyle :: AlphaColour Double -> FillStyle Source #

Fill style that fill everything this the given colour.

# Backend and general Types

module Graphics.Rendering.Chart.Backend

# Accessors

point_color :: Lens' PointStyle (AlphaColour Double) Source #

point_border_color :: Lens' PointStyle (AlphaColour Double) Source #

point_border_width :: Lens' PointStyle Double Source #

point_radius :: Lens' PointStyle Double Source #

point_shape :: Lens' PointStyle PointShape Source #