Made to Order Software Corporation Logo

libsswf: sswf::Style Class Reference

Defines the style of a shape. More...

#include <libsswf.h>

Inheritance diagram for sswf::Style:

:ItemBase :MemBuffer

List of all members.


Public Types

enum  cap_t { STYLE_LINE_CAP_SAME = -1, STYLE_LINE_CAP_ROUND = 0, STYLE_LINE_CAP_NONE = 1, STYLE_LINE_CAP_SQUARE = 2 }
 How the line start and end. More...
enum  interpolation_t { STYLE_GRADIENT_INTERPOLATION_NORMAL = 0, STYLE_GRADIENT_INTERPOLATION_LINEAR = 1 }
 How the gradient colors are computed. More...
enum  join_t { STYLE_LINE_JOIN_UNKNOWN = -1, STYLE_LINE_JOIN_ROUND = 0, STYLE_LINE_JOIN_BEVEL = 1, STYLE_LINE_JOIN_MITER = 2 }
 How the lines segments join together. More...
enum  spread_t { STYLE_GRADIENT_SPREAD_PAD = 0, STYLE_GRADIENT_SPREAD_REFLECT = 1, STYLE_GRADIENT_SPREAD_REPEAT = 2 }
 How the gradient is spread on the edges. More...
enum  style_t {
  STYLE_TYPE_UNKNOWN = 0, STYLE_TYPE_NO_LINE, STYLE_TYPE_NO_FILL, STYLE_TYPE_LINE,
  STYLE_TYPE_ENHANCED_LINE, STYLE_TYPE_SOLID, STYLE_TYPE_GRADIENT_LINEAR, STYLE_TYPE_GRADIENT_RADIAL,
  STYLE_TYPE_GRADIENT_FOCAL, STYLE_TYPE_BITMAP_TILLED, STYLE_TYPE_BITMAP_CLIPPED, STYLE_TYPE_BITMAP_HARDEDGE_TILLED,
  STYLE_TYPE_BITMAP_HARDEDGE_CLIPPED, STYLE_TYPE_MATRIX, STYLE_TYPE_max
}
 The enumeration of all the supported types. More...

Public Member Functions

signed char Gradients (void) const
 Return the number of gradients in a gradient style.
bool HasAlpha (void) const
 Use to check the style for an alpha channel.
bool HasHardEdges (void) const
 Check whether the style uses hard edges.
bool HasMorph (void) const
 Check whether the style is defined as a morphing style.
bool operator== (const Style &style) const
 Compare two styles between each other.
void Reset (void)
 Resets a style to all defaults.
ErrorManager::error_code_t Save (Data &data, bool save_alpha, bool save_morph)
 Save a style in the specified Data buffer.
bool SetBitmap (sswf_id_t id_ref)
 Set the identifier of the bitmap to used by this fill.
bool SetClipping (void)
 Mark style as clipping style.
bool SetColor (int index, const Color &color)
 Defines the color of a style.
bool SetGradient (int index, int pos, const Color &color)
 Defines a gradient entry.
bool SetGradientFocal (float focal)
 Defines the focal point of a gradient.
bool SetGradientModes (spread_t spread, interpolation_t interpolation)
 Defines the modes of a gradient.
bool SetLine (int index, unsigned short width, const Color &color)
 Define this style as a line.
bool SetLineCaps (cap_t start, cap_t end=STYLE_LINE_CAP_SAME)
 Define the caps of a line.
bool SetLineFillStyle (const Style &fill_style)
 Set a fill for the line.
bool SetLineJoin (join_t join, float miter_limit_factor=0.0f)
 Define how to join line segments.
bool SetLineNoClose (bool no_close)
 Equal start and end points and closure.
bool SetLinePixelHinting (bool pixel_hinting)
 Drawn pixels alignment with physical pixels.
bool SetLineScale (bool horiz, bool vert)
 Define the scaling effects on this line.
bool SetMatrix (int index, const Matrix &matrix)
 Defines the fill matrix.
bool SetType (style_t style_type)
 Sets the type of the style.
 Style (ErrorManager &error_manager)
 Initializes a style.
style_t Type (void) const
 Retrieve the current type of the style.
virtual ~Style ()
 Clean up the style.

Static Public Attributes

static const signed char MAX_GRADIENTS = 15
 Defines the total number of gradients available in a gradient style.

Private Attributes

sswf_id_t f_bitmap_ref
Color f_color [2]
cap_t f_end_cap_style
ErrorManagerf_error_manager
Stylef_fill_style
signed char f_gradient
Color f_gradient_color [MAX_GRADIENTS *2]
signed short f_gradient_focal
interpolation_t f_gradient_interpolation
unsigned char f_gradient_pos [MAX_GRADIENTS *2]
spread_t f_gradient_spread
join_t f_join_style
unsigned short f_line_width [2]
Matrix f_matrix [2]
float f_miter_limit_factor
bool f_morph
bool f_no_close
bool f_no_hscale
bool f_no_vscale
bool f_pixel_hinting
cap_t f_start_cap_style
style_t f_style
bool f_use_alpha

Detailed Description

When drawing a shape, one can change the style. This indicates the line width and color, as well as the fill of the inside of the shape.

The Style object includes support for morphing shapes.

See also:
sswf::TagShape

SWF Alexis' Reference—swf_fill_style

SWF Alexis' Reference—swf_fill_style_array

SWF Alexis' Reference—swf_gradient

SWF Alexis' Reference—swf_gradient_record

SWF Alexis' Reference—swf_line_style

SWF Alexis' Reference—swf_line_style_array

SWF Alexis' Reference—swf_styles


Member Enumeration Documentation

This enumeration lists the different possible ways the start and end of a line are drawn.

Enumerator:
STYLE_LINE_CAP_SAME  Use the other side cap definition.

When the start or end line cap is set to this value (but not both) the SetLineCaps() sets both caps to the other value.

STYLE_LINE_CAP_ROUND  Use a round cap (half a circle.).

This is the default and the same as the old style for the tip of a line: half a circle.

STYLE_LINE_CAP_NONE  Do not draw any cap.

This mode means that no cap shall be added. It looks similar to the Style::STYLE_LINE_CAP_SQUARE but the line stops right at the last point or edge.

See also:
sswf::Style::STYLE_LINE_CAP_SQUARE

STYLE_LINE_CAP_SQUARE  Draw a square (rectangle) cap.

This mode means that the cap shall be flat (a rectangle). It looks like a flat edge. Before, this could be achive with the use of a rectangle to draw the line. Yet, it is easier to draw a line since it connects with multiple segments and curves.

See also:
sswf::Style::STYLE_LINE_CAP_NONE

This enumeration lists the different possible ways a gradient colors can be computed.

Enumerator:
STYLE_GRADIENT_INTERPOLATION_NORMAL  Draw in normal RGB mode, taking the luminance in account.

The normal interpolation mode is what was used before for gradients. It means that the luminance is taken in account whenever computing the intermediate colors.

STYLE_GRADIENT_INTERPOLATION_LINEAR  Draw in linear RGB mode.

The linear interpolation mode is very fast and computes the different colors with a very simple line equation (x = ay + b).

This enumeration lists the different possible ways two line segment will be joined.

Enumerator:
STYLE_LINE_JOIN_UNKNOWN  Unknown join for your own purpose.

This mode can be used to mark that a join was not defined in a variable. (It is used in sswf.)

STYLE_LINE_JOIN_ROUND  Draw a circle where two segments meet.

This mode is the default. It draws rounded joins wherever two line segments meet.

STYLE_LINE_JOIN_BEVEL  Draw a square where two segments meet.

This mode can be used to draw a triangle to close the join.

STYLE_LINE_JOIN_MITER  Continue the edges until they meet.

This mode is similar to the bevel join. It continues the edges until they meet unless the specified miter limit is reached.

This enumeration lists the different possible ways a gradient can be repeated on the edges.

Enumerator:
STYLE_GRADIENT_SPREAD_PAD  Draw the edge color on the sides.

This mode is the default mode which what was used in the previous gradients.

STYLE_GRADIENT_SPREAD_REFLECT  Draw the gradient and mirror.

In this mode, the edges are rendered going backward into the gradient, ping-ponging as many times as necessary.

STYLE_GRADIENT_SPREAD_REPEAT  Draw the gradient multiple times.

In this mode, the edges are rendered restarting on the other side of the gradient as many times as necessary.

This is the list of styles supported by the SSWF library.

Enumerator:
STYLE_TYPE_UNKNOWN  Until set, the type of a style is unknown.

By default, this type is the type of a style.

STYLE_TYPE_NO_LINE  Used to remove a previous line style.

This special type is used to create a style used to remove a previous line style. When creating a shape, you can have a line, then a fill without line. In that case, you need to remove the line, This is done with a style of this type.

See also:
sswf::Style::STYLE_TYPE_NO_FILL

STYLE_TYPE_NO_FILL  Used to remove a previous fill style.

This special type is used to create a style used to remove a previous fill style. When creating a shape, you can have a fill, then a line without fill. In that case, you need to remove the fill, This is done with a style of this type.

See also:
sswf::Style::STYLE_TYPE_NO_LINE

STYLE_TYPE_LINE  Draw a simple solid color line.

This style defines a line thickness and color. It can be used for a morphing shape.

See also:
sswf::Style::STYLE_TYPE_ENHANCED_LINE

STYLE_TYPE_ENHANCED_LINE  Draw a line.

This style defines a line thickness, color, caps, joins, scaling reaction, hinting, closing behavior and fill style.

Support for this type of line appeared in SWF version 8.

See also:
sswf::Style::STYLE_TYPE_LINE

STYLE_TYPE_SOLID  Fill with a solid color.

This style is called solid because it uses just one color. Note that it can still make use of a color with transparency.

STYLE_TYPE_GRADIENT_LINEAR  Fill with a linear gradient.

Fill with a gradient drawn linearly (left to right).

STYLE_TYPE_GRADIENT_RADIAL  Fill with a radial gradient.

Fill with a gradient drawn in a circle (center to edge).

See also:
sswf::Style::STYLE_TYPE_GRADIENT_FOCAL

STYLE_TYPE_GRADIENT_FOCAL  Fill with a radial gradient using a focal point to start.

Fill with a gradient drawn in a circle (focal position to edge).

See also:
sswf::Style::STYLE_TYPE_GRADIENT_RADIAL

STYLE_TYPE_BITMAP_TILLED  Fill with a bitmap, repeat as required.

This style type is used to fill a background with a repeated bitmap.

See also:
sswf::Style::STYLE_TYPE_BITMAP_HARDEDGE_TILLED

STYLE_TYPE_BITMAP_CLIPPED  Fill with a bitmap, draw nothing on the edges.

This style type is used to draw an image.

See also:
sswf::Style::STYLE_TYPE_BITMAP_HARDEDGE_CLIPPED

STYLE_TYPE_BITMAP_HARDEDGE_TILLED  Fill with a bitmap, repeat as required.

This style type is used to fill a background with a repeated bitmap.

See also:
sswf::Style::STYLE_TYPE_BITMAP_TILLED

STYLE_TYPE_BITMAP_HARDEDGE_CLIPPED  Fill with a bitmap, draw nothing on the edges.

This style type is used to draw an image.

See also:
sswf::Style::STYLE_TYPE_BITMAP_CLIPPED

STYLE_TYPE_MATRIX  Used internally to mark that a matrix was defined.

This type is used to mark a style which type was not yet defined as a style using a matrix.

This enables tests to ensure that the style is a bitmap or a gradient style (only ones that accept a matrix.)

STYLE_TYPE_max  Used to know the maximum number of available styles.

This is not a style type. It only defines the maximum number of styles. Any valid style will have a positive or null number smaller than this value.


Constructor & Destructor Documentation

Style::Style ( ErrorManager error_manager  )  [explicit]

The constructor initializes a style to all defaults.

This means no lines and no fill.

References Reset().

Referenced by SetLineFillStyle().

Style::~Style (  )  [virtual]

Since version 1.8.1 a style can include another style when a line uses a fill style to get rendered. This sub-style needs to be deleted.

References f_fill_style.


Member Function Documentation

signed char sswf::Style::Gradients ( void   )  const [inline]

This function can be used to determine how many gradients are defined in a gradient style.

Since version 8 of SWF, it is possible to use up to 15 gradients. The older versions accepted only up to 8.

This function can be used to determine the version necessary to handle this style. When 9 or more gradients are used, it is necessary to use a DefineShape4.

Returns:
The number of gradients currently defined.

References f_gradient.

Referenced by sswf::TagShape::AddStyle().

sswf::Style::HasAlpha ( void   )  const [inline]

This function can be used to check whether a style has one color or more which is not solid. This is important to determine the version of shape to use.

Returns:
true if at least one color of the style is not 100% solid.

References f_use_alpha.

Referenced by sswf::TagShape::AddStyle().

sswf::Style::HasHardEdges ( void   )  const [inline]

This function checks whether the type of the style implies that it uses hard edges.

The two types which implies hard edges are:

This is important since these types only appeared in SWF version 7.

Returns:
true if at the style type is one of the hard edge bitmap styles

References f_style, STYLE_TYPE_BITMAP_HARDEDGE_CLIPPED, and STYLE_TYPE_BITMAP_HARDEDGE_TILLED.

Referenced by sswf::TagShape::AddStyle().

sswf::Style::HasMorph ( void   )  const [inline]

This function checks whether any of the setup function was called with a morphing index (1 for most functions, Style::MAX_GRADIENT to Style::MAX_GRADIENT * 2 - 1 for the gradient function.)

Returns:
true if at least one function was called with a morph index

References f_morph.

Referenced by sswf::TagShape::AddStyle().

bool Style::operator== ( const Style style  )  const

This comparison operator can be used to compare two styles. This is used in many places to know whether a certain style already exists in a list of styles. This let's us optimize as much as possible.

Note that if both types have different types, they are always considered different.

When types have the same types, then the corresponding data is compared between both objects. Thus, a bitmap style requires the bitmap identifier and matrix comparisons.

Bug:
Try to compare a style of type Style::STYLE_TYPE_UNKNOWN generates an error and returns false.
Parameters:
[in] style The style to compare against
Returns:
true if the two styles are indeed equal

References sswf::ErrorManager::ERROR_CODE_INVALID_STYLE, f_bitmap_ref, f_color, f_end_cap_style, f_error_manager, f_fill_style, f_gradient, f_gradient_color, f_gradient_pos, f_join_style, f_line_width, f_matrix, f_miter_limit_factor, f_morph, f_no_close, f_no_hscale, f_no_vscale, f_pixel_hinting, f_start_cap_style, f_style, MAX_GRADIENTS, sswf::ErrorManager::OnError(), STYLE_TYPE_BITMAP_CLIPPED, STYLE_TYPE_BITMAP_HARDEDGE_CLIPPED, STYLE_TYPE_BITMAP_HARDEDGE_TILLED, STYLE_TYPE_BITMAP_TILLED, STYLE_TYPE_ENHANCED_LINE, STYLE_TYPE_GRADIENT_FOCAL, STYLE_TYPE_GRADIENT_LINEAR, STYLE_TYPE_GRADIENT_RADIAL, STYLE_TYPE_LINE, STYLE_TYPE_SOLID, and STYLE_TYPE_UNKNOWN.

ErrorManager::error_code_t Style::Save ( Data data,
bool  save_alpha,
bool  save_morph 
)

This function saves the style in a Data buffer.

The caller must know whether the style is using alpha or is for a morphing shape. If it does not correspond, then errors are generated.

This function is used by the regular shapes and the font glyphs. When used by font glyphs, the save_morph parameter is always set to false.

When a morphing shape is saved, the save_morph is set to true in which case the save_alpha is expected to be true too.

Parameters:
[in] data The Data buffer where the style is saved
[in] save_alpha Whether the alpha should be saved
[in] save_morph Whether the morph data should be saved
Returns:
an error code or ERROR_CODE_NONE when no error occurs

References sswf::Data::Align(), sswf::assert(), sswf::ErrorManager::ERROR_CODE_ALPHA_MISMATCH, sswf::ErrorManager::ERROR_CODE_ENHANCED_LINE_REQUIRES_ALPHA, sswf::ErrorManager::ERROR_CODE_INVALID_STYLE, sswf::ErrorManager::ERROR_CODE_MORPH_GRADIENT_LIMIT, sswf::ErrorManager::ERROR_CODE_MORPH_MISMATCH, sswf::ErrorManager::ERROR_CODE_MORPH_REQUIRES_ALPHA, sswf::ErrorManager::ERROR_CODE_NO_FOCAL_WITH_MORPH, sswf::ErrorManager::ERROR_CODE_NONE, f_bitmap_ref, f_color, f_end_cap_style, f_error_manager, f_fill_style, f_gradient, f_gradient_color, f_gradient_focal, f_gradient_interpolation, f_gradient_pos, f_gradient_spread, f_join_style, f_line_width, f_matrix, f_miter_limit_factor, f_morph, f_no_close, f_no_hscale, f_no_vscale, f_pixel_hinting, f_start_cap_style, f_style, f_use_alpha, MAX_GRADIENTS, sswf::ErrorManager::OnError(), sswf::Data::PutByte(), sswf::Data::PutShort(), sswf::Matrix::Save(), Save(), sswf::Color::Save(), STYLE_LINE_JOIN_MITER, STYLE_TYPE_BITMAP_CLIPPED, STYLE_TYPE_BITMAP_HARDEDGE_CLIPPED, STYLE_TYPE_BITMAP_HARDEDGE_TILLED, STYLE_TYPE_BITMAP_TILLED, STYLE_TYPE_ENHANCED_LINE, STYLE_TYPE_GRADIENT_FOCAL, STYLE_TYPE_GRADIENT_LINEAR, STYLE_TYPE_GRADIENT_RADIAL, STYLE_TYPE_LINE, STYLE_TYPE_SOLID, and sswf::Data::WriteBits().

Referenced by Save(), and sswf::TagShape::SaveStyles().

bool Style::SetBitmap ( sswf_id_t  id_ref  ) 

This function sets the identifier of the bitmap to use in case the style is a bitmap fill.

By default, this function sets the type of the style to Style::STYLE_TYPE_BITMAP_TILLED.

Parameters:
[in] id_ref The identifier of the bitmap object
Returns:
true when the identifier is used; false if the identifier is invalid or the style type cannot be changed

References sswf::ErrorManager::ERROR_CODE_INVALID_MORPH_INDEX, f_bitmap_ref, f_error_manager, f_style, sswf::ErrorManager::OnError(), SetType(), STYLE_TYPE_BITMAP_CLIPPED, STYLE_TYPE_BITMAP_HARDEDGE_CLIPPED, STYLE_TYPE_BITMAP_HARDEDGE_TILLED, and STYLE_TYPE_BITMAP_TILLED.

bool Style::SetClipping ( void   ) 

This function marks the bitmap style as clipping.

Returns:
true when the clipping is set; false if the type cannot be changed as necessary.

References f_bitmap_ref, f_style, SetType(), SSWF_ID_NONE, STYLE_TYPE_BITMAP_CLIPPED, STYLE_TYPE_BITMAP_HARDEDGE_CLIPPED, STYLE_TYPE_BITMAP_HARDEDGE_TILLED, and STYLE_TYPE_BITMAP_TILLED.

bool Style::SetColor ( int  index,
const Color color 
)

This function defines a style as a solid color.

On success, the type of the style is set to Style::STYLE_TYPE_SOLID.

Returns:
true when the style is set to the specified color; false if a parameter is invalid or the type of the style cannot be modified

References sswf::Color::Alpha(), sswf::ErrorManager::ERROR_CODE_INVALID_MORPH_INDEX, f_color, f_error_manager, f_morph, f_use_alpha, sswf::ErrorManager::OnError(), SetType(), and STYLE_TYPE_SOLID.

bool Style::SetGradient ( int  index,
int  pos,
const Color color 
)

This function defines the style as a gradient and sets the specified gradient entry to the specified color.

It is expected that one will only use small indices. If you need a gradient with three colors, then you should only use indices 0, 1 and 2.

To create a morphing gradient, add Style::MAX_GRADIENTS to the index to change the color of the second image.

Style::MAX_GRADIENTS is currently 15. It was 8 in previous versions.

The position parameter must be set to 0 for the very first point and 255 for the very last. Any intermediate values are acceptable.

Note:
This function sets the type to Style::STYLE_TYPE_GRADIENT_LINEAR if the current style is not one of the available gradient types.
Parameters:
[in] index The gradient color to change (0 to Style::MAX_GRADIENTS)
[in] pos The position of the color in the gradient definition
[in] color The gradient color at that position
Returns:
true when the style is set to the specified color; false if a parameter is invalid or the type of the style cannot be modified

References sswf::Color::Alpha(), sswf::ErrorManager::ERROR_CODE_INVALID_MORPH_INDEX, sswf::ErrorManager::ERROR_CODE_INVALID_POSITION, f_error_manager, f_gradient, f_gradient_color, f_gradient_pos, f_morph, f_style, f_use_alpha, MAX_GRADIENTS, sswf::ErrorManager::OnError(), SetType(), STYLE_TYPE_GRADIENT_FOCAL, STYLE_TYPE_GRADIENT_LINEAR, and STYLE_TYPE_GRADIENT_RADIAL.

bool Style::SetGradientFocal ( float  focal  ) 

This function defines the focal point of a gradient.

The value goes from -1 to +1, where -1 represents the left side, 0 the center and +1 the right side.

Using the matrix and rotation it is possible to place the focal point anywhere.

The style must be a gradient style or still undefined for this function to work.

The focal value must be defined between -1 and +1 or the function will return false.

Parameters:
[in] focal The gradient focal point
Returns:
true when the gradient focal could be saved; false otherwise

References sswf::ErrorManager::ERROR_CODE_INVALID_FOCAL, f_error_manager, f_gradient_focal, sswf::ErrorManager::OnError(), SetType(), and STYLE_TYPE_GRADIENT_FOCAL.

bool Style::SetGradientModes ( spread_t  spread,
interpolation_t  interpolation 
)

This function defines a gradient style modes.

Spread Modes:

Interpolation Modes:

Note:
This function sets the type to Style::STYLE_TYPE_GRADIENT_LINEAR if the current style is not one of the available gradient types.
Parameters:
[in] spread One of STYLE_GRADIENT_SPREAD_...
[in] interpolation One of STYLE_GRADIENT_INTERPOLATION_...
Returns:
true when the style is set to the specified color; false if a parameter is invalid or the type of the style cannot be modified

References sswf::ErrorManager::ERROR_CODE_INVALID_INTERPOLATION_MODE, sswf::ErrorManager::ERROR_CODE_INVALID_SPREAD_MODE, f_error_manager, f_gradient_interpolation, f_gradient_spread, f_style, sswf::ErrorManager::OnError(), SetType(), STYLE_GRADIENT_INTERPOLATION_LINEAR, STYLE_GRADIENT_INTERPOLATION_NORMAL, STYLE_GRADIENT_SPREAD_PAD, STYLE_GRADIENT_SPREAD_REFLECT, STYLE_GRADIENT_SPREAD_REPEAT, STYLE_TYPE_GRADIENT_FOCAL, STYLE_TYPE_GRADIENT_LINEAR, and STYLE_TYPE_GRADIENT_RADIAL.

bool Style::SetLine ( int  index,
unsigned short  width,
const Color color 
)

This function defines the current style as a line. The style must have been reset, never set or set to a line or the function will fail.

On success, the type of the style is set to Style::STYLE_TYPE_LINE.

Note:
This is the only Line style available. All the other styles are considered fill styles.
Parameters:
[in] index The morph index (0 or 1)
[in] width The width (thickness) of the line
[in] color The color of the line
Returns:
true when the style is set to the specified line; false if a parameter is invalid or the type of the style cannot be modified

References sswf::Color::Alpha(), sswf::ErrorManager::ERROR_CODE_INVALID_MORPH_INDEX, f_color, f_error_manager, f_line_width, f_morph, f_use_alpha, sswf::ErrorManager::OnError(), SetType(), and STYLE_TYPE_LINE.

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

bool Style::SetLineCaps ( cap_t  start,
cap_t  end = STYLE_LINE_CAP_SAME 
)

This function defines the start and end caps.

Caps can be:

By default, the start and end caps are set to Style::STYLE_LINE_CAP_ROUND.

Note:
The function returns an error if the style cannot be set to the enhanced line mode.
Parameters:
[in] start One of STYLE_LINE_CAP_...
[in] end One of STYLE_LINE_CAP_...
Returns:
true when the line style can be set; false otherwise

References sswf::ErrorManager::ERROR_CODE_INVALID_LINE_INFO, f_end_cap_style, f_error_manager, f_start_cap_style, sswf::ErrorManager::OnError(), SetType(), STYLE_LINE_CAP_NONE, STYLE_LINE_CAP_ROUND, STYLE_LINE_CAP_SAME, STYLE_LINE_CAP_SQUARE, and STYLE_TYPE_ENHANCED_LINE.

bool Style::SetLineFillStyle ( const Style fill_style  ) 

This function defines a fill style to use to render the enhanced line.

With regular lines, only a color can be used.

By default, solid colors are used.

Note:
If the fill_style is a solid color, then the line becomes a regular line and the fill style colors are copied. If you want to keep an enhanced line, use the SetColor() function instead.
Parameters:
[in] fill_style The solid, bitmap or gradient fill
Returns:
true when the line style can be set; false otherwise
See also:
sswf::Style::SetColor(int index, const Color& color)

References sswf::ErrorManager::ERROR_CODE_INVALID_LINE_INFO, f_color, f_error_manager, f_fill_style, f_style, sswf::ErrorManager::OnError(), SetType(), Style(), STYLE_TYPE_BITMAP_CLIPPED, STYLE_TYPE_BITMAP_HARDEDGE_CLIPPED, STYLE_TYPE_BITMAP_HARDEDGE_TILLED, STYLE_TYPE_BITMAP_TILLED, STYLE_TYPE_ENHANCED_LINE, STYLE_TYPE_GRADIENT_FOCAL, STYLE_TYPE_GRADIENT_LINEAR, STYLE_TYPE_GRADIENT_RADIAL, STYLE_TYPE_LINE, and STYLE_TYPE_SOLID.

bool Style::SetLineJoin ( join_t  join,
float  miter_limit_factor = 0.0f 
)

This function defines the join and when set to a miter join, the limit factor of the miter join.

The maximum length of the miter is the limit factor times the width of the line. Over that limit, the line is cutoff. The miter factor must be positive or null.

The available joins are:

By default, the join is set to Style::STYLE_LINE_JOIN_ROUND and the miter limit is set to 0.0f.

Note:
The function returns an error if the style cannot be set to the enhanced line mode.
Bug:
The miter join limit factor is always saved. The default is 0.0f which will have no effects.
Parameters:
[in] join One of STYLE_LINE_JOIN_...
[in] miter_limit_factor The limit of the miter join
Returns:
true when the line style can be set; false otherwise

References sswf::ErrorManager::ERROR_CODE_INVALID_LINE_INFO, sswf::ErrorManager::ERROR_CODE_NEGATIVE_MITER, f_error_manager, f_join_style, f_miter_limit_factor, sswf::ErrorManager::OnError(), SetType(), STYLE_LINE_JOIN_BEVEL, STYLE_LINE_JOIN_MITER, STYLE_LINE_JOIN_ROUND, and STYLE_TYPE_ENHANCED_LINE.

bool Style::SetLineNoClose ( bool  no_close  ) 

This function is used to tell Flash whether a start and end point which are equal represent an enclosed shape and thus to draw a join (false) or whether it is a line with ends anyway (true).

By default, this value is set to false meaning that the line forms an enclosed shape if the start and end points are equal.

Parameters:
[in] no_close If true, this is an open line
Returns:
true when the line style can be set; false otherwise

References f_no_close, SetType(), and STYLE_TYPE_ENHANCED_LINE.

bool Style::SetLinePixelHinting ( bool  pixel_hinting  ) 

This function defines whether pixels should be drawn at a pixel boundary on the screen.

This is good to avoid anti-aliasing, but bad if you want to move your objects slowly.

By default, this flag is set to false meaning that lines are drawn anywhere.

Parameters:
[in] pixel_hinting True to force pixels to screen boundaries
Returns:
true when the line style can be set; false otherwise

References f_pixel_hinting, SetType(), and STYLE_TYPE_ENHANCED_LINE.

bool Style::SetLineScale ( bool  horiz,
bool  vert 
)

This function defines whether a scale factor affects a line. The factors can be cancelled horizontally, vertically or in both direction.

It is not clear what happens when the object is rotated.

By default, these flags are set to false which means that the line will be resized in both directions.

Parameters:
[in] horiz Whether to scale the line horizontally
[in] vert Whether to scale the line vertically
Returns:
true when the line style can be set; false otherwise

References f_no_hscale, f_no_vscale, SetType(), and STYLE_TYPE_ENHANCED_LINE.

bool Style::SetMatrix ( int  index,
const Matrix matrix 
)

The gradient and bitmap fills support a matrix. The matrix is used to define the scale, position and rotation to use with the accompagnying image.

The style must have been Created, Reset() or be of one of the gradient or bitmap fills for this function to work.

Parameters:
[in] index The morph index (0 or 1)
[in] matrix The matrix to set at the specified index position
Returns:
true when the matrix could be saved; false otherwise

References sswf::ErrorManager::ERROR_CODE_INVALID_MORPH_INDEX, f_error_manager, f_matrix, f_style, sswf::ErrorManager::OnError(), SetType(), STYLE_TYPE_BITMAP_CLIPPED, STYLE_TYPE_BITMAP_HARDEDGE_CLIPPED, STYLE_TYPE_BITMAP_HARDEDGE_TILLED, STYLE_TYPE_BITMAP_TILLED, STYLE_TYPE_GRADIENT_FOCAL, STYLE_TYPE_GRADIENT_LINEAR, STYLE_TYPE_GRADIENT_RADIAL, and STYLE_TYPE_MATRIX.

bool Style::SetType ( style_t  style  ) 

This function can be used to change between style flavors.

If the style type is not yet set, then any type can be selected with this function.

Groups of styles are defined as follow:

Style::STYLE_TYPE_NO_LINE, Style::STYLE_TYPE_NO_FILL

Style::STYLE_TYPE_LINE Style::STYLE_TYPE_ENHANCED_LINE

Style::STYLE_TYPE_SOLID

Style::STYLE_TYPE_GRADIENT_LINEAR, Style::STYLE_TYPE_GRADIENT_RADIAL, Style::STYLE_TYPE_GRADIENT_FOCAL

Style::STYLE_TYPE_BITMAP_TILLED, Style::STYLE_TYPE_BITMAP_CLIPPED, Style::STYLE_TYPE_BITMAP_HARDEDGE_TILLED, Style::STYLE_TYPE_BITMAP_HARDEDGE_CLIPPED

One can change between the different types in a group at will.

The special type Style::STYLE_TYPE_MATRIX is used internally to know that you are creating a style including a bitmap or a gradient. It helps enforcing that you do specify a bitmap or gradient type later.

If the type is currently set to Style::STYLE_TYPE_UNKNOWN any style will be accepted. The type is set to Unknown after a call to Reset() and on construction of a style object. Trying to set the type to unknown results in an assert in debug and an error in release.

Different functions will automatically force the type of a style so you usually do not need to call this very function unless the default is not what you want.

Returns:
true when the type was changed as requested; false when the type cannot be changed
See also:
sswf::Style::Reset()

References sswf::assert(), sswf::ErrorManager::ERROR_CODE_CANNOT_CHANGE_STYLE, sswf::ErrorManager::ERROR_CODE_INVALID_STYLE, f_error_manager, f_style, sswf::ErrorManager::OnError(), STYLE_TYPE_BITMAP_CLIPPED, STYLE_TYPE_BITMAP_HARDEDGE_CLIPPED, STYLE_TYPE_BITMAP_HARDEDGE_TILLED, STYLE_TYPE_BITMAP_TILLED, STYLE_TYPE_ENHANCED_LINE, STYLE_TYPE_GRADIENT_FOCAL, STYLE_TYPE_GRADIENT_LINEAR, STYLE_TYPE_GRADIENT_RADIAL, STYLE_TYPE_LINE, STYLE_TYPE_MATRIX, STYLE_TYPE_NO_FILL, STYLE_TYPE_NO_LINE, STYLE_TYPE_SOLID, and STYLE_TYPE_UNKNOWN.

Referenced by sswf::TagShape::SaveStyles(), SetBitmap(), SetClipping(), SetColor(), SetGradient(), SetGradientFocal(), SetGradientModes(), SetLine(), SetLineCaps(), SetLineFillStyle(), SetLineJoin(), SetLineNoClose(), SetLinePixelHinting(), SetLineScale(), and SetMatrix().

sswf::Style::Type ( void   )  const [inline]

This function returns the current type of the style. It can be one of:

On creation and after a call to Reset(), the style type is set to UNKNOWN.

The MATRIX type is an intermediate style of force you to create a style with a matrix (i.e. if you set the matrix before the image or gradient.)

The NO_LINE and NO_FILL are special types used to create empty styles to be able to turn off the current line or fill style (which at times is necessary.)

Many functions will change the type on you forcing you to create a style of that type (or group of style.)

Returns:
one of the STYLE_TYPE_...
See also:
sswf::Style::SetType(style_t style)

References f_style.

Referenced by sswf::TagShape::AddStyle().


Member Data Documentation

signed char sswf::Style::f_gradient [private]

signed short sswf::Style::f_gradient_focal [private]

Referenced by Reset(), Save(), and SetGradientFocal().

unsigned char sswf::Style::f_gradient_pos[MAX_GRADIENTS *2] [private]

Referenced by operator==(), Reset(), Save(), and SetGradient().

unsigned short sswf::Style::f_line_width[2] [private]

Referenced by operator==(), Reset(), Save(), and SetLine().

Referenced by operator==(), Reset(), Save(), and SetMatrix().

bool sswf::Style::f_no_close [private]

bool sswf::Style::f_no_hscale [private]

Referenced by operator==(), Reset(), Save(), and SetLineScale().

bool sswf::Style::f_no_vscale [private]

Referenced by operator==(), Reset(), Save(), and SetLineScale().

const signed char sswf::Style::MAX_GRADIENTS = 15 [static]

This value represents the maximum number of gradients a gradient style supports. Older movies would support up to 8 gradients. Newer movies (since SWF version 8) support up to 15 gradient definitions.

Referenced by operator==(), Reset(), Save(), and SetGradient().


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


Generated on Wed Mar 18 15:13:58 2009 for libsswf by  doxygen 1.5.5