better overflow for RGBA creation

This commit is contained in:
nek0 2016-03-26 08:49:24 +01:00
parent 89fc700dfe
commit 693215792b

View file

@ -13,8 +13,8 @@ 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
| x < 0 = x - (x `div` 256) * 255 + 1
| otherwise = x - (x `div` 256) * 255
getR :: RGBA -> Int
getR (RGBA r _ _ _) = r