fix shift and trace scaling

This commit is contained in:
shun-iwasawa 2021-04-09 15:32:04 +09:00 committed by manongjohn
parent 3e4842dd1a
commit b8b432234d

View file

@ -530,14 +530,16 @@ void ShiftTraceTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e) {
m_aff[m_ghostIndex] = TTranslation(delta) * m_aff[m_ghostIndex]; m_aff[m_ghostIndex] = TTranslation(delta) * m_aff[m_ghostIndex];
} else if (m_gadget == ScaleGadget) { } else if (m_gadget == ScaleGadget) {
TAffine aff = getGhostAff(); TAffine aff = getGhostAff();
TPointD c = aff * m_center[m_ghostIndex]; TPointD c = m_center[m_ghostIndex];
TPointD a = m_oldPos - c; TPointD a = aff.inv() * m_oldPos - c;
TPointD b = pos - c; TPointD b = aff.inv() * pos - c;
TPointD imgC = aff * m_center[m_ghostIndex];
if (e.isShiftPressed()) if (e.isShiftPressed())
m_aff[m_ghostIndex] = m_oldAff * TScale(b.x / a.x, b.y / a.y); m_aff[m_ghostIndex] = TScale(imgC, b.x / a.x, b.y / a.y) * m_oldAff;
else { else {
double scale = std::max(b.x / a.x, b.y / a.y); double scale = std::max(b.x / a.x, b.y / a.y);
m_aff[m_ghostIndex] = m_oldAff * TScale(scale, scale); m_aff[m_ghostIndex] = TScale(imgC, scale) * m_oldAff;
} }
} }