4 #include <X11/keysym.h>
7 const VGfloat white_color
[4] = {1.0, 1.0, 1.0, 1.0};
8 const VGfloat color
[4] = {0.4, 0.1, 1.0, 1.0};
13 VGint cap_style
= VG_CAP_BUTT
;
18 static const VGubyte cmds
[] = {VG_MOVE_TO_ABS
,
23 static const VGfloat coords
[] = {100, 100, 150, 100,
27 static const VGfloat coords
[] = {100, 20, 100, 220,
30 VGfloat dash_pattern
[2] = { 20.f
, 20.f
};
31 path
= vgCreatePath(VG_PATH_FORMAT_STANDARD
, VG_PATH_DATATYPE_F
, 1, 0, 0, 0,
32 VG_PATH_CAPABILITY_APPEND_TO
);
33 vgAppendPathData(path
, 3, cmds
, coords
);
35 fill
= vgCreatePaint();
36 vgSetParameterfv(fill
, VG_PAINT_COLOR
, 4, color
);
37 vgSetPaint(fill
, VG_FILL_PATH
);
39 vgSetfv(VG_CLEAR_COLOR
, 4, white_color
);
40 vgSetf(VG_STROKE_LINE_WIDTH
, 20);
41 vgSeti(VG_STROKE_CAP_STYLE
, cap_style
);
42 vgSeti(VG_STROKE_JOIN_STYLE
, VG_JOIN_ROUND
);
43 vgSetfv(VG_STROKE_DASH_PATTERN
, 2, dash_pattern
);
44 vgSetf(VG_STROKE_DASH_PHASE
, 0.0f
);
47 /* new window size or exposure */
57 vgClear(0, 0, window_width(), window_height());
58 vgDrawPath(path
, VG_STROKE_PATH
);
63 static int key_press(unsigned key
)
69 if (cap_style
> VG_CAP_SQUARE
)
70 cap_style
= VG_CAP_BUTT
;
73 fprintf(stderr
, "Cap style 'butt'\n");
76 fprintf(stderr
, "Cap style 'round'\n");
79 fprintf(stderr
, "Cap style 'square'\n");
82 vgSeti(VG_STROKE_CAP_STYLE
, cap_style
);
91 int main(int argc
, char **argv
)
93 return run(argc
, argv
, init
, reshape
,