sswf::TagShape Class Reference

Defines an SWF shape. More...

#include <libsswf.h>

Inheritance diagram for sswf::TagShape:

sswf::TagBaseID sswf::TagBase sswf::MemoryManager List of all members.

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 SRectangleBounds (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_tf_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_tf_morph_edges
Vectors f_morph_record
Vectors f_record
shape_setup_tf_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...

Detailed Description

This object defines a shape or character.

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.

See also:
sswf::Style

sswf::TagFont

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

SWF Alexis' Reference—swf_shape_with_style

SWF Alexis' Reference—swf_tag


Member Enumeration Documentation

enum sswf::TagShape::fill_t

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.)

Enumerator:
SHAPE_FILL_EVEN  Use Fill0.

This enumeration defines Fill0 (or the even fill.)

SHAPE_FILL_ODD  Use Fill1.

This enumeration defines Fill1 (or the odd fill.)

enum sswf::TagShape::morph_t

This enumeration helps you create only the first, only the last or both shapes at once.

Enumerator:
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.

See also:
sswf::TagShape::MORPH_MODE_SHAPE1

sswf::TagShape::MORPH_MODE_BOTH_SHAPES

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.

See also:
sswf::TagShape::MORPH_MODE_SHAPE0

sswf::TagShape::MORPH_MODE_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.

See also:
sswf::TagShape::MORPH_MODE_SHAPE0

sswf::TagShape::MORPH_MODE_SHAPE1

enum sswf::TagShape::what_t [private]

Enumerator:
SHAPE_EDGES 
SHAPE_SETUP 


Constructor & Destructor Documentation

TagShape::TagShape ( TagBase parent  ) 

This function initializes the shape.

By default the shape is empty.

Parameters:
[in] parent The TagHeader in which this TagShape is inserted


Member Function Documentation

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.

Parameters:
[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)

See also:
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)

See also:
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.

Parameters:
[in] morph_mode One of the available morph modes
[in] x The new horizontal location
[in] y The new vertical location
Returns:
An error code or ErrorManager::ERROR_CODE_NONE

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.

Parameters:
[in] style The style to add
[in] fill The odd or even fill (i.e. SHAPE_FILL_EVEN or SHAPE_FILL_ODD)
Returns:
An Error code or ErrorManager::ERROR_CODE_NONE

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.

Parameters:
[in] index The morph image index (0 or 1)
Returns:
true if the bounds rectangle was defined
See also:
sswf::TagShape::SetBounds(int index, const SRectangle& rect, bool show_bounds)

sswf::TagShape::HasBounds(void) const

sswf::TagShape::HasShowBounds(void) const

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.

Returns:
True if the alignment zone is defined in this glyph.

sswf::TagShape::HasBounds ( void   )  const [inline]

This function defines whether the bounds are defined or not.

Returns:
true if the bounds rectangle was defined
See also:
sswf::TagShape::SetBounds(int index, const SRectangle& rect, bool show_bounds)

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.

Returns:
true if the bounds rectangle was defined
See also:
sswf::TagShape::SetBounds(int index, const SRectangle& rect, bool show_bounds)

bool TagShape::IsEmpty ( void   )  const

This function checks to see whether the shape is still empty.

Returns:
true if the shape was not yet defined.

bool TagShape::IsGlyph ( void   )  const

This function checks whether the Glyph() function was called.

Returns:
true if the shape is a glyph

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.

Note:
This will enable one to have smaller fill & line style references (less bits) -- however that is most probably useless (my point of view.)

ErrorManager::error_code_t TagShape::PreSave ( void   )  [private, virtual]

This function ensures that the minimum version necessary to save that TagShape is acceptable.

Returns:
An error code or ErrorManager::ERROR_CODE_NONE.

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.

Note:
Glyphs aren't saved via this function. Instead the Font saves the edges as required.
Parameters:
[in] data The Data buffer where the edges are to be saved
Returns:
An error code or ErrorManager::ERROR_CODE_NONE.

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.

Bug:
At this time I assume that the rectangle has to be defined in TWIPS. This means each coordinate is divided by 20 before being saved. That seems to correspond to what the documentation says, but the exact type of coordinate is not really defined.
Parameters:
[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).

Parameters:
[in] info Definition of what needs to be saved
[in] setup Setup to save
[in] last Previous setup saved (to avoid repeats)
Returns:
An error code or ErrorManager::ERROR_CODE_NONE.

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.

Parameters:
[in] info Definition of what needs to be saved.
[in] last_setup Current shape setup (move, fill & line styles)
Returns:
An error code or ErrorManager::ERROR_CODE_NONE.

ErrorManager::error_code_t TagShape::SaveStyles ( save_info_t info  )  [private]

This function saves a set of styles.

Parameters:
[in] info Definition of what needs to be saved
Returns:
An error code or ErrorManager::ERROR_CODE_NONE.

ErrorManager::error_code_t TagShape::SaveStylesCount ( save_info_t info,
long  count 
) [private]

This function saves a setup (move, fill and lines).

Parameters:
[in] info Definition of what needs to be saved
[in] count Save this count depending on the version
Returns:
An error code or ErrorManager::ERROR_CODE_NONE.

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.

Parameters:
[in] data The Data buffer where the edges are to be saved
Returns:
An error code or ErrorManager::ERROR_CODE_NONE.

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.

Parameters:
[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.

Bug:
The show bounds feature does not work for a shape used as the hit test of a button or in a glyph.
Parameters:
[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
Returns:
An error code or ErrorManager::ERROR_CODE_NONE

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.

Bug:
This needs to be done dynamically whenever we save the shapes.
Parameters:
[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.

Bug:
This needs to be done dynamically whenever we save the shapes.
Parameters:
[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.

Parameters:
[in] index The morph image index (0 or 1)
[in] rect The rectangle defining the bounds
Returns:
An error code or ErrorManager::ERROR_CODE_NONE

sswf::TagShape::ShowBounds ( bool  show = true  )  [inline]

This function defines the flag used to tell the shape whether to show the bounds with lines.

Bug:
The show bounds feature does not work for a shape used as the hit test of a button or in a glyph.
Parameters:
[in] show Set to true if the bounds rectangle should be draw
See also:
sswf::TagShape::SetBounds(int index, const SRectangle& rect, bool show_bounds)

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.

Bug:
The show origin feature does not work for a shape used as the hit test of a button or in a glyph.
Parameters:
[in] show Set to true if the origin lines should be draw
See also:
sswf::TagShape::SetBounds(int index, const SRectangle& rect, bool show_bounds)

TagBase::swf_type_t TagShape::TypeFlags ( void   )  const [virtual]

The shape object is a definition, it references other objects and it has an identifier.

Returns:
SWF_TYPE_DEFINE, SWF_TYPE_REFERENCE and SWF_TYPE_HAS_ID

Implements sswf::TagBase.


Member Data Documentation

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]


The documentation for this class was generated from the following files:
Generated on Tue Jun 26 02:36:46 2007 for libsswf by  doxygen 1.4.7