@@ -1,12 +1,13 @@
1-- This header file was generated by ./256colres.pl
1-- This header file was generated by ./256colres.pl
2module Graphics.Vty.Attributes.Color240
2module Graphics.Vty.Attributes.Color240
4− , color240ToRGB
4+ , color240CodeToRGB
8import Graphics.Vty.Attributes.Color
8import Graphics.Vty.Attributes.Color
10+import Data.Word (Word8)
10import Text.Printf
11import Text.Printf
12-- Note: rgbColor's mapping from RGB to 240 colors was generated from
13-- Note: rgbColor's mapping from RGB to 240 colors was generated from
@@ -263,10 +264,9 @@ rgbColor r g b
263 (fromIntegral g :: Int)
264 (fromIntegral g :: Int)
264 (fromIntegral b :: Int))
265 (fromIntegral b :: Int))
266−-- | Create a RGB triple from a Vty 'Color' (in the 240 color set). Error if Color is not
267+-- | Create a RGB triple from a value in the Color240 set.
267−-- a Color240.
268+color240CodeToRGB :: Word8 -> (Int, Int, Int)
268−color240ToRGB :: Color -> (Int, Int, Int)
269+color240CodeToRGB n = case n of
269−color240ToRGB (Color240 n) = case n of
270 0 -> (0, 0, 0)
270 0 -> (0, 0, 0)
271 1 -> (0, 0, 95)
271 1 -> (0, 0, 95)
272 2 -> (0, 0, 135)
272 2 -> (0, 0, 135)
@@ -507,5 +507,4 @@ color240ToRGB (Color240 n) = case n of
507 237 -> (218, 218, 218)
507 237 -> (218, 218, 218)
508 238 -> (228, 228, 228)
508 238 -> (228, 228, 228)
509 239 -> (238, 238, 238)
509 239 -> (238, 238, 238)
510− _ -> error (printf "Color240 %d is invalid." n)
510+ _ -> error (printf "Color240 value %d is invalid." n)
511−color240ToRGB _ = error "tried to map non-Color240 to RGB"