2 #include <Elementary.h>
9 static uint32_t buffer[WIDTH * HEIGHT];
10 unique_ptr<tvg::SwCanvas> canvas = nullptr;
11 tvg::Scene* pScene1 = nullptr;
12 tvg::Scene* pScene2 = nullptr;
17 canvas = tvg::SwCanvas::gen();
18 canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
21 auto scene = tvg::Scene::gen();
22 pScene1 = scene.get();
23 scene->reserve(3); //reserve 3 shape nodes (optional)
25 //Prepare Round Rectangle (Scene1)
26 auto shape1 = tvg::Shape::gen();
27 shape1->appendRect(-235, -250, 400, 400, 50); //x, y, w, h, cornerRadius
28 shape1->fill(0, 255, 0, 255); //r, g, b, a
29 scene->push(move(shape1));
31 //Prepare Circle (Scene1)
32 auto shape2 = tvg::Shape::gen();
33 shape2->appendCircle(-165, -150, 200, 200); //cx, cy, radiusW, radiusH
34 shape2->fill(255, 255, 0, 255); //r, g, b, a
35 scene->push(move(shape2));
37 //Prepare Ellipse (Scene1)
38 auto shape3 = tvg::Shape::gen();
39 shape3->appendCircle(265, 250, 150, 100); //cx, cy, radiusW, radiusH
40 shape3->fill(0, 255, 255, 255); //r, g, b, a
41 scene->push(move(shape3));
43 scene->translate(350, 350);
47 auto scene2 = tvg::Scene::gen();
48 pScene2 = scene2.get();
49 scene2->reserve(2); //reserve 2 shape nodes (optional)
52 auto shape4 = tvg::Shape::gen();
55 shape4->moveTo(0, -114.5);
56 shape4->lineTo(54, -5.5);
57 shape4->lineTo(175, 11.5);
58 shape4->lineTo(88, 95.5);
59 shape4->lineTo(108, 216.5);
60 shape4->lineTo(0, 160.5);
61 shape4->lineTo(-102, 216.5);
62 shape4->lineTo(-87, 96.5);
63 shape4->lineTo(-173, 12.5);
64 shape4->lineTo(-53, -5.5);
66 shape4->fill(0, 0, 127, 127);
67 scene2->push(move(shape4));
70 auto shape5 = tvg::Shape::gen();
75 auto halfRadius = radius * 0.552284f;
78 shape5->moveTo(cx, cy - radius);
79 shape5->cubicTo(cx + halfRadius, cy - radius, cx + radius, cy - halfRadius, cx + radius, cy);
80 shape5->cubicTo(cx + radius, cy + halfRadius, cx + halfRadius, cy + radius, cx, cy+ radius);
81 shape5->cubicTo(cx - halfRadius, cy + radius, cx - radius, cy + halfRadius, cx - radius, cy);
82 shape5->cubicTo(cx - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius);
83 shape5->fill(127, 0, 0, 127);
84 scene2->push(move(shape5));
86 scene2->translate(500, 350);
88 //Push scene2 onto the scene
89 scene->push(move(scene2));
91 //Draw the Scene onto the Canvas
92 canvas->push(move(scene));
98 void transit_cb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progress)
100 /* Update scene directly.
101 You can update only necessary properties of this scene,
102 while retaining other properties. */
104 pScene1->rotate(360 * progress);
105 pScene2->rotate(360 * progress);
107 //Update shape for drawing (this may work asynchronously)
108 canvas->update(pScene1);
115 Eo* img = (Eo*) effect;
116 evas_object_image_data_update_add(img, 0, 0, WIDTH, HEIGHT);
120 win_del(void *data, Evas_Object *o, void *ev)
125 int main(int argc, char **argv)
127 //Initialize TizenVG Engine
132 //Show the result using EFL...
133 elm_init(argc, argv);
135 Eo* win = elm_win_util_standard_add(NULL, "TizenVG Test");
136 evas_object_smart_callback_add(win, "delete,request", win_del, 0);
138 Eo* img = evas_object_image_filled_add(evas_object_evas_get(win));
139 evas_object_image_size_set(img, WIDTH, HEIGHT);
140 evas_object_image_data_set(img, buffer);
141 evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
142 evas_object_show(img);
144 elm_win_resize_object_add(win, img);
145 evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT);
146 evas_object_show(win);
148 Elm_Transit *transit = elm_transit_add();
149 elm_transit_effect_add(transit, transit_cb, img, nullptr);
150 elm_transit_duration_set(transit, 2);
151 elm_transit_repeat_times_set(transit, -1);
152 elm_transit_go(transit);
157 //Terminate TizenVG Engine