mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
examples: updated scale up/down
This commit is contained in:
parent
edd8756b73
commit
bcab78e7d6
6 changed files with 4 additions and 26 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
BIN
src/examples/resources/scaledown.jpg
Normal file
BIN
src/examples/resources/scaledown.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 310 KiB |
Binary file not shown.
Before Width: | Height: | Size: 109 KiB |
BIN
src/examples/resources/scaleup.jpg
Normal file
BIN
src/examples/resources/scaleup.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
Before Width: | Height: | Size: 7.1 KiB |
Loading…
Add table
Reference in a new issue