#include <libsswf.h>
Inheritance diagram for sswf::TagShape:
Public Types | |
enum | fill_t { SHAPE_FILL_EVEN = 0, SHAPE_FILL_ODD = 1 } |
Which fill is to be defined. More... | |
MORPH_MODE_BOTH_SHAPES = 2 | |
Added the information to both shapes. | |
MORPH_MODE_SHAPE0 = 0 | |
Added the information to the first shape. | |
MORPH_MODE_SHAPE1 = 1 | |
Added the information to the last shape. | |
enum | morph_t { MORPH_MODE_SHAPE0 = 0, MORPH_MODE_SHAPE1 = 1, MORPH_MODE_BOTH_SHAPES = 2 } |
The mode used to add a style or edge. More... | |
SHAPE_FILL_EVEN = 0 | |
Use Fill0. | |
SHAPE_FILL_ODD = 1 | |
Use Fill1. | |
Public Member Functions | |
ErrorManager::error_code_t | AddEdge (morph_t morph_mode, const Edges::edge_t &edge) |
Add an edge. | |
ErrorManager::error_code_t | AddEdge (morph_t morph_mode, long x, long y, long ctrl_x, long ctrl_y) |
Save a curve segment. | |
ErrorManager::error_code_t | AddEdge (morph_t morph_mode, long x, long y) |
Save a line segment. | |
ErrorManager::error_code_t | AddMove (morph_t morph_mode, long x, long y) |
Add a move to a specific location. | |
ErrorManager::error_code_t | AddStyle (const Style &style, fill_t fill=SHAPE_FILL_EVEN) |
Add a style to the shape. | |
const SRectangle & | Bounds (int index) const |
Retrieve a copy of the bounds. | |
void | Glyph (void) |
Mark the shape as being a glyph. | |
bool | HasAlignZone (void) const |
Check whether a zone align rectangle is defined. | |
bool | HasBounds (void) const |
Check whether bounds were properly defined. | |
bool | HasShowBounds (void) const |
Check whether bounds should be shown. | |
bool | IsEmpty (void) const |
Check whether there is anything in this shape. | |
bool | IsGlyph (void) const |
Check whehter this shape is a glyph. | |
void | NewStyles (void) |
Force a new set of styles. | |
virtual ErrorManager::error_code_t | Save (Data &data) |
This function saves the TagShape in a Data buffer. | |
void | SaveAlignZone (Data &data) const |
Save alignment zone in a Data buffer. | |
ErrorManager::error_code_t | SaveWithoutStyles (Data &data) |
Save the edges only. | |
void | SetAlignZone (const SRectangle &zone) |
Set the alignment zone rectangle of a glyph. | |
ErrorManager::error_code_t | SetBounds (int index, const SRectangle &rect, bool show=false) |
Set the rectangle within which the shape is enclosed. | |
void | SetNonScalingStrokes (bool has_non_scaling_strokes) |
Set whether the shape has any non-scaling strokes. | |
void | SetScalingStrokes (bool has_scaling_strokes) |
Set whether the shape has any scaling strokes. | |
ErrorManager::error_code_t | SetStrokesBounds (int index, const SRectangle &rect) |
Set the rectangle where the shape including "leaking" strokes is to be rendered. | |
void | ShowBounds (bool show=true) |
Set whether the shape should show the bounds. | |
void | ShowOrigin (bool show=true) |
Set whether the shape should draw origin lines. | |
TagShape (TagBase *parent) | |
Initializes the shape object. | |
virtual swf_type_t | TypeFlags (void) const |
Returns the type of a shape object. | |
Private Types | |
SHAPE_EDGES | |
SHAPE_SETUP | |
enum | what_t { SHAPE_EDGES, SHAPE_SETUP } |
Private Member Functions | |
void | NewEdges (void) |
Allocate a new edges structure. | |
void | NewSetup (void) |
Allocate a new setup structure. | |
virtual ErrorManager::error_code_t | PreSave (void) |
Ensure the minimum version is acceptable. | |
void | RecordEdges (void) |
Record the edges. | |
void | RecordSetup (void) |
Record the setup. | |
ErrorManager::error_code_t | SaveSetup (save_info_t &info, const shape_setup_t &setup, shape_setup_t &last) |
Save the specified shape setup. | |
ErrorManager::error_code_t | SaveShape (save_info_t &info, shape_setup_t &last_setup) |
Save a shape. | |
ErrorManager::error_code_t | SaveStyles (save_info_t &info) |
Save the specified shape styles. | |
ErrorManager::error_code_t | SaveStylesCount (save_info_t &info, long count) |
Save the specified shape setup. | |
void | SetMorph (void) |
Mark the shape as a morphing shape. | |
Private Attributes | |
SRectangle | f_align_zone |
SRectangle | f_bounds [2] |
shape_edges_t * | f_edges |
Vectors | f_fill_styles |
bool | f_has_non_scaling_strokes |
bool | f_has_scaling_strokes |
bool | f_is_glyph |
Vectors | f_line_styles |
bool | f_morph |
shape_edges_t * | f_morph_edges |
Vectors | f_morph_record |
Vectors | f_record |
shape_setup_t * | f_setup |
Vectors | f_shapes |
bool | f_show_bounds |
bool | f_show_origin |
SRectangle | f_strokes_bounds [2] |
unsigned char | f_version |
Classes | |
struct | save_info_t |
Holds information used to save a shape. More... | |
struct | shape_edges_t |
The set of edges: line and curve segments. More... | |
struct | shape_record_t |
Records to separate different sets of styles. More... | |
struct | shape_setup_t |
The set of setup: fill, line and move. More... | |
struct | shape_what_t |
A base class to define edges and setup information. More... |
A shape is a set of lines and curves defining a picture. It is composed of fill and line styles and edges. The edges define the (x, y) coordinates of the images to render. The fill styles define the colors, images and gradients used to fill inside the polygones defined by the edges. And the line styles define how to render the segments defined by the edges.
It is possible to not have a fill or line.
Note that a glyph in a font is a special type of shape. (a shape without all the bells and wissels)
All the possibilities define a shape of many different SWF versions.
SWF Alexis' Reference—Define Shape
SWF Alexis' Reference—Define Shape2
SWF Alexis' Reference—Define Shape3
SWF Alexis' Reference—Define Shape4
SWF Alexis' Reference—Define Morph Shape
SWF Alexis' Reference—Define Morph Shape2
SWF Alexis' Reference—swf_shape
SWF Alexis' Reference—swf_shape_record
This enumeration is used to determine the fill to define. Whenever rendering a filled shape, two fills are available: Fill0 and Fill1 (or even and odd fills.)
This enumeration helps you create only the first, only the last or both shapes at once.
MORPH_MODE_SHAPE0 |
Added the information to the first shape.
This is used to add information to the first shape of a morph. Use this if you are not creating a morph shape.
|
MORPH_MODE_SHAPE1 |
Added the information to the last shape.
This is used to add information to the last shape of a morph. Use this only if you intend to create a morph shape. Remember that a morph shape must have the exact same number of entries in both shapes.
|
MORPH_MODE_BOTH_SHAPES |
Added the information to both shapes.
This is used to add the same information the first and the last shapes at the same time. It is equivalent to calling the corresponding function once with TagShape::MORPH_MODE_SHAPE0 and once with TagShape::MORPH_MODE_SHAPE1.
|
enum sswf::TagShape::what_t [private] |
TagShape::TagShape | ( | TagBase * | parent | ) |
ErrorManager::error_code_t TagShape::AddEdge | ( | morph_t | morph_mode, | |
const Edges::edge_t & | edge | |||
) |
Shapes are drawn using edges. An edge defines a curve or a line segment.
To draw a morph shape, you can drawn in both shapes at the same time or choose to draw only in one or the other.
[in] | morph_mode | One of the morph mode available |
[in] | edge | The edge to add |
sswf::TagShape::AddEdge | ( | morph_t | morph_mode, | |
long | x, | |||
long | y, | |||
long | ctrl_x, | |||
long | ctrl_y | |||
) | [inline] |
Add the specified curve. This is a helper function which saves the parameters in an edge_t structure then calls sswf::TagShape::AddEdge(morph_t morph_mode, const Edges::edge_t& edge)
sswf::TagShape::AddEdge | ( | morph_t | morph_mode, | |
long | x, | |||
long | y | |||
) | [inline] |
Add the specified line segment. This is a helper function which saves the parameters in an edge_t structure then calls sswf::TagShape::AddEdge(morph_t morph_mode, const Edges::edge_t& edge)
ErrorManager::error_code_t TagShape::AddMove | ( | morph_t | morph_mode, | |
long | x, | |||
long | y | |||
) |
This function is used to move the drawing pen to a specified location. No drawing happens when moving the pen in this way.
The function can be called multiple times in a raw, though only the last position is kept.
[in] | morph_mode | One of the available morph modes |
[in] | x | The new horizontal location |
[in] | y | The new vertical location |
ErrorManager::error_code_t TagShape::AddStyle | ( | const Style & | style, | |
fill_t | fill = SHAPE_FILL_EVEN | |||
) |
Since version 3 of SWF, it is possible to add new styles after adding edges. Otherwise, all the styles should be defined before the edges.
However, the SSWF library works in a slightly different way. It expects the user to call AddStyle() with a full and a line style. Then to call AddEdges(). For the next set of edges (next polygon), one is expected to call AddStyle() again and AddEdges().
The library will take care of compressing the result as much as possible eventually making use of the new feature of defining extraneous styles within the shape.
[in] | style | The style to add |
[in] | fill | The odd or even fill (i.e. SHAPE_FILL_EVEN or SHAPE_FILL_ODD) |
sswf::TagShape::Bounds | ( | int | index | ) | const [inline] |
This function retrieves a copy of the bounds rectangle currently defined in the shape.
The function returns a direct reference to the bounds defined inside the shape. It will change whenever the TagShape::SetBounds() function is called.
[in] | index | The morph image index (0 or 1) |
void TagShape::Glyph | ( | void | ) |
This function marks the shape as being a glyph. It has two effects: make sure the shape can be used in a font as a glyph and it removes the identification used for this shape.
bool TagShape::HasAlignZone | ( | void | ) | const |
This function returns true if an align zone is defined. This means that the rectangle used to define the alignment zone is not empty.
sswf::TagShape::HasBounds | ( | void | ) | const [inline] |
This function defines whether the bounds are defined or not.
sswf::TagShape::HasShowBounds | ( | void | ) | const [inline] |
This function defines whether the Save() function will add lines around the shape to show the location of the bounds.
bool TagShape::IsEmpty | ( | void | ) | const |
This function checks to see whether the shape is still empty.
bool TagShape::IsGlyph | ( | void | ) | const |
void TagShape::NewEdges | ( | void | ) | [private] |
This function ensures that the current setup is recorded and creates a new edges structure.
void TagShape::NewSetup | ( | void | ) | [private] |
This function ensures that the current edges are recorded and creates a new setup structure.
void TagShape::NewStyles | ( | void | ) |
This function can be called to request the TagShape object to create a new set of styles.
ErrorManager::error_code_t TagShape::PreSave | ( | void | ) | [private, virtual] |
This function ensures that the minimum version necessary to save that TagShape is acceptable.
Reimplemented from sswf::TagBase.
void TagShape::RecordEdges | ( | void | ) | [private] |
This function is used to record the current edges in order to start saving new style specifications.
This function can safely be called multiple times.
void TagShape::RecordSetup | ( | void | ) | [private] |
This function records the current setup. This allows one to continue by adding new edges.
This function can safely be called multiple times.
ErrorManager::error_code_t TagShape::Save | ( | Data & | data | ) | [virtual] |
This function determines the type of a shape this shape is (DefineShape, DefineShape2, DefineShape3, DefineShape4, DefineMorphShape or DefineMorphShape2) and then saves it in the specified Data buffer.
The PreSave() function must have been called once before.
[in] | data | The Data buffer where the edges are to be saved |
Implements sswf::TagBase.
void TagShape::SaveAlignZone | ( | Data & | data | ) | const |
This function saves the alignment zone in a Data buffer.
This represents one entry in an swf_zone_array structure.
[in] | data | The Data buffer where the zone is saved |
ErrorManager::error_code_t TagShape::SaveSetup | ( | save_info_t & | info, | |
const shape_setup_t & | setup, | |||
shape_setup_t & | last | |||
) | [private] |
This function saves a setup (move, fill and lines).
[in] | info | Definition of what needs to be saved |
[in] | setup | Setup to save |
[in] | last | Previous setup saved (to avoid repeats) |
info.f_save_styles ||
ErrorManager::error_code_t TagShape::SaveShape | ( | save_info_t & | info, | |
shape_setup_t & | last_setup | |||
) | [private] |
This function saves a shape depending on the info definitions.
[in] | info | Definition of what needs to be saved. |
[in] | last_setup | Current shape setup (move, fill & line styles) |
ErrorManager::error_code_t TagShape::SaveStyles | ( | save_info_t & | info | ) | [private] |
This function saves a set of styles.
[in] | info | Definition of what needs to be saved |
ErrorManager::error_code_t TagShape::SaveStylesCount | ( | save_info_t & | info, | |
long | count | |||
) | [private] |
This function saves a setup (move, fill and lines).
[in] | info | Definition of what needs to be saved |
[in] | count | Save this count depending on the version |
ErrorManager::error_code_t TagShape::SaveWithoutStyles | ( | Data & | data | ) |
This function is used by the sswf::TagFont object to save the edges without any style.
Note that this function is expected to be used to save glyphs only and thus shapes that are not morphing.
[in] | data | The Data buffer where the edges are to be saved |
void TagShape::SetAlignZone | ( | const SRectangle & | zone | ) |
This function is used to define a alignment zone to properly place glyphs on a pixel boundary.
Calling this function implies calling the Glyph() function to mark the shape as being a glyph.
You must set an align zone on all the glyphs of a font for them to be taken in account.
[in] | zone | The align zone rectangle |
ErrorManager::error_code_t TagShape::SetBounds | ( | int | index, | |
const SRectangle & | rect, | |||
bool | show_bounds = false | |||
) |
This function is used to mark the edges of the shape. This is the limit where the points on a shape go. Watchout, whenever you draw a curve, the points drawn can go outside of the limits defined by the control points.
[in] | index | The morph image index (0 or 1) |
[in] | rect | The rectangle defining the bounds |
[in] | show_bounds | Whether the Save() function should generate lines to show the bounds in the resulting animation |
void TagShape::SetMorph | ( | void | ) | [private] |
This function marks the shape as a morphing shape.
This means all the styles and edges must be defined twice. Once for the "normal" shape and once for the "morphed" shape.
sswf::TagShape::SetNonScalingStrokes | ( | bool | has_non_scaling_strokes | ) | [inline] |
This function can be used to mark whether some of the LINE2 are marked as non-scaling.
[in] | has_non_scaling_strokes | Set whether that flag should be saved as true or false |
sswf::TagShape::SetScalingStrokes | ( | bool | has_scaling_strokes | ) | [inline] |
This function can be used to mark whether some of the LINE2 are marked as scaling.
[in] | has_scaling_strokes | Set whether that flag should be saved as true or false |
ErrorManager::error_code_t TagShape::SetStrokesBounds | ( | int | index, | |
const SRectangle & | rect | |||
) |
This function is used to mark the edges of the shape including the strokes. This is the limit where the points of a shape go plus the width of the strokes used by the lines on the edges. Watchout, whenever you draw a curve, the points drawn can go outside of the limits defined by the control points.
[in] | index | The morph image index (0 or 1) |
[in] | rect | The rectangle defining the bounds |
sswf::TagShape::ShowBounds | ( | bool | show = true |
) | [inline] |
This function defines the flag used to tell the shape whether to show the bounds with lines.
[in] | show | Set to true if the bounds rectangle should be draw |
sswf::TagShape::ShowOrigin | ( | bool | show = true |
) | [inline] |
This function defines the flag used to tell the shape whether to draw lines to show the origin of the shape.
This is particularly useful if the shape needs to be rotated.
[in] | show | Set to true if the origin lines should be draw |
TagBase::swf_type_t TagShape::TypeFlags | ( | void | ) | const [virtual] |
The shape object is a definition, it references other objects and it has an identifier.
Implements sswf::TagBase.
SRectangle sswf::TagShape::f_align_zone [private] |
SRectangle sswf::TagShape::f_bounds[2] [private] |
shape_edges_t* sswf::TagShape::f_edges [private] |
Vectors sswf::TagShape::f_fill_styles [private] |
bool sswf::TagShape::f_has_non_scaling_strokes [private] |
bool sswf::TagShape::f_has_scaling_strokes [private] |
bool sswf::TagShape::f_is_glyph [private] |
Vectors sswf::TagShape::f_line_styles [private] |
bool sswf::TagShape::f_morph [private] |
shape_edges_t* sswf::TagShape::f_morph_edges [private] |
Vectors sswf::TagShape::f_morph_record [private] |
Vectors sswf::TagShape::f_record [private] |
shape_setup_t* sswf::TagShape::f_setup [private] |
Vectors sswf::TagShape::f_shapes [private] |
bool sswf::TagShape::f_show_bounds [private] |
bool sswf::TagShape::f_show_origin [private] |
SRectangle sswf::TagShape::f_strokes_bounds[2] [private] |
unsigned char sswf::TagShape::f_version [private] |