Skip to content

Commit

Permalink
fix: arrow tool glitches (#2395)
Browse files Browse the repository at this point in the history
  • Loading branch information
UnkwUsr authored Feb 13, 2022
1 parent b4188f7 commit db94616
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/tools/arrow/arrowtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ QPainterPath getArrowHead(QPoint p1, QPoint p2, const int thickness)
// Create the vector for the position of the base of the arrowhead
QLineF temp(QPoint(0, 0), p2 - p1);
int val = ArrowHeight + thickness * 4;
if (base.length() < val) {
if (base.length() < (val - thickness * 2)) {
val = static_cast<int>(base.length() + thickness * 2);
}
temp.setLength(base.length() + thickness * 2 - val);
Expand Down Expand Up @@ -45,10 +45,13 @@ QLine getShorterLine(QPoint p1, QPoint p2, const int thickness)
{
QLineF l(p1, p2);
int val = ArrowHeight + thickness * 4;
if (l.length() < val) {
val = static_cast<int>(l.length() + thickness * 2);
}
l.setLength(l.length() + thickness * 2 - val);
if (l.length() < (val - thickness * 2)) {
// here should be 0, but then we lose "angle", so this is hack, but
// looks not very bad
val = thickness / 4;
l.setLength(val);
} else
l.setLength(l.length() + thickness * 2 - val);
return l.toLine();
}

Expand Down

0 comments on commit db94616

Please sign in to comment.