test: revise stroke example
[platform/core/graphics/tizenvg.git] / test / testStroke.cpp
1 #include <tizenvg.h>
2 #include <Elementary.h>
3
4 using namespace std;
5
6 #define WIDTH 800
7 #define HEIGHT 800
8
9 static uint32_t buffer[WIDTH * HEIGHT];
10
11
12 void tvgtest()
13 {
14     //Initialize TizenVG Engine
15     tvg::Engine::init();
16
17     //Initialize TizenVG Engine
18     tvg::Engine::init();
19
20     //Create a Canvas
21     auto canvas = tvg::SwCanvas::gen();
22     canvas->target(buffer, WIDTH, WIDTH, HEIGHT);
23
24     //Shape 1
25     auto shape1 = tvg::Shape::gen();
26     shape1->appendRect(50, 50, 200, 200, 0);
27     shape1->fill(50, 50, 50, 255);
28     shape1->stroke(255, 255, 255, 255);       //color: r, g, b, a
29     shape1->stroke(tvg::StrokeJoin::Bevel);   //default is Bevel
30     shape1->stroke(10);                       //width: 10px
31
32     canvas->push(move(shape1));
33
34     //Shape 2
35     auto shape2 = tvg::Shape::gen();
36     shape2->appendRect(300, 50, 200, 200, 0);
37     shape2->fill(50, 50, 50, 255);
38     shape2->stroke(255, 255, 255, 255);
39     shape2->stroke(tvg::StrokeJoin::Round);
40     shape2->stroke(10);
41
42     canvas->push(move(shape2));
43
44     //Shape 3
45     auto shape3 = tvg::Shape::gen();
46     shape3->appendRect(550, 50, 200, 200, 0);
47     shape3->fill(50, 50, 50, 255);
48     shape3->stroke(255, 255, 255, 255);
49     shape3->stroke(tvg::StrokeJoin::Miter);
50     shape3->stroke(10);
51
52     canvas->push(move(shape3));
53
54     //Shape 4
55     auto shape4 = tvg::Shape::gen();
56     shape4->appendCircle(150, 450, 100, 100);
57     shape4->fill(50, 50, 50, 255);
58     shape4->stroke(255, 255, 255, 255);
59     shape4->stroke(1);
60
61     canvas->push(move(shape4));
62
63     //Shape 5
64     auto shape5 = tvg::Shape::gen();
65     shape5->appendCircle(400, 450, 100, 100);
66     shape5->fill(50, 50, 50, 255);
67     shape5->stroke(255, 255, 255, 255);
68     shape5->stroke(2);
69
70     canvas->push(move(shape5));
71
72     //Shape 6
73     auto shape6 = tvg::Shape::gen();
74     shape6->appendCircle(650, 450, 100, 100);
75     shape6->fill(50, 50, 50, 255);
76     shape6->stroke(255, 255, 255, 255);
77     shape6->stroke(4);
78
79     canvas->push(move(shape6));
80
81
82     canvas->draw();
83     canvas->sync();
84
85     //Terminate TizenVG Engine
86     tvg::Engine::term();
87 }
88
89 void
90 win_del(void *data, Evas_Object *o, void *ev)
91 {
92    elm_exit();
93 }
94
95
96 int main(int argc, char **argv)
97 {
98     tvgtest();
99
100     //Show the result using EFL...
101     elm_init(argc, argv);
102
103     Eo* win = elm_win_util_standard_add(NULL, "TizenVG Test");
104     evas_object_smart_callback_add(win, "delete,request", win_del, 0);
105
106     Eo* img = evas_object_image_filled_add(evas_object_evas_get(win));
107     evas_object_image_size_set(img, WIDTH, HEIGHT);
108     evas_object_image_data_set(img, buffer);
109     evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
110     evas_object_show(img);
111
112     elm_win_resize_object_add(win, img);
113     evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT);
114     evas_object_show(win);
115
116     elm_run();
117     elm_shutdown();
118 }