diagrams-lib-0.1: Embedded domain-specific language for declarative graphics

Maintainerdiagrams-discuss@googlegroups.com

Diagrams.Attributes

Contents

Description

Diagrams may have attributes which affect the way they are rendered. This module defines some common attributes; particular backends may also define more backend-specific attributes.

Synopsis

Color

Diagrams outsources all things color-related to Russell O'Connor's very nice colour package (http://hackage.haskell.org/package/colour). For starters, it provides a large collection of standard color names. However, it also provides a rich set of combinators for combining and manipulating colors; see its documentation for more information.

class Color c whereSource

The Color type class encompasses color representations which can be used by the Diagrams library. Instances are provided for both the Colour and AlphaColour types from the Data.Colour library.

Methods

colorToRGBA :: c -> (Double, Double, Double, Double)Source

Convert a color to red, green, blue, and alpha channels in the range [0,1].

data SomeColor Source

An existential wrapper for instances of the Color class.

Constructors

forall c . Color c => SomeColor c 

Line color

newtype LineColor Source

The color with which lines (strokes) are drawn.

Constructors

LineColor SomeColor 

lineColor :: (Color c, HasStyle a) => c -> a -> aSource

Set the line (stroke) color. This function is polymorphic in the color type (so it can be used with either Colour or AlphaColour), but this can sometimes create problems for type inference, so the lc and lcA variants are provided with more concrete types.

lc :: HasStyle a => Colour Double -> a -> aSource

A synonym for lineColor, specialized to Colour Double (i.e. opaque colors).

lcA :: HasStyle a => AlphaColour Double -> a -> aSource

A synonym for lineColor, specialized to AlphaColour Double (i.e. colors with transparency).

Fill color

newtype FillColor Source

The color with which shapes are filled.

Constructors

FillColor SomeColor 

fillColor :: (Color c, HasStyle a) => c -> a -> aSource

Set the fill color. This function is polymorphic in the color type (so it can be used with either Colour or AlphaColour), but this can sometimes create problems for type inference, so the fc and fcA variants are provided with more concrete types.

fc :: HasStyle a => Colour Double -> a -> aSource

A synonym for fillColor, specialized to Colour Double (i.e. opaque colors).

fcA :: HasStyle a => AlphaColour Double -> a -> aSource

A synonym for fillColor, specialized to AlphaColour Double (i.e. colors with transparency).

Lines

newtype LineWidth Source

The width of lines. By default, the line width is measured with respect to the final coordinate system of a rendered diagram, as opposed to the local coordinate systems in effect at the time the line width was set for various subdiagrams. This is so that it is easy to combine a variety of shapes (some created by scaling) and have them all drawn using a consistent line width. However, sometimes it is desirable for scaling to affect line width; the freeze operation is provided for this purpose. The line width of frozen diagrams is affected by transformations.

Constructors

LineWidth Double 

lineWidth :: HasStyle a => Double -> a -> aSource

Set the line (stroke) width.

lw :: HasStyle a => Double -> a -> aSource

A convenient synonym for lineWidth.

data LineCap Source

What sort of shape should be placed at the endpoints of lines?

Constructors

LineCapButt

Lines end precisely at their endpoints.

LineCapRound

Lines are capped with semicircles centered on endpoints.

LineCapSquare

Lines are capped with a squares centered on endpoints.

lineCap :: HasStyle a => LineCap -> a -> aSource

Set the line end cap attribute.

data LineJoin Source

How should the join points between line segments be drawn?

Constructors

LineJoinMiter

Use a "miter" shape (whatever that is).

LineJoinRound

Use rounded join points.

LineJoinBevel

Use a "bevel" shape (whatever that is). Are these... carpentry terms?

lineJoin :: HasStyle a => LineJoin -> a -> aSource

Set the segment join style.

data Dashing Source

Create lines that are dashing... er, dashed.

Constructors

Dashing [Double] Double 

dashingSource

Arguments

:: HasStyle a 
=> [Double]

A list specifying alternate lengths of on and off portions of the stroke. The empty list indicates no dashing.

-> Double

An offset into the dash pattern at which the stroke should start.

-> a 
-> a 

Set the line dashing style.