8 static const VGfloat white_color
[4] = {1.0, 1.0, 1.0, 1.0};
14 VGfloat centeredGradient
[5] = {200.0f
, 200.0f
, 200.0f
, 200.0f
, 100};
15 VGfloat noncenteredGradient
[5] = {200.0f
, 200.0f
, 250.0f
, 250.0f
, 100};
16 VGfloat
*radialGradient
= centeredGradient
;
18 VGColorRampSpreadMode spread
= VG_COLOR_RAMP_SPREAD_PAD
;
23 static const VGubyte sqrCmds
[5] = {VG_MOVE_TO_ABS
, VG_HLINE_TO_ABS
, VG_VLINE_TO_ABS
, VG_HLINE_TO_ABS
, VG_CLOSE_PATH
};
24 static const VGfloat sqrCoords
[5] = {0.0f
, 0.0f
, 400.0f
, 400.0f
, 0.0f
};
26 VGfloat rampStop
[] = {0.00f
, 1.0f
, 1.0f
, 1.0f
, 1.0f
,
27 0.33f
, 1.0f
, 0.0f
, 0.0f
, 1.0f
,
28 0.66f
, 0.0f
, 1.0f
, 0.0f
, 1.0f
,
29 1.00f
, 0.0f
, 0.0f
, 1.0f
, 1.0f
};
31 path
= vgCreatePath(VG_PATH_FORMAT_STANDARD
, VG_PATH_DATATYPE_F
, 1, 0, 0, 0,
32 VG_PATH_CAPABILITY_APPEND_TO
);
33 vgAppendPathData(path
, 5, sqrCmds
, sqrCoords
);
35 fill
= vgCreatePaint();
36 vgSetPaint(fill
, VG_FILL_PATH
);
38 vgSetParameteri(fill
, VG_PAINT_TYPE
, VG_PAINT_TYPE_RADIAL_GRADIENT
);
39 vgSetParameteri(fill
, VG_PAINT_COLOR_RAMP_SPREAD_MODE
, spread
);
40 vgSetParameterfv(fill
, VG_PAINT_RADIAL_GRADIENT
, 5, radialGradient
);
41 vgSetParameterfv(fill
, VG_PAINT_COLOR_RAMP_STOPS
, 20, rampStop
);
43 vgSetfv(VG_CLEAR_COLOR
, 4, white_color
);
46 /* new window size or exposure */
56 vgClear(0, 0, window_width(), window_height());
58 vgDrawPath(path
, VG_FILL_PATH
);
64 int main(int argc
, char **argv
)
67 for (i
= 1; i
< argc
; ++i
) {
68 const char *arg
= argv
[i
];
69 if (!strcmp("-pad", arg
))
70 spread
= VG_COLOR_RAMP_SPREAD_PAD
;
71 else if (!strcmp("-repeat", arg
))
72 spread
= VG_COLOR_RAMP_SPREAD_REPEAT
;
73 else if (!strcmp("-reflect", arg
))
74 spread
= VG_COLOR_RAMP_SPREAD_REFLECT
;
75 else if (!strcmp("-center", arg
)) {
76 printf("Centered radial gradient\n");
77 radialGradient
= centeredGradient
;
78 } else if (!strcmp("-noncenter", arg
)) {
79 printf("Non centered radial gradient\n");
80 radialGradient
= noncenteredGradient
;
85 case VG_COLOR_RAMP_SPREAD_PAD
:
86 printf("Using spread mode: pad\n");
88 case VG_COLOR_RAMP_SPREAD_REPEAT
:
89 printf("Using spread mode: repeat\n");
91 case VG_COLOR_RAMP_SPREAD_REFLECT
:
92 printf("Using spread mode: reflect\n");
95 set_window_size(400, 400);
97 return run(argc
, argv
, init
, reshape
,