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) = 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
_) = 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) = 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 -> forall a. a -> a -> a -> RGB a
RGB a
v a
t a
p
Integer
1 -> forall a. a -> a -> a -> RGB a
RGB a
q a
v a
p
Integer
2 -> forall a. a -> a -> a -> RGB a
RGB a
p a
v a
t
Integer
3 -> forall a. a -> a -> a -> RGB a
RGB a
p a
q a
v
Integer
4 -> forall a. a -> a -> a -> RGB a
RGB a
t a
p a
v
Integer
5 -> forall a. a -> a -> a -> RGB a
RGB a
v a
p a
q
where
hi :: Integer
hi = forall a b. (RealFrac a, Integral b) => a -> b
floor (a
hforall a. Fractional a => a -> a -> a
/a
60) forall a. Integral a => a -> a -> a
`mod` Integer
6
f :: a
f = forall {a}. RealFrac a => a -> a
mod1 (a
hforall a. Fractional a => a -> a -> a
/a
60)
p :: a
p = a
vforall a. Num a => a -> a -> a
*(a
1forall a. Num a => a -> a -> a
-a
s)
q :: a
q = a
vforall a. Num a => a -> a -> a
*(a
1forall a. Num a => a -> a -> a
-a
fforall a. Num a => a -> a -> a
*a
s)
t :: a
t = a
vforall a. Num a => a -> a -> a
*(a
1forall a. Num a => a -> a -> a
-(a
1forall a. Num a => a -> a -> a
-a
f)forall a. Num a => a -> a -> a
*a
s)