Public Member Functions | Public Attributes

gnash::Path Class Reference

A subset of a shape, a series of edges sharing a single set of styles. More...

#include <Geometry.h>

Collaboration diagram for gnash::Path:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Path (bool newShape=false)
 Default constructor.
 Path (const Path &from)
 Path (boost::int32_t ax, boost::int32_t ay, unsigned fill0, unsigned fill1, unsigned line, bool newShape)
 Initialize a path.
void reset (boost::int32_t ax, boost::int32_t ay, unsigned fill0, unsigned fill1, unsigned line)
 Re-initialize a path, maintaining the "new shape" flag untouched.
void expandBounds (SWFRect &r, unsigned int thickness, int swfVersion) const
 Expand given SWFRect to include bounds of this path.
bool isClosed () const
 Returns true if the last and the first point of the path match.
void close ()
 Close this path with a straight line, if not already closed.
bool withinSquareDistance (const point &p, double dist) const
 Return true if the given point is within the given squared distance from this path edges.
void transform (const SWFMatrix &mat)
 Transform all path coordinates according to the given SWFMatrix.
void setNewShape ()
 Set this path as the start of a new (sub)shape.
bool getNewShape () const
 Return true if this path starts a new (sub)shape.
bool empty () const
 Return true if this path contains no edges.
void setLeftFill (unsigned f)
 Set the fill to use on the left side.
unsigned getLeftFill () const
void setRightFill (unsigned f)
 Set the fill to use on the left side.
unsigned getRightFill () const
void setLineStyle (unsigned i)
 Set the line style to use for this path.
unsigned getLineStyle () const
size_t size () const
 Return the number of edges in this path.
Edgeoperator[] (size_t n)
 Return a reference to the Nth edge.
const Edgeoperator[] (size_t n) const
 Return a const reference to the Nth edge.
bool isNewShape () const
 Returns true if this path begins a new subshape. <-- VERIFYME.

void drawLineTo (boost::int32_t dx, boost::int32_t dy)
 Draw a straight line.
void drawCurveTo (boost::int32_t cdx, boost::int32_t cdy, boost::int32_t adx, boost::int32_t ady)
 Draw a curve.
void clear ()
 Remove all edges and reset style infomation.

Public Attributes

unsigned m_fill0
 Left fill style index (1-based).
unsigned m_fill1
 Right fill style index (1-based).
unsigned m_line
 Line style index (1-based).
point ap
 Start point of the path.
std::vector< Edgem_edges
 Edges forming the path.
bool m_new_shape

Detailed Description

A subset of a shape, a series of edges sharing a single set of styles.


Constructor & Destructor Documentation

gnash::Path::Path ( bool  newShape = false  )  [inline]

Default constructor.

Parameters:
newShape True if this path starts a new subshape
gnash::Path::Path ( const Path from  )  [inline]
gnash::Path::Path ( boost::int32_t  ax,
boost::int32_t  ay,
unsigned  fill0,
unsigned  fill1,
unsigned  line,
bool  newShape 
) [inline]

Initialize a path.

Parameters:
ax X coordinate of path origin in TWIPS
ay Y coordinate in path origin in TWIPS
fill0 Fill style index for left fill (1-based). Zero means NO style.
fill1 Fill style index for right fill (1-based) Zero means NO style.
line Line style index for right fill (1-based). Zero means NO style.
newShape True if this path starts a new subshape

Member Function Documentation

void gnash::Path::clear (  )  [inline]

Remove all edges and reset style infomation.

Referenced by gnash::SWF::ShapeRecord::read().

void gnash::Path::close ( void   )  [inline]

Close this path with a straight line, if not already closed.

References gnash::Edge::ap.

Referenced by gnash::DynamicShape::endFill(), and gnash::DynamicShape::finalize().

void gnash::Path::drawCurveTo ( boost::int32_t  cdx,
boost::int32_t  cdy,
boost::int32_t  adx,
boost::int32_t  ady 
) [inline]

Draw a curve.

Offset values are relative to path origin and expressed in TWIPS.

Parameters:
cx Control point's X coordinate.
cy Control point's Y coordinate.
ax Anchor point's X ordinate.
ay Anchor point's Y ordinate.

Referenced by gnash::DynamicShape::curveTo().

void gnash::Path::drawLineTo ( boost::int32_t  dx,
boost::int32_t  dy 
) [inline]

Draw a straight line.

Primitives for the Drawing API

Name of these functions track Ming interface Point coordinates are relative to path origin and expressed in TWIPS.

Parameters:
x X coordinate in TWIPS
y Y coordinate in TWIPS

Referenced by gnash::DynamicShape::lineTo().

bool gnash::Path::empty (  )  const [inline]

Return true if this path contains no edges.

Referenced by gnash::DisplayObject::getTarget(), gnash::DisplayObject::getTargetPath(), and gnash::SWF::ShapeRecord::read().

void gnash::Path::expandBounds ( SWFRect r,
unsigned int  thickness,
int  swfVersion 
) const [inline]

Expand given SWFRect to include bounds of this path.

Parameters:
r The rectangle to expand with our own bounds
thickness The thickess of our lines, half the thickness will be added in all directions in swf8+, all of it will in swf7-
swfVersion SWF version to use.

References gnash::SWFRect::expand_to_circle(), gnash::SWFRect::expand_to_point(), gnash::key::j, m_edges, and gnash::key::p.

Referenced by gnash::DynamicShape::curveTo(), gnash::DynamicShape::lineTo(), and gnash::SWF::ShapeRecord::read().

unsigned gnash::Path::getLeftFill (  )  const [inline]
unsigned gnash::Path::getLineStyle (  )  const [inline]
bool gnash::Path::getNewShape (  )  const [inline]

Return true if this path starts a new (sub)shape.

unsigned gnash::Path::getRightFill (  )  const [inline]
bool gnash::Path::isClosed (  )  const [inline]

Returns true if the last and the first point of the path match.

bool gnash::Path::isNewShape (  )  const [inline]

Returns true if this path begins a new subshape. <-- VERIFYME.

Edge& gnash::Path::operator[] ( size_t  n  )  [inline]

Return a reference to the Nth edge.

const Edge& gnash::Path::operator[] ( size_t  n  )  const [inline]

Return a const reference to the Nth edge.

void gnash::Path::reset ( boost::int32_t  ax,
boost::int32_t  ay,
unsigned  fill0,
unsigned  fill1,
unsigned  line 
) [inline]

Re-initialize a path, maintaining the "new shape" flag untouched.

Parameters:
ax X coordinate of path origin in TWIPS
ay Y coordinate in path origin in TWIPS
fill0 Fill style index for left fill
fill1 Fill style index for right fill
line Line style index for right fill

Referenced by gnash::SWF::ShapeRecord::setLerp().

void gnash::Path::setLeftFill ( unsigned  f  )  [inline]

Set the fill to use on the left side.

Parameters:
f The fill index (1-based). When this path is added to a DefineShapeTag, the index (decremented by 1) will reference an element in the FillStyle vector defined for that shape. If zero, no fill will be active.

Referenced by gnash::SWF::ShapeRecord::read().

void gnash::Path::setLineStyle ( unsigned  i  )  [inline]

Set the line style to use for this path.

Parameters:
f The LineStyle index (1-based). When this path is added to a DefineShapeTag, the index (decremented by 1) will reference an element in the LineStyle vector defined for that shape. If zero, no fill will be active.

Referenced by gnash::SWF::ShapeRecord::read().

void gnash::Path::setNewShape (  )  [inline]

Set this path as the start of a new (sub)shape.

void gnash::Path::setRightFill ( unsigned  f  )  [inline]

Set the fill to use on the left side.

Parameters:
f The fill index (1-based). When this path is added to a DefineShapeTag, the index (decremented by 1) will reference an element in the FillStyle vector defined for that shape. If zero, no fill will be active.

Referenced by gnash::SWF::ShapeRecord::read().

size_t gnash::Path::size (  )  const [inline]

Return the number of edges in this path.

Referenced by gnash::DynamicShape::curveTo(), gnash::DynamicShape::lineTo(), and gnash::SWF::ShapeRecord::setLerp().

void gnash::Path::transform ( const SWFMatrix mat  )  [inline]

Transform all path coordinates according to the given SWFMatrix.

References gnash::SWFMatrix::transform().

Referenced by gnash::Renderer_cairo::drawShape().

bool gnash::Path::withinSquareDistance ( const point p,
double  dist 
) const [inline]

Member Data Documentation

std::vector<Edge> gnash::Path::m_edges

Left fill style index (1-based).

Referenced by gnash::Renderer_cairo::add_paths().

Right fill style index (1-based).

Referenced by gnash::Renderer_cairo::add_paths().

Line style index (1-based).

Referenced by gnash::SWF::ShapeRecord::read().

This flag is set when the path is the first one of a new "sub-shape". All paths with a higher index in the list belong to the same shape unless they have m_new_shape==true on their own. Sub-shapes affect the order in which outlines and shapes are rendered.


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