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