#include <libsswf.h>
Public Types | |
enum | blend_mode_t { BLEND_MODE_UNDEFINED = -1, BLEND_MODE_NORMAL = 1, BLEND_MODE_LAYER = 2, BLEND_MODE_MULTIPLY = 3, BLEND_MODE_SCREEN = 4, BLEND_MODE_LIGHTEN = 5, BLEND_MODE_DARKEN = 6, BLEND_MODE_DIFFERENCE = 7, BLEND_MODE_ADD = 8, BLEND_MODE_SUBTRACT = 9, BLEND_MODE_INVERT = 10, BLEND_MODE_ALPHA = 11, BLEND_MODE_ERASE = 12, BLEND_MODE_OVERLAY = 13, BLEND_MODE_HARDLIGHT = 14 } |
List all the available blend modes. More... | |
Public Member Functions | |
BlendMode (void) | |
Initialize the blend mode to undefined. | |
blend_mode_t | GetBlendMode (void) const |
Get the current blending mode. | |
bool | HasBlendMode (void) const |
Test whether a blending filter was defined. | |
ErrorManager::error_code_t | Parse (const Data &data) |
Parse the Data buffer reading a blend mode. | |
void | Save (Data &data) |
Save the filter in the specified Data buffer. | |
void | SetBlendMode (blend_mode_t blend_mode_value) |
Defines a filter by value. | |
bool | SetBlendModeByName (const char *blend_mode_name) |
Defines the filter by name. | |
Private Attributes | |
blend_mode_t | f_blend_mode |
This class is used to declare a blending mode which can be shared by different classes.
The following lists the blend modes available when placing an object on your screen.
In the following, I included formulas which use the following variables:
BLEND_MODE_UNDEFINED |
According to Macromedia this is the same as sswf::BlendMode::BLEND_MODE_NORMAL.
This value should probably not be used, yet according to the Macromedia documentation, it is equivalent to sswf::BlendMode::BLEND_MODE_NORMAL This is a do nothing blending mode.
R = C |
BLEND_MODE_NORMAL |
A do nothing blending mode.
This blending mode has no effect on the object being placed.
R = C |
BLEND_MODE_LAYER |
Use multiple objects.
This blending mode uses multiple objects to render the final output. At this time, it isn't clear to me what this does... |
BLEND_MODE_MULTIPLY |
Multiply the background and the object colors (light effect).
This blending mode can be used to multiply the background colors with the object being placed. When the object being placed is a grey scale, this is a way to apply brightness to the background. Thus you can generate the effect of a light (or a reflection of a light) on the screen.
R = B × C / 255 |
BLEND_MODE_SCREEN |
Multiply the inverse of the background and the object colors.
There is probably no good reason to use the inverse color of the object since the object could be rendered properly in the first place (i.e. if you need 255, use white and if you need 0 use black). Yet, this filter multiplies the inverse of the background and the object colors together.
R = (255 - B) × (255 - C) / 255 |
BLEND_MODE_LIGHTEN |
Use the largest of the two colors.
Select which of the background or the object being placed has the largest component. Use black in your object to not affect the screen.
R = max(B, C) |
BLEND_MODE_DARKEN |
Use the largest of the two colors.
Select which of the background or the object being placed has the smallest component. Use white in your object to not affect the screen.
R = min(B, C) |
BLEND_MODE_DIFFERENCE |
Take the absolute value of the object color minus the background color.
At this time, I'm not too sure what this is for. The colors will loop around with this object and in general this make the image look weird. May be a good idea to create some sort of negative effect.
R = | B - C | |
BLEND_MODE_ADD |
Add the object components to the background.
This filter can be used for a strong brightness effect. Watchout, do not create too bright an object for this blend mode. It would otherwise make your screen look bad.
R = max(B + C, 255) |
BLEND_MODE_SUBTRACT |
Subject the object components from the background.
This filter can be used for a strong darkning effect. Watchout, do not create too bright an object for this blend mode. It would otherwise make your screen look bad.
R = min(B - C, 0) |
BLEND_MODE_INVERT |
Inverse the background colors.
This filter does not use the source image for anything more than know where to apply the filter. Otherwise it inverts the color creating a negative (the same as when you take pictures with your camera, the resulting film is a negative -- the colors are invered.)
R = 255 - B |
BLEND_MODE_ALPHA |
Copy the object alpha in the background.
This filter copies the alpha channel as is from the object to the background. Used in a Sprite, I suppose this can be used to switch between different alpha channels for the same object.
Ra = Ca |
BLEND_MODE_ERASE |
Copy the inverse of the object alpha in the background.
This filter copies the inverts of the alpha channel from the object to the background. This as the effect of making the object itself disappear... and what's around appear, I would think.
Ra = 255 - Ca |
BLEND_MODE_OVERLAY |
Applies a MULTIPLY or SCREEN effect depending on the current background colors.
This filter copies the alpha channel as is from the object to the background.
R = (B < 128 ? B × C : (255 - B) × (255 - C)) / 255 |
BLEND_MODE_HARDLIGHT |
Applies a MULTIPLY or SCREEN effect depending on the current background colors.
This filter copies the alpha channel as is from the object to the background.
R = (C < 128 ? B × C : (255 - B) × (255 - C)) / 255 |
BlendMode::BlendMode | ( | void | ) |
The constructor initializes the blend mode to the default of: BLEND_MODE_UNDEFINED.
References BLEND_MODE_UNDEFINED, and f_blend_mode.
BlendMode::blend_mode_t BlendMode::GetBlendMode | ( | void | ) | const |
This function returns the current blending mode as set by SetBlendMode() or SetBlendModeByName().
sswf::BlendMode::SetBlendModeByName(const char *blend_mode_name)
References f_blend_mode.
bool BlendMode::HasBlendMode | ( | void | ) | const |
This function determines whether a filter was defined in this BlendMode object.
This is the same as testing wheter the BlendMode::HasBlendMode(void) const function returns BLEND_MODE_UNDEFINED.
sswf::BlendMode::SetBlendModeByName(const char *blend_mode_name)
References BLEND_MODE_UNDEFINED, and f_blend_mode.
Referenced by sswf::TagPlace::PreSave(), sswf::TagPlace::Save(), and sswf::State::Save().
ErrorManager::error_code_t BlendMode::Parse | ( | const Data & | data | ) |
This function reads the blend mode in the specified Data buffer.
[in] | data | The Data buffer where the blend mode is to be saved |
References sswf::ErrorManager::ERROR_CODE_NONE, f_blend_mode, and sswf::Data::GetByte().
Referenced by sswf::State::Parse().
void BlendMode::Save | ( | Data & | data | ) |
This function saves the specified blend mode in the specified Data buffer.
[in] | data | The Data buffer where the blend mode is to be saved |
References f_blend_mode, and sswf::Data::PutByte().
Referenced by sswf::TagPlace::Save(), and sswf::State::Save().
void BlendMode::SetBlendMode | ( | blend_mode_t | blend_mode | ) |
This function defines the filter to use with a TagPlace or State object.
[in] | blend_mode | The new blend mode (BLEND_MODE_...) |
References BLEND_MODE_ADD, BLEND_MODE_ALPHA, BLEND_MODE_DARKEN, BLEND_MODE_DIFFERENCE, BLEND_MODE_ERASE, BLEND_MODE_HARDLIGHT, BLEND_MODE_INVERT, BLEND_MODE_LAYER, BLEND_MODE_LIGHTEN, BLEND_MODE_MULTIPLY, BLEND_MODE_NORMAL, BLEND_MODE_OVERLAY, BLEND_MODE_SCREEN, BLEND_MODE_SUBTRACT, BLEND_MODE_UNDEFINED, and f_blend_mode.
bool BlendMode::SetBlendModeByName | ( | const char * | blend_mode_name | ) |
This function is similar to the sswf::BlendMode::SetBlendMode(blend_mode_t blend_mode) except that it takes a name instead of a number to define the blending mode to use.
The supported names are the same as those found in the sswf::BlendMode::blend_mode_t enumeration without the "BLEND_MODE_" part and excluding UNDEFINED (you can reset the blend mode to Undefined by calling sswf::BlendMode::SetBlendMode(sswf::BlendMode::BLEND_MODE_UNDEFINED) instead.)
[in] | blend_mode_name | The ASCII name of the blend mode to use |
References BLEND_MODE_ADD, BLEND_MODE_ALPHA, BLEND_MODE_DARKEN, BLEND_MODE_DIFFERENCE, BLEND_MODE_ERASE, BLEND_MODE_HARDLIGHT, BLEND_MODE_INVERT, BLEND_MODE_LAYER, BLEND_MODE_LIGHTEN, BLEND_MODE_MULTIPLY, BLEND_MODE_NORMAL, BLEND_MODE_OVERLAY, BLEND_MODE_SCREEN, BLEND_MODE_SUBTRACT, BLEND_MODE_UNDEFINED, and f_blend_mode.
blend_mode_t sswf::BlendMode::f_blend_mode [private] |
Referenced by BlendMode(), GetBlendMode(), HasBlendMode(), Parse(), Save(), SetBlendMode(), and SetBlendModeByName().