libsswf: sswf::TagShape Class Reference

# sswf::TagShape Class Reference

Defines an SWF shape. More...

`#include <libsswf.h>`

Inheritance diagram for sswf::TagShape:

List of all members.

## Public Types
enum | fill_t { SHAPE_FILL_EVEN = 0, SHAPE_FILL_ODD = 1 }
| Which fill is to be defined. More...
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...
## 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
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.
void | ParseAlignZone (const Data &data)
| Save alignment zone in a Data buffer.
virtual ErrorManager::error_code_t | ParseTag (swf_tag_t tag, const Data &data)
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...

## 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

References f_edges, f_has_non_scaling_strokes, f_has_scaling_strokes, f_is_glyph, f_morph, f_morph_edges, f_setup, f_show_bounds, f_show_origin, and f_version.

## 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

References sswf::Vectors::Count(), sswf::ErrorManager::ERROR_CODE_INVALID_MORPH_INDEX, sswf::ErrorManager::ERROR_CODE_INVALID_SHAPE, sswf::ErrorManager::ERROR_CODE_NONE, f_edges, sswf::TagShape::shape_edges_t::f_edges, f_fill_styles, f_line_styles, f_morph_edges, sswf::MemoryManager::MemAttach(), MORPH_MODE_BOTH_SHAPES, MORPH_MODE_SHAPE0, MORPH_MODE_SHAPE1, NewEdges(), sswf::TagBase::OnError(), sswf::Edges::Set(), SetMorph(), and SHAPE_EDGES.

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)

References AddEdge().

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)

Referenced by AddEdge().

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

References sswf::ErrorManager::ERROR_CODE_INVALID_MORPH_INDEX, sswf::ErrorManager::ERROR_CODE_NONE, f_morph_edges, f_morph_record, f_setup, sswf::TagShape::shape_setup_t::f_x, sswf::TagShape::shape_setup_t::f_y, sswf::MemoryManager::MemAttach(), MORPH_MODE_BOTH_SHAPES, MORPH_MODE_SHAPE0, MORPH_MODE_SHAPE1, NewSetup(), sswf::TagBase::OnError(), sswf::Vectors::Set(), SetMorph(), and SHAPE_SETUP.

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

References sswf::Vectors::Count(), sswf::ErrorManager::ERROR_CODE_INVALID_FILL_PARAMETER, sswf::ErrorManager::ERROR_CODE_NONE, sswf::ErrorManager::ERROR_CODE_TOO_MANY_STYLES, sswf::TagShape::shape_setup_t::f_fill_ref, f_fill_styles, sswf::TagShape::shape_setup_t::f_line_ref, f_line_styles, f_setup, f_version, sswf::Vectors::Get(), sswf::Style::Gradients(), sswf::Style::HasAlpha(), sswf::Style::HasHardEdges(), sswf::Style::HasMorph(), sswf::MemoryManager::MemAttach(), NewSetup(), sswf::TagBase::OnError(), sswf::Vectors::Set(), SetMorph(), SHAPE_FILL_EVEN, SHAPE_FILL_ODD, sswf::Style::STYLE_TYPE_ENHANCED_LINE, sswf::Style::STYLE_TYPE_GRADIENT_FOCAL, sswf::Style::STYLE_TYPE_LINE, sswf::Style::STYLE_TYPE_NO_FILL, sswf::Style::STYLE_TYPE_NO_LINE, and sswf::Style::Type().

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

References sswf::assert(), and f_bounds.

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

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.

References f_is_glyph, and sswf::TagBaseID::NoIdentification().

Referenced by SetAlignZone().

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.

References f_align_zone, and sswf::SRectangle::IsEmpty().

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

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)

References f_bounds, and sswf::SRectangle::IsEmpty().

Referenced by sswf::TagFont::PreSave2ndPass().

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)

References f_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.

References sswf::Vectors::Count(), f_edges, and f_record.

Referenced by sswf::TagFont::FindGlyph(), sswf::TagFont::GlyphInfo(), and Save().

bool TagShape::IsGlyph | ( | void |  | ) | const

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

Returns:
  true if the shape is a glyph

References f_is_glyph.

void TagShape::NewEdges | ( | void |  | ) | `[private]`

This function ensures that the current setup is recorded and creates a new edges structure.

References f_edges, sswf::MemoryManager::MemAttach(), RecordSetup(), and SHAPE_EDGES.

Referenced by AddEdge().

void TagShape::NewSetup | ( | void |  | ) | `[private]`

This function ensures that the current edges are recorded and creates a new setup structure.

References f_setup, sswf::MemoryManager::MemAttach(), RecordEdges(), and SHAPE_SETUP.

Referenced by AddMove(), and AddStyle().

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

References sswf::Vectors::Empty(), f_fill_styles, sswf::TagShape::shape_record_t::f_fill_styles, f_line_styles, sswf::TagShape::shape_record_t::f_line_styles, f_record, sswf::TagShape::shape_record_t::f_record, f_shapes, f_version, sswf::MemoryManager::MemAttach(), and sswf::Vectors::Set().

void TagShape::ParseAlignZone | ( | const Data & | data | ) | `[private]`

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

References f_align_zone, sswf::Data::GetShortFloat(), and sswf::SRectangle::Set().

virtual ErrorManager::error_code_t sswf::TagShape::ParseTag | ( | swf_tag_t | tag,
|  | const Data & | data |
| ) |  |  | `[private, virtual]`

Implements sswf::TagBase.

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.

References sswf::ErrorManager::ERROR_CODE_NONE, f_version, and sswf::TagBase::MinimumVersion().

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.

References f_edges, f_record, and sswf::Vectors::Set().

Referenced by NewSetup(), Save(), and SaveWithoutStyles().

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.

References f_record, f_setup, and sswf::Vectors::Set().

Referenced by NewEdges().

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.

References sswf::Data::Align(), sswf::Data::Append(), sswf::assert(), sswf::Data::ByteSize(), sswf::Vectors::Count(), sswf::ErrorManager::ERROR_CODE_INTERNAL_ERROR, sswf::ErrorManager::ERROR_CODE_NONE, f_bounds, sswf::TagShape::save_info_t::f_data, sswf::TagShape::shape_edges_t::f_edges, sswf::TagShape::save_info_t::f_ext_size, sswf::TagShape::shape_setup_t::f_fill_ref, f_fill_styles, sswf::TagShape::shape_record_t::f_fill_styles, sswf::TagShape::save_info_t::f_first, f_has_non_scaling_strokes, f_has_scaling_strokes, f_is_glyph, sswf::TagShape::shape_setup_t::f_line_ref, f_line_styles, sswf::TagShape::shape_record_t::f_line_styles, f_morph, f_morph_edges, f_morph_record, f_record, sswf::TagShape::shape_record_t::f_record, sswf::TagShape::save_info_t::f_save_alpha, sswf::TagShape::save_info_t::f_save_styles, sswf::TagShape::save_info_t::f_shape4, f_shapes, f_show_bounds, f_show_origin, sswf::TagShape::save_info_t::f_sr, f_strokes_bounds, f_version, sswf::TagShape::shape_setup_t::f_x, sswf::TagShape::shape_setup_t::f_y, sswf::Vectors::Get(), sswf::TagBase::Header(), IsEmpty(), sswf::TagBase::OnError(), sswf::Data::PutByte(), sswf::Data::PutLong(), RecordEdges(), sswf::SRectangle::Save(), sswf::TagBaseID::SaveID(), SaveShape(), sswf::TagBase::SaveTag(), sswf::Edges::Set(), sswf::Color::Set(), sswf::Vectors::Set(), sswf::SRectangle::Set(), sswf::Style::SetLine(), sswf::SRectangle::SetReorder(), SHAPE_EDGES, SHAPE_SETUP, sswf::TagBase::SWF_TAG_DEFINE_MORPH_SHAPE, sswf::TagBase::SWF_TAG_DEFINE_MORPH_SHAPE2, sswf::TagBase::SWF_TAG_DEFINE_SHAPE, sswf::TagBase::SWF_TAG_DEFINE_SHAPE2, sswf::TagBase::SWF_TAG_DEFINE_SHAPE3, sswf::TagBase::SWF_TAG_DEFINE_SHAPE4, sswf::Data::WriteBits(), sswf::SRectangle::XMax(), sswf::SRectangle::XMin(), sswf::SRectangle::YMax(), and sswf::SRectangle::YMin().

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

References f_align_zone, sswf::Data::PutShortFloat(), sswf::SRectangle::XMax(), sswf::SRectangle::XMin(), sswf::SRectangle::YMax(), and sswf::SRectangle::YMin().

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

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

References sswf::ErrorManager::ERROR_CODE_NONE, sswf::TagShape::save_info_t::f_data, sswf::TagShape::save_info_t::f_fill_bits_count, sswf::TagShape::shape_setup_t::f_fill_ref, sswf::TagShape::save_info_t::f_line_bits_count, sswf::TagShape::shape_setup_t::f_line_ref, f_version, sswf::TagShape::shape_setup_t::f_x, sswf::TagShape::shape_setup_t::f_y, sswf::TagBase::SIBitSize(), and sswf::Data::WriteBits().

Referenced by SaveShape().

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.

References sswf::Vectors::Count(), sswf::ErrorManager::ERROR_CODE_NONE, sswf::TagShape::save_info_t::f_data, sswf::TagShape::shape_edges_t::f_edges, sswf::TagShape::save_info_t::f_first, sswf::TagShape::shape_record_t::f_record, sswf::TagShape::save_info_t::f_save_styles, sswf::TagShape::save_info_t::f_sr, sswf::TagShape::shape_what_t::f_what, sswf::TagShape::shape_setup_t::f_x, sswf::TagShape::shape_setup_t::f_y, sswf::Vectors::Get(), sswf::Edges::Save(), SaveSetup(), SaveStyles(), SHAPE_SETUP, and sswf::Data::WriteBits().

Referenced by Save(), and SaveWithoutStyles().

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.

References sswf::Vectors::Count(), sswf::ErrorManager::ERROR_CODE_NONE, sswf::TagShape::save_info_t::f_data, sswf::TagShape::save_info_t::f_fill_bits_count, sswf::TagShape::shape_record_t::f_fill_styles, sswf::TagShape::save_info_t::f_line_bits_count, sswf::TagShape::shape_record_t::f_line_styles, f_morph, sswf::TagShape::save_info_t::f_save_alpha, sswf::TagShape::save_info_t::f_shape4, sswf::TagShape::save_info_t::f_sr, sswf::Vectors::Get(), sswf::Data::PutByte(), sswf::Style::Save(), SaveStylesCount(), sswf::Style::SetType(), sswf::Style::STYLE_TYPE_ENHANCED_LINE, sswf::Style::STYLE_TYPE_LINE, and sswf::TagBase::UIBitSize().

Referenced by SaveShape().

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.

References sswf::ErrorManager::ERROR_CODE_NONE, sswf::ErrorManager::ERROR_CODE_TOO_MANY_STYLES, sswf::TagShape::save_info_t::f_data, f_version, sswf::TagBase::OnError(), sswf::Data::PutByte(), and sswf::Data::PutShort().

Referenced by SaveStyles().

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.

References sswf::Data::Append(), sswf::Vectors::Count(), sswf::ErrorManager::ERROR_CODE_INCOMPATIBLE_MORPH, sswf::ErrorManager::ERROR_CODE_NONE, sswf::TagShape::save_info_t::f_data, sswf::TagShape::save_info_t::f_ext_size, sswf::TagShape::save_info_t::f_fill_bits_count, f_fill_styles, sswf::TagShape::shape_record_t::f_fill_styles, sswf::TagShape::save_info_t::f_first, sswf::TagShape::save_info_t::f_line_bits_count, f_line_styles, sswf::TagShape::shape_record_t::f_line_styles, f_morph, f_record, sswf::TagShape::shape_record_t::f_record, sswf::TagShape::save_info_t::f_save_alpha, sswf::TagShape::save_info_t::f_save_styles, f_shapes, sswf::TagShape::save_info_t::f_sr, sswf::Vectors::Get(), sswf::TagBase::OnError(), sswf::Data::PutByte(), RecordEdges(), SaveShape(), SHAPE_SETUP, and sswf::Data::WriteBits().

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

References f_align_zone, and Glyph().

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

References sswf::ErrorManager::ERROR_CODE_INVALID_MORPH_INDEX, sswf::ErrorManager::ERROR_CODE_NONE, f_bounds, f_show_bounds, sswf::TagBase::OnError(), and SetMorph().

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.

References f_morph, and f_version.

Referenced by AddEdge(), AddMove(), AddStyle(), SetBounds(), and SetStrokesBounds().

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

References f_has_non_scaling_strokes.

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

References f_has_scaling_strokes.

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

References sswf::ErrorManager::ERROR_CODE_INVALID_MORPH_INDEX, sswf::ErrorManager::ERROR_CODE_NONE, f_strokes_bounds, sswf::TagBase::OnError(), and SetMorph().

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)

References f_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)

References f_show_origin.

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.

References SWF_TYPE_DEFINE, SWF_TYPE_HAS_ID, and SWF_TYPE_REFERENCE.

## Member Data Documentation

SRectangle sswf::TagShape::f_align_zone`[private]`

Referenced by HasAlignZone(), ParseAlignZone(), SaveAlignZone(), and SetAlignZone().

SRectangle sswf::TagShape::f_bounds[2]`[private]`

Referenced by Bounds(), HasBounds(), Save(), and SetBounds().

shape_edges_t* sswf::TagShape::f_edges`[private]`

Referenced by AddEdge(), IsEmpty(), NewEdges(), RecordEdges(), and TagShape().

Vectors sswf::TagShape::f_fill_styles`[private]`

Referenced by AddEdge(), AddStyle(), NewStyles(), Save(), and SaveWithoutStyles().

bool sswf::TagShape::f_has_non_scaling_strokes`[private]`

Referenced by Save(), SetNonScalingStrokes(), and TagShape().

bool sswf::TagShape::f_has_scaling_strokes`[private]`

Referenced by Save(), SetScalingStrokes(), and TagShape().

bool sswf::TagShape::f_is_glyph`[private]`

Referenced by Glyph(), IsGlyph(), Save(), and TagShape().

Vectors sswf::TagShape::f_line_styles`[private]`

Referenced by AddEdge(), AddStyle(), NewStyles(), Save(), and SaveWithoutStyles().

bool sswf::TagShape::f_morph`[private]`

Referenced by Save(), SaveStyles(), SaveWithoutStyles(), SetMorph(), and TagShape().

shape_edges_t* sswf::TagShape::f_morph_edges`[private]`

Referenced by AddEdge(), AddMove(), Save(), and TagShape().

Vectors sswf::TagShape::f_morph_record`[private]`

Referenced by AddMove(), and Save().

Vectors sswf::TagShape::f_record`[private]`

Referenced by IsEmpty(), NewStyles(), RecordEdges(), RecordSetup(), Save(), and SaveWithoutStyles().

shape_setup_t* sswf::TagShape::f_setup`[private]`

Referenced by AddMove(), AddStyle(), NewSetup(), RecordSetup(), and TagShape().

Vectors sswf::TagShape::f_shapes`[private]`

Referenced by NewStyles(), Save(), and SaveWithoutStyles().

bool sswf::TagShape::f_show_bounds`[private]`

Referenced by HasShowBounds(), Save(), SetBounds(), ShowBounds(), and TagShape().

bool sswf::TagShape::f_show_origin`[private]`

Referenced by Save(), ShowOrigin(), and TagShape().

SRectangle sswf::TagShape::f_strokes_bounds[2]`[private]`

Referenced by Save(), and SetStrokesBounds().

unsigned char sswf::TagShape::f_version`[private]`

Referenced by AddStyle(), NewStyles(), PreSave(), Save(), SaveSetup(), SaveStylesCount(), SetMorph(), and TagShape().

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

- libsswf.h
- libsswf_tag_shape.c++