2 #include <Elementary.h>
9 static uint32_t buffer[WIDTH * HEIGHT];
10 unique_ptr<tvg::SwCanvas> canvas = nullptr;
11 tvg::Shape* pShape = nullptr;
16 canvas = tvg::SwCanvas::gen();
17 canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
20 auto shape = tvg::Shape::gen();
22 /* Acquire shape pointer to access it again.
23 instead, you should consider not to interrupt this pointer life-cycle. */
26 shape->moveTo(0, -114.5);
27 shape->lineTo(54, -5.5);
28 shape->lineTo(175, 11.5);
29 shape->lineTo(88, 95.5);
30 shape->lineTo(108, 216.5);
31 shape->lineTo(0, 160.5);
32 shape->lineTo(-102, 216.5);
33 shape->lineTo(-87, 96.5);
34 shape->lineTo(-173, 12.5);
35 shape->lineTo(-53, -5.5);
37 shape->fill(0, 0, 255, 255);
38 canvas->push(move(shape));
45 void transit_cb(Elm_Transit_Effect *effect, Elm_Transit* transit, double progress)
47 /* Update shape directly.
48 You can update only necessary properties of this shape,
49 while retaining other properties. */
52 tvg::Matrix m = {1, 0, 0, 0, 1, 0, 0, 0, 1};
55 m.e11 = 1 - (progress * 0.5f);
58 m.e22 = 1 + (progress * 2.0f);
61 constexpr auto PI = 3.141592f;
63 auto radian = degree / 180.0f * PI;
64 auto cosVal = cosf(radian);
65 auto sinVal = sinf(radian);
67 auto t11 = m.e11 * cosVal + m.e12 * sinVal;
68 auto t12 = m.e11 * -sinVal + m.e12 * cosVal;
69 auto t21 = m.e21 * cosVal + m.e22 * sinVal;
70 auto t22 = m.e21 * -sinVal + m.e22 * cosVal;
71 auto t31 = m.e31 * cosVal + m.e32 * sinVal;
72 auto t32 = m.e31 * -sinVal + m.e32 * cosVal;
82 m.e31 = progress * 300.0f + 300.0f;
83 m.e32 = progress * -100.0f + 300.0f;
87 //Update shape for drawing (this may work asynchronously)
88 canvas->update(pShape);
95 Eo* img = (Eo*) effect;
96 evas_object_image_data_update_add(img, 0, 0, WIDTH, HEIGHT);
99 void win_del(void *data, Evas_Object *o, void *ev)
104 int main(int argc, char **argv)
106 //Initialize TizenVG Engine
107 tvg::Initializer::init(tvg::CanvasEngine::Sw);
111 //Show the result using EFL...
112 elm_init(argc, argv);
114 Eo* win = elm_win_util_standard_add(NULL, "TizenVG Test");
115 evas_object_smart_callback_add(win, "delete,request", win_del, 0);
117 Eo* img = evas_object_image_filled_add(evas_object_evas_get(win));
118 evas_object_image_size_set(img, WIDTH, HEIGHT);
119 evas_object_image_data_set(img, buffer);
120 evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
121 evas_object_show(img);
123 elm_win_resize_object_add(win, img);
124 evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT);
125 evas_object_show(win);
127 Elm_Transit *transit = elm_transit_add();
128 elm_transit_effect_add(transit, transit_cb, img, nullptr);
129 elm_transit_duration_set(transit, 2);
130 elm_transit_repeat_times_set(transit, -1);
131 elm_transit_auto_reverse_set(transit, EINA_TRUE);
132 elm_transit_go(transit);
137 //Terminate TizenVG Engine
138 tvg::Initializer::term(tvg::CanvasEngine::Sw);