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

Copyright(c) Tim Docker 2014
LicenseBSD-style (see chart/COPYRIGHT)
Safe HaskellNone
LanguageHaskell98

Graphics.Rendering.Chart.Backend

Contents

Description

This module provides the API for drawing operations abstracted to drive arbitrary Backend.

Synopsis

The backend Monad

type BackendProgram a = Program ChartBackendInstr a #

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 () #

Fill the given path using the current FillStyle. The given path will be closed prior to filling. This function does not perform alignment operations on the path. See Path for the exact semantic of paths.

strokePath :: Path -> BackendProgram () #

Stroke the outline of the given path using the current LineStyle. This function does not perform alignment operations on the path. See Path for the exact semantic of paths.

drawText :: Point -> String -> BackendProgram () #

Draw a single-line textual label anchored by the baseline (vertical) left (horizontal) point. Uses the current FontStyle for drawing.

textSize :: String -> BackendProgram TextSize #

Calculate a TextSize object with rendering information about the given string without actually rendering it.

withTransform :: Matrix -> BackendProgram a -> BackendProgram a #

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 #

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 #

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 #

Use the given fill style in this local environment when filling paths.

withLineStyle :: LineStyle -> BackendProgram a -> BackendProgram a #

Use the given line style in this local environment when stroking paths.

Backend Helpers

getPointAlignFn :: BackendProgram (Point -> Point) #

Get the point alignment function

getCoordAlignFn :: BackendProgram (Point -> Point) #

Get the coordinate alignment function

Text Metrics

data TextSize #

Text metrics returned by textSize.

Constructors

TextSize 

Fields

Instances
Eq TextSize # 
Instance details

Defined in Graphics.Rendering.Chart.Backend.Types

Show TextSize # 
Instance details

Defined in Graphics.Rendering.Chart.Backend.Types

Line Types

data LineCap #

The different supported line ends.

Constructors

LineCapButt

Just cut the line straight.

LineCapRound

Make a rounded line end.

LineCapSquare

Make a square that ends the line.

data LineJoin #

The different supported ways to join line ends.

Constructors

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 LineStyle #

Data type for the style of a line.

Constructors

LineStyle 

Fields

Instances
Eq LineStyle # 
Instance details

Defined in Graphics.Rendering.Chart.Backend.Types

Show LineStyle # 
Instance details

Defined in Graphics.Rendering.Chart.Backend.Types

Default LineStyle #

The default line style.

Instance details

Defined in Graphics.Rendering.Chart.Backend.Types

Methods

def :: LineStyle #

Fill Types

newtype FillStyle #

Abstract data type for a fill style.

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

Instances
Eq FillStyle # 
Instance details

Defined in Graphics.Rendering.Chart.Backend.Types

Show FillStyle # 
Instance details

Defined in Graphics.Rendering.Chart.Backend.Types

Default FillStyle #

The default fill style.

Instance details

Defined in Graphics.Rendering.Chart.Backend.Types

Methods

def :: FillStyle #

Font and Text Types

data FontWeight #

The possible weights of a font.

Constructors

FontWeightNormal

Normal font style without weight.

FontWeightBold

Bold font.

data FontSlant #

The possible slants of a font.

Constructors

FontSlantNormal

Normal font style without slant.

FontSlantItalic

With a slight slant.

FontSlantOblique

With a greater slant.

data FontStyle #

Data type for a font.

Constructors

FontStyle 

Fields

Instances
Eq FontStyle # 
Instance details

Defined in Graphics.Rendering.Chart.Backend.Types

Show FontStyle # 
Instance details

Defined in Graphics.Rendering.Chart.Backend.Types

Default FontStyle #

The default font style.

Instance details

Defined in Graphics.Rendering.Chart.Backend.Types

Methods

def :: FontStyle #

type AlignmentFn = Point -> Point #

A function to align points for a certain rendering device.

data AlignmentFns #

Holds the point and coordinate alignment function.

vectorAlignmentFns :: AlignmentFns #

Alignment to render on vector based graphics.

bitmapAlignmentFns :: AlignmentFns #

Alignment to render on raster based graphics.