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

Method setLineDash

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

* @brief Sets the dash pattern. Empty array means a solid line. */

Source from the content-addressed store, hash-verified

1417 * @brief Sets the dash pattern. Empty array means a solid line.
1418 */
1419void Widgets::PainterContext::setLineDash(const QJSValue& segments)
1420{
1421 m_state.lineDash.clear();
1422 if (segments.isArray()) {
1423 const int n = segments.property(QStringLiteral("length")).toInt();
1424 m_state.lineDash.reserve(n);
1425 for (int i = 0; i < n; ++i) {
1426 const qreal v = segments.property(static_cast<quint32>(i)).toNumber();
1427 if (v < 0.0)
1428 return;
1429
1430 m_state.lineDash.push_back(v);
1431 }
1432
1433 if ((n & 1) != 0) {
1434 const int dup = n;
1435 for (int i = 0; i < dup; ++i)
1436 m_state.lineDash.push_back(m_state.lineDash[i]);
1437 }
1438 }
1439
1440 applyDashToPen();
1441}
1442
1443/**
1444 * @brief Returns the active dash pattern as a JS-friendly variant list.

Callers 7

drawLineFunction · 0.80
aMethod · 0.80
GnFunction · 0.80
JnFunction · 0.80
drawGridMethod · 0.80
_drawMethod · 0.80
_drawColorBoxMethod · 0.80

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected