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

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:
newShapeTrue 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:
axX coordinate of path origin in TWIPS
ayY coordinate in path origin in TWIPS
fill0Fill style index for left fill (1-based). Zero means NO style.
fill1Fill style index for right fill (1-based) Zero means NO style.
lineLine style index for right fill (1-based). Zero means NO style.
newShapeTrue 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 ( ) [inline]

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

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:
cxControl point's X coordinate.
cyControl point's Y coordinate.
axAnchor point's X ordinate.
ayAnchor 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:
xX coordinate in TWIPS
yY coordinate in TWIPS

Referenced by gnash::Bitmap::construct(), and gnash::DynamicShape::lineTo().

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

Expand given SWFRect to include bounds of this path.

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

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

Referenced by gnash::DynamicShape::lineTo(), gnash::DynamicShape::curveTo(), 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.

References gnash::key::n.

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

Return a const reference to the Nth edge.

References gnash::key::n.

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:
axX coordinate of path origin in TWIPS
ayY coordinate in path origin in TWIPS
fill0Fill style index for left fill
fill1Fill style index for right fill
lineLine style index for right fill

References assert.

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

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

Set the fill to use on the left side.

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

References gnash::key::f.

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

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

Set the line style to use for this path.

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

References gnash::key::i.

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

References gnash::key::f.

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::lineTo(), gnash::DynamicShape::curveTo(), 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::apply_matrix_to_paths().

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

Return true if the given point is within the given squared distance from this path edges.

NOTE: if the path is empty, false is returned.

References gnash::key::i, gnash::key::e, gnash::key::d, gnash::Edge::squareDistancePtSeg(), gnash::key::A, gnash::key::C, gnash::key::B, gnash::geometry::Point2d::x, gnash::geometry::Point2d::y, gnash::Edge::pointOnCurve(), and gnash::geometry::Point2d::setTo().

Referenced by gnash::geometry::pointTest().


Member Data Documentation

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

Left fill style index (1-based)

Referenced by gnash::geometry::pointTest(), and gnash::Renderer_cairo::draw_mask().

Right fill style index (1-based)

Referenced by gnash::geometry::pointTest(), and gnash::Renderer_cairo::draw_mask().

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.

Referenced by gnash::geometry::pointTest(), and gnash::Renderer_cairo::find_subshapes().


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