overflow handling not needed. SDL does it.

This commit is contained in:
nek0 2016-03-26 09:33:38 +01:00
parent 693215792b
commit 2e8a31c731
2 changed files with 13 additions and 32 deletions

View file

@ -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

View file

@ -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
}