52 if (
color().isValid()) {
57 const QRectF targetRect = fillPath.boundingRect();
59 painter.setClipPath(fillPath);
60 QPen pen(
d->lineColor);
70 const int angleOffset[] = {-90, 0, -45 };
72 int loops = (
d->style ==
Single) ? 1 : (
d->style ==
Double) ? 2 : 3;
74 for (
int i = 0; i < loops; ++i) {
75 int angle =
d->angle - angleOffset[i];
76 qreal cosAngle = ::cos(angle/180.0*
M_PI);
78 if (qAbs(cosAngle) > 0.00001) {
79 qreal xDiff = tan(angle/180.0*
M_PI) * targetRect.height();
82 qreal xOffset = qAbs(
d->distance / cosAngle);
86 while (-xDiff < xStart) {
93 while (xDiff < -xEndOffset) {
94 xEndOffset += xOffset;
98 lines.reserve(lines.size() +
int((targetRect.width() + xEndOffset - xStart) / xOffset) + 1);
99 for (qreal x = xStart; x < targetRect.width() + xEndOffset; x += xOffset) {
100 lines.append(QLineF(x, 0, x + xDiff, targetRect.height()));
105 lines.reserve(lines.size() +
int(targetRect.height()/
d->distance) + 1);
106 for (qreal y = 0; y < targetRect.height(); y +=
d->distance) {
107 lines.append(QLineF(0, y, targetRect.width(), y));
112 painter.drawLines(lines);