From 693215792b21933a8943621a560c0400a19bbdf4 Mon Sep 17 00:00:00 2001 From: nek0 Date: Sat, 26 Mar 2016 08:49:24 +0100 Subject: [PATCH] better overflow for RGBA creation --- src/Affection/Types.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Affection/Types.hs b/src/Affection/Types.hs index 0c350ef..93bc849 100644 --- a/src/Affection/Types.hs +++ b/src/Affection/Types.hs @@ -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