sw_engine: implment basic stroke functions.
[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     //Prepare a Shape (Rectangle + Rectangle + Circle + Circle)
25     auto shape1 = tvg::Shape::gen();
26     shape1->appendRect(0, 0, 200, 200, 0);          //x, y, w, h, cornerRadius
27     shape1->appendRect(100, 100, 300, 300, 100);    //x, y, w, h, cornerRadius
28     shape1->appendCircle(400, 400, 100, 100);       //cx, cy, radiusW, radiusH
29     shape1->appendCircle(400, 500, 170, 100);       //cx, cy, radiusW, radiusH
30     shape1->fill(255, 255, 0, 255);                 //r, g, b, a
31
32     //Stroke Style
33     shape1->stroke(255, 255, 255, 255);   //color: r, g, b, a
34     shape1->stroke(5);                    //width: 5px
35 //    shape1->strokeJoin(tvg::StrokeJoin::Miter);
36 //    shape1->strokeLineCap(tvg::StrokeLineCap::Butt);
37
38 //   uint32_t dash[] = {3, 1, 5, 1};        //dash pattern
39 //   shape1->strokeDash(dash, 4);
40
41     canvas->push(move(shape1));
42
43     canvas->draw();
44     canvas->sync();
45
46     //Terminate TizenVG Engine
47     tvg::Engine::term();
48 }
49
50 void
51 win_del(void *data, Evas_Object *o, void *ev)
52 {
53    elm_exit();
54 }
55
56
57 int main(int argc, char **argv)
58 {
59     tvgtest();
60
61     //Show the result using EFL...
62     elm_init(argc, argv);
63
64     Eo* win = elm_win_util_standard_add(NULL, "TizenVG Test");
65     evas_object_smart_callback_add(win, "delete,request", win_del, 0);
66
67     Eo* img = evas_object_image_filled_add(evas_object_evas_get(win));
68     evas_object_image_size_set(img, WIDTH, HEIGHT);
69     evas_object_image_data_set(img, buffer);
70     evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
71     evas_object_show(img);
72
73     elm_win_resize_object_add(win, img);
74     evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT);
75     evas_object_show(win);
76
77     elm_run();
78     elm_shutdown();
79 }