Skip to content

Commit d4b89bf

Browse files
authored
Merge pull request #96 from scratchcpp/fix_scaling_glitch
Fix #95: Fix scaling glitch
2 parents 51ba7fe + 86a2cf1 commit d4b89bf

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/renderedtarget.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ void RenderedTarget::setStageScale(double newStageScale)
307307
m_stageScale = newStageScale;
308308
calculateSize();
309309
calculatePos();
310+
beforeRedraw();
310311
emit stageScaleChanged();
311312
}
312313

@@ -602,11 +603,10 @@ void RenderedTarget::calculateRotation()
602603
void RenderedTarget::calculateSize()
603604
{
604605
if (m_skin && m_costume) {
605-
Texture texture = m_skin->getTexture(m_size * m_stageScale);
606-
m_texture = texture;
607-
m_width = texture.width();
608-
m_height = texture.height();
609-
setScale(m_size * m_stageScale / m_skin->getTextureScale(texture) / m_costume->bitmapResolution());
606+
m_texture = m_skin->getTexture(m_size * m_stageScale);
607+
m_width = m_texture.width();
608+
m_height = m_texture.height();
609+
setScale(m_size * m_stageScale / m_skin->getTextureScale(m_texture) / m_costume->bitmapResolution());
610610
}
611611
}
612612

test/renderedtarget/renderedtarget_test.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,13 @@ TEST_F(RenderedTargetTest, UpdateMethods)
270270
ASSERT_EQ(texture.width(), 26);
271271
ASSERT_EQ(texture.height(), 26);
272272

273+
// Stage scale (SVG) - should update width and height
274+
EXPECT_CALL(engine, stageWidth()).WillOnce(Return(480));
275+
EXPECT_CALL(engine, stageHeight()).WillOnce(Return(360));
276+
target.setStageScale(3.5);
277+
ASSERT_EQ(target.width(), 52);
278+
ASSERT_EQ(target.height(), 52);
279+
273280
context.doneCurrent();
274281
}
275282

0 commit comments

Comments
 (0)