diff --git a/src/control/shaperecognizer/ShapeRecognizer.cpp b/src/control/shaperecognizer/ShapeRecognizer.cpp index 3250b523e07f..005271539dc1 100644 --- a/src/control/shaperecognizer/ShapeRecognizer.cpp +++ b/src/control/shaperecognizer/ShapeRecognizer.cpp @@ -297,22 +297,30 @@ auto ShapeRecognizer::recognizePatterns(Stroke* stroke) -> ShapeRecognizerResult if (n == 1) // current stroke is a line { + bool aligned = true; if (fabs(rs->angle) < SLANT_TOLERANCE) // nearly horizontal { rs->angle = 0.0; rs->y1 = rs->y2 = rs->ycenter; - } - if (fabs(rs->angle) > M_PI / 2 - SLANT_TOLERANCE) // nearly vertical - { + } else if (fabs(rs->angle) > M_PI / 2 - SLANT_TOLERANCE) { // nearly vertical rs->angle = (rs->angle > 0) ? (M_PI / 2) : (-M_PI / 2); rs->x1 = rs->x2 = rs->xcenter; + } else { + aligned = false; } auto* s = new Stroke(); s->applyStyleFrom(this->stroke); - s->addPoint(Point(rs->x1, rs->y1)); - s->addPoint(Point(rs->x2, rs->y2)); + if (aligned) { + s->addPoint(Point(rs->x1, rs->y1)); + s->addPoint(Point(rs->x2, rs->y2)); + } else { + auto points = stroke->getPointVector(); + s->addPoint(points.front()); + s->addPoint(points.back()); + } + rs->stroke = s; auto* result = new ShapeRecognizerResult(s); RDEBUG("return line");