demo.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #include "evasapp.h"
  19. #include "lottieview.h"
  20. #include<iostream>
  21. #include <stdio.h>
  22. #include <fstream>
  23. #include <sstream>
  24. using namespace std;
  25. static void
  26. onExitCb(void *data, void */*extra*/)
  27. {
  28. LottieView *view = (LottieView *)data;
  29. delete view;
  30. }
  31. int
  32. main(void)
  33. {
  34. EvasApp *app = new EvasApp(800, 800);
  35. app->setup();
  36. std::string filePath = DEMO_DIR;
  37. filePath +="circuit.json";
  38. LottieView *view = new LottieView(app->evas());
  39. view->setFilePath(filePath.c_str());
  40. if (view->player()) {
  41. view->player()->setValue<rlottie::Property::FillColor>("**",
  42. [](const rlottie::FrameInfo& info) {
  43. if (info.curFrame() < 15 )
  44. return rlottie::Color(0, 1, 0);
  45. else {
  46. return rlottie::Color(1, 0, 0);
  47. }
  48. });
  49. }
  50. view->setPos(0, 0);
  51. view->setSize(800, 800);
  52. view->show();
  53. // view->setMinProgress(0.5);
  54. // view->setMaxProgress(0.0);
  55. view->play();
  56. view->loop(true);
  57. view->setRepeatMode(LottieView::RepeatMode::Reverse);
  58. app->addExitCb(onExitCb, view);
  59. app->run();
  60. delete app;
  61. return 0;
  62. }