added lottie2gif converter for both cmake and meson build
[platform/core/uifw/lottie-player.git] / example / demo.cpp
1 /* 
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
3  * 
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  * 
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  * 
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18
19 #include "evasapp.h"
20 #include "lottieview.h"
21 #include<iostream>
22 #include <stdio.h>
23 #include <fstream>
24 #include <sstream>
25 using namespace std;
26
27 static void
28 onExitCb(void *data, void *extra)
29 {
30     LottieView *view = (LottieView *)data;
31     delete view;
32 }
33
34 static void
35 onRenderPreCb(void *data, void *extra)
36 {
37     LottieView *view = (LottieView *)data;
38     view->render();
39 }
40
41 int
42 main(void)
43 {
44    EvasApp *app = new EvasApp(800, 800);
45    app->setup();
46
47    std::string filePath = DEMO_DIR;
48    filePath +="circuit.json";
49
50    LottieView *view = new LottieView(app->evas());
51    view->setFilePath(filePath.c_str());
52    if (view->player()) {
53        view->player()->setValue<rlottie::Property::FillColor>("**", rlottie::Color(0, 1, 0));
54    }
55    view->setPos(0, 0);
56    view->setSize(800, 800);
57    view->show();
58 //   view->setMinProgress(0.5);
59 //   view->setMaxProgress(0.0);
60    view->play();
61    view->loop(true);
62    view->setRepeatMode(LottieView::RepeatMode::Reverse);
63
64    app->addExitCb(onExitCb, view);
65    app->addRenderPreCb(onRenderPreCb, view);
66    app->run();
67    delete app;
68    return 0;
69 }
70
71
72
73
74