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
;
14 VGint join_style
= VG_JOIN_MITER
;
20 static const VGubyte cmds
[] = {VG_MOVE_TO_ABS
,
23 static const VGfloat coords
[] = {30, 30, 264, 0, 0, 264, 234, 234
26 static const VGubyte cmds
[] = {VG_MOVE_TO_ABS
,
30 static const VGfloat coords
[] = {30, 30, 202, 30, 150, 224
33 VGfloat dash_pattern
[2] = { 20.f
, 20.f
};
34 path
= vgCreatePath(VG_PATH_FORMAT_STANDARD
, VG_PATH_DATATYPE_F
, 1, 0, 0, 0,
35 VG_PATH_CAPABILITY_APPEND_TO
);
36 vgAppendPathData(path
, 3, cmds
, coords
);
38 fill
= vgCreatePaint();
39 vgSetParameterfv(fill
, VG_PAINT_COLOR
, 4, color
);
40 vgSetPaint(fill
, VG_FILL_PATH
);
42 vgSetfv(VG_CLEAR_COLOR
, 4, white_color
);
43 vgSetf(VG_STROKE_LINE_WIDTH
, 20);
44 vgSeti(VG_STROKE_CAP_STYLE
, cap_style
);
45 vgSeti(VG_STROKE_JOIN_STYLE
, join_style
);
46 vgSetfv(VG_STROKE_DASH_PATTERN
, 2, dash_pattern
);
47 vgSetf(VG_STROKE_DASH_PHASE
, 0.0f
);
50 /* new window size or exposure */
60 vgClear(0, 0, window_width(), window_height());
61 vgDrawPath(path
, VG_STROKE_PATH
);
66 static int key_press(unsigned key
)
72 if (cap_style
> VG_CAP_SQUARE
)
73 cap_style
= VG_CAP_BUTT
;
76 fprintf(stderr
, "Cap style 'butt'\n");
79 fprintf(stderr
, "Cap style 'round'\n");
82 fprintf(stderr
, "Cap style 'square'\n");
85 vgSeti(VG_STROKE_CAP_STYLE
, cap_style
);
90 if (join_style
> VG_JOIN_BEVEL
)
91 join_style
= VG_JOIN_MITER
;
94 fprintf(stderr
, "Join style 'miter'\n");
97 fprintf(stderr
, "Join style 'round'\n");
100 fprintf(stderr
, "Join style 'bevel'\n");
103 vgSeti(VG_STROKE_JOIN_STYLE
, join_style
);
112 int main(int argc
, char **argv
)
114 return run(argc
, argv
, init
, reshape
,