2 #include <Elementary.h>
9 static uint32_t buffer[WIDTH * HEIGHT];
13 //Initialize TizenVG Engine
17 auto canvas = tvg::SwCanvas::gen();
18 canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
21 auto scene = tvg::Scene::gen();
22 scene->reserve(3); //reserve 3 shape nodes (optional)
24 //Prepare Round Rectangle
25 auto shape1 = tvg::Shape::gen();
26 shape1->appendRect(0, 0, 400, 400, 50); //x, y, w, h, cornerRadius
27 shape1->fill(0, 255, 0, 255); //r, g, b, a
28 scene->push(move(shape1));
31 auto shape2 = tvg::Shape::gen();
32 shape2->appendCircle(400, 400, 200, 200); //cx, cy, radiusW, radiusH
33 shape2->fill(255, 255, 0, 255); //r, g, b, a
34 scene->push(move(shape2));
37 auto shape3 = tvg::Shape::gen();
38 shape3->appendCircle(600, 600, 150, 100); //cx, cy, radiusW, radiusH
39 shape3->fill(0, 255, 255, 255); //r, g, b, a
40 scene->push(move(shape3));
42 //Create another Scene
43 auto scene2 = tvg::Scene::gen();
44 scene2->reserve(2); //reserve 2 shape nodes (optional)
47 auto shape4 = tvg::Shape::gen();
50 shape4->moveTo(199, 34);
51 shape4->lineTo(253, 143);
52 shape4->lineTo(374, 160);
53 shape4->lineTo(287, 244);
54 shape4->lineTo(307, 365);
55 shape4->lineTo(199, 309);
56 shape4->lineTo(97, 365);
57 shape4->lineTo(112, 245);
58 shape4->lineTo(26, 161);
59 shape4->lineTo(146, 143);
61 shape4->fill(0, 0, 255, 255);
62 scene2->push(move(shape4));
65 auto shape5 = tvg::Shape::gen();
70 auto halfRadius = radius * 0.552284f;
73 shape5->moveTo(cx, cy - radius);
74 shape5->cubicTo(cx + halfRadius, cy - radius, cx + radius, cy - halfRadius, cx + radius, cy);
75 shape5->cubicTo(cx + radius, cy + halfRadius, cx + halfRadius, cy + radius, cx, cy+ radius);
76 shape5->cubicTo(cx - halfRadius, cy + radius, cx - radius, cy + halfRadius, cx - radius, cy);
77 shape5->cubicTo(cx - radius, cy - halfRadius, cx - halfRadius, cy - radius, cx, cy - radius);
78 shape5->fill(255, 0, 0, 255);
79 scene2->push(move(shape5));
81 //Push scene2 onto the scene
82 scene->push(move(scene2));
84 //Draw the Scene onto the Canvas
85 canvas->push(move(scene));
89 //Terminate TizenVG Engine
94 win_del(void *data, Evas_Object *o, void *ev)
100 int main(int argc, char **argv)
104 //Show the result using EFL...
105 elm_init(argc, argv);
107 Eo* win = elm_win_util_standard_add(NULL, "TizenVG Test");
108 evas_object_smart_callback_add(win, "delete,request", win_del, 0);
110 Eo* img = evas_object_image_filled_add(evas_object_evas_get(win));
111 evas_object_image_size_set(img, WIDTH, HEIGHT);
112 evas_object_image_data_set(img, buffer);
113 evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
114 evas_object_show(img);
116 elm_win_resize_object_add(win, img);
117 evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT);
118 evas_object_show(win);