imj-base-0.1.0.2: Game engine with geometry, easing, animated text, delta rendering.

Safe HaskellNone
LanguageHaskell2010

Imj.Graphics.Color

Contents

Synopsis

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.

data Color8 a Source #

ANSI allows for a palette of up to 256 8-bit colors.

Instances

Enum (Color8 a) Source # 

Methods

succ :: Color8 a -> Color8 a #

pred :: Color8 a -> Color8 a #

toEnum :: Int -> Color8 a #

fromEnum :: Color8 a -> Int #

enumFrom :: Color8 a -> [Color8 a] #

enumFromThen :: Color8 a -> Color8 a -> [Color8 a] #

enumFromTo :: Color8 a -> Color8 a -> [Color8 a] #

enumFromThenTo :: Color8 a -> Color8 a -> Color8 a -> [Color8 a] #

Eq (Color8 a) Source # 

Methods

(==) :: Color8 a -> Color8 a -> Bool #

(/=) :: Color8 a -> Color8 a -> Bool #

Read (Color8 a) Source # 
Show (Color8 a) Source # 

Methods

showsPrec :: Int -> Color8 a -> ShowS #

show :: Color8 a -> String #

showList :: [Color8 a] -> ShowS #

DiscreteDistance (Color8 a) Source #

Using bresenham 3D algorithm in RGB space.

DiscreteInterpolation (Color8 a) Source #

Using bresenham 3D algorithm in RGB space.

Create a single color

rgb Source #

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]

gray Source #

Arguments

:: Word8

gray value in [0..23]

-> Color8 a 

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

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.

Predefined colors