libsswf: sswf::Color Class Reference

# sswf::Color Class Reference

A small object to hold an SWF color. More...

`#include <libsswf.h>`

List of all members.

## Public Member Functions
unsigned char | Alpha (void) const
| Returns the alpha (or transparency) component.
unsigned char | Blue (void) const
| Returns the blue component.
| Color (void)
| Construct a color object.
unsigned char | Green (void) const
| Returns the green component.
bool | IsInvisible (void) const
| Checks whether this color is invisible.
bool | IsSolid (void) const
| Checks whether this color represents a solid color.
bool | operator!= (const Color &color) const
| operator != compares two colors for inequality
bool | operator== (const Color &color) const
| operator == compares two colors for equality
ErrorManager::error_code_t | Parse (const Data &data, bool parse_alpha=true)
| Parse input data as 3 or 4 bytes of color.
unsigned char | Red (void) const
| Returns the red component.
void | Reset (void)
| Reset the color to its default values.
void | Save (Data &data, bool save_alpha=true) const
| Save the color to a Data buffer.
void | Set (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
| Set the color to the specified values.
## Private Attributes
unsigned char | f_alpha
unsigned char | f_blue
unsigned char | f_green
unsigned char | f_red

## Detailed Description

The Color class is used to specify an RGB and RGBA colors of objects.

When only an RGB color is necessary, you should pass a Color object with the alpha component set to 255 (solid).

See also:
  SWF Alexis' Reference—swf_rgb

  SWF Alexis' Reference—swf_xrgb

  SWF Alexis' Reference—swf_rgba

  SWF Alexis' Reference—swf_argb

## Constructor & Destructor Documentation

sswf::Color::Color | ( | void |  | ) | `[inline]`

The Color() constructor initialize the color with a call to Reset().

This is supposed to have the effect of setting the color to solid white.

References Reset().

## Member Function Documentation

sswf::Color::Alpha | ( | void |  | ) | const`[inline]`

The Alpha() function is used to read the alpha component of a Color object.

Returns:
  The alpha component

References f_alpha.

Referenced by sswf::Style::SetColor(), sswf::Style::SetGradient(), and sswf::Style::SetLine().

sswf::Color::Blue | ( | void |  | ) | const`[inline]`

The Blue() function is used to read the blue component of a Color object.

Returns:
  The blue component

References f_blue.

Referenced by sswf::TagSetBackgroundColor::Save().

sswf::Color::Green | ( | void |  | ) | const`[inline]`

The Green() function is used to read the green component of a Color object.

Returns:
  The green component

References f_green.

Referenced by sswf::TagSetBackgroundColor::Save().

sswf::Color::IsInvisible | ( | void |  | ) | const`[inline]`

The IsInvisible() function returns true when the alpha is 0.

Returns:
  'true' when alpha is 0

References f_alpha.

Referenced by sswf::TagText::Save().

sswf::Color::IsSolid | ( | void |  | ) | const`[inline]`

The IsSolid() function returns true when the alpha is 255.

Returns:
  'false' when alpha is 255

References f_alpha.

Referenced by sswf::TagText::PreSave().

bool Color::operator!= | ( | const Color & | color | ) | const

The != operator compares two colors together and returns true when any of the components, including the alpha channel, does not match exactly.

Parameters:

  `[in]` | color | The other color to compare 'this' with

Returns:
  'true' when both colors are inequal

References f_alpha, f_blue, f_green, and f_red.

bool Color::operator== | ( | const Color & | color | ) | const

The == operator compares two colors together and returns true when all the components, including the alpha channel, match exactly.

Parameters:

  `[in]` | color | The other color to compare 'this' with

Returns:
  'true' when both colors are equal

References f_alpha, f_blue, f_green, and f_red.

ErrorManager::error_code_t Color::Parse | ( | const Data & | data,
|  | bool | parse_alpha = `true` |
| ) |  |  |

This function reads colors from the specified Data buffer.

If the `parse_alpha` flag is set to true, then 4 bytes are read. The 4th is the Alpha Channel.

When parse_alpha is set to false, the f_alpha parameter is set to 255.

Parameters:

  `[in]` | data | The data buffer the color is read from
  `[in]` | parse_alpha | Whether the function reads the alpha channel

Returns:
  An error if one occurs, ERROR_CODE_NONE otherwise.

References sswf::ErrorManager::ERROR_CODE_NONE, f_alpha, f_blue, f_green, f_red, and sswf::Data::GetByte().

Referenced by sswf::TagSetBackgroundColor::ParseTag(), and sswf::TagEditText::ParseTag().

sswf::Color::Red | ( | void |  | ) | const`[inline]`

The Red() function is used to read the red component of a Color object.

Returns:
  The red component

References f_red.

Referenced by sswf::TagSetBackgroundColor::Save().

void Color::Reset | ( | void |  | ) |

The Reset() function sets the color to solid white which is the default animation background color.

References f_alpha, f_blue, f_green, and f_red.

Referenced by Color(), and sswf::Style::Reset().

void Color::Save | ( | Data & | data,
|  | bool | save_alpha = `true` |
| ) |  |  | const

The Save() function saves the color to a Data buffer.

The 'save_alpha' flag can be used to determine whether the alpha should also be saved.

This function saves the color as RGB or RGBA. To save the color as XRGB or ARGB you need to write your own code.

Parameters:

  `[in]` | data | The output buffer where the result is saved.
  `[in]` | save_alpha | A flag used to specify whether the alpha is saved too

References f_alpha, f_blue, f_green, f_red, and sswf::Data::PutByte().

Referenced by sswf::TagText::Save(), sswf::TagEditText::Save(), and sswf::Style::Save().

void Color::Set | ( | unsigned char | red,
|  | unsigned char | green,
|  | unsigned char | blue,
|  | unsigned char | alpha = `255` |
| ) |  |  |

The Set() function sets the color to the specified red, green, blue and alpha values.

0 represent none and 255 represents full color.

For the alpha, 0 represent 100% transparent and 255 represents 100% solid. Notice that by default the alpha will be set to 255 which means a solid color.

Parameters:

  `[in]` | red | The value for the red component
  `[in]` | green | The value for the green component
  `[in]` | blue | The value for the blue component
  `[in]` | alpha | The value for the alpha component

References f_alpha, f_blue, f_green, and f_red.

Referenced by sswf::TagText::Save(), and sswf::TagShape::Save().

## Member Data Documentation

unsigned char sswf::Color::f_alpha`[private]`

Referenced by Alpha(), IsInvisible(), IsSolid(), operator!=(), operator==(), Parse(), Reset(), Save(), and Set().

unsigned char sswf::Color::f_blue`[private]`

Referenced by Blue(), operator!=(), operator==(), Parse(), Reset(), Save(), and Set().

unsigned char sswf::Color::f_green`[private]`

Referenced by Green(), operator!=(), operator==(), Parse(), Reset(), Save(), and Set().

unsigned char sswf::Color::f_red`[private]`

Referenced by operator!=(), operator==(), Parse(), Red(), Reset(), Save(), and Set().

The documentation for this class was generated from the following files:

- libsswf.h
- libsswf_tags.c++