35 #include <QPainterPath>
39 #define _USE_MATH_DEFINES
42 using namespace WebCore;
47 : m_path(
new QPainterPath())
73 Qt::FillRule savedRule = m_path->fillRule();
74 m_path->setFillRule(rule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
76 bool contains = m_path->contains(point);
78 m_path->setFillRule(savedRule);
86 *m_path = (*m_path) * matrix;
91 return m_path->boundingRect();
96 m_path->moveTo(point);
106 m_path->quadTo(cp, p);
111 m_path->cubicTo(cp1, cp2, p);
117 qWarning(
"arcTo is busted");
118 m_path->arcTo(p1.
x(), p1.
y(), p2.
x(), p2.
y(), radius, 90);
123 m_path->closeSubpath();
126 #define DEGREES(t) ((t) * 180.0 / M_PI)
140 anticlockwise = !anticlockwise;
148 double xs = xc - radius;
149 double ys = yc - radius;
150 double width = radius*2;
151 double height = radius*2;
153 if (!anticlockwise && (ea < sa))
155 else if (anticlockwise && (sa < ea))
160 if (!(qFuzzyCompare(span + (ea - sa), 0.0) &&
161 qFuzzyCompare(qAbs(span), 360.0))) {
165 m_path->moveTo(QPointF(xc + radius * cos(sar),
166 yc - radius * sin(sar)));
168 m_path->arcTo(xs, ys, width, height, sa, span);
183 *m_path = QPainterPath();
188 return m_path->isEmpty();
194 for (
int i = 0; i < m_path->elementCount(); ++i) {
195 const QPainterPath::Element &cur = m_path->elementAt(i);
198 case QPainterPath::MoveToElement:
199 ret +=
QString(
"M %1 %2").arg(cur.x).arg(cur.y);
201 case QPainterPath::LineToElement:
202 ret +=
QString(
"L %1 %2").arg(cur.x).arg(cur.y);
204 case QPainterPath::CurveToElement:
206 const QPainterPath::Element &c1 = m_path->elementAt(i + 1);
207 const QPainterPath::Element &c2 = m_path->elementAt(i + 2);
209 Q_ASSERT(c1.type == QPainterPath::CurveToDataElement);
210 Q_ASSERT(c2.type == QPainterPath::CurveToDataElement);
212 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);
217 case QPainterPath::CurveToDataElement:
226 void Path::apply(
void* info, PathApplierFunction
function)
const
231 for (
int i = 0; i < m_path->elementCount(); ++i) {
232 const QPainterPath::Element& cur = m_path->elementAt(i);
235 case QPainterPath::MoveToElement:
236 pelement.
type = PathElementMoveToPoint;
237 pelement.
points[0] = QPointF(cur);
238 function(info, &pelement);
240 case QPainterPath::LineToElement:
241 pelement.
type = PathElementAddLineToPoint;
242 pelement.
points[0] = QPointF(cur);
243 function(info, &pelement);
245 case QPainterPath::CurveToElement:
247 const QPainterPath::Element& c1 = m_path->elementAt(i + 1);
248 const QPainterPath::Element& c2 = m_path->elementAt(i + 2);
250 Q_ASSERT(c1.type == QPainterPath::CurveToDataElement);
251 Q_ASSERT(c2.type == QPainterPath::CurveToDataElement);
253 pelement.
type = PathElementAddCurveToPoint;
254 pelement.
points[0] = QPointF(cur);
255 pelement.
points[1] = QPointF(c1);
256 pelement.
points[2] = QPointF(c2);
257 function(info, &pelement);
262 case QPainterPath::CurveToDataElement:
272 QPainterPath temp = mat.map(*m_path);
274 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 &)
This class implements the basic string we use in the DOM.
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 &)