## cr-rgb cr-rgb |

## Functions

CRRgb * | cr_rgb_new ()
CRRgb * | cr_rgb_new_with_vals ()
CRRgb * | cr_rgb_parse_from_buf ()
enum CRStatus | cr_rgb_compute_from_percentage ()
enum CRStatus | cr_rgb_set ()
enum CRStatus | cr_rgb_copy ()
enum CRStatus | cr_rgb_set_to_inherit ()
gboolean | cr_rgb_is_set_to_inherit ()
gboolean | cr_rgb_is_set_to_transparent ()
enum CRStatus | cr_rgb_set_to_transparent ()
enum CRStatus | cr_rgb_set_from_rgb ()
enum CRStatus | cr_rgb_set_from_name ()
enum CRStatus | cr_rgb_set_from_hex_str ()
enum CRStatus | cr_rgb_set_from_term ()
guchar * | cr_rgb_to_string ()
void | cr_rgb_dump ()
void | cr_rgb_destroy ()

## Types and Values

struct | CRRgb

## Description

## Functions

### cr_rgb_new ()

    CRRgb *
    cr_rgb_new (void);

The default constructor of CRRgb.

Returns the newly built instance of CRRgb

### cr_rgb_new_with_vals ()

    CRRgb *
    cr_rgb_new_with_vals (gulong a_red,
                          gulong a_green,
                          gulong a_blue,
                          gboolean a_is_percentage);

A constructor of CRRgb.

Returns the newly built instance of CRRgb.

#### Parameters

a_red | the red component of the color. |
a_green | the green component of the color. |
a_blue | the blue component of the color. |
a_unit | the unit of the rgb values. (either percentage or integer values) |

### cr_rgb_parse_from_buf ()

    CRRgb *
    cr_rgb_parse_from_buf (const guchar *a_str,
                           enum CREncoding a_enc);

Parses a text buffer that contains a rgb color

Returns the parsed color, or NULL in case of error

#### Parameters

a_str | a string that contains a color description |
a_enc | the encoding of a_str |

### cr_rgb_compute_from_percentage ()

    enum CRStatus
    cr_rgb_compute_from_percentage (CRRgb *a_this);

If the rgb values are expressed in percentage, compute their real value.

Returns CR_OK upon successful completion, an error code otherwise.

#### Parameters

a_this | the current instance of CRRgb |

### cr_rgb_set ()

    enum CRStatus
    cr_rgb_set (CRRgb *a_this,
                gulong a_red,
                gulong a_green,
                gulong a_blue,
                gboolean a_is_percentage);

Sets rgb values to the RGB.

Returns CR_OK upon successful completion, an error code otherwise.

#### Parameters

a_this | the current instance of CRRgb. |
a_red | the red value. |
a_green | the green value. |
a_blue | the blue value. |

### cr_rgb_copy ()

    enum CRStatus
    cr_rgb_copy (CRRgb *a_dest,
                 CRRgb const *a_src);

### cr_rgb_set_to_inherit ()

    enum CRStatus
    cr_rgb_set_to_inherit (CRRgb *a_this,
                           gboolean a_inherit);

sets the value of the rgb to inherit. Look at the css spec from chapter 6.1 to 6.2 to understand the meaning of "inherit".

Returns CR_OK upon succesful completion, an error code otherwise.

#### Parameters

a_this | the current instance of CRRgb |

### cr_rgb_is_set_to_inherit ()

    gboolean
    cr_rgb_is_set_to_inherit (CRRgb const *a_this);

`a_this` : the current instance of CRRgb.

Returns TRUE if the rgb is set to the value "inherit", FALSE otherwise.

### cr_rgb_is_set_to_transparent ()

    gboolean
    cr_rgb_is_set_to_transparent (CRRgb const *a_this);

Tests if the the rgb is set to the value "transparent" or not.

Returns TRUE if the rgb has been set to transparent, FALSE otherwise.

#### Parameters

a_this | the current instance of CRRgb |

### cr_rgb_set_to_transparent ()

    enum CRStatus
    cr_rgb_set_to_transparent (CRRgb *a_this,
                               gboolean a_is_transparent);

Sets the rgb to the "transparent" value (or not) Returns CR_OK upon successfull completion, an error code otherwise.

#### Parameters

a_this | the current instance of CRRgb |
a_is_transparent | set to transparent or not. |

### cr_rgb_set_from_rgb ()

    enum CRStatus
    cr_rgb_set_from_rgb (CRRgb *a_this,
                         CRRgb const *a_rgb);

Sets the rgb from an other one.

Returns CR_OK upon successful completion, an error code otherwise.

#### Parameters

a_this | the current instance of CRRgb. |
a_rgb | the rgb to "copy" |

### cr_rgb_set_from_name ()

    enum CRStatus
    cr_rgb_set_from_name (CRRgb *a_this,
                          const guchar *a_color_name);

Returns CR_OK upon successful completion, an error code otherwise.

#### Parameters

a_this | the current instance of CRRgb |
a_color_name | the color name |

### cr_rgb_set_from_hex_str ()

    enum CRStatus
    cr_rgb_set_from_hex_str (CRRgb *a_this,
                             const guchar *a_hex_value);

Returns CR_OK upon successful completion.

#### Parameters

a_this | the current instance of CRRgb |
a_hex | the hexadecimal value to set. |

### cr_rgb_set_from_term ()

    enum CRStatus
    cr_rgb_set_from_term (CRRgb *a_this,
                          const struct _CRTerm *a_value);

Set the rgb from a terminal symbol

Returns CR_OK upon successful completion, an error code otherwise.

#### Parameters

a_this | the instance of CRRgb to set |
a_value | the terminal from which to set |

### cr_rgb_to_string ()

    guchar *
    cr_rgb_to_string (CRRgb const *a_this);

Serializes the rgb into a zero terminated string.

Returns the zero terminated string containing the serialized rgb. MUST BE FREED by the caller using `g_free()`.

#### Parameters

a_this | the instance of CRRgb to serialize. |

### cr_rgb_dump ()

    void
    cr_rgb_dump (CRRgb const *a_this,
                 FILE *a_fp);

Dumps the current instance of CRRgb to a file.

#### Parameters

a_this | the "this pointer" of the current instance of CRRgb. |
a_fp | the destination file pointer. |

### cr_rgb_destroy ()

    void
    cr_rgb_destroy (CRRgb *a_this);

Destructor of CRRgb.

#### Parameters

a_this | the "this pointer" of the current instance of CRRgb. |

## Types and Values

### struct CRRgb

    struct CRRgb {
            /*
             *the unit of the rgb.
             *Either NO_UNIT (integer) or
             *UNIT_PERCENTAGE (percentage).
             */
            const guchar *name ;
            glong red ;
            glong green ;
            glong blue ;
            gboolean is_percentage ;
    	gboolean inherit ;
            gboolean is_transparent ;
            CRParsingLocation location ;
    };