Ipelib
|
A geometric shape, consisting of several (open or closed) subpaths. More...
#include <ipeshape.h>
A geometric shape, consisting of several (open or closed) subpaths.
This class represents vector graphics geometry following the PDF "path", but is actually a bit more complicated since we add new subtypes: arcs, parabolas, uniform B-splines (in PDF, all of these are converted to cubic Bezier splines).
A Shape consists of a set of subpaths (SubPath), each of which is either open or closed, and which are rendered by stroking and filling as a whole. The distinction between open and closed is meaningful for stroking only, for filling any open subpath is implicitely closed. Stroking a set of subpaths is identical to stroking them individually. This is not true for filling: using several subpaths, one can construct objects with holes, and more complicated pattern.
A subpath is either an Ellipse (a complete, closed ellipse), a ClosedSpline (a closed uniform B-spline curve), or a Curve. A curve consists of a sequence of segments. Segments are either straight, a quadratic Bezier spline, a cubic Bezier spline, an elliptic arc, or a uniform cubic B-spline.
Shape is implemented using reference counting and can be copied and passed by value efficiently. The only mutator methods are appendSubPath() and load(), which can only be called during construction of the Shape (that is, before its implementation has been shared).
Shape::Shape | ( | ) |
Construct an empty shape (zero subpaths).
Shape::Shape | ( | const Rect & | rect | ) | [explicit] |
Convenience function: create a rectangle shape.
Shape::Shape | ( | const Segment & | seg | ) | [explicit] |
Convenience function: create a single line segment.
Shape::Shape | ( | const Vector & | center, |
double | radius | ||
) | [explicit] |
Convenience function: create circle with center and radius.
Shape::Shape | ( | const Vector & | center, |
double | radius, | ||
double | alpha0, | ||
double | alpha1 | ||
) | [explicit] |
Convenience function: create circular arc.
If alpha1 is larger than alpha0, the arc is oriented positively, otherwise negatively.
Shape::~Shape | ( | ) |
Destructor (takes care of reference counting).
Shape::Shape | ( | const Shape & | rhs | ) |
Copy constructor (constant time).
bool Shape::load | ( | String | data | ) |
Create a Shape from XML data.
Appends subpaths from XML data to the current Shape. Returns false if the path syntax is incorrect (the Shape will be in an inconsistent state and must be discarded).
This method can only be used during construction of the Shape. It will panic if the implementation has been shared.
Add shape (transformed by m) to box.
int ipe::Shape::countSubPaths | ( | ) | const [inline] |
Return number of subpaths.
const SubPath* ipe::Shape::subPath | ( | int | i | ) | const [inline] |
Return subpath.
bool Shape::isSegment | ( | ) | const |
Is this Shape a single straight segment?
void Shape::appendSubPath | ( | SubPath * | sp | ) |
void Shape::draw | ( | Painter & | painter | ) | const |
Draw the Shape as a path to painter.
Does not call newPath() on painter.