gloss-1.13.2.1: Painless 2D vector graphics, animations and simulations.

Safe Haskell | None
Language | Haskell2010

Graphics.Gloss.Data.Color

Contents

- Color data type
- Color functions
- Pre-defined colors
  - Primary
  - Secondary
  - Tertiary

Description

Predefined and custom colors.

Synopsis

- data Color
- makeColor :: Float -> Float -> Float -> Float -> Color
- makeColorI :: Int -> Int -> Int -> Int -> Color
- rgbaOfColor :: Color -> (Float, Float, Float, Float)
- mixColors :: Float -> Float -> Color -> Color -> Color
- addColors :: Color -> Color -> Color
- dim :: Color -> Color
- bright :: Color -> Color
- light :: Color -> Color
- dark :: Color -> Color
- withRed :: Float -> Color -> Color
- withGreen :: Float -> Color -> Color
- withBlue :: Float -> Color -> Color
- withAlpha :: Float -> Color -> Color
- greyN :: Float -> Color
- black :: Color
- white :: Color
- red :: Color
- green :: Color
- blue :: Color
- yellow :: Color
- cyan :: Color
- magenta :: Color
- rose :: Color
- violet :: Color
- azure :: Color
- aquamarine :: Color
- chartreuse :: Color
- orange :: Color

## Color data type

data Color #

An abstract color value. We keep the type abstract so we can be sure that the components are in the required range. To make a custom color use `makeColor`.

#### Instances

Instances details

Eq Color |
Instance details Defined in Graphics.Gloss.Internals.Data.Color Methods (==) :: Color -> Color -> Bool # (/=) :: Color -> Color -> Bool #
Data Color |
Instance details Defined in Graphics.Gloss.Internals.Data.Color Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Color -> c Color # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Color # toConstr :: Color -> Constr # dataTypeOf :: Color -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Color) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Color) # gmapT :: (forall b. Data b => b -> b) -> Color -> Color # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Color -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Color -> r # gmapQ :: (forall d. Data d => d -> u) -> Color -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Color -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Color -> m Color # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Color -> m Color # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Color -> m Color #
Num Color |
Instance details Defined in Graphics.Gloss.Internals.Data.Color Methods (+) :: Color -> Color -> Color # (-) :: Color -> Color -> Color # (*) :: Color -> Color -> Color # negate :: Color -> Color # abs :: Color -> Color # signum :: Color -> Color # fromInteger :: Integer -> Color #
Show Color |
Instance details Defined in Graphics.Gloss.Internals.Data.Color Methods showsPrec :: Int -> Color -> ShowS # show :: Color -> String # showList :: [Color] -> ShowS #

makeColor #

Arguments

:: Float | Red component.
-> Float | Green component.
-> Float | Blue component.
-> Float | Alpha component.
-> Color |

Make a custom color. All components are clamped to the range [0..1].

makeColorI :: Int -> Int -> Int -> Int -> Color #

Make a custom color. All components are clamped to the range [0..255].

rgbaOfColor :: Color -> (Float, Float, Float, Float) #

Take the RGBA components of a color.

## Color functions

mixColors #

Arguments

:: Float | Proportion of first color.
-> Float | Proportion of second color.
-> Color | First color.
-> Color | Second color.
-> Color | Resulting color.

Mix two colors with the given ratios.

addColors :: Color -> Color -> Color #

Add RGB components of a color component-wise, then normalise them to the highest resulting one. The alpha components are averaged.

dim :: Color -> Color #

Make a dimmer version of a color, scaling towards black.

bright :: Color -> Color #

Make a brighter version of a color, scaling towards white.

light :: Color -> Color #

Lighten a color, adding white.

dark :: Color -> Color #

Darken a color, adding black.

withRed :: Float -> Color -> Color #

Set the red value of a `Color`.

withGreen :: Float -> Color -> Color #

Set the green value of a `Color`.

withBlue :: Float -> Color -> Color #

Set the blue value of a `Color`.

withAlpha :: Float -> Color -> Color #

Set the alpha value of a `Color`.

## Pre-defined colors

greyN :: Float -> Color #

A greyness of a given order.

Range is 0 = black, to 1 = white.

black :: Color #

white :: Color #

### Primary

red :: Color #

green :: Color #

blue :: Color #

### Secondary

yellow :: Color #

cyan :: Color #

magenta :: Color #

### Tertiary

rose :: Color #

violet :: Color #

azure :: Color #

aquamarine :: Color #

chartreuse :: Color #

orange :: Color #