Skip to content

Commit

Permalink
Fix brush cursor size with canvas rotation (#1869)
Browse files Browse the repository at this point in the history
  • Loading branch information
scribblemaniac authored Jul 27, 2024
1 parent 92c2281 commit e910aee
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core_lib/src/canvascursorpainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ GNU General Public License for more details.
#include "canvascursorpainter.h"

#include <QPainter>
#include <QtMath>

CanvasCursorPainter::CanvasCursorPainter()
{
Expand Down Expand Up @@ -45,8 +46,14 @@ void CanvasCursorPainter::preparePainter(const CanvasCursorPainterOptions& paint
{
mOptions = painterOptions;
if (mOptions.isAdjusting || mOptions.showCursor) {
mOptions.widthRect = viewTransform.mapRect(mOptions.widthRect);
mOptions.featherRect = viewTransform.mapRect(mOptions.featherRect);
// Apply full transform to center of widthRect, but only apply scale to the rect as a whole
// Otherwise, view rotations will result in an incorrect rect size
QPointF newCenter = viewTransform.map(mOptions.widthRect.center());
qreal scale = qSqrt(qPow(viewTransform.m11(), 2) + qPow(viewTransform.m21(), 2));
mOptions.widthRect.setSize(mOptions.widthRect.size() * scale);
mOptions.widthRect.moveCenter(newCenter);
mOptions.featherRect.setSize(mOptions.featherRect.size() * scale);
mOptions.featherRect.moveCenter(newCenter);
}
}

Expand Down

0 comments on commit e910aee

Please sign in to comment.