MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / arc

Method arc

app/src/UI/Widgets/PainterContext.cpp:1013–1036  ·  view source on GitHub ↗

* @brief Adds a circular arc to the path (Canvas2D semantics). */

Source from the content-addressed store, hash-verified

1011 * @brief Adds a circular arc to the path (Canvas2D semantics).
1012 */
1013void Widgets::PainterContext::arc(
1014 qreal x, qreal y, qreal r, qreal startRad, qreal endRad, bool counterClockwise)
1015{
1016 if (r <= 0.0)
1017 return;
1018
1019 constexpr qreal kTau = 2.0 * M_PI;
1020 const qreal raw = endRad - startRad;
1021 qreal sweepRad;
1022 if (std::abs(raw) >= kTau)
1023 sweepRad = counterClockwise ? -kTau : kTau;
1024 else {
1025 sweepRad = std::fmod(raw, kTau);
1026 if (!counterClockwise && sweepRad < 0.0)
1027 sweepRad += kTau;
1028 else if (counterClockwise && sweepRad > 0.0)
1029 sweepRad -= kTau;
1030 }
1031
1032 const qreal startDeg = -qRadiansToDegrees(startRad);
1033 const qreal sweepDeg = -qRadiansToDegrees(sweepRad);
1034 const QRectF box(x - r, y - r, 2.0 * r, 2.0 * r);
1035 m_path.arcTo(box, startDeg, sweepDeg);
1036}
1037
1038/**
1039 * @brief Adds a Canvas2D-style arcTo: tangent arc of radius r between two segments.

Callers 15

paintFunction · 0.80
paintFunction · 0.80
paintFunction · 0.80
paintFunction · 0.80
paintFunction · 0.80
paintFunction · 0.80
paintFunction · 0.80
paintFunction · 0.80
paintFunction · 0.80
zoneFunction · 0.80
paintFunction · 0.80
paintFunction · 0.80

Calls 3

absFunction · 0.85
fmodFunction · 0.85
arcToMethod · 0.80

Tested by

no test coverage detected