examples: updated scale up/down

This commit is contained in:
Hermet Park 2024-01-18 18:45:35 +09:00 committed by Hermet Park
parent edd8756b73
commit bcab78e7d6
6 changed files with 4 additions and 26 deletions

View file

@ -36,7 +36,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Original //Original
auto picture = tvg::Picture::gen(); auto picture = tvg::Picture::gen();
if (picture->load(EXAMPLE_DIR"/scaledown.png") != tvg::Result::Success) { if (picture->load(EXAMPLE_DIR"/scaledown.jpg") != tvg::Result::Success) {
cout << "The PNG file is not loaded correctly. Did you enable PNG Loader?" << endl; cout << "The PNG file is not loaded correctly. Did you enable PNG Loader?" << endl;
return; return;
} }
@ -52,18 +52,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
canvas->clear(false); canvas->clear(false);
auto scale = 1.0f; pPicture->scale(1.0f - progress);
if (progress > 0.875f) scale = 0.125f;
else if (progress > 0.75f) scale = 0.25f;
else if (progress > 0.625f) scale = 0.375f;
else if (progress > 0.5f) scale = 0.5f;
else if (progress > 0.375f) scale = 0.625f;
else if (progress > 0.25f) scale = 0.75f;
else if (progress > 0.125f) scale = 0.875f;
else scale = 1.0f;
pPicture->scale(scale);
canvas->update(pPicture); canvas->update(pPicture);
} }

View file

@ -36,7 +36,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
//Original //Original
auto picture = tvg::Picture::gen(); auto picture = tvg::Picture::gen();
if (picture->load(EXAMPLE_DIR"/scaleup.png") != tvg::Result::Success) { if (picture->load(EXAMPLE_DIR"/scaleup.jpg") != tvg::Result::Success) {
cout << "The PNG file is not loaded correctly. Did you enable PNG Loader?" << endl; cout << "The PNG file is not loaded correctly. Did you enable PNG Loader?" << endl;
return; return;
} }
@ -52,18 +52,7 @@ void tvgUpdateCmds(tvg::Canvas* canvas, float progress)
canvas->clear(false); canvas->clear(false);
auto scale = 1.0f; pPicture->scale(progress * 4.0f);
if (progress > 0.875f) scale = 4.0f;
else if (progress > 0.75f) scale = 3.0f;
else if (progress > 0.625f) scale = 2.5f;
else if (progress > 0.5f) scale = 2.0f;
else if (progress > 0.375f) scale = 1.75f;
else if (progress > 0.25f) scale = 1.5f;
else if (progress > 0.125f) scale = 1.25f;
else scale = 1.0f;
pPicture->scale(scale);
canvas->update(pPicture); canvas->update(pPicture);
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB