| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Imj.Graphics.Color
- data Color8 a
- rgb :: Word8 -> Word8 -> Word8 -> Color8 a
- gray :: Word8 -> Color8 a
- data LayeredColor = LayeredColor {}
- data Background
- data Foreground
- onBlack :: Color8 Foreground -> LayeredColor
- whiteOnBlack :: LayeredColor
- white :: Color8 a
- black :: Color8 a
- red :: Color8 a
- green :: Color8 a
- magenta :: Color8 a
- cyan :: Color8 a
- yellow :: Color8 a
- blue :: Color8 a
8-bits colors
There are several types of colors we can use to draw in a terminal. Here, we support 8-bit colors.
8-bit colors have 6*6*6 = 216 rgb colors, 24 grays and are represented by
Color8. You can create a Color8 ny using rgb or gray.
It is possible to interpolate between two colors in RGB space using the
DiscreteInterpolation instance of Color8.
We also have LayeredColor because when drawing in the terminal, we can
change both the Background and the Foreground color.
ANSI allows for a palette of up to 256 8-bit colors.
Create a single color
Arguments
| :: Word8 | red component in [0..5] |
| -> Word8 | green component in [0..5] |
| -> Word8 | blue component in [0..5] |
| -> Color8 a |
Creates a rgb Color8 as defined in
ANSI 8-bit colors
Input components are expected to be in range [0..5]
Creates a gray Color8 as defined in
ANSI 8-bit colors
Input is expected to be in the range [0..23] (from darkest to lightest)
Create a LayeredColor
data LayeredColor Source #
A background and a foreground Color8.
Constructors
| LayeredColor | |
Fields
| |
Instances
| Eq LayeredColor Source # | |
| Show LayeredColor Source # | |
| DiscreteDistance LayeredColor Source # | First interpolate background color, then foreground color |
| DiscreteInterpolation LayeredColor Source # | First interpolate background color, then foreground color |
data Background Source #
data Foreground Source #
onBlack :: Color8 Foreground -> LayeredColor Source #
Creates a LayeredColor with a black background color.
whiteOnBlack :: LayeredColor Source #
Creates a LayeredColor with white foreground and black background color.