132001f49Smrg#include "eglcommon.h"
232001f49Smrg
332001f49Smrg#include <VG/openvg.h>
432001f49Smrg
532001f49Smrgconst VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0};
632001f49Smrgconst VGfloat green_color[4] = {0.0, 1.0, 0.0, 0.8};
732001f49Smrgconst VGfloat black_color[4] = {0.0, 0.0, 0.0, 1.0};
832001f49Smrg
932001f49SmrgVGPath path;
1032001f49SmrgVGPaint fill;
1132001f49Smrg
1232001f49Smrg
1332001f49Smrgstatic void draw_point(VGfloat x, VGfloat y)
1432001f49Smrg{
1532001f49Smrg
1632001f49Smrg   static const VGubyte cmds[] = {VG_MOVE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS,
1732001f49Smrg                                  VG_LINE_TO_ABS, VG_CLOSE_PATH};
1832001f49Smrg   const VGfloat coords[]   = {  x - 2,  y - 2,
1932001f49Smrg                                 x + 2,  y - 2,
2032001f49Smrg                                 x + 2,  y + 2,
2132001f49Smrg                                 x - 2,  y + 2};
2232001f49Smrg   VGPath path;
2332001f49Smrg   VGPaint fill;
2432001f49Smrg
2532001f49Smrg   path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
2632001f49Smrg                       VG_PATH_CAPABILITY_ALL);
2732001f49Smrg   vgAppendPathData(path, 5, cmds, coords);
2832001f49Smrg
2932001f49Smrg   fill = vgCreatePaint();
3032001f49Smrg   vgSetParameterfv(fill, VG_PAINT_COLOR, 4, black_color);
3132001f49Smrg   vgSetPaint(fill, VG_FILL_PATH);
3232001f49Smrg
3332001f49Smrg   vgDrawPath(path, VG_FILL_PATH);
3432001f49Smrg
3532001f49Smrg   vgDestroyPath(path);
3632001f49Smrg   vgDestroyPaint(fill);
3732001f49Smrg}
3832001f49Smrg
3932001f49Smrgstatic void draw_marks(VGPath path)
4032001f49Smrg{
4132001f49Smrg    VGfloat point[2], tangent[2];
4232001f49Smrg    int i = 0;
4332001f49Smrg
4432001f49Smrg    for (i = 0; i < 1300; i += 50) {
4532001f49Smrg        vgPointAlongPath(path, 0, 6, i,
4632001f49Smrg                         point + 0, point + 1,
4732001f49Smrg                         tangent + 0, tangent + 1);
4832001f49Smrg        draw_point(point[0], point[1]);
4932001f49Smrg    }
5032001f49Smrg}
5132001f49Smrg
5232001f49Smrgstatic void
5332001f49Smrginit(void)
5432001f49Smrg{
5532001f49Smrg   static const VGubyte cmds[6] = {VG_MOVE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS, VG_LINE_TO_ABS,
5632001f49Smrg                                   VG_LINE_TO_ABS, VG_CLOSE_PATH};
5732001f49Smrg   static const VGfloat coords[]   = {  0,  200,
5832001f49Smrg                                        300,  200,
5932001f49Smrg                                        50,   0,
6032001f49Smrg                                        150, 300,
6132001f49Smrg                                        250,   0};
6232001f49Smrg   path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0,
6332001f49Smrg                       VG_PATH_CAPABILITY_ALL);
6432001f49Smrg   vgAppendPathData(path, 6, cmds, coords);
6532001f49Smrg
6632001f49Smrg   fill = vgCreatePaint();
6732001f49Smrg   vgSetParameterfv(fill, VG_PAINT_COLOR, 4, green_color);
6832001f49Smrg   vgSetPaint(fill, VG_FILL_PATH);
6932001f49Smrg
7032001f49Smrg   vgSetfv(VG_CLEAR_COLOR, 4, white_color);
7132001f49Smrg}
7232001f49Smrg
7332001f49Smrg/* new window size or exposure */
7432001f49Smrgstatic void
7532001f49Smrgreshape(int w, int h)
7632001f49Smrg{
7732001f49Smrg   vgLoadIdentity();
7832001f49Smrg}
7932001f49Smrg
8032001f49Smrgstatic void
8132001f49Smrgdraw(void)
8232001f49Smrg{
8332001f49Smrg    VGfloat point[2], tangent[2];
8432001f49Smrg    int i = 0;
8532001f49Smrg
8632001f49Smrg    vgClear(0, 0, window_width(), window_height());
8732001f49Smrg
8832001f49Smrg    vgSetPaint(fill, VG_FILL_PATH);
8932001f49Smrg    vgDrawPath(path, VG_FILL_PATH);
9032001f49Smrg
9132001f49Smrg    draw_marks(path);
9232001f49Smrg
9332001f49Smrg
9432001f49Smrg    vgFlush();
9532001f49Smrg}
9632001f49Smrg
9732001f49Smrg
9832001f49Smrgint main(int argc, char **argv)
9932001f49Smrg{
10032001f49Smrg   return run(argc, argv, init, reshape,
10132001f49Smrg              draw, 0);
10232001f49Smrg}
103