20 #ifndef GNASH_GEOMETRY_H 21 #define GNASH_GEOMETRY_H 58 constexpr
Edge(std::int32_t cx, std::int32_t cy, std::int32_t ax,
93 std::int32_t dx = B.
x - A.
x;
94 std::int32_t dy = B.
y - A.
y;
96 if ( dx == 0 && dy == 0 )
101 std::int32_t pdx = p.
x - A.
x;
102 std::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);
193 reset(0, 0, 0, 0, 0);
198 m_fill0(from.m_fill0),
199 m_fill1(from.m_fill1),
202 m_edges(from.m_edges)
225 Path(std::int32_t ax, std::int32_t ay,
226 unsigned fill0,
unsigned fill1,
unsigned line)
228 reset(ax, ay, fill0, fill1, line);
248 void reset(std::int32_t ax, std::int32_t ay,
249 unsigned fill0,
unsigned fill1,
unsigned line)
278 const Path&
p = *
this;
279 size_t nedges = m_edges.size();
281 if ( ! nedges )
return;
288 unsigned int radius = swfVersion < 8 ? thickness : thickness/2;
291 for (
unsigned int j = 0;
j<nedges;
j++)
300 for (
unsigned int j = 0;
j<nedges;
j++)
327 m_edges.emplace_back(dx, dy, dx, dy);
348 drawCurveTo(std::int32_t cdx, std::int32_t cdy, std::int32_t adx, std::int32_t ady)
350 m_edges.emplace_back(cdx, cdy, adx, ady);
357 m_fill0 = m_fill1 = m_line = 0;
366 if (m_edges.empty())
return true;
367 return m_edges.back().ap ==
ap;
373 if ( m_edges.empty() )
return;
376 const Edge& lastedge = m_edges.back();
377 if ( lastedge.
ap != ap )
379 m_edges.emplace_back(ap, ap);
392 size_t nedges = m_edges.size();
394 if ( ! nedges )
return false;
397 for (
size_t i=0;
i<nedges; ++
i)
399 const Edge&
e = m_edges[
i];
405 if ( d <= dist )
return true;
423 for (
int i=1;
i<=segCount; ++
i)
425 float t1 =
static_cast<float>(
i) / segCount;
431 if ( d <= dist )
return true;
446 std::vector<Edge>::iterator it = m_edges.begin(), ie = m_edges.end();
447 for(; it != ie; ++it)
449 (*it).transform(mat);
456 return m_edges.empty();
519 return m_edges.size();
529 const Edge& operator[] (
size_t n)
const 538 bool pointTest(
const std::vector<Path>& paths,
539 const std::vector<LineStyle>& lineStyles, std::int32_t
x,
547 #endif // GNASH_GEOMETRY_H
static double squareDistancePtSeg(const point &p, const point &A, const point &B)
Return squared distance between point pt and segment A-B.
Definition: Geometry.h:91
bool empty() const
Return true if this path contains no edges.
Definition: Geometry.h:454
Definition: GnashKey.h:150
Path(const Path &from)
Definition: Geometry.h:196
unsigned getRightFill() const
Definition: Geometry.h:492
void transform(const SWFMatrix &mat)
Transform the edge according to the given SWFMatrix.
Definition: Geometry.h:83
void transform(geometry::Point2d &p) const
Transform a given point by our SWFMatrix.
Definition: SWFMatrix.cpp:99
Definition: SWFMatrix.h:53
Definition: GnashKey.h:114
Definition: GnashKey.h:167
point cp
Definition: Geometry.h:49
constexpr Edge()
Definition: Geometry.h:52
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
Point2d & setTo(const std::int32_t cx, const std::int32_t cy)
Set coordinates to given values.
Definition: Point2d.h:79
constexpr Edge(std::int32_t cx, std::int32_t cy, std::int32_t ax, std::int32_t ay)
Definition: Geometry.h:58
bool pointTest(const std::vector< Path > &paths, const std::vector< LineStyle > &lineStyles, std::int32_t x, std::int32_t y, const SWFMatrix &wm)
Definition: Geometry.cpp:125
2D Point class
Definition: Point2d.h:38
Definition: GnashKey.h:152
void transform(const SWFMatrix &mat)
Transform all path coordinates according to the given SWFMatrix.
Definition: Geometry.h:443
void expand_to_point(std::int32_t x, std::int32_t y)
Expand this rectangle to enclose the given point.
Definition: SWFRect.h:171
Definition: GnashKey.h:115
bool isClosed() const
Returns true if the last and the first point of the path match.
Definition: Geometry.h:364
Definition: GnashKey.h:156
static double distancePtSeg(const point &pt, const point &A, const point &B)
Return distance between point pt and segment A-B.
Definition: Geometry.h:123
unsigned getLineStyle() const
Definition: Geometry.h:511
Definition: GnashKey.h:160
Definition: GnashKey.h:164
void setLeftFill(unsigned f)
Set the fill to use on the left side.
Definition: Geometry.h:468
Definition: GnashKey.h:166
unsigned m_fill1
Right fill style index (1-based)
Definition: Geometry.h:173
constexpr Edge(const Edge &from)
Definition: Geometry.h:65
std::int32_t y
The y coordinate.
Definition: Point2d.h:46
static point pointOnCurve(const point &A, const point &C, const point &B, float t)
Find point of the quadratic curve defined by points A,C,B.
Definition: Geometry.h:137
A subset of a shape, a series of edges sharing a single set of styles.
Definition: Geometry.h:166
unsigned m_fill0
Left fill style index (1-based)
Definition: Geometry.h:170
std::vector< Edge > m_edges
Edges forming the path.
Definition: Geometry.h:182
unsigned getLeftFill() const
Definition: Geometry.h:473
std::int32_t x
Definition: BitmapData_as.cpp:434
bool withinSquareDistance(const point &p, double dist) const
Return true if the given point is within the given squared distance from this path edges...
Definition: Geometry.h:390
Definition: GnashKey.h:130
#define DSOEXPORT
Definition: dsodefs.h:55
void setLineStyle(unsigned i)
Set the line style to use for this path.
Definition: Geometry.h:506
std::int32_t x
The x coordinate.
Definition: Point2d.h:43
static std::int64_t squareDistancePtCurve(const point &A, const point &C, const point &B, const point &p, float t)
Definition: Geometry.h:155
unsigned m_line
Line style index (1-based)
Definition: Geometry.h:176
constexpr Edge(const point &ncp, const point &nap)
Definition: Geometry.h:71
bool straight() const
Definition: Geometry.h:77
std::int32_t y
Definition: BitmapData_as.cpp:435
void expandBounds(SWFRect &r, unsigned int thickness, int swfVersion) const
Expand given SWFRect to include bounds of this path.
Definition: Geometry.h:276
Rectangle class, see swf defined rectangle record.
Definition: SWFRect.h:44
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.
Definition: Geometry.h:248
Definition: GnashKey.h:162
Definition: GnashKey.h:155
Definition: GnashKey.h:151
void drawCurveTo(std::int32_t cdx, std::int32_t cdy, std::int32_t adx, std::int32_t ady)
Draw a curve.
Definition: Geometry.h:348
Defines an edge with a control point and an anchor point.
Definition: Geometry.h:44
void expand_to_circle(std::int32_t x, std::int32_t y, std::int32_t radius)
Expand this rectangle to enclose the given circle.
Definition: SWFRect.h:186
void clear()
Remove all edges and reset style infomation.
Definition: Geometry.h:354
point ap
Definition: Geometry.h:50
Definition: GnashKey.h:113
point ap
Start point of the path.
Definition: Geometry.h:179
size_t size() const
Return the number of edges in this path.
Definition: Geometry.h:517
Path()
Default constructor.
Definition: Geometry.h:191
static std::int64_t squareDistance(const Point2d &p0, const Point2d &p1)
Return square distance between two given points.
Definition: Point2d.h:103
void close()
Close this path with a straight line, if not already closed.
Definition: Geometry.h:371
void setRightFill(unsigned f)
Set the fill to use on the left side.
Definition: Geometry.h:487
Path(std::int32_t ax, std::int32_t ay, unsigned fill0, unsigned fill1, unsigned line)
Initialize a path.
Definition: Geometry.h:225
void drawLineTo(std::int32_t dx, std::int32_t dy)
Draw a straight line.
Definition: Geometry.h:325