| 101 | } |
| 102 | |
| 103 | void RectangleShape::updatePath(const QSizeF &size) |
| 104 | { |
| 105 | qreal rx = 0; |
| 106 | qreal ry = 0; |
| 107 | if (m_cornerRadiusX > 0 && m_cornerRadiusY > 0) { |
| 108 | rx = size.width() / 200.0 * m_cornerRadiusX; |
| 109 | ry = size.height() / 200.0 * m_cornerRadiusY; |
| 110 | } |
| 111 | |
| 112 | qreal x2 = size.width() - rx; |
| 113 | qreal y2 = size.height() - ry; |
| 114 | |
| 115 | QPointF curvePoints[12]; |
| 116 | |
| 117 | int requiredCurvePointCount = 4; |
| 118 | if (rx && m_cornerRadiusX < 100) { |
| 119 | requiredCurvePointCount += 2; |
| 120 | } |
| 121 | if (ry && m_cornerRadiusY < 100) { |
| 122 | requiredCurvePointCount += 2; |
| 123 | } |
| 124 | |
| 125 | createPoints(requiredCurvePointCount); |
| 126 | |
| 127 | KoSubpath &points = *subpaths()[0]; |
| 128 | |
| 129 | int cp = 0; |
| 130 | |
| 131 | // first path starts and closes path |
| 132 | points[cp]->setProperty(KoPathPoint::StartSubpath); |
| 133 | points[cp]->setProperty(KoPathPoint::CloseSubpath); |
| 134 | points[cp]->setPoint(QPointF(rx, 0)); |
| 135 | points[cp]->removeControlPoint1(); |
| 136 | points[cp]->removeControlPoint2(); |
| 137 | |
| 138 | if (m_cornerRadiusX < 100 || m_cornerRadiusY == 0) { |
| 139 | // end point of the top edge |
| 140 | points[++cp]->setPoint(QPointF(x2, 0)); |
| 141 | points[cp]->removeControlPoint1(); |
| 142 | points[cp]->removeControlPoint2(); |
| 143 | } |
| 144 | |
| 145 | if (rx) { |
| 146 | // the top right radius |
| 147 | arcToCurve(rx, ry, 90, -90, points[cp]->point(), curvePoints); |
| 148 | points[cp]->setControlPoint2(curvePoints[0]); |
| 149 | points[++cp]->setControlPoint1(curvePoints[1]); |
| 150 | points[cp]->setPoint(curvePoints[2]); |
| 151 | points[cp]->removeControlPoint2(); |
| 152 | } |
| 153 | |
| 154 | if (m_cornerRadiusY < 100 || m_cornerRadiusX == 0) { |
| 155 | // the right edge |
| 156 | points[++cp]->setPoint(QPointF(size.width(), y2)); |
| 157 | points[cp]->removeControlPoint1(); |
| 158 | points[cp]->removeControlPoint2(); |
| 159 | } |
| 160 |
nothing calls this directly
no test coverage detected