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);
197 m_new_shape(newShape)
199 reset(0, 0, 0, 0, 0);
204 m_fill0(from.m_fill0),
205 m_fill1(from.m_fill1),
208 m_edges(from.m_edges),
209 m_new_shape(from.m_new_shape)
235 Path(boost::int32_t ax, boost::int32_t ay,
236 unsigned fill0,
unsigned fill1,
unsigned line,
239 m_new_shape(newShape)
241 reset(ax, ay, fill0, fill1, line);
261 void reset(boost::int32_t ax, boost::int32_t ay,
262 unsigned fill0,
unsigned fill1,
unsigned line)
289 expandBounds(
SWFRect&
r,
unsigned int thickness,
int swfVersion)
const
291 const Path&
p = *
this;
292 size_t nedges = m_edges.size();
294 if ( ! nedges )
return;
301 unsigned int radius = swfVersion < 8 ? thickness : thickness/2;
304 for (
unsigned int j = 0;
j<nedges;
j++)
313 for (
unsigned int j = 0;
j<nedges;
j++)
338 drawLineTo(boost::int32_t dx, boost::int32_t dy)
340 m_edges.push_back(
Edge(dx, dy, dx, dy));
361 drawCurveTo(boost::int32_t cdx, boost::int32_t cdy, boost::int32_t adx, boost::int32_t ady)
363 m_edges.push_back(
Edge(cdx, cdy, adx, ady));
370 m_fill0 = m_fill1 = m_line = 0;
377 bool isClosed()
const
379 if (m_edges.empty())
return true;
380 return m_edges.back().ap == ap;
386 if ( m_edges.empty() )
return;
389 const Edge& lastedge = m_edges.back();
390 if ( lastedge.
ap != ap )
392 Edge newedge(ap, ap);
393 m_edges.push_back(newedge);
406 size_t nedges = m_edges.size();
408 if ( ! nedges )
return false;
411 for (
size_t i=0;
i<nedges; ++
i)
413 const Edge&
e = m_edges[
i];
419 if ( d <= dist )
return true;
437 for (
int i=1;
i<=segCount; ++
i)
439 float t1 =
static_cast<float>(
i) / segCount;
445 if ( d <= dist )
return true;
460 std::vector<Edge>::iterator it = m_edges.begin(), ie = m_edges.end();
461 for(; it != ie; ++it)
463 (*it).transform(mat);
474 bool getNewShape()
const
482 return m_edges.empty();
494 void setLeftFill(
unsigned f)
499 unsigned getLeftFill()
const
513 void setRightFill(
unsigned f)
518 unsigned getRightFill()
const
532 void setLineStyle(
unsigned i)
537 unsigned getLineStyle()
const
545 return m_edges.size();
555 const Edge& operator[] (
size_t n)
const
561 bool isNewShape()
const
571 bool pointTest(
const std::vector<Path>& paths,
572 const std::vector<LineStyle>& lineStyles, boost::int32_t
x,
573 boost::int32_t
y,
const SWFMatrix& wm);
580 #endif // GNASH_GEOMETRY_H