colour-2.3.5: A model for human colour/color perception

Safe Haskell | Safe
Language | Haskell98

Data.Colour.RGBSpace

Contents

- RGB Tuple
- RGB Gamut
- RGB Space

Description

An `RGBSpace` is characterized by `Chromaticity` for red, green, and blue, the `Chromaticity` of the white point, and it's `TransferFunction`.

Synopsis

- data Colour a
- data RGB a = RGB {
  - channelRed :: !a
  - channelGreen :: !a
  - channelBlue :: !a
  }
- uncurryRGB :: (a -> a -> a -> b) -> RGB a -> b
- curryRGB :: (RGB a -> b) -> a -> a -> a -> b
- data RGBGamut
- mkRGBGamut :: RGB (Chromaticity Rational) -> Chromaticity Rational -> RGBGamut
- primaries :: RGBGamut -> RGB (Chromaticity Rational)
- whitePoint :: RGBGamut -> Chromaticity Rational
- inGamut :: (Ord a, Fractional a) => RGBGamut -> Colour a -> Bool
- data TransferFunction a = TransferFunction {
  - transfer :: a -> a
  - transferInverse :: a -> a
  - transferGamma :: a
  }
- linearTransferFunction :: Num a => TransferFunction a
- powerTransferFunction :: Floating a => a -> TransferFunction a
- inverseTransferFunction :: Fractional a => TransferFunction a -> TransferFunction a
- data RGBSpace a
- mkRGBSpace :: RGBGamut -> TransferFunction a -> RGBSpace a
- gamut :: RGBSpace a -> RGBGamut
- transferFunction :: RGBSpace a -> TransferFunction a
- linearRGBSpace :: Num a => RGBGamut -> RGBSpace a
- rgbUsingSpace :: Fractional a => RGBSpace a -> a -> a -> a -> Colour a
- toRGBUsingSpace :: Fractional a => RGBSpace a -> Colour a -> RGB a

# Documentation

data Colour a Source #

This type represents the human preception of colour. The `a` parameter is a numeric type used internally for the representation.

The `Monoid` instance allows one to add colours, but beware that adding colours can take you out of gamut. Consider using `blend` whenever possible.

#### Instances

Instances details

ColourOps Colour Source # |
Instance details Defined in Data.Colour.Internal Methods over :: Num a => AlphaColour a -> Colour a -> Colour a Source # darken :: Num a => a -> Colour a -> Colour a Source #
AffineSpace Colour Source # |
Instance details Defined in Data.Colour.Internal Methods affineCombo :: Num a => [(a, Colour a)] -> Colour a -> Colour a Source #
Eq a => Eq (Colour a) Source # |
Instance details Defined in Data.Colour.Internal Methods (==) :: Colour a -> Colour a -> Bool (/=) :: Colour a -> Colour a -> Bool
(Fractional a, Read a) => Read (Colour a) |
Instance details Defined in Data.Colour Methods readsPrec :: Int -> ReadS (Colour a) readList :: ReadS [Colour a] readPrec :: ReadPrec (Colour a) readListPrec :: ReadPrec [Colour a]
(Fractional a, Show a) => Show (Colour a) |
Instance details Defined in Data.Colour Methods showsPrec :: Int -> Colour a -> ShowS show :: Colour a -> String showList :: [Colour a] -> ShowS
Num a => Semigroup (Colour a) Source # |
Instance details Defined in Data.Colour.Internal Methods (<>) :: Colour a -> Colour a -> Colour a sconcat :: NonEmpty (Colour a) -> Colour a stimes :: Integral b => b -> Colour a -> Colour a
Num a => Monoid (Colour a) Source # |
Instance details Defined in Data.Colour.Internal Methods mempty :: Colour a mappend :: Colour a -> Colour a -> Colour a mconcat :: [Colour a] -> Colour a

# RGB Tuple

data RGB a Source #

An RGB triple for an unspecified colour space.

Constructors

RGB |

Fields

- channelRed :: !a
- channelGreen :: !a
- channelBlue :: !a

#### Instances

Instances details

Functor RGB Source # |
Instance details Defined in Data.Colour.RGB Methods fmap :: (a -> b) -> RGB a -> RGB b (<$) :: a -> RGB b -> RGB a
Applicative RGB Source # |
Instance details Defined in Data.Colour.RGB Methods pure :: a -> RGB a (<*>) :: RGB (a -> b) -> RGB a -> RGB b liftA2 :: (a -> b -> c) -> RGB a -> RGB b -> RGB c (*>) :: RGB a -> RGB b -> RGB b (<*) :: RGB a -> RGB b -> RGB a
Eq a => Eq (RGB a) Source # |
Instance details Defined in Data.Colour.RGB Methods (==) :: RGB a -> RGB a -> Bool (/=) :: RGB a -> RGB a -> Bool
Read a => Read (RGB a) Source # |
Instance details Defined in Data.Colour.RGB Methods readsPrec :: Int -> ReadS (RGB a) readList :: ReadS [RGB a] readPrec :: ReadPrec (RGB a) readListPrec :: ReadPrec [RGB a]
Show a => Show (RGB a) Source # |
Instance details Defined in Data.Colour.RGB Methods showsPrec :: Int -> RGB a -> ShowS show :: RGB a -> String showList :: [RGB a] -> ShowS

uncurryRGB :: (a -> a -> a -> b) -> RGB a -> b Source #

Uncurries a function expecting three r, g, b parameters.

curryRGB :: (RGB a -> b) -> a -> a -> a -> b Source #

Curries a function expecting one RGB parameter.

# RGB Gamut

data RGBGamut Source #

An `RGBGamut` is a 3-D colour “cube” that contains all the colours that can be displayed by a RGB device. The “cube” is normalized so that white has `luminance` 1.

#### Instances

Instances details

Eq RGBGamut Source # |
Instance details Defined in Data.Colour.RGB Methods (==) :: RGBGamut -> RGBGamut -> Bool (/=) :: RGBGamut -> RGBGamut -> Bool
Read RGBGamut Source # |
Instance details Defined in Data.Colour.RGB Methods readsPrec :: Int -> ReadS RGBGamut readList :: ReadS [RGBGamut] readPrec :: ReadPrec RGBGamut readListPrec :: ReadPrec [RGBGamut]
Show RGBGamut Source # |
Instance details Defined in Data.Colour.RGB Methods showsPrec :: Int -> RGBGamut -> ShowS show :: RGBGamut -> String showList :: [RGBGamut] -> ShowS

mkRGBGamut Source #

Arguments

:: RGB (Chromaticity Rational) | The three primaries
-> Chromaticity Rational | The white point
-> RGBGamut |

An RGB gamut is specified by three primary colours (red, green, and blue) and a white point (often `d65`).

primaries :: RGBGamut -> RGB (Chromaticity Rational) Source #

whitePoint :: RGBGamut -> Chromaticity Rational Source #

inGamut :: (Ord a, Fractional a) => RGBGamut -> Colour a -> Bool Source #

Returns `True` if the given colour lies inside the given gamut.

# RGB Space

data TransferFunction a Source #

A `transfer` function is a function that typically translates linear colour space coordinates into non-linear coordinates. The `transferInverse` function reverses this by translating non-linear colour space coordinates into linear coordinates. It is required that

    transfer . transferInverse === id === transferInverse . inverse

(or that this law holds up to floating point rounding errors).

We also require that `transfer` is approximately `(**transferGamma)` (and hence `transferInverse` is approximately `(**(recip transferGamma))`). The value `transferGamma` is for informational purposes only, so there is no bound on how good this approximation needs to be.

Constructors

TransferFunction |

Fields

- transfer :: a -> a
- transferInverse :: a -> a
- transferGamma :: a

#### Instances

Instances details

Num a => Semigroup (TransferFunction a) Source # |
Instance details Defined in Data.Colour.RGBSpace Methods (<>) :: TransferFunction a -> TransferFunction a -> TransferFunction a sconcat :: NonEmpty (TransferFunction a) -> TransferFunction a stimes :: Integral b => b -> TransferFunction a -> TransferFunction a
Num a => Monoid (TransferFunction a) Source # |
Instance details Defined in Data.Colour.RGBSpace Methods mempty :: TransferFunction a mappend :: TransferFunction a -> TransferFunction a -> TransferFunction a mconcat :: [TransferFunction a] -> TransferFunction a

linearTransferFunction :: Num a => TransferFunction a Source #

This is the identity `TransferFunction`.

powerTransferFunction :: Floating a => a -> TransferFunction a Source #

This is the `(**gamma)` `TransferFunction`.

inverseTransferFunction :: Fractional a => TransferFunction a -> TransferFunction a Source #

This reverses a `TransferFunction`.

data RGBSpace a Source #

An `RGBSpace` is a colour coordinate system for colours laying `inGamut` of `gamut`. Linear coordinates are passed through a `transferFunction` to produce non-linear `RGB` values.

mkRGBSpace :: RGBGamut -> TransferFunction a -> RGBSpace a Source #

An RGBSpace is specified by an `RGBGamut` and a `TransferFunction`.

gamut :: RGBSpace a -> RGBGamut Source #

transferFunction :: RGBSpace a -> TransferFunction a Source #

linearRGBSpace :: Num a => RGBGamut -> RGBSpace a Source #

Produce a linear colour space from an `RGBGamut`.

rgbUsingSpace :: Fractional a => RGBSpace a -> a -> a -> a -> Colour a Source #

Create a `Colour` from red, green, and blue coordinates given in a general `RGBSpace`.

toRGBUsingSpace :: Fractional a => RGBSpace a -> Colour a -> RGB a Source #

Return the coordinates of a given `Colour` for a general `RGBSpace`.