Gnash  0.8.11dev
Public Member Functions | Public Attributes | List of all members
gnash::Path Class Reference

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

#include <Geometry.h>

Public Member Functions

 Path ()
 Default constructor. More...
 
 Path (const Path &from)
 
 Path (std::int32_t ax, std::int32_t ay, unsigned fill0, unsigned fill1, unsigned line)
 Initialize a path. More...
 
void reset (std::int32_t ax, std::int32_t ay, unsigned fill0, unsigned fill1, unsigned line)
 Re-initialize a path, maintaining the "new shape" flag untouched. More...
 
void expandBounds (SWFRect &r, unsigned int thickness, int swfVersion) const
 Expand given SWFRect to include bounds of this path. More...
 
bool isClosed () const
 Returns true if the last and the first point of the path match. More...
 
void close ()
 Close this path with a straight line, if not already closed. More...
 
bool withinSquareDistance (const point &p, double dist) const
 Return true if the given point is within the given squared distance from this path edges. More...
 
void transform (const SWFMatrix &mat)
 Transform all path coordinates according to the given SWFMatrix. More...
 
bool empty () const
 Return true if this path contains no edges. More...
 
void setLeftFill (unsigned f)
 Set the fill to use on the left side. More...
 
unsigned getLeftFill () const
 
void setRightFill (unsigned f)
 Set the fill to use on the left side. More...
 
unsigned getRightFill () const
 
void setLineStyle (unsigned i)
 Set the line style to use for this path. More...
 
unsigned getLineStyle () const
 
size_t size () const
 Return the number of edges in this path. More...
 
Edgeoperator[] (size_t n)
 Return a reference to the Nth edge. More...
 
const Edgeoperator[] (size_t n) const
 Return a const reference to the Nth edge. More...
 
void drawLineTo (std::int32_t dx, std::int32_t dy)
 Draw a straight line. More...
 
void drawCurveTo (std::int32_t cdx, std::int32_t cdy, std::int32_t adx, std::int32_t ady)
 Draw a curve. More...
 
void clear ()
 Remove all edges and reset style infomation. More...
 

Public Attributes

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

Detailed Description

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

Constructor & Destructor Documentation

§ Path() [1/3]

gnash::Path::Path ( )
inline

Default constructor.

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.

§ Path() [2/3]

gnash::Path::Path ( const Path from)
inline

§ Path() [3/3]

gnash::Path::Path ( std::int32_t  ax,
std::int32_t  ay,
unsigned  fill0,
unsigned  fill1,
unsigned  line 
)
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.

Member Function Documentation

§ clear()

void gnash::Path::clear ( )
inline

Remove all edges and reset style infomation.

§ close()

void gnash::Path::close ( )
inline

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

References gnash::Edge::ap.

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

§ drawCurveTo()

void gnash::Path::drawCurveTo ( std::int32_t  cdx,
std::int32_t  cdy,
std::int32_t  adx,
std::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().

§ drawLineTo()

void gnash::Path::drawLineTo ( std::int32_t  dx,
std::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().

§ empty()

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

Return true if this path contains no edges.

Referenced by gnash::DisplayObject::getTarget(), gnash::DisplayObject::getTargetPath(), and gnash::geometry::pointTest().

§ expandBounds()

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::Edge::cp, gnash::SWFRect::expand_to_circle(), gnash::SWFRect::expand_to_point(), gnash::key::j, m_edges, gnash::key::p, gnash::geometry::Point2d::x, and gnash::geometry::Point2d::y.

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

§ getLeftFill()

unsigned gnash::Path::getLeftFill ( ) const
inline

§ getLineStyle()

unsigned gnash::Path::getLineStyle ( ) const
inline

§ getRightFill()

unsigned gnash::Path::getRightFill ( ) const
inline

§ isClosed()

bool gnash::Path::isClosed ( ) const
inline

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

References gnash::Edge::ap.

§ operator[]() [1/2]

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

Return a reference to the Nth edge.

References gnash::key::n.

§ operator[]() [2/2]

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

Return a const reference to the Nth edge.

References gnash::key::n, gnash::geometry::pointTest(), x, and y.

§ reset()

void gnash::Path::reset ( std::int32_t  ax,
std::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 gnash::geometry::Point2d::x, and gnash::geometry::Point2d::y.

§ setLeftFill()

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.

§ setLineStyle()

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.

§ setRightFill()

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.

§ size()

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

Return the number of edges in this path.

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

§ transform()

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

§ withinSquareDistance()

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.

Member Data Documentation

§ ap

point gnash::Path::ap

§ m_edges

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

§ m_fill0

unsigned gnash::Path::m_fill0

Left fill style index (1-based)

Referenced by gnash::renderer::openvg::Renderer_ovg::disable_mask().

§ m_fill1

unsigned gnash::Path::m_fill1

Right fill style index (1-based)

Referenced by gnash::renderer::openvg::Renderer_ovg::disable_mask().

§ m_line

unsigned gnash::Path::m_line

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