examples: revise picture sample code.

This commit is contained in:
Hermet Park 2021-04-01 20:03:57 +09:00
parent ac3e848cfe
commit 6cc7dfdc56
5 changed files with 32 additions and 8 deletions

View file

@ -1,4 +1,27 @@
/*
* Copyright (c) 2020-2021 Samsung Electronics Co., Ltd. All rights reserved.
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "Common.h"
/************************************************************************/
/* Drawing Commands */
/************************************************************************/
@ -7,12 +30,13 @@ void tvgDrawCmds(tvg::Canvas* canvas)
{
if (!canvas) return;
for (int i = 0; i < 40; ++i) {
auto png = tvg::Picture::gen();
if (png->load(EXAMPLE_DIR"/samsung.png") != tvg::Result::Success) return;
png->translate(i* 5, i * 10);
png->rotate(10 * i);
if (canvas->push(move(png)) != tvg::Result::Success) return;
for (int i = 0; i < 5; ++i) {
auto picture = tvg::Picture::gen();
if (picture->load(EXAMPLE_DIR"/logo.png") != tvg::Result::Success) return;
picture->translate(i* 150, i * 150);
picture->rotate(30 * i);
picture->scale(0.25);
if (canvas->push(move(picture)) != tvg::Result::Success) return;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

View file

@ -13,13 +13,13 @@ source_file = [
'GradientStroke.cpp',
'GradientTransform.cpp',
'LinearGradient.cpp',
'LoadPng.cpp',
'MultiCanvas.cpp',
'MultiShapes.cpp',
'Opacity.cpp',
'PathCopy.cpp',
'Path.cpp',
'PixelImage.cpp',
'PicturePng.cpp',
'PictureRaw.cpp',
'RadialGradient.cpp',
'Scene.cpp',
'SceneTransform.cpp',