common: redesigned interfaces
[platform/core/graphics/tizenvg.git] / test / testScene.cpp
1 #include <tizenvg.h>
2
3 using namespace std;
4
5 #define WIDTH 800
6 #define HEIGHT 800
7
8 static uint32_t buffer[WIDTH * HEIGHT];
9
10 int main(int argc, char **argv)
11 {
12     //Initialize TizenVG Engine
13     tvg::Engine::init();
14
15     //Create a Canvas
16     auto canvas = tvg::SwCanvas::gen(buffer, WIDTH, HEIGHT);
17
18     //Create a Scene
19     auto scene = tvg::Scene::gen();
20     scene->reserve(3);   //reserve 3 shape nodes (optional)
21
22     //Shape1
23     auto shape1 = tvg::Shape::gen();
24     shape1->rect(0, 0, 400, 400, 0.1);
25     shape1->fill(255, 0, 0, 255);
26     shape1->rotate(0, 0, 45);   //axis x, y, z
27     scene->push(move(shape1));
28
29     //Shape2
30     auto shape2 = tvg::Shape::gen();
31     shape2->rect(0, 0, 400, 400, 0.1);
32     shape2->fill(0, 255, 0, 255);
33     shape2->transform(matrix);  //by matrix (var matrix[4 * 4];)
34     scene->push(move(shape2));
35
36     //Shape3
37     auto shape3 = tvg::Shape::gen();
38     shape3->rect(0, 0, 400, 400, 0.1);
39     shape3->fill(0, 0, 255, 255);
40     shape3->origin(100, 100);   //offset
41     scene->push(move(shape3));
42
43     //Draw the Scene onto the Canvas
44     canvas->push(move(scene));
45     canvas->draw();
46     canvas->sync();
47
48     //Terminate TizenVG Engine
49     tvg::Engine::term();
50 }