module Data.Colour.RGBSpace.HSL
(RGB
,hslView
,hue, saturation, lightness
,hsl
)
where
import Data.Colour.RGB
hslView :: (Fractional a, Ord a) => RGB a -> (a,a,a)
hslView :: forall a. (Fractional a, Ord a) => RGB a -> (a, a, a)
hslView RGB a
rgb = (a
h,a
s,a
l)
where
(a
h,a
s,a
l,a
_,a
_) = forall a. (Fractional a, Ord a) => RGB a -> (a, a, a, a, a)
hslsv RGB a
rgb
saturation :: (Fractional a, Ord a) => RGB a -> a
saturation :: forall a. (Fractional a, Ord a) => RGB a -> a
saturation RGB a
rgb = a
s
where
(a
_,a
s,a
_,a
_,a
_) = forall a. (Fractional a, Ord a) => RGB a -> (a, a, a, a, a)
hslsv RGB a
rgb
lightness :: (Fractional a, Ord a) => RGB a -> a
lightness :: forall a. (Fractional a, Ord a) => RGB a -> a
lightness RGB a
rgb = a
l
where
(a
_,a
_,a
l,a
_,a
_) = forall a. (Fractional a, Ord a) => RGB a -> (a, a, a, a, a)
hslsv RGB a
rgb
hsl :: (RealFrac a, Ord a) => a -> a -> a -> RGB a
hsl :: forall a. (RealFrac a, Ord a) => a -> a -> a -> RGB a
hsl a
h a
s a
l = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> a
component RGB a
t
where
hk :: a
hk = a
hforall a. Fractional a => a -> a -> a
/a
360
tr :: a
tr = forall {a}. RealFrac a => a -> a
mod1 (a
hk forall a. Num a => a -> a -> a
+ a
1forall a. Fractional a => a -> a -> a
/a
3)
tg :: a
tg = forall {a}. RealFrac a => a -> a
mod1 a
hk
tb :: a
tb = forall {a}. RealFrac a => a -> a
mod1 (a
hk forall a. Num a => a -> a -> a
- a
1forall a. Fractional a => a -> a -> a
/a
3)
t :: RGB a
t = forall a. a -> a -> a -> RGB a
RGB a
tr a
tg a
tb
q :: a
q | a
l forall a. Ord a => a -> a -> Bool
< a
0.5 = a
lforall a. Num a => a -> a -> a
*(a
1forall a. Num a => a -> a -> a
+a
s)
| Bool
otherwise = a
l forall a. Num a => a -> a -> a
+ a
s forall a. Num a => a -> a -> a
- a
lforall a. Num a => a -> a -> a
*a
s
p :: a
p = a
2forall a. Num a => a -> a -> a
*a
l forall a. Num a => a -> a -> a
- a
q
component :: a -> a
component a
t | a
t forall a. Ord a => a -> a -> Bool
< a
1forall a. Fractional a => a -> a -> a
/a
6 = a
p forall a. Num a => a -> a -> a
+ ((a
qforall a. Num a => a -> a -> a
-a
p)forall a. Num a => a -> a -> a
*a
6forall a. Num a => a -> a -> a
*a
t)
| a
t forall a. Ord a => a -> a -> Bool
< a
1forall a. Fractional a => a -> a -> a
/a
2 = a
q
| a
t forall a. Ord a => a -> a -> Bool
< a
2forall a. Fractional a => a -> a -> a
/a
3 = a
p forall a. Num a => a -> a -> a
+ ((a
qforall a. Num a => a -> a -> a
-a
p)forall a. Num a => a -> a -> a
*a
6forall a. Num a => a -> a -> a
*(a
2forall a. Fractional a => a -> a -> a
/a
3forall a. Num a => a -> a -> a
-a
t))
| Bool
otherwise = a
p