roundedrect.c revision 32001f49
1#include "eglcommon.h"
2
3#include <VG/openvg.h>
4
5const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
6const VGfloat color[4] = {0.9, 0.1, 0.1, 0.8};
7
8VGPath path;
9VGPaint fill;
10
11
12static void
13init(void)
14{
15   static const VGubyte sqrCmds[10] = {VG_MOVE_TO_ABS,
16                                       VG_LINE_TO_ABS,
17                                       VG_CUBIC_TO_ABS,
18                                       VG_LINE_TO_ABS,
19                                       VG_CUBIC_TO_ABS,
20                                       VG_LINE_TO_ABS,
21                                       VG_CUBIC_TO_ABS,
22                                       VG_LINE_TO_ABS,
23                                       VG_CUBIC_TO_ABS,
24                                       VG_CLOSE_PATH};
25   static const VGfloat sqrCoords[]   = {
26      45.885571, 62.857143,
27      154.11442, 62.857143,
28      162.1236, 62.857143, 168.57142, 70.260744, 168.57142, 79.457144,
29      168.57142, 123.4,
30      168.57142, 132.5964, 162.1236,  140, 154.11442, 140,
31      45.885571, 140,
32      37.876394, 140, 31.428572, 132.5964, 31.428572, 123.4,
33      31.428572, 79.457144,
34      31.428572, 70.260744, 37.876394,62.857143, 45.885571,62.857143
35   };
36   path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
37                       VG_PATH_CAPABILITY_APPEND_TO);
38   vgAppendPathData(path, 10, sqrCmds, sqrCoords);
39
40   fill = vgCreatePaint();
41   vgSetParameterfv(fill, VG_PAINT_COLOR, 4, color);
42   vgSetPaint(fill, VG_FILL_PATH);
43
44   vgSetfv(VG_CLEAR_COLOR, 4, white_color);
45   vgSetf(VG_STROKE_LINE_WIDTH, 6);
46}
47
48/* new window size or exposure */
49static void
50reshape(int w, int h)
51{
52   vgLoadIdentity();
53}
54
55static void
56draw(void)
57{
58   vgClear(0, 0, window_width(), window_height());
59   vgDrawPath(path, VG_STROKE_PATH);
60}
61
62
63int main(int argc, char **argv)
64{
65   return run(argc, argv, init, reshape,
66              draw, 0);
67}
68