module Data.Colour.RGBSpace.HSV
(RGB
,hsvView
,hue, saturation, value
,hsv
)
where
import Data.Colour.RGB
hsvView :: (Fractional a, Ord a) => RGB a -> (a,a,a)
hsvView :: forall a. (Fractional a, Ord a) => RGB a -> (a, a, a)
hsvView RGB a
rgb = (a
h,a
s,a
v)
where
(a
h,a
_,a
_,a
s,a
v) = RGB a -> (a, a, a, 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
_,a
_,a
s,a
_) = RGB a -> (a, a, a, a, a)
forall a. (Fractional a, Ord a) => RGB a -> (a, a, a, a, a)
hslsv RGB a
rgb
value :: (Fractional a, Ord a) => RGB a -> a
value :: forall a. (Fractional a, Ord a) => RGB a -> a
value RGB a
rgb = a
v
where
(a
_,a
_,a
_,a
_,a
v) = RGB a -> (a, a, a, a, a)
forall a. (Fractional a, Ord a) => RGB a -> (a, a, a, a, a)
hslsv RGB a
rgb
hsv :: (RealFrac a, Ord a) => a -> a -> a -> RGB a
hsv :: forall a. (RealFrac a, Ord a) => a -> a -> a -> RGB a
hsv a
h a
s a
v = case Integer
hi of
Integer
0 -> a -> a -> a -> RGB a
forall a. a -> a -> a -> RGB a
RGB a
v a
t a
p
Integer
1 -> a -> a -> a -> RGB a
forall a. a -> a -> a -> RGB a
RGB a
q a
v a
p
Integer
2 -> a -> a -> a -> RGB a
forall a. a -> a -> a -> RGB a
RGB a
p a
v a
t
Integer
3 -> a -> a -> a -> RGB a
forall a. a -> a -> a -> RGB a
RGB a
p a
q a
v
Integer
4 -> a -> a -> a -> RGB a
forall a. a -> a -> a -> RGB a
RGB a
t a
p a
v
Integer
5 -> a -> a -> a -> RGB a
forall a. a -> a -> a -> RGB a
RGB a
v a
p a
q
where
hi :: Integer
hi = a -> Integer
forall b. Integral b => a -> b
forall a b. (RealFrac a, Integral b) => a -> b
floor (a
ha -> a -> a
forall a. Fractional a => a -> a -> a
/a
60) Integer -> Integer -> Integer
forall a. Integral a => a -> a -> a
`mod` Integer
6
f :: a
f = a -> a
forall {a}. RealFrac a => a -> a
mod1 (a
ha -> a -> a
forall a. Fractional a => a -> a -> a
/a
60)
p :: a
p = a
va -> a -> a
forall a. Num a => a -> a -> a
*(a
1a -> a -> a
forall a. Num a => a -> a -> a
-a
s)
q :: a
q = a
va -> a -> a
forall a. Num a => a -> a -> a
*(a
1a -> a -> a
forall a. Num a => a -> a -> a
-a
fa -> a -> a
forall a. Num a => a -> a -> a
*a
s)
t :: a
t = a
va -> a -> a
forall a. Num a => a -> a -> a
*(a
1a -> a -> a
forall a. Num a => a -> a -> a
-(a
1a -> a -> a
forall a. Num a => a -> a -> a
-a
f)a -> a -> a
forall a. Num a => a -> a -> a
*a
s)