132001f49Smrg#include "eglcommon.h" 232001f49Smrg 332001f49Smrg#include <VG/openvg.h> 432001f49Smrg 532001f49Smrg#include <stdio.h> 632001f49Smrg#include <string.h> 732001f49Smrg 832001f49Smrgstatic const VGfloat white_color[4] = {1.0, 1.0, 1.0, 1.0}; 932001f49Smrg 1032001f49Smrgstatic VGPath path; 1132001f49Smrgstatic VGPaint fill; 1232001f49Smrg 1332001f49Smrg 1432001f49SmrgVGfloat centeredGradient[5] = {200.0f, 200.0f, 200.0f, 200.0f, 100}; 1532001f49SmrgVGfloat noncenteredGradient[5] = {200.0f, 200.0f, 250.0f, 250.0f, 100}; 1632001f49SmrgVGfloat *radialGradient = centeredGradient; 1732001f49Smrg 1832001f49SmrgVGColorRampSpreadMode spread = VG_COLOR_RAMP_SPREAD_PAD; 1932001f49Smrg 2032001f49Smrgstatic void 2132001f49Smrginit(void) 2232001f49Smrg{ 2332001f49Smrg static const VGubyte sqrCmds[5] = {VG_MOVE_TO_ABS, VG_HLINE_TO_ABS, VG_VLINE_TO_ABS, VG_HLINE_TO_ABS, VG_CLOSE_PATH}; 2432001f49Smrg static const VGfloat sqrCoords[5] = {0.0f, 0.0f, 400.0f, 400.0f, 0.0f}; 2532001f49Smrg 2632001f49Smrg VGfloat rampStop[] = {0.00f, 1.0f, 1.0f, 1.0f, 1.0f, 2732001f49Smrg 0.33f, 1.0f, 0.0f, 0.0f, 1.0f, 2832001f49Smrg 0.66f, 0.0f, 1.0f, 0.0f, 1.0f, 2932001f49Smrg 1.00f, 0.0f, 0.0f, 1.0f, 1.0f}; 3032001f49Smrg 3132001f49Smrg path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0, 3232001f49Smrg VG_PATH_CAPABILITY_APPEND_TO); 3332001f49Smrg vgAppendPathData(path, 5, sqrCmds, sqrCoords); 3432001f49Smrg 3532001f49Smrg fill = vgCreatePaint(); 3632001f49Smrg vgSetPaint(fill, VG_FILL_PATH); 3732001f49Smrg 3832001f49Smrg vgSetParameteri(fill, VG_PAINT_TYPE, VG_PAINT_TYPE_RADIAL_GRADIENT); 3932001f49Smrg vgSetParameteri(fill, VG_PAINT_COLOR_RAMP_SPREAD_MODE, spread); 4032001f49Smrg vgSetParameterfv(fill, VG_PAINT_RADIAL_GRADIENT, 5, radialGradient); 4132001f49Smrg vgSetParameterfv(fill, VG_PAINT_COLOR_RAMP_STOPS, 20, rampStop); 4232001f49Smrg 4332001f49Smrg vgSetfv(VG_CLEAR_COLOR, 4, white_color); 4432001f49Smrg} 4532001f49Smrg 4632001f49Smrg/* new window size or exposure */ 4732001f49Smrgstatic void 4832001f49Smrgreshape(int w, int h) 4932001f49Smrg{ 5032001f49Smrg vgLoadIdentity(); 5132001f49Smrg} 5232001f49Smrg 5332001f49Smrgstatic void 5432001f49Smrgdraw(void) 5532001f49Smrg{ 5632001f49Smrg vgClear(0, 0, window_width(), window_height()); 5732001f49Smrg 5832001f49Smrg vgDrawPath(path, VG_FILL_PATH); 5932001f49Smrg 6032001f49Smrg vgFlush(); 6132001f49Smrg} 6232001f49Smrg 6332001f49Smrg 6432001f49Smrgint main(int argc, char **argv) 6532001f49Smrg{ 6632001f49Smrg VGint i; 6732001f49Smrg for (i = 1; i < argc; ++i) { 6832001f49Smrg const char *arg = argv[i]; 6932001f49Smrg if (!strcmp("-pad", arg)) 7032001f49Smrg spread = VG_COLOR_RAMP_SPREAD_PAD; 7132001f49Smrg else if (!strcmp("-repeat", arg)) 7232001f49Smrg spread = VG_COLOR_RAMP_SPREAD_REPEAT; 7332001f49Smrg else if (!strcmp("-reflect", arg)) 7432001f49Smrg spread = VG_COLOR_RAMP_SPREAD_REFLECT; 7532001f49Smrg else if (!strcmp("-center", arg)) { 7632001f49Smrg printf("Centered radial gradient\n"); 7732001f49Smrg radialGradient = centeredGradient; 7832001f49Smrg } else if (!strcmp("-noncenter", arg)) { 7932001f49Smrg printf("Non centered radial gradient\n"); 8032001f49Smrg radialGradient = noncenteredGradient; 8132001f49Smrg } 8232001f49Smrg } 8332001f49Smrg 8432001f49Smrg switch(spread) { 8532001f49Smrg case VG_COLOR_RAMP_SPREAD_PAD: 8632001f49Smrg printf("Using spread mode: pad\n"); 8732001f49Smrg break; 8832001f49Smrg case VG_COLOR_RAMP_SPREAD_REPEAT: 8932001f49Smrg printf("Using spread mode: repeat\n"); 9032001f49Smrg break; 9132001f49Smrg case VG_COLOR_RAMP_SPREAD_REFLECT: 9232001f49Smrg printf("Using spread mode: reflect\n"); 9332001f49Smrg } 9432001f49Smrg 9532001f49Smrg set_window_size(400, 400); 9632001f49Smrg 9732001f49Smrg return run(argc, argv, init, reshape, 9832001f49Smrg draw, 0); 9932001f49Smrg} 100