20 #ifndef GNASH_GEOMETRY_H
21 #define GNASH_GEOMETRY_H
58 Edge(boost::int32_t cx, boost::int32_t cy, boost::int32_t ax,
93 boost::int32_t dx = B.
x - A.
x;
94 boost::int32_t dy = B.
y - A.
y;
96 if ( dx == 0 && dy == 0 )
101 boost::int32_t pdx = p.
x - A.
x;
102 boost::int32_t pdy = p.
y - A.
y;
104 double u = (
static_cast<double>(pdx) * dx + static_cast<double>(pdy) * dy ) /
105 (static_cast<double>(dx)*dx +
static_cast<double>(dy)*dy );
126 return std::sqrt(square);
196 reset(0, 0, 0, 0, 0);
201 m_fill0(from.m_fill0),
202 m_fill1(from.m_fill1),
205 m_edges(from.m_edges)
231 Path(boost::int32_t ax, boost::int32_t ay,
232 unsigned fill0,
unsigned fill1,
unsigned line)
234 reset(ax, ay, fill0, fill1, line);
254 void reset(boost::int32_t ax, boost::int32_t ay,
255 unsigned fill0,
unsigned fill1,
unsigned line)
282 expandBounds(
SWFRect&
r,
unsigned int thickness,
int swfVersion)
const
284 const Path&
p = *
this;
285 size_t nedges = m_edges.size();
287 if ( ! nedges )
return;
294 unsigned int radius = swfVersion < 8 ? thickness : thickness/2;
297 for (
unsigned int j = 0;
j<nedges;
j++)
306 for (
unsigned int j = 0;
j<nedges;
j++)
331 drawLineTo(boost::int32_t dx, boost::int32_t dy)
333 m_edges.push_back(
Edge(dx, dy, dx, dy));
354 drawCurveTo(boost::int32_t cdx, boost::int32_t cdy, boost::int32_t adx, boost::int32_t ady)
356 m_edges.push_back(
Edge(cdx, cdy, adx, ady));
363 m_fill0 = m_fill1 = m_line = 0;
370 bool isClosed()
const
372 if (m_edges.empty())
return true;
373 return m_edges.back().ap == ap;
379 if ( m_edges.empty() )
return;
382 const Edge& lastedge = m_edges.back();
383 if ( lastedge.
ap != ap )
385 Edge newedge(ap, ap);
386 m_edges.push_back(newedge);
399 size_t nedges = m_edges.size();
401 if ( ! nedges )
return false;
404 for (
size_t i=0;
i<nedges; ++
i)
406 const Edge&
e = m_edges[
i];
412 if ( d <= dist )
return true;
430 for (
int i=1;
i<=segCount; ++
i)
432 float t1 =
static_cast<float>(
i) / segCount;
438 if ( d <= dist )
return true;
453 std::vector<Edge>::iterator it = m_edges.begin(), ie = m_edges.end();
454 for(; it != ie; ++it)
456 (*it).transform(mat);
463 return m_edges.empty();
475 void setLeftFill(
unsigned f)
480 unsigned getLeftFill()
const
494 void setRightFill(
unsigned f)
499 unsigned getRightFill()
const
513 void setLineStyle(
unsigned i)
518 unsigned getLineStyle()
const
526 return m_edges.size();
536 const Edge& operator[] (
size_t n)
const
545 bool pointTest(
const std::vector<Path>& paths,
546 const std::vector<LineStyle>& lineStyles, boost::int32_t
x,
547 boost::int32_t
y,
const SWFMatrix& wm);
554 #endif // GNASH_GEOMETRY_H