#include <libsswf.h>
Public Member Functions | |
bool | IsNull (void) const |
Check whether the matrix has an effect. | |
Matrix (void) | |
Initialize a matrix to a "no effect" matrix. | |
bool | operator!= (const Matrix &matrix) const |
Compare two matrices for inequality. | |
bool | operator== (const Matrix &matrix) const |
Compare two matrices for equality. | |
void | Reset (void) |
Reset a matrix to a "no effect" matrix. | |
void | Save (Data &data) |
Save a matrix to a data buffer. | |
void | SetRotate (double rotate) |
Change the rotation.Set the rotation in radian. | |
void | SetScale (double scale) |
Define the scale of the object. | |
void | SetScale (double x, double y) |
Define the horizontal and vertical scaling factors. | |
void | SetSkew (double skew0, double skew1) |
Set a skew (sliding off). | |
void | SetTranslate (long x, long y) |
Define the matrix translation. | |
Private Member Functions | |
void | ComputeMatrix (signed_matrix_t &m) const |
Internal function used to compute the matrix. | |
Private Attributes | |
double | f_rotate |
double | f_scale_x |
double | f_scale_y |
double | f_skew_0 |
double | f_skew_1 |
long | f_translate_x |
long | f_translate_y |
Classes | |
struct | signed_matrix_t |
Matrix of longs; used to compute the matrix to be saved in the movie. More... |
The matrix is a 2D matrix and thus is only a 3x3.
The default is the identity matrix:
| 1 0 0 | | 0 1 0 | | 0 0 1 |
However, the matrix is not managed as a matrix. Instead, you define the scaling, skewing, rotation and translation parameters. The library takes care of generating the matrix when it is saved in the SWF movie.
Notice that the translation is defined in twips and not floating point values.
Matrix::Matrix | ( | void | ) |
The constructor creates and initializes a matrix with no effect. (i.e. the identity matrix.)
void Matrix::ComputeMatrix | ( | signed_matrix_t & | m | ) | const [private] |
This function computes the matrix of signed values. The matrix is saved as 4x 16.16 fixed point values. This function computes the 4 fixed point values using the current definition of the matrix (i.e. rotation, skew and scaling.) The translation is not added in this matrix since this matrix is a 2x2 matrix.
[out] | m | When the computed matrix is saved |
bool Matrix::IsNull | ( | void | ) | const |
This function checks whether the different parameters define a null matrix. If so, then the function returns true.
The test is performed with the floating point values transformed in 16.16 fixed points as when they are saved in the final matrix. To ensures that the normal rounding is applied and thus it catches more matrices as null matrices.
bool Matrix::operator!= | ( | const Matrix & | matrix | ) | const |
This operator compares two matrices to know whether they are inequal.
Note that the doubles are first transformed into 16.16 fixed point values and these are compared for inequality. This means less matrices may look inequal than what their exact definitions with doubles would imply.
bool Matrix::operator== | ( | const Matrix & | matrix | ) | const |
This operator compares two matrices to know whether they are equal or not.
Note that the doubles are first transformed into 16.16 fixed point values and these are compared for equality. This means more matrices may look equal than what their exact definitions with doubles would imply.
void Matrix::Reset | ( | void | ) |
The Reset() function sets all the parameters to no effect. (i.e. the identity matrix.)
void Matrix::Save | ( | Data & | data | ) |
The Save() function computes the matrix and then saves it in the specified data buffer.
It is valid to save an identity matrix.
[in] | data | The buffer where the matrix is to be saved |
void Matrix::SetRotate | ( | double | rotate | ) |
The SetRotate() function takes a radian angle and saves it as the current rotation angle. This function is not cumulative. Instead the new angle overwrites any other angle previously defined with SetRotate().
[in] | rotate | The rotation angle |
sswf::Matrix::SetScale | ( | double | scale | ) | [inline] |
This function changes the matrix scaling. This function can be used to change the scaling uniformly in both directions. This is often used when you need to enlarge or reduce an object without losing its aspect ratio.
A call to this function is not cumulative. Each call sets the new scale to the specified value by overwriting the previous value.
It is equivalent to call SetScale() with the same value in x and y:
[in] | scale | Defines the new horizontal and vertical scaling |
sswf::Matrix::SetScale | ( | double | x, | |
double | y | |||
) | [inline] |
This function changes the matrix scaling. This function can be used to change the horizontal and vertical scaling with different values. This let's you scale objects exactly the way you want.
A call to this function is not cumulative. Each call sets the new scaling values to the specified (x, y) scaling by overwriting the previous values.
[in] | x | Defines the new horizontal scaling |
[in] | y | Defines the new vertical scaling |
sswf::Matrix::SetSkew | ( | double | skew0, | |
double | skew1 | |||
) | [inline] |
This function is used to change the skew parameters. The skew makes the top and bottom (or left and right) edges move horizontally (vertically) away from each others.
The skew defined by this function is not cumulative. Instead it replaces the current value with the new values.
The unit of the skew is the twips times the scaling factors.
[in] | skew0 | The horizontal skew |
[in] | skew1 | The vertical skew |
sswf::Matrix::SetTranslate | ( | long | x, | |
long | y | |||
) | [inline] |
Set the translation to (x, y). Previous translations are replaced by each new call to this function.
The translation is defined in twips and taken as long values. (i.e. 20 represents 1 pixel on the screen.)
[in] | x | The horizontal translation |
[in] | y | The vertical translation |
double sswf::Matrix::f_rotate [private] |
double sswf::Matrix::f_scale_x [private] |
double sswf::Matrix::f_scale_y [private] |
double sswf::Matrix::f_skew_0 [private] |
double sswf::Matrix::f_skew_1 [private] |
long sswf::Matrix::f_translate_x [private] |
long sswf::Matrix::f_translate_y [private] |