Coconut Data Framework  beta
Classes | Defines | Typedefs | Enumerations | Functions | Variables
CNColor.h File Reference

Functions to operate colors for OpenGL. More...

#import <Coconut/Coconut.h>
#import <OpenGL/gl.h>

Go to the source code of this file.

Classes

struct  CNColor

Defines

#define CNColorPartNum   4

Typedefs

typedef uint16_t CNColor16
 16bit color format to save/load file

Enumerations

enum  CNColorPartIndex { CNRedPos = 0, CNGreenPos = 1, CNBluePos = 2, CNAlphaPos = 3 }
enum  CNBasicColorId {
  CNBlackId = 'k', CNRedId = 'r', CNGreenId = 'g', CNBlueId = 'b',
  CNYellowId = 'y', CNMagentaId = 'm', CNCyanId = 'c', CNWhiteId = 'w',
  CNForegroundColorId = '*', CNBackgroundColorId = '.'
}

Functions

static GLfloat CNRedPartOfColor (const struct CNColor *src)
 Get red part in CNColor.
static GLfloat CNGreenPartOfColor (const struct CNColor *src)
 Get green part in CNColor.
static GLfloat CNBluePartOfColor (const struct CNColor *src)
 Get blue part in CNColor.
static GLfloat CNAlphaPartOfColor (const struct CNColor *src)
 Get alpha part in CNColor.
static const GLfloat * CNVectorInColor (const struct CNColor *src)
 Get vector of parts in CNColor.
static uint64_t CNHashValueOfColor (const struct CNColor *src)
 Get hash value for CNColor object.
static int CNCompareColor (const struct CNColor *src0, const struct CNColor *src1)
 Compare 2 colors.
static CNBasicColorId CNColorToBasicId (const struct CNColor *src)
 Get color by color-id.
static unsigned int CNColorPartToColor16Part (GLfloat src)
 Convert part of CNColor to CNColor16.
static CNColor16 CNColorToColor16 (const struct CNColor *src)
 Convert CNColor to CNColor16.

Variables

struct CNColorCNBlack
struct CNColorCNRed
struct CNColorCNGreen
struct CNColorCNBlue
struct CNColorCNYellow
struct CNColorCNMagenta
struct CNColorCNCyan
struct CNColorCNWhite
struct CNColorCNForegroundColor
struct CNColorCNBackgroundColor
static const CNBasicColorId CNNotBasicColorId = (CNBasicColorId) 0

Detailed Description

Functions to operate colors for OpenGL.

Copyright
Copyright (C) 2010 Steel Wheels Project

Define Documentation

#define CNColorPartNum   4

The number of components of CNColor


Enumeration Type Documentation

Index of the color part in CNColor

Enumerator:
CNRedPos 

Index of red in CNColor

CNGreenPos 

Index of green in CNColor

CNBluePos 

Index of blue in CNColor

CNAlphaPos 

Index of alpha in CNColor

Index of basic color in basic color table

Enumerator:
CNBlackId 

Id for color: black

CNRedId 

Id for color: red

CNGreenId 

Id for color: green

CNBlueId 

Id for color: blue

CNYellowId 

Id for color: yellow

CNMagentaId 

Id for color: magenta

CNCyanId 

Id for color: cyan

CNWhiteId 

Id for color: white

CNForegroundColorId 

Id for color: foreground-color

CNBackgroundColorId 

Id for color: background-color


Function Documentation

static GLfloat CNRedPartOfColor ( const struct CNColor src) [inline, static]

Get red part in CNColor.

Returns:
Red part of color
Parameters:
srcSource color

References CNRedPos, and CNColor::vector.

Referenced by CNColorToColor16().

static GLfloat CNGreenPartOfColor ( const struct CNColor src) [inline, static]

Get green part in CNColor.

Returns:
Green part of color
Parameters:
srcSource color

References CNGreenPos, and CNColor::vector.

Referenced by CNColorToColor16().

static GLfloat CNBluePartOfColor ( const struct CNColor src) [inline, static]

Get blue part in CNColor.

Returns:
Blue part of color
Parameters:
srcSource color

References CNBluePos, and CNColor::vector.

Referenced by CNColorToColor16().

static GLfloat CNAlphaPartOfColor ( const struct CNColor src) [inline, static]

Get alpha part in CNColor.

Returns:
Alpha part of color
Parameters:
srcSource color

References CNAlphaPos, and CNColor::vector.

Referenced by CNColorToColor16().

static const GLfloat* CNVectorInColor ( const struct CNColor src) [inline, static]

Get vector of parts in CNColor.

Returns:
Vector of color parts
Parameters:
srcSource color

References CNColor::vector.

static uint64_t CNHashValueOfColor ( const struct CNColor src) [inline, static]

Get hash value for CNColor object.

Returns:
Hash value
Parameters:
srcSource color

References CNColor::hashValue.

static int CNCompareColor ( const struct CNColor src0,
const struct CNColor src1 
) [inline, static]

Compare 2 colors.

Return values:
Pos-valSrc1 is bigger than src2.
Neg-valSrc1 is smaller than src2.
0Src1 and src2 are same
Parameters:
src0Source color 0
src1Source color 1

References CNColor::hashValue.

static CNBasicColorId CNColorToBasicId ( const struct CNColor src) [inline, static]

Get color by color-id.

Return values:
color_idBasic color Id
0The given color is NOT basic color
Parameters:
srcSource color

References CNBackgroundColorId, CNBlackId, CNBlueId, CNCyanId, CNForegroundColorId, CNGreenId, CNMagentaId, CNNotBasicColorId, CNRedId, CNWhiteId, and CNYellowId.

static unsigned int CNColorPartToColor16Part ( GLfloat  src) [inline, static]

Convert part of CNColor to CNColor16.

f

Returns:
CNColor16 value
Parameters:
srcSource part of CNColor value

Referenced by CNColorToColor16().

static CNColor16 CNColorToColor16 ( const struct CNColor src) [inline, static]

Convert CNColor to CNColor16.

Returns:
CNColor16 value
Parameters:
srcSource CNColor value

References CNAlphaPartOfColor(), CNBluePartOfColor(), CNColorPartToColor16Part(), CNGreenPartOfColor(), and CNRedPartOfColor().


Variable Documentation

struct CNColor* CNBlack

Black color for OpenGL

struct CNColor* CNRed

Red color for OpenGL

struct CNColor* CNGreen

Green color for OpenGL

struct CNColor* CNBlue

Blue color for OpenGL

struct CNColor* CNYellow

Yellow color for OpenGL

struct CNColor* CNMagenta

Magenta color for OpenGL

struct CNColor* CNCyan

Cyan color for OpenGL

struct CNColor* CNWhite

White color for OpenGL

Dummy color for foreground

Dummy color for background

The color is which does not match basic color

Referenced by CNColorToBasicId().