painter.setPen(QPen(colorAlpha,curWidth,pStyle,Qt::FlatCap));painter.setCompositionMode(mode);painter.drawPolyline(points);
C++ (Qt)void CalcBluePt( const QPolygonF & poly, int index, int lineWidth, QPointF bluePt[2] ){ QVector2D dir; const QPointF & base = poly[index]; if (index > 0) dir += QVector2D(base - poly[index - 1]).normalized(): if (index < poly.size() - 1) dir += QVector2D(poly[index + 1] - base).normalized(): dir.normalize(); dir *= lineWidth; QPointF ofs(-dir.y(), dir.x()); bluePt[0] = base + ofs; bluePt[1] = base - ofs;}
C++ (Qt)void CalcBluePt( const QPolygonF & poly, int index, qreal halfWidth, QPointF bluePt[2] ){ QVector2D dir, dir1, dir2; const QPointF & base = poly[index]; qreal dot = 1.0; if (index == 0) dir = QVector2D(poly[index + 1] - base).normalized(); else if (index == poly.size() - 1) dir = QVector2D(base - poly[index - 1]).normalized(); else { dir1 = QVector2D(poly[index + 1] - base).normalized(); dir2 = QVector2D(base - poly[index - 1]).normalized(); dir = (dir1 + dir2).normalized(); dot = QVector2D::dotProduct(dir, dir2); } dir *= halfWidth / dot; QPointF ofs(-dir.y(), dir.x()); bluePt[0] = base + ofs; bluePt[1] = base - ofs;}