33#include <Pt/Gfx/Api.h>
34#include <Pt/Gfx/FillRule.h>
35#include <Pt/Gfx/Point.h>
36#include <Pt/Gfx/Rect.h>
37#include <Pt/Gfx/Polygon.h>
38#include <Pt/Gfx/Transform.h>
39#include <Pt/SmartPtr.h>
177 void quadTo(
const PointF &cp,
const PointF& to);
181 void cubicTo(
const PointF &cp1,
const PointF &cp2,
const PointF& to);
192 double degBegin,
double degEnd);
226 double degBegin,
double degEnd);
231 double degBegin,
double degEnd);
236 double degBegin,
double degEnd);
263 Iterator
getPolygon(Iterator it, Polygon& polygon,
float tolerance = 0.25f)
const;
280 PathEntry(Type type, std::size_t n)
291 std::size_t size()
const
306 friend class PathIterator;
309 PathElement(
const PathEntry* entry,
const PointF* points)
316 void setPosition(
const PointF& pos)
321 void setEntry(
const PathEntry* entry,
const PointF* points)
332 return _entry->type();
339 return _entry->size();
351 const PointF&
point(std::size_t n)
const
358 void flatten(Polygon& points,
double tolerance = 0.25)
const;
361 const PathEntry* _entry;
363 const PointF* _points;
372 using iterator_category = std::forward_iterator_tag;
373 using value_type = Path::Element;
374 using difference_type = std::ptrdiff_t;
375 using pointer =
const Path::Element*;
376 using reference =
const Path::Element&;
392 , _element(_entry, _points)
414 if( _entry->size() > 0)
416 const PointF& pos = _points[ _entry->size() - 1 ];
417 _element.setPosition(pos);
420 _points += _entry->
size();
423 _element.setEntry(_entry, _points);
440 return _entry == other._entry;
447 return _entry != other._entry;
454 return _entry < other._entry;
458 const PathEntry* _entry;
459 const PointF* _points;
460 Path::Element _element;
474 const PointF& currentPosition()
const
479 void setCurrentPosition(
const PointF& p)
484 Path::Iterator begin()
const
486 return Path::Iterator( _entries.data(), _points.data() );
489 Path::Iterator end()
const
491 return Path::Iterator(_entries.data() + _entries.size(), _points.data() + _points.size());
494 std::size_t size()
const
496 return _entries.size();
501 return _entries.empty();
509 _position = PointF();
512 void append(
const PathData& path);
514 void moveTo(
const PointF& pos);
516 void lineTo(
const PointF& pos);
518 void quadTo(
const PointF& cp,
const PointF& to);
520 void cubicTo(
const PointF& cp1,
const PointF& cp2,
const PointF& to);
524 void transform(
const Transform& tform);
527 std::vector<PathEntry> _entries;
528 std::vector<PointF> _points;
Read-only view of a path element.
Definition Path.h:305
void flatten(Polygon &points, double tolerance=0.25) const
Flattens the element into polygon points.
Path::ElementType type() const
Returns the element type.
Definition Path.h:330
const PointF & position() const
Returns the current path position before the element.
Definition Path.h:344
const PointF & point(std::size_t n) const
Returns one point of the element.
Definition Path.h:351
std::size_t size() const
Returns the number of points stored in the element.
Definition Path.h:337
Forward iterator over path elements.
Definition Path.h:370
PathIterator operator++(int)
Advances to the next path element and returns the previous iterator.
Definition Path.h:429
PathIterator & operator++()
Advances to the next path element.
Definition Path.h:412
const Path::Element & operator*() const
Returns the current path element.
Definition Path.h:398
PathIterator(const PathEntry *entry, const PointF *points)
Constructs an iterator for the given storage pointers.
Definition Path.h:389
bool operator!=(const PathIterator &other) const
Returns true if both iterators refer to different elements.
Definition Path.h:445
bool operator<(const PathIterator &other) const
Returns true if this iterator precedes the other iterator.
Definition Path.h:452
bool operator==(const PathIterator &other) const
Returns true if both iterators refer to the same element.
Definition Path.h:438
const Path::Element * operator->() const
Returns a pointer to the current path element.
Definition Path.h:405
PathIterator()
Constructs an end iterator.
Definition Path.h:380
void quadTo(const PointF &cp, const PointF &to)
Adds a quadratic Bezier segment.
void addRect(const RectF &rect)
Adds a rectangle as a new subpath.
Iterator begin() const
Returns an iterator to the first element.
ElementType
Identifies the command stored in a path element.
Definition Path.h:86
void cubicTo(const PointF &cp1, const PointF &cp2, const PointF &to)
Adds a cubic Bezier segment.
void addChord(const PointF &topLeft, const SizeF &size, double degBegin, double degEnd)
Adds a chord as a new subpath.
void close()
Closes the current subpath.
void lineTo(const PointF &p)
Adds a straight line to the given point.
Iterator end() const
Returns an iterator past the last element.
const PointF & currentPosition() const
Returns the current drawing position.
void addArc(const PointF &topLeft, const SizeF &size, double degBegin, double degEnd)
Adds an arc as a new subpath.
void addEllipse(const PointF &topLeft, const SizeF &size)
Adds an ellipse as a new subpath.
Path toTransformed(const Transform &transform) const
Returns a copy of the path with the transform applied.
Path(const Path &other)
Copies another path.
bool intersects(const RectF &rect, FillRule rule=FillRule::NonZero) const
Returns true if the filled area of the path overlaps rect.
void addRoundedRect(const RectF &rect, double radius)
Adds a rounded rectangle as a new subpath.
void transform(const Transform &transform)
Applies a transform to all path coordinates.
Path()
Constructs an empty path.
bool contains(const PointF &point, FillRule rule=FillRule::NonZero) const
Returns true if the point lies inside the filled area of the path.
Iterator getPolygon(Iterator it, Polygon &polygon, float tolerance=0.25f) const
Flattens one subpath into polygon starting at it.
void addPie(const PointF &topLeft, const SizeF &size, double degBegin, double degEnd)
Adds a pie segment as a new subpath.
void addPolyline(const PointF *points, std::size_t count)
Adds a polyline as a new subpath.
void clear()
Removes all path elements.
bool isEmpty() const
Returns true if the path has no elements.
~Path()
Destroys the path.
void addPath(const Path &p)
Appends all elements of p to this path.
void addRoundedRect(const RectF &rect, double rx, double ry)
Adds a rounded rectangle with elliptical corners as a new subpath.
void arcTo(const PointF &topLeft, const SizeF &size, double degBegin, double degEnd)
Adds an arc segment to the current subpath.
std::size_t size() const
Returns the number of path elements.
void addPolygon(const PointF *points, std::size_t count)
Adds a polygon as a new closed subpath.
void moveTo(const PointF &p)
Starts a new subpath at the given point.
bool contains(const RectF &rect, FillRule rule=FillRule::NonZero) const
Returns true if the rectangle lies entirely inside the filled area.
Path & operator=(const Path &other)
Replaces the path contents.
RectF boundingRect() const
Returns the bounding rectangle of the path.
Policy based smart pointer.
Definition SmartPtr.h:462
FillRule
Determines how overlapping subpaths of a filled shape are painted.
Definition FillRule.h:45
@ NonZero
Fills regions enclosed by a non-zero net winding count.
Definition FillRule.h:52
Graphics and imaging services.
Definition Api-Argb32Image.h:12
Core module.
Definition Allocator.h:33