Data.GraphViz.Attributes.Colors

graphviz-2999.18.1.2: Bindings to Graphviz for graph visualisation.

Copyright | (c) Ivan Lazar Miljenovic
License | 3-Clause BSD-style
Maintainer | Ivan.Miljenovic@gmail.com
Safe Haskell | Safe
Language | Haskell2010

Data.GraphViz.Attributes.Colors

Contents

- Color schemes.
- Colors
- Conversion to/from `Colour`.

Description

This module defines the various colors, etc. for Graphviz. For information on colors in general, see: http://graphviz.org/doc/info/attrs.html#k:color For named colors, see: http://graphviz.org/doc/info/colors.html

Note that the ColorBrewer Color Schemes (shortened to just "Brewer" for the rest of this module) are covered by the following license (also available in the LICENSE file of this library): http://graphviz.org/doc/info/colors.html#brewer_license

Synopsis

- data ColorScheme
  - = X11
  - | SVG
  - | Brewer BrewerScheme
- data Color
  - = RGB {
    - red :: Word8
    - green :: Word8
    - blue :: Word8
    }
  - | RGBA {
    - red :: Word8
    - green :: Word8
    - blue :: Word8
    - alpha :: Word8
    }
  - | HSV {
    - hue :: Double
    - saturation :: Double
    - value :: Double
    }
  - | X11Color X11Color
  - | SVGColor SVGColor
  - | BrewerColor BrewerColor
- type ColorList = [WeightedColor]
- data WeightedColor = WC {
  - wColor :: Color
  - weighting :: Maybe Double
  }
- toWC :: Color -> WeightedColor
- toColorList :: [Color] -> ColorList
- class NamedColor nc where
- toWColor :: NamedColor nc => nc -> WeightedColor
- toColour :: Color -> Maybe (AlphaColour Double)
- fromColour :: Colour Double -> Color
- fromAColour :: AlphaColour Double -> Color

# Color schemes.

data ColorScheme #

This represents the color schemes that Graphviz accepts.

Constructors

X11 |
SVG |
Brewer BrewerScheme |

Instances

Eq ColorScheme # |
Methods (==) :: ColorScheme -> ColorScheme -> Bool # (/=) :: ColorScheme -> ColorScheme -> Bool #
Ord ColorScheme # |
Methods compare :: ColorScheme -> ColorScheme -> Ordering # (<) :: ColorScheme -> ColorScheme -> Bool # (<=) :: ColorScheme -> ColorScheme -> Bool # (>) :: ColorScheme -> ColorScheme -> Bool # (>=) :: ColorScheme -> ColorScheme -> Bool # max :: ColorScheme -> ColorScheme -> ColorScheme # min :: ColorScheme -> ColorScheme -> ColorScheme #
Read ColorScheme # |
Methods readsPrec :: Int -> ReadS ColorScheme # readList :: ReadS [ColorScheme] # readPrec :: ReadPrec ColorScheme # readListPrec :: ReadPrec [ColorScheme] #
Show ColorScheme # |
Methods showsPrec :: Int -> ColorScheme -> ShowS # show :: ColorScheme -> String # showList :: [ColorScheme] -> ShowS #
ParseDot ColorScheme # |
Methods parseUnqt :: Parse ColorScheme # parse :: Parse ColorScheme # parseUnqtList :: Parse [ColorScheme] # parseList :: Parse [ColorScheme] #
PrintDot ColorScheme # |
Methods unqtDot :: ColorScheme -> DotCode # toDot :: ColorScheme -> DotCode # unqtListToDot :: [ColorScheme] -> DotCode # listToDot :: [ColorScheme] -> DotCode #

# Colors

data Color #

Defining a color for use with Graphviz. Note that named colors have been split up into `X11Color`s and those based upon the Brewer color schemes.

Constructors

RGB |
Fields red :: Word8 green :: Word8 blue :: Word8
RGBA |
Fields red :: Word8 green :: Word8 blue :: Word8 alpha :: Word8
HSV | The `hue`, `saturation` and `value` values must all be `0 <= x <=1`.
Fields hue :: Double saturation :: Double value :: Double
X11Color X11Color |
SVGColor SVGColor |
BrewerColor BrewerColor |

Instances

Eq Color # |
Methods (==) :: Color -> Color -> Bool # (/=) :: Color -> Color -> Bool #
Ord Color # |
Methods compare :: Color -> Color -> Ordering # (<) :: Color -> Color -> Bool # (<=) :: Color -> Color -> Bool # (>) :: Color -> Color -> Bool # (>=) :: Color -> Color -> Bool # max :: Color -> Color -> Color # min :: Color -> Color -> Color #
Read Color # |
Methods readsPrec :: Int -> ReadS Color # readList :: ReadS [Color] # readPrec :: ReadPrec Color # readListPrec :: ReadPrec [Color] #
Show Color # |
Methods showsPrec :: Int -> Color -> ShowS # show :: Color -> String # showList :: [Color] -> ShowS #
ParseDot Color # |
Methods parseUnqt :: Parse Color # parse :: Parse Color # parseUnqtList :: Parse [Color] # parseList :: Parse [Color] #
PrintDot Color # |
Methods unqtDot :: Color -> DotCode # toDot :: Color -> DotCode # unqtListToDot :: [Color] -> DotCode # listToDot :: [Color] -> DotCode #

type ColorList = [WeightedColor] #

The sum of the optional weightings must sum to at most `1`.

data WeightedColor #

A `Color` tagged with an optional weighting.

Constructors

WC |
Fields wColor :: Color weighting :: Maybe Double Must be in range `0 <= W <= 1`.

Instances

Eq WeightedColor # |
Methods (==) :: WeightedColor -> WeightedColor -> Bool # (/=) :: WeightedColor -> WeightedColor -> Bool #
Ord WeightedColor # |
Methods compare :: WeightedColor -> WeightedColor -> Ordering # (<) :: WeightedColor -> WeightedColor -> Bool # (<=) :: WeightedColor -> WeightedColor -> Bool # (>) :: WeightedColor -> WeightedColor -> Bool # (>=) :: WeightedColor -> WeightedColor -> Bool # max :: WeightedColor -> WeightedColor -> WeightedColor # min :: WeightedColor -> WeightedColor -> WeightedColor #
Read WeightedColor # |
Methods readsPrec :: Int -> ReadS WeightedColor # readList :: ReadS [WeightedColor] # readPrec :: ReadPrec WeightedColor # readListPrec :: ReadPrec [WeightedColor] #
Show WeightedColor # |
Methods showsPrec :: Int -> WeightedColor -> ShowS # show :: WeightedColor -> String # showList :: [WeightedColor] -> ShowS #
ParseDot WeightedColor # |
Methods parseUnqt :: Parse WeightedColor # parse :: Parse WeightedColor # parseUnqtList :: Parse [WeightedColor] # parseList :: Parse [WeightedColor] #
PrintDot WeightedColor # |
Methods unqtDot :: WeightedColor -> DotCode # toDot :: WeightedColor -> DotCode # unqtListToDot :: [WeightedColor] -> DotCode # listToDot :: [WeightedColor] -> DotCode #

toWC :: Color -> WeightedColor #

For colors without weightings.

toColorList :: [Color] -> ColorList #

For a list of colors without weightings.

class NamedColor nc where #

More easily convert named colors to an overall `Color` value.

Minimal complete definition

colorScheme, toColor, printNC, parseNC'

Methods

toColor :: nc -> Color #

Instances

NamedColor X11Color # |
Methods colorScheme :: X11Color -> ColorScheme toColor :: X11Color -> Color # printNC :: Bool -> X11Color -> DotCode parseNC' :: Bool -> Parse X11Color
NamedColor SVGColor # |
Methods colorScheme :: SVGColor -> ColorScheme toColor :: SVGColor -> Color # printNC :: Bool -> SVGColor -> DotCode parseNC' :: Bool -> Parse SVGColor
NamedColor BrewerColor # |
Methods colorScheme :: BrewerColor -> ColorScheme toColor :: BrewerColor -> Color # printNC :: Bool -> BrewerColor -> DotCode parseNC' :: Bool -> Parse BrewerColor

toWColor :: NamedColor nc => nc -> WeightedColor #

# Conversion to/from `Colour`.

toColour :: Color -> Maybe (AlphaColour Double) #

Attempt to convert a `Color` into a `Colour` value with an alpha channel. The use of `Maybe` is because the RGB values of the `BrewerColor`s haven't been stored here (primarily for licensing reasons).

fromColour :: Colour Double -> Color #

Convert a `Colour` value to an `RGB` `Color`.

fromAColour :: AlphaColour Double -> Color #

Convert an `AlphaColour` to an `RGBA` `Color`. The exception to this is for any `AlphaColour` which has `alphaChannel ac == 0`; these are converted to `X11Color `Transparent`` (note that the `Show` instance for such an `AlphaColour` is `"transparent"`).