generative-art-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Draw.Color

Description

Utilities to manipulate colors, and setting them for Cairo drawings.

Synopsis

Documentation

type Color a = Colour a Source #

American English type synonym

type AlphaColor a = AlphaColour a Source #

American English type synonym

class CairoColor color where Source #

Anything we can instruct Cairo to set its color to.

Minimal complete definition

Nothing

Methods

setColor :: color -> Render () Source #

>>> :{
haddockRender "Draw/Color/set_color.svg" 140 40 $ \_ -> do
    for_ (zip [0..] [30, 40 .. 150-30]) $ \(i, x) -> do
        setColor (mma i)
        sketch (Circle (Vec2 x 20) 10)
        C.fill
:}
Generated file: size 4KB, crc32: 0xe0e16234

setColour :: color -> Render () Source #

Instances

Instances details
(Real a, Floating a) => CairoColor (AlphaColour a) Source # 
Instance details

Defined in Draw.Color

Methods

setColor :: AlphaColour a -> Render () Source #

setColour :: AlphaColour a -> Render () Source #

Real a => CairoColor (Colour a) Source # 
Instance details

Defined in Draw.Color

Methods

setColor :: Colour a -> Render () Source #

setColour :: Colour a -> Render () Source #

rgb Source #

Arguments

:: Double

Red [0..1]

-> Double

Green [0..1]

-> Double

Blue [0..1]

-> Color Double 

Convert a color from sRGB space

hsv Source #

Arguments

:: Double

Hue [0..360]

-> Double

Saturation [0..1]

-> Double

Value (~ brightness) [0..1]

-> Color Double 

Convert a color from HSV space

hsl Source #

Arguments

:: Double

Hue [0..360]

-> Double

Saturation [0..1]

-> Double

Lightness [0..1]

-> Color Double 

Convert a color from HSL space

rgba Source #

Arguments

:: Double

Red [0..1]

-> Double

Green [0..1]

-> Double

Blue [0..1]

-> Double

Alpha [0..1]

-> AlphaColor Double 

Convert a color from sRGBA space

hsva Source #

Arguments

:: Double

Hue [0..360]

-> Double

Saturation [0..1]

-> Double

Value (~ brightness) [0..1]

-> Double

Alpha [0..1]

-> AlphaColor Double 

Convert a color from HSVA space

hsla Source #

Arguments

:: Double

Hue [0..360]

-> Double

Saturation [0..1]

-> Double

Lightness [0..1]

-> Double

Alpha [0..1]

-> AlphaColor Double 

Convert a color from HSLA space

parseRgbaHex :: String -> AlphaColor Double Source #

Parse a RGBA hex value. errors on bad input, so be careful!

parseRgbaHex "0x123456ab"
==
rgba (fromIntegral 0x12255) (fromIntegral 0x34255) (fromIntegral 0x56255) (fromIntegral 0xab255)

parseRgbHex :: String -> Color Double Source #

Parse a RGB hex value. errors on bad input, so be careful!

parseRgbHex "0x123456"
==
rgb (fromIntegral 0x12255) (fromIntegral 0x34255) (fromIntegral 0x56/255)

data Colour a #

Instances

Instances details
AffineSpace Colour 
Instance details

Defined in Data.Colour.Internal

Methods

affineCombo :: Num a => [(a, Colour a)] -> Colour a -> Colour a #

ColourOps Colour 
Instance details

Defined in Data.Colour.Internal

Methods

over :: Num a => AlphaColour a -> Colour a -> Colour a #

darken :: Num a => a -> Colour a -> Colour a #

Num a => Monoid (Colour a) 
Instance details

Defined in Data.Colour.Internal

Methods

mempty :: Colour a #

mappend :: Colour a -> Colour a -> Colour a #

mconcat :: [Colour a] -> Colour a #

Num a => Semigroup (Colour a) 
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 #

Real a => CairoColor (Colour a) Source # 
Instance details

Defined in Draw.Color

Methods

setColor :: Colour a -> Render () Source #

setColour :: Colour a -> Render () Source #

Eq a => Eq (Colour a) 
Instance details

Defined in Data.Colour.Internal

Methods

(==) :: Colour a -> Colour a -> Bool #

(/=) :: Colour a -> Colour a -> Bool #

data AlphaColour a #

Instances

Instances details
AffineSpace AlphaColour 
Instance details

Defined in Data.Colour.Internal

Methods

affineCombo :: Num a => [(a, AlphaColour a)] -> AlphaColour a -> AlphaColour a #

ColourOps AlphaColour 
Instance details

Defined in Data.Colour.Internal

Methods

over :: Num a => AlphaColour a -> AlphaColour a -> AlphaColour a #

darken :: Num a => a -> AlphaColour a -> AlphaColour a #

Num a => Monoid (AlphaColour a) 
Instance details

Defined in Data.Colour.Internal

Num a => Semigroup (AlphaColour a) 
Instance details

Defined in Data.Colour.Internal

(Real a, Floating a) => CairoColor (AlphaColour a) Source # 
Instance details

Defined in Draw.Color

Methods

setColor :: AlphaColour a -> Render () Source #

setColour :: AlphaColour a -> Render () Source #

Eq a => Eq (AlphaColour a) 
Instance details

Defined in Data.Colour.Internal

class AffineSpace (f :: Type -> Type) where #

Methods

affineCombo :: Num a => [(a, f a)] -> f a -> f a #

Instances

Instances details
AffineSpace AlphaColour 
Instance details

Defined in Data.Colour.Internal

Methods

affineCombo :: Num a => [(a, AlphaColour a)] -> AlphaColour a -> AlphaColour a #

AffineSpace Colour 
Instance details

Defined in Data.Colour.Internal

Methods

affineCombo :: Num a => [(a, Colour a)] -> Colour a -> Colour a #

class ColourOps (f :: Type -> Type) where #

Methods

over :: Num a => AlphaColour a -> f a -> f a #

darken :: Num a => a -> f a -> f a #

Instances

Instances details
ColourOps AlphaColour 
Instance details

Defined in Data.Colour.Internal

Methods

over :: Num a => AlphaColour a -> AlphaColour a -> AlphaColour a #

darken :: Num a => a -> AlphaColour a -> AlphaColour a #

ColourOps Colour 
Instance details

Defined in Data.Colour.Internal

Methods

over :: Num a => AlphaColour a -> Colour a -> Colour a #

darken :: Num a => a -> Colour a -> Colour a #

dissolve :: Num a => a -> AlphaColour a -> AlphaColour a #

withOpacity :: Num a => Colour a -> a -> AlphaColour a #

blend :: (Num a, AffineSpace f) => a -> f a -> f a -> f a #

opaque :: Num a => Colour a -> AlphaColour a #

black :: Num a => Colour a #

white :: (Ord a, Floating a) => Colour a #

adjustHsl Source #

Arguments

:: (Double -> Double)

Adjust Hue [0..360]

-> (Double -> Double)

Adjust Saturation [0..1]

-> (Double -> Double)

Adjust Luminance [0..1]

-> Color Double 
-> Color Double 

Adjust a HSL value per component.

adjustHsv Source #

Arguments

:: (Double -> Double)

Adjust Hue [0..360]

-> (Double -> Double)

Adjust Saturation [0..1]

-> (Double -> Double)

Adjust Value (~ Brightness) [0..1]

-> Color Double 
-> Color Double 

Adjust a HSV value per component.