- Main Page
- Modules
- Files
- Related Pages

# color manipulations
[g2 User Interface]

## Functions
void | g2_pen (int dev, int color)
void | g2_set_background (int dev, int color)
int | g2_ink (int pd_dev, double red, double green, double blue)
void | g2_reset_palette (int dev)
void | g2_clear_palette (int dev)
void | g2_allocate_basic_colors (int dev)

## Detailed Description

The color concept used in the g2 library is inspired by Sir Clive Sinclair solution implemented in the ZX Spectrum computer. With the g2_pen() function it is possible to choose a pen created by the g2_ink() function. Note that g2_ink function is only defined for physical devices. The predefined colors (see g2_test demo program) have pens from 0 till 26 (inclusive).

Some basic colors are:

- 0 white
- 1 black
- 3 blue
- 7 green
- 19 red
- 25 yellow

## Function Documentation

void g2_allocate_basic_colors | ( | int | dev | ) |

  | Allocate basic colors Parameters:
  | dev | device

void g2_clear_palette | ( | int | dev | ) |

  | Remove all inks. Parameters:
  | dev | device

int g2_ink | ( | int | pd_dev,
|  | double | red,
|  | double | green,
|  | double | blue
| ) |

  | Create an ink. To put ink into the pen use g2_pen(). Parameters:
  | pd_dev | physical device
  | red | red component (0-1) according to the RGB color model
  | green | green component (0-1) according to the RGB color model
  | blue | blue component (0-1) according to the RGB color model
Returns: new pen, see g2_pen()

void g2_pen | ( | int | dev,
|  | int | color
| ) |

  | Set pen color for all following operations, see also g2_ink(). Parameters:
  | dev | device
  | color | pen (either one of default pens 0-26, or a pen returned by g2_ink() )

void g2_reset_palette | ( | int | dev | ) |

  | Clear collor palette (remove all inks) and reallocate basic colors. Parameters:
  | dev | device

void g2_set_background | ( | int | dev,
|  | int | color
| ) |

  | Set the background color Parameters:
  | dev | device
  | color | pen (either one of default pens 0-26, or a pen returned by g2_ink() )