Safe Haskell  Safe 

Language  Haskell2010 
 data Red = Red
 data Green = Green
 data Blue = Blue
 data Colour a = RGB !(Chan Red a) !(Chan Green a) !(Chan Blue a)
 colourConvert :: (Fractional b, Real a) => Colour a > Colour b
 black :: Num a => Colour a
 data Alpha = Alpha
 data AlphaColour a = RGBA !(Colour a) !(Chan Alpha a)
 transparent :: Num a => AlphaColour a
 alphaColourConvert :: (Fractional b, Real a) => AlphaColour a > AlphaColour b
 opaque :: Num a => Colour a > AlphaColour a
 dissolve :: Num a => a > AlphaColour a > AlphaColour a
 withOpacity :: Num a => Colour a > a > AlphaColour a
 class AffineSpace f where
 blend :: (Num a, AffineSpace f) => a > f a > f a > f a
 class ColourOps f where
 atop :: Fractional a => AlphaColour a > AlphaColour a > AlphaColour a
 quantize :: (RealFrac a1, Integral a, Bounded a) => a1 > a
 alphaChannel :: AlphaColour a > a
 colourChannel :: Fractional a => AlphaColour a > Colour a
 rgbaAdd :: Num a => AlphaColour a > AlphaColour a > AlphaColour a
Documentation
colourConvert :: (Fractional b, Real a) => Colour a > Colour b Source #
Change the type used to represent the colour coordinates.
data AlphaColour a Source #
This type represents a Colour
that may be semitransparent.
The Monoid
instance allows you to composite colours.
x `mappend` y == x `over` y
To get the (premultiplied) colour channel of an AlphaColour
c
,
simply composite c
over black.
c `over` black
ColourOps AlphaColour Source #  
AffineSpace AlphaColour Source #  
Eq a => Eq (AlphaColour a) Source #  
Num a => Semigroup (AlphaColour a) Source # 

Num a => Monoid (AlphaColour a) Source #  
transparent :: Num a => AlphaColour a Source #
This AlphaColour
is entirely transparent and has no associated
colour channel.
alphaColourConvert :: (Fractional b, Real a) => AlphaColour a > AlphaColour b Source #
Change the type used to represent the colour coordinates.
opaque :: Num a => Colour a > AlphaColour a Source #
Creates an opaque AlphaColour
from a Colour
.
dissolve :: Num a => a > AlphaColour a > AlphaColour a Source #
Returns an AlphaColour
more transparent by a factor of o
.
withOpacity :: Num a => Colour a > a > AlphaColour a Source #
Creates an AlphaColour
from a Colour
with a given opacity.
c `withOpacity` o == dissolve o (opaque c)
class AffineSpace f where Source #
affineCombo :: Num a => [(a, f a)] > f a > f a Source #
Compute a affine Combination (weightedaverage) of points. The last parameter will get the remaining weight. e.g.
affineCombo [(0.2,a), (0.3,b)] c == 0.2*a + 0.3*b + 0.5*c
Weights can be negative, or greater than 1.0; however, be aware that nonconvex combinations may lead to out of gamut colours.
blend :: (Num a, AffineSpace f) => a > f a > f a > f a Source #
Compute the weighted average of two points. e.g.
blend 0.4 a b = 0.4*a + 0.6*b
The weight can be negative, or greater than 1.0; however, be aware that nonconvex combinations may lead to out of gamut colours.
class ColourOps f where Source #
over :: Num a => AlphaColour a > f a > f a Source #
c1 `over` c2
returns the Colour
created by compositing the
AlphaColour
c1
over c2
, which may be either a Colour
or
AlphaColour
.
darken :: Num a => a > f a > f a Source #
darken s c
blends a colour with black without changing it's opacity.
For Colour
, darken s c = blend s c mempty
atop :: Fractional a => AlphaColour a > AlphaColour a > AlphaColour a Source #
c1 `atop` c2
returns the AlphaColour
produced by covering
the portion of c2
visible by c1
.
The resulting alpha channel is always the same as the alpha channel
of c2
.
c1 `atop` (opaque c2) == c1 `over` (opaque c2) AlphaChannel (c1 `atop` c2) == AlphaChannel c2
alphaChannel :: AlphaColour a > a Source #
Returns the opacity of an AlphaColour
.
colourChannel :: Fractional a => AlphaColour a > Colour a Source #
Returns the colour of an AlphaColour
.
colourChannel transparent
is undefined and may result in nan
or an
error.
Its use is discouraged.
If you are desperate, use
darken (recip (alphaChannel c)) (c `over` black)
rgbaAdd :: Num a => AlphaColour a > AlphaColour a > AlphaColour a Source #