Maintainer | diagrams-discuss@googlegroups.com |
---|---|
Safe Haskell | None |
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.
- class Color c where
- colorToRGBA :: c -> (Double, Double, Double, Double)
- data SomeColor = forall c . Color c => SomeColor c
- data LineColor
- getLineColor :: LineColor -> SomeColor
- lineColor :: (Color c, HasStyle a) => c -> a -> a
- lc :: HasStyle a => Colour Double -> a -> a
- lcA :: HasStyle a => AlphaColour Double -> a -> a
- data FillColor
- getFillColor :: FillColor -> SomeColor
- recommendFillColor :: (Color c, HasStyle a) => c -> a -> a
- fillColor :: (Color c, HasStyle a) => c -> a -> a
- fc :: HasStyle a => Colour Double -> a -> a
- fcA :: HasStyle a => AlphaColour Double -> a -> a
- data Opacity
- getOpacity :: Opacity -> Double
- opacity :: HasStyle a => Double -> a -> a
- data LineWidth
- getLineWidth :: LineWidth -> Double
- lineWidth :: HasStyle a => Double -> a -> a
- lw :: HasStyle a => Double -> a -> a
- data LineCap
- data LineCapA
- getLineCap :: LineCapA -> LineCap
- lineCap :: HasStyle a => LineCap -> a -> a
- data LineJoin
- data LineJoinA
- getLineJoin :: LineJoinA -> LineJoin
- lineJoin :: HasStyle a => LineJoin -> a -> a
- data Dashing = Dashing [Double] Double
- data DashingA
- getDashing :: DashingA -> Dashing
- dashing :: HasStyle a => [Double] -> Double -> a -> a
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.
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.
An existential wrapper for instances of the Color
class.
Line color
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.
lcA :: HasStyle a => AlphaColour Double -> a -> aSource
A synonym for lineColor
, specialized to
(i.e. colors with transparency).
AlphaColour
Double
Fill color
recommendFillColor :: (Color c, HasStyle a) => c -> a -> aSource
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.
fcA :: HasStyle a => AlphaColour Double -> a -> aSource
A synonym for fillColor
, specialized to
(i.e. colors with transparency).
AlphaColour
Double
Opacity
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,
. In other
words, for example, opacity
o1 . opacity
o2 === opacity
(o1 * o2)opacity 0.8
means "decrease this diagram's
opacity to 80% of its previous opacity".
getOpacity :: Opacity -> DoubleSource
opacity :: HasStyle a => Double -> a -> aSource
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".
Lines
Width
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.
Line widths specified on child nodes always override line widths specified at parent nodes.
Cap style
What sort of shape should be placed at the endpoints of lines?
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. |
getLineCap :: LineCapA -> LineCapSource
Join style
How should the join points between line segments be drawn?
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? |
Dashing
Create lines that are dashing... er, dashed.
getDashing :: DashingA -> DashingSource