diff --git a/src/Affection/Render.hs b/src/Affection/Render.hs index 3e4b12b..8b5f9bc 100644 --- a/src/Affection/Render.hs +++ b/src/Affection/Render.hs @@ -72,12 +72,12 @@ inRender _ (TLiftIO x) = return =<< x inRender r (TRender f) = f r changeColor :: RGBA -> RenderT RenderM () -changeColor colours = TRender $ \r -> - SDL.rendererDrawColor r SDL.$= V4 - (fromIntegral $ getR colours) - (fromIntegral $ getG colours) - (fromIntegral $ getB colours) - (fromIntegral $ getA colours) +changeColor (RGBA r g b a) = TRender $ \rend -> + SDL.rendererDrawColor rend SDL.$= V4 + (fromIntegral r) + (fromIntegral g) + (fromIntegral b) + (fromIntegral a) clear :: RenderT RenderM () clear = TRender $ \r -> SDL.clear r diff --git a/src/Affection/Types.hs b/src/Affection/Types.hs index 93bc849..4807ab4 100644 --- a/src/Affection/Types.hs +++ b/src/Affection/Types.hs @@ -1,29 +1,10 @@ module Affection.Types - ( RGBA - , newRGBA - , getR - , getG - , getB - , getA + ( RGBA(..) ) where -data RGBA = RGBA Int Int Int Int - -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 = x - (x `div` 256) * 255 + 1 - | otherwise = x - (x `div` 256) * 255 - -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 +data RGBA = RGBA + { r :: Int + , g :: Int + , b :: Int + , a :: Int + }