35 #include <QPainterPath>
39 #define _USE_MATH_DEFINES
45 : m_path(new QPainterPath())
55 : m_path(new QPainterPath(*other.platformPath()))
71 Qt::FillRule savedRule = m_path->fillRule();
72 m_path->setFillRule(rule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
74 bool contains = m_path->contains(point);
76 m_path->setFillRule(savedRule);
84 *m_path = (*m_path) * matrix;
89 return m_path->boundingRect();
94 m_path->moveTo(point);
104 m_path->quadTo(cp, p);
109 m_path->cubicTo(cp1, cp2, p);
115 qWarning(
"arcTo is busted");
116 m_path->arcTo(p1.
x(), p1.
y(), p2.
x(), p2.
y(), radius, 90);
121 m_path->closeSubpath();
124 #define DEGREES(t) ((t) * 180.0 / M_PI)
138 anticlockwise = !anticlockwise;
146 double xs = xc - radius;
147 double ys = yc - radius;
148 double width = radius*2;
149 double height = radius*2;
151 if (!anticlockwise && (ea < sa))
153 else if (anticlockwise && (sa < ea))
158 if (!(qFuzzyCompare(span + (ea - sa), 0.0) &&
159 qFuzzyCompare(qAbs(span), 360.0))) {
163 m_path->moveTo(QPointF(xc + radius * cos(sar),
164 yc - radius * sin(sar)));
166 m_path->arcTo(xs, ys, width, height, sa, span);
181 *m_path = QPainterPath();
186 return m_path->isEmpty();
192 for (
int i = 0; i < m_path->elementCount(); ++i) {
193 const QPainterPath::Element &cur = m_path->elementAt(i);
196 case QPainterPath::MoveToElement:
197 ret +=
QString(
"M %1 %2").arg(cur.x).arg(cur.y);
199 case QPainterPath::LineToElement:
200 ret +=
QString(
"L %1 %2").arg(cur.x).arg(cur.y);
202 case QPainterPath::CurveToElement:
204 const QPainterPath::Element &c1 = m_path->elementAt(i + 1);
205 const QPainterPath::Element &c2 = m_path->elementAt(i + 2);
207 Q_ASSERT(c1.type == QPainterPath::CurveToDataElement);
208 Q_ASSERT(c2.type == QPainterPath::CurveToDataElement);
210 ret +=
QString(
"C %1 %2 %3 %4 %5 %6").arg(cur.x).arg(cur.y).arg(c1.x).arg(c1.y).arg(c2.x).arg(c2.y);
215 case QPainterPath::CurveToDataElement:
229 for (
int i = 0; i < m_path->elementCount(); ++i) {
230 const QPainterPath::Element& cur = m_path->elementAt(i);
233 case QPainterPath::MoveToElement:
234 pelement.
type = PathElementMoveToPoint;
235 pelement.
points[0] = QPointF(cur);
236 function(info, &pelement);
238 case QPainterPath::LineToElement:
239 pelement.
type = PathElementAddLineToPoint;
240 pelement.
points[0] = QPointF(cur);
241 function(info, &pelement);
243 case QPainterPath::CurveToElement:
245 const QPainterPath::Element& c1 = m_path->elementAt(i + 1);
246 const QPainterPath::Element& c2 = m_path->elementAt(i + 2);
248 Q_ASSERT(c1.type == QPainterPath::CurveToDataElement);
249 Q_ASSERT(c2.type == QPainterPath::CurveToDataElement);
251 pelement.
type = PathElementAddCurveToPoint;
252 pelement.
points[0] = QPointF(cur);
253 pelement.
points[1] = QPointF(c1);
254 pelement.
points[2] = QPointF(c2);
255 function(info, &pelement);
260 case QPainterPath::CurveToDataElement:
270 QPainterPath temp = mat.map(*m_path);
272 m_path =
new QPainterPath(temp);
FloatRect boundingRect() const
void addLineTo(const FloatPoint &)
void transform(const AffineTransform &)
void addBezierCurveTo(const FloatPoint &controlPoint1, const FloatPoint &controlPoint2, const FloatPoint &)
bool contains(const FloatPoint &, WindRule rule=RULE_NONZERO) const
PlatformPath * platformPath() const
void addEllipse(const FloatRect &)
void addArc(const FloatPoint &, float radius, float startAngle, float endAngle, bool anticlockwise)
DOM::DOMString debugString() const
void addRect(const FloatRect &)
void moveTo(const FloatPoint &)
void translate(const FloatSize &)
void apply(void *info, PathApplierFunction) const
void addArcTo(const FloatPoint &, const FloatPoint &, float radius)
void addQuadCurveTo(const FloatPoint &controlPoint, const FloatPoint &point)
Path & operator=(const Path &)