(18) 矩形转换 :
(19) 路径中的元素 :
++以下是详细代码 :
//这个枚举描述了用于在子路径中连接顶点的元素类型。
//请注意,那些闭合子路径,使用`addEllipse()、addRegion()和`addText()、
// addPath()、`addPolygon()、`addRect()这些便捷函数添加的元素,
//实际上是通过`moveTo()、lineTo()`和cubicTo()函数以一系列独立元素的形式添加到路径中的。
enum ElementType {
MoveToElement, //一个新的子路径。另见moveTo()。
LineToElement, //一条线。另见lineTo()。
CurveToElement, //一条曲线。另见 cubicTo()和 quadTo()。 //Curve曲线
CurveToDataElement //在CurveToElement元素中描述曲线所需的额外数据。
};
//The QPainterPath::Element class specifies the position and type of a subpath.
class Element
{
public:
qreal x; //该变量存储元素位置的 x坐标。
qreal y; //该变量存储元素位置的 y坐标。
ElementType type; //此变量持有元素的类型。
bool isMoveTo () const { return type == MoveToElement; }
bool isLineTo () const { return type == LineToElement; }
bool isCurveTo() const { return type == CurveToElement; }
operator QPointF () const { return QPointF(x, y); }
//类型转换运算符函数,得到路径中元素的起点。
bool operator== (const Element & e) const //判断本元素和形参中元素是否是同一元素。
{ return qFuzzyCompare(x, e.x) && qFuzzyCompare(y, e.y) && type == e.type; }
inline
bool operator!= (const Element & e) const { return !operator==(e); }
};
int elementCount () const; //返回画家路径中的元素数量。
QPainterPath::Element elementAt (int i) const; //返回画家路径中在索引 i处的元素。
void setElementPositionAt(int i, qreal x, qreal y);
//将索引为index的元素的x和y坐标设置为x和y。
++测试一下 :
(20)路径百分比 :
(21) 路径的交并运算 :
(22) 符号运算符 :
(23) 路径平移 :
(24) QPainterPathStroker 似是为了为路径描边即轮廓 :
(25)
谢谢