evas vg: evas-vg-json.c example added gradient animation test 71/257871/3
authorMichal Maciola <m.maciola@samsung.com>
Mon, 19 Apr 2021 13:18:15 +0000 (15:18 +0200)
committerHermet Park <chuneon.park@samsung.com>
Thu, 6 May 2021 08:47:36 +0000 (08:47 +0000)
Added gradient.json example file and some minor fixes in evas-vg-json.c.

Change-Id: I3f60338d1dd1919216150675283bb5eb7efdae72

src/examples/evas/evas-vg-json.c
src/examples/evas/resources/vg/gradient.json [new file with mode: 0644]

index 59ab6c7..fe26814 100644 (file)
 #define AUTOPLAY 1
 
 Eo *anim;
-static Eo *gvg[5];
+static Eo *gvg[6];
 
 static void
 _running_cb(void *data EINA_UNUSED, const Efl_Event *event)
 {
    double progress = *((double*)event->info);
+   unsigned int len = sizeof(gvg) / sizeof(Eo*);
+   unsigned int i;
 
-   int i;
-   for (i = 0; i < 5; i++)
+   for (i = 0; i < len; i++)
      {
+        if (!gvg[i]) continue;
         double frameCnt = (double) (efl_gfx_frame_controller_frame_count_get(gvg[i]) - 1);
         int frame = (int) (frameCnt * progress);
         efl_gfx_frame_controller_frame_set(gvg[i], frame);
@@ -133,7 +135,6 @@ main(void)
 
    //1
    Eo *vg = gvg[0] = efl_add(EFL_CANVAS_VG_OBJECT_CLASS, evas);
-
    snprintf(buf, sizeof(buf), "%s/browser.json", PACKAGE_EXAMPLES_DIR EVAS_VG_FOLDER);
    efl_file_simple_load(vg, buf, NULL);
    efl_gfx_entity_size_set(vg, EINA_SIZE2D(200, 200));
@@ -171,12 +172,20 @@ main(void)
    efl_gfx_entity_size_set(vg5, EINA_SIZE2D(200, 200));
    efl_gfx_entity_visible_set(vg5, EINA_TRUE);
 
+   //6
+   Eo* vg6 = gvg[5] = efl_add(EFL_CANVAS_VG_OBJECT_CLASS, evas);
+   snprintf(buf, sizeof(buf), "%s/gradient.json", PACKAGE_EXAMPLES_DIR EVAS_VG_FOLDER);
+   efl_file_simple_load(vg6, buf, NULL);
+   efl_gfx_entity_position_set(vg6, EINA_POSITION2D(200, 400));
+   efl_gfx_entity_size_set(vg6, EINA_SIZE2D(200, 200));
+   efl_gfx_entity_visible_set(vg6, EINA_TRUE);
+
    //Play custom animation
    anim = efl_add(EFL_CANVAS_ANIMATION_CLASS, evas);
    efl_animation_duration_set(anim, efl_gfx_frame_controller_frame_duration_get(vg, 0, 0));
    efl_event_callback_add(vg, EFL_CANVAS_OBJECT_ANIMATION_EVENT_ANIMATION_PROGRESS_UPDATED, _running_cb, NULL);
 #ifdef AUTOPLAY
-   efl_canvas_object_animation_start(gvg[0], anim, 1.0, 0.0);
+   efl_canvas_object_animation_start(vg, anim, 1.0, 0.0);
 #endif // AUTOPLAY
 
    _print_help();
diff --git a/src/examples/evas/resources/vg/gradient.json b/src/examples/evas/resources/vg/gradient.json
new file mode 100644 (file)
index 0000000..772ee1f
--- /dev/null
@@ -0,0 +1 @@
+{"v":"4.6.10","fr":15,"ip":0,"op":155,"w":1080,"h":1080,"nm":"background","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 1","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[540,960,0]},"a":{"a":0,"k":[0,0,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[1160,880]},"p":{"a":0,"k":[0,0]},"r":{"a":0,"k":0},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect"},{"ty":"st","c":{"a":0,"k":[0.9960784,0.7843137,0.145098,1]},"o":{"a":0,"k":100},"w":{"a":0,"k":6},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke"},{"ty":"gf","o":{"a":0,"k":100},"r":1,"g":{"p":3,"k":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":0,"s":[0,0.511,0.89,0.283,0.5,0.334,0.873,0.583,1,0.156,0.857,0.882],"e":[0,0.726,0.283,0.89,0.5,0.441,0.356,0.886,1,0.156,0.429,0.882]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":31,"s":[0,0.726,0.283,0.89,0.5,0.441,0.356,0.886,1,0.156,0.429,0.882],"e":[0,0.89,0.283,0.283,0.5,0.886,0.553,0.219,1,0.882,0.823,0.156]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":61,"s":[0,0.89,0.283,0.283,0.5,0.886,0.553,0.219,1,0.882,0.823,0.156],"e":[0,0,0.312,0.737,0.5,0.078,0.597,0.754,1,0.156,0.882,0.771]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":91,"s":[0,0,0.312,0.737,0.5,0.078,0.597,0.754,1,0.156,0.882,0.771],"e":[0,0.51,0.89,0.282,0.5,0.333,0.873,0.582,1,0.157,0.855,0.882]},{"t":120}]}},"s":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":0,"s":[-430.769,-404.573],"e":[23.726,-364.48],"to":[75.7491683959961,6.68213844299316],"ti":[-123.915840148926,-8.51547145843506]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":31,"s":[23.726,-364.48],"e":[312.726,-353.48],"to":[123.915840148926,8.51547145843506],"ti":[-1.00208830833435,-1.83333337306976]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":61,"s":[312.726,-353.48],"e":[29.739,-353.48],"to":[1.00208830833435,1.83333337306976],"ti":[120.055290222168,0.60746711492538]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":91,"s":[29.739,-353.48],"e":[-407.606,-357.125],"to":[-120.055290222168,-0.60746711492538],"ti":[72.8907089233398,0.60746711492538]},{"t":120}]},"e":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":0,"s":[374.412,342.611],"e":[22.822,357.191],"to":[-58.5984153747559,2.42986845970154],"ti":[132.520950317383,-7.89707231521606]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":31,"s":[22.822,357.191],"e":[-420.714,389.994],"to":[-132.520950317383,7.89707231521606],"ti":[-4.68509674072266,-7.89707231521606]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":61,"s":[-420.714,389.994],"e":[50.932,404.573],"to":[4.68509674072266,7.89707231521606],"ti":[-132.918350219727,4.25226974487305]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":91,"s":[50.932,404.573],"e":[376.797,364.48],"to":[132.918350219727,-4.25226974487305],"ti":[-54.3107261657715,6.68213844299316]},{"t":120}]},"t":1,"nm":"Gradient Fill 1","mn":"ADBE Vector Graphic - G-Fill"},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[93.29,219.491],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group"}],"ip":0,"op":155,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":1,"nm":"Deep Red Solid 1","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[540,960,0]},"a":{"a":0,"k":[540,960,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"sw":1080,"sh":1080,"sc":"#be2a2a","ip":0,"op":155,"st":0,"bm":0,"sr":1}]}
\ No newline at end of file