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

Graphics.Rendering.Chart.Types

Description

This module contains basic types and functions used for drawing.

Note that template haskell is used to derive accessor functions (see Data.Accessor) for each field of the following data types:

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 :: Data.Accessor.Accessor D F

Synopsis

Documentation

data Rect Source

A rectangle is defined by two points

Constructors

Rect Point Point 

Instances

data Point Source

A point in two dimensions

Constructors

Point 

Fields

p_x :: Double
 
p_y :: Double
 

Instances

data Vector Source

Constructors

Vector 

Fields

v_x :: Double
 
v_y :: Double
 

Instances

mkrect :: Point -> Point -> Point -> Point -> RectSource

Create a rectangle based upon the coordinates of 4 points

pvadd :: Point -> Vector -> PointSource

add a point and a vector

pvsub :: Point -> Vector -> PointSource

subtract a vector from a point

psub :: Point -> Point -> VectorSource

subtract two points

vscale :: Double -> Vector -> VectorSource

scale a vector by a constant

within :: Point -> Rect -> BoolSource

Test if a point is within a rectangle

type PointMapFn x y = (x, y) -> PointSource

a function mapping between points

preserveCState :: CRender a -> CRender aSource

Execute a rendering action in a saved context (ie bracketed between C.save and C.restore)

strokeLines :: [Point] -> CRender ()Source

stroke the lines between successive points

rectPath :: Rect -> CRender ()Source

make a path from a rectable

maybeM :: Monad m => a -> (a1 -> m a) -> Maybe a1 -> m aSource

data Color Source

Constructors

Color 

Fields

c_r :: Double
 
c_g :: Double
 
c_b :: Double
 

data CairoLineStyle Source

Data type for the style of a line

solidLineSource

Arguments

:: Double

width of line

-> Color 
-> CairoLineStyle 

dashedLineSource

Arguments

:: Double

width of line

-> [Double]

the dash pattern in device coordinates

-> Color 
-> CairoLineStyle 

newtype CairoFillStyle Source

Abstract data type for a fill style

The contained Cairo action sets the required fill style in the Cairo rendering state.

Constructors

CairoFillStyle (CRender ()) 

newtype CairoPointStyle Source

Abstract data type for the style of a plotted point

The contained Cairo action draws a point in the desired style, at the supplied device coordinates.

Constructors

CairoPointStyle (Point -> CRender ()) 

filledPolygonSource

Arguments

:: Double

radius of circle

-> Int

Number of vertices

-> Bool

Is right-side-up?

-> Color 
-> CairoPointStyle 

hollowPolygonSource

Arguments

:: Double

radius of circle

-> Double

thickness of line

-> Int

Number of vertices

-> Bool

Is right-side-up?

-> Color 
-> CairoPointStyle 

filledCirclesSource

Arguments

:: Double

radius of circle

-> Color

colour

-> CairoPointStyle 

hollowCirclesSource

Arguments

:: Double

radius of circle

-> Double

thickness of line

-> Color 
-> CairoPointStyle 

plussesSource

Arguments

:: Double

radius of circle

-> Double

thickness of line

-> Color 
-> CairoPointStyle 

exesSource

Arguments

:: Double

radius of circle

-> Double

thickness of line

-> Color 
-> CairoPointStyle 

starsSource

Arguments

:: Double

radius of circle

-> Double

thickness of line

-> Color 
-> CairoPointStyle 

drawText :: HTextAnchor -> VTextAnchor -> Point -> String -> CRender ()Source

Function to draw a textual label anchored by one of it's corners or edges.

textSize :: String -> CRender RectSizeSource

Return the bounding rectancgle for a text string rendered in the current context.

newtype CRender a Source

The reader monad containing context information to control the rendering process.

Constructors

DR (ReaderT CEnv Render a) 

data CEnv Source

The environment present in the CRender Monad.

Constructors

CEnv 

Fields

cenv_point_alignfn :: Point -> Point

A transform applied immediately prior to values being displayed in device coordinates

When device coordinates correspond to pixels, a cleaner image is created if this transform rounds to the nearest pixel. With higher-resolution output, this transform can just be the identity function.