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

Copyright(c) 2011-2015 diagrams-lib team (see LICENSE)
LicenseBSD-style (see LICENSE)
Maintainerdiagrams-discuss@googlegroups.com
Safe HaskellNone
LanguageHaskell2010

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.

Every attribute type must have a semigroup structure, that is, an associative binary operation for combining two attributes into one. Unless otherwise noted, all the attributes defined here use the Last structure, that is, combining two attributes simply keeps the second one and throws away the first. This means that child attributes always override parent attributes.

Synopsis

Standard measures

Line width

data LineWidth n Source #

Line widths specified on child nodes always override line widths specified at parent nodes.

_LineWidthM :: Iso' (LineWidthM n) (Measure n) Source #

lineWidth :: (N a ~ n, HasStyle a, Typeable n) => Measure n -> a -> a Source #

Set the line (stroke) width.

lineWidthM :: (N a ~ n, HasStyle a, Typeable n) => LineWidthM n -> a -> a Source #

Apply a LineWidth attribute.

_lineWidth :: (Typeable n, OrderedField n) => Lens' (Style v n) (Measure n) Source #

Lens onto a measured line width in a style.

_lw :: (Typeable n, OrderedField n) => Lens' (Style v n) (Measure n) Source #

Lens onto a measured line width in a style.

_lineWidthU :: Typeable n => Lens' (Style v n) (Maybe n) Source #

Lens onto the unmeasured linewith attribute. This is useful for backends to use on styles once they have been unmeasured. Using on a diagram style could lead to unexpected results.

lw :: (N a ~ n, HasStyle a, Typeable n) => Measure n -> a -> a Source #

Default for lineWidth.

lwN :: (N a ~ n, HasStyle a, Typeable n, Num n) => n -> a -> a Source #

A convenient synonym for 'lineWidth (normalized w)'.

lwO :: (N a ~ n, HasStyle a, Typeable n) => n -> a -> a Source #

A convenient synonym for 'lineWidth (output w)'.

lwL :: (N a ~ n, HasStyle a, Typeable n, Num n) => n -> a -> a Source #

A convenient sysnonym for 'lineWidth (local w)'.

lwG :: (N a ~ n, HasStyle a, Typeable n, Num n) => n -> a -> a Source #

A convenient synonym for 'lineWidth (global w)'.

Dashing

data Dashing n Source #

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

Constructors

Dashing [n] n 

Instances

Functor Dashing Source # 

Methods

fmap :: (a -> b) -> Dashing a -> Dashing b #

(<$) :: a -> Dashing b -> Dashing a #

Eq n => Eq (Dashing n) Source # 

Methods

(==) :: Dashing n -> Dashing n -> Bool #

(/=) :: Dashing n -> Dashing n -> Bool #

Semigroup (Dashing n) Source # 

Methods

(<>) :: Dashing n -> Dashing n -> Dashing n #

sconcat :: NonEmpty (Dashing n) -> Dashing n #

stimes :: Integral b => b -> Dashing n -> Dashing n #

Typeable * n => AttributeClass (Dashing n) Source # 

dashing Source #

Arguments

:: (N a ~ n, HasStyle a, Typeable n) 
=> [Measure n]

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

-> Measure n

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

-> a 
-> a 

Set the line dashing style.

dashingN :: (N a ~ n, HasStyle a, Typeable n, Num n) => [n] -> n -> a -> a Source #

A convenient synonym for 'dashing (normalized w)'.

dashingO :: (N a ~ n, HasStyle a, Typeable n) => [n] -> n -> a -> a Source #

A convenient synonym for 'dashing (output w)'.

dashingL :: (N a ~ n, HasStyle a, Typeable n, Num n) => [n] -> n -> a -> a Source #

A convenient sysnonym for 'dashing (local w)'.

dashingG :: (N a ~ n, HasStyle a, Typeable n, Num n) => [n] -> n -> a -> a Source #

A convenient synonym for 'dashing (global w)'.

_dashing :: Typeable n => Lens' (Style v n) (Maybe (Measured n (Dashing n))) Source #

Lens onto a measured dashing attribute in a style.

_dashingU :: Typeable n => Lens' (Style v n) (Maybe (Dashing n)) Source #

Lens onto the unmeasured Dashing attribute. This is useful for backends to use on styles once they have been unmeasured. Using on a diagram style could lead to unexpected results.

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 where Source #

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.

Minimal complete definition

toAlphaColour, fromAlphaColour

Methods

toAlphaColour :: c -> AlphaColour Double Source #

Convert a color to its standard representation, AlphaColour.

fromAlphaColour :: AlphaColour Double -> c Source #

Convert from an AlphaColour Double. Note that this direction may lose some information. For example, the instance for Colour drops the alpha channel.

data SomeColor Source #

An existential wrapper for instances of the Color class.

Constructors

Color c => SomeColor c 

Opacity

data Opacity Source #

Although the individual colors in a diagram can have transparency, the opacity/transparency of a diagram as a whole can be specified with the Opacity attribute. The opacity is a value between 1 (completely opaque, the default) and 0 (completely transparent). Opacity is multiplicative, that is, opacity o1 . opacity o2 === opacity (o1 * o2). In other words, for example, opacity 0.8 means "decrease this diagram's opacity to 80% of its previous opacity".

opacity :: HasStyle a => Double -> a -> a Source #

Multiply the opacity (see Opacity) by the given value. For example, opacity 0.8 means "decrease this diagram's opacity to 80% of its previous opacity".

_opacity :: Lens' (Style v n) Double Source #

Lens onto the opacity in a style.

data FillOpacity Source #

Like Opacity, but set the opacity only for fills (as opposed to strokes). As with Opacity, the fill opacity is a value between 1 (completely opaque, the default) and 0 (completely transparent), and is multiplicative.

fillOpacity :: HasStyle a => Double -> a -> a Source #

Multiply the fill opacity (see FillOpacity) by the given value. For example, fillOpacity 0.8 means "decrease this diagram's fill opacity to 80% of its previous value".

_fillOpacity :: Lens' (Style v n) Double Source #

Lens onto the fill opacity in a style.

data StrokeOpacity Source #

Like Opacity, but set the opacity only for strokes (as opposed to fills). As with Opacity, the fill opacity is a value between 1 (completely opaque, the default) and 0 (completely transparent), and is multiplicative.

strokeOpacity :: HasStyle a => Double -> a -> a Source #

Multiply the stroke opacity (see StrokeOpacity) by the given value. For example, strokeOpacity 0.8 means "decrease this diagram's stroke opacity to 80% of its previous value".

_strokeOpacity :: Lens' (Style v n) Double Source #

Lens onto the stroke opacity in a style.

Converting colors

colorToSRGBA :: Color c => c -> (Double, Double, Double, Double) Source #

Convert to sRGBA.

colorToRGBA :: Color c => c -> (Double, Double, Double, Double) Source #

Deprecated: Renamed to colorToSRGBA.

Convert to sRGBA.

Line stuff

Cap style

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 -> a Source #

Set the line end cap attribute.

_lineCap :: Lens' (Style v n) LineCap Source #

Lens onto the line cap in a style.

Join style

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 -> a Source #

Set the segment join style.

_lineJoin :: Lens' (Style v n) LineJoin Source #

Lens onto the line join type in a style.

Miter limit

lineMiterLimit :: HasStyle a => Double -> a -> a Source #

Set the miter limit for joins with LineJoinMiter.

lineMiterLimitA :: HasStyle a => LineMiterLimit -> a -> a Source #

Apply a LineMiterLimit attribute.

_lineMiterLimit :: Lens' (Style v n) Double Source #

Lens onto the line miter limit in a style.

Recommend optics

_Commit :: Prism' (Recommend a) a Source #

Prism onto a Commit.

_recommend :: Lens (Recommend a) (Recommend b) a b Source #

Lens onto the value inside either a Recommend or Commit. Unlike committed, this is a valid lens.

isCommitted :: Lens' (Recommend a) Bool Source #

Lens onto whether something is committed or not.

committed :: Iso (Recommend a) (Recommend b) a b Source #

Commit a value for any Recommend. This is *not* a valid Iso because the resulting Recommend b is always a Commit. This is useful because it means any Recommend styles set with a lens will not be accidentally overridden. If you want a valid lens onto a recommend value use _recommend.

Other lenses that use this are labeled with a warning.