2016-03-25 15:58:46 +00:00
|
|
|
module Affection.Types
|
2016-03-26 02:50:39 +00:00
|
|
|
( RGBA
|
|
|
|
, newRGBA
|
|
|
|
, getR
|
|
|
|
, getG
|
|
|
|
, getB
|
|
|
|
, getA
|
2016-03-25 15:58:46 +00:00
|
|
|
) where
|
|
|
|
|
2016-03-26 02:50:39 +00:00
|
|
|
data RGBA = RGBA Int Int Int Int
|
2016-03-25 15:58:46 +00:00
|
|
|
|
|
|
|
newRGBA :: Int -> Int -> Int -> Int -> RGBA
|
|
|
|
newRGBA r g b a = RGBA (overflow r) (overflow g) (overflow b) (overflow a)
|
|
|
|
where
|
|
|
|
overflow x
|
|
|
|
| x < 0 = 255 + (x `mod` 255)
|
|
|
|
| otherwise = x `mod` 255
|
2016-03-26 02:50:39 +00:00
|
|
|
|
|
|
|
getR :: RGBA -> Int
|
|
|
|
getR (RGBA r _ _ _) = r
|
|
|
|
|
|
|
|
getG :: RGBA -> Int
|
|
|
|
getG (RGBA _ g _ _) = g
|
|
|
|
|
|
|
|
getB :: RGBA -> Int
|
|
|
|
getB (RGBA _ _ b _) = b
|
|
|
|
|
|
|
|
getA :: RGBA -> Int
|
|
|
|
getA (RGBA _ _ _ a) = a
|