overflow handling not needed. SDL does it.
This commit is contained in:
parent
693215792b
commit
2e8a31c731
2 changed files with 13 additions and 32 deletions
|
@ -72,12 +72,12 @@ inRender _ (TLiftIO x) = return =<< x
|
||||||
inRender r (TRender f) = f r
|
inRender r (TRender f) = f r
|
||||||
|
|
||||||
changeColor :: RGBA -> RenderT RenderM ()
|
changeColor :: RGBA -> RenderT RenderM ()
|
||||||
changeColor colours = TRender $ \r ->
|
changeColor (RGBA r g b a) = TRender $ \rend ->
|
||||||
SDL.rendererDrawColor r SDL.$= V4
|
SDL.rendererDrawColor rend SDL.$= V4
|
||||||
(fromIntegral $ getR colours)
|
(fromIntegral r)
|
||||||
(fromIntegral $ getG colours)
|
(fromIntegral g)
|
||||||
(fromIntegral $ getB colours)
|
(fromIntegral b)
|
||||||
(fromIntegral $ getA colours)
|
(fromIntegral a)
|
||||||
|
|
||||||
clear :: RenderT RenderM ()
|
clear :: RenderT RenderM ()
|
||||||
clear = TRender $ \r -> SDL.clear r
|
clear = TRender $ \r -> SDL.clear r
|
||||||
|
|
|
@ -1,29 +1,10 @@
|
||||||
module Affection.Types
|
module Affection.Types
|
||||||
( RGBA
|
( RGBA(..)
|
||||||
, newRGBA
|
|
||||||
, getR
|
|
||||||
, getG
|
|
||||||
, getB
|
|
||||||
, getA
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
data RGBA = RGBA Int Int Int Int
|
data RGBA = RGBA
|
||||||
|
{ r :: Int
|
||||||
newRGBA :: Int -> Int -> Int -> Int -> RGBA
|
, g :: Int
|
||||||
newRGBA r g b a = RGBA (overflow r) (overflow g) (overflow b) (overflow a)
|
, b :: Int
|
||||||
where
|
, a :: Int
|
||||||
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
|
|
||||||
|
|
Loading…
Reference in a new issue