#include <Pt/Gfx/Path.h>
Sequence of lines and curves. More...
Public Types | |
| enum | ElementType |
| Identifies the command stored in a path element. | |
Public Member Functions | |
| Path () | |
| Constructs an empty path. | |
| Path (const Path &other) | |
| Copies another path. | |
| Path & | operator= (const Path &other) |
| Replaces the path contents. | |
| ~Path () | |
| Destroys the path. | |
| std::size_t | size () const |
| Returns the number of path elements. | |
| bool | isEmpty () const |
| Returns true if the path has no elements. | |
| Iterator | begin () const |
| Returns an iterator to the first element. | |
| Iterator | end () const |
| Returns an iterator past the last element. | |
| void | clear () |
| Removes all path elements. | |
| RectF | boundingRect () const |
| Returns the bounding rectangle of the path. | |
| bool | contains (const PointF &point, FillRule rule=FillRule::NonZero) const |
| Returns true if the point lies inside the filled area of the path. | |
| bool | contains (const RectF &rect, FillRule rule=FillRule::NonZero) const |
| Returns true if the rectangle lies entirely inside the filled area. | |
| bool | intersects (const RectF &rect, FillRule rule=FillRule::NonZero) const |
| Returns true if the filled area of the path overlaps rect. | |
| const PointF & | currentPosition () const |
| Returns the current drawing position. | |
| void | moveTo (const PointF &p) |
| Starts a new subpath at the given point. | |
| void | lineTo (const PointF &p) |
| Adds a straight line to the given point. | |
| void | quadTo (const PointF &cp, const PointF &to) |
| Adds a quadratic Bezier segment. | |
| void | cubicTo (const PointF &cp1, const PointF &cp2, const PointF &to) |
| Adds a cubic Bezier segment. | |
| void | arcTo (const PointF &topLeft, const SizeF &size, double degBegin, double degEnd) |
| Adds an arc segment to the current subpath. | |
| void | close () |
| Closes the current subpath. | |
| void | addPath (const Path &p) |
| Appends all elements of p to this path. | |
| void | addRect (const RectF &rect) |
| Adds a rectangle as a new subpath. | |
| void | addRoundedRect (const RectF &rect, double radius) |
| Adds a rounded rectangle as a new subpath. | |
| void | addRoundedRect (const RectF &rect, double rx, double ry) |
| Adds a rounded rectangle with elliptical corners as a new subpath. | |
| void | addEllipse (const PointF &topLeft, const SizeF &size) |
| Adds an ellipse as a new subpath. | |
| void | addArc (const PointF &topLeft, const SizeF &size, double degBegin, double degEnd) |
| Adds an arc as a new subpath. | |
| void | addPie (const PointF &topLeft, const SizeF &size, double degBegin, double degEnd) |
| Adds a pie segment as a new subpath. | |
| void | addChord (const PointF &topLeft, const SizeF &size, double degBegin, double degEnd) |
| Adds a chord as a new subpath. | |
| void | addPolyline (const PointF *points, std::size_t count) |
| Adds a polyline as a new subpath. | |
| void | addPolygon (const PointF *points, std::size_t count) |
| Adds a polygon as a new closed subpath. | |
| void | transform (const Transform &transform) |
| Applies a transform to all path coordinates. | |
| Path | toTransformed (const Transform &transform) const |
| Returns a copy of the path with the transform applied. | |
| Iterator | getPolygon (Iterator it, Polygon &polygon, float tolerance=0.25f) const |
| Flattens one subpath into polygon starting at it. | |
Path stores moves, lines, quadratic and cubic curves, and close commands. It does not belong to a painter. Build a path, then stroke or fill it with PainterBase::drawPath() and fillPath(), or assign it as the painter's current path.
moveTo() starts a subpath. lineTo(), quadTo(), cubicTo(), and the arc helpers append to the current subpath. contains() and intersects() test geometry against the filled area using a FillRule, without a surface.
The example builds a triangle and fills it on a bitmap.
| bool contains | ( | const PointF & | point, |
| FillRule | rule = FillRule::NonZero ) const |
The test uses a horizontal ray cast from the point. The rule parameter controls how overlapping subpaths are handled. A point exactly on an upward-crossing edge is considered outside.
| bool contains | ( | const RectF & | rect, |
| FillRule | rule = FillRule::NonZero ) const |
Every point of rect must be covered by the filled area of the path. Returns false if any path segment crosses a rectangle edge or any corner of rect is outside the filled area.
| bool intersects | ( | const RectF & | rect, |
| FillRule | rule = FillRule::NonZero ) const |
Returns true if any part of the filled path area shares at least one point with the interior of rect. The test covers three cases: a corner of rect lies inside the path, a path segment crosses a rect edge, or the entire path lies inside rect.
| void arcTo | ( | const PointF & | topLeft, |
| const SizeF & | size, | ||
| double | degBegin, | ||
| double | degEnd ) |
The arc is drawn inside the ellipse bounded by topLeft and size. Angles are measured clockwise from the positive x-axis. A positive sweep (degEnd > degBegin) is clockwise; a negative sweep is counter-clockwise. If the path is empty a MoveTo is added, otherwise a LineTo.
| void addRoundedRect | ( | const RectF & | rect, |
| double | rx, | ||
| double | ry ) |
rx is the horizontal corner radius, ry the vertical corner radius.
| void addArc | ( | const PointF & | topLeft, |
| const SizeF & | size, | ||
| double | degBegin, | ||
| double | degEnd ) |
Starts a new subpath at the arc start point. Angle and sweep-direction semantics are identical to arcTo().
| Iterator getPolygon | ( | Iterator | it, |
| Polygon & | polygon, | ||
| float | tolerance = 0.25f ) const |