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 1332001f49SmrgVGColorRampSpreadMode spread = VG_COLOR_RAMP_SPREAD_PAD; 1432001f49Smrg 1532001f49Smrgstatic void 1632001f49Smrginit(void) 1732001f49Smrg{ 1832001f49Smrg static const VGubyte sqrCmds[5] = {VG_MOVE_TO_ABS, VG_HLINE_TO_ABS, VG_VLINE_TO_ABS, VG_HLINE_TO_ABS, VG_CLOSE_PATH}; 1932001f49Smrg static const VGfloat sqrCoords[5] = {0.0f, 0.0f, 400.0f, 400.0f, 0.0f}; 2032001f49Smrg 2132001f49Smrg VGfloat rampStop[] = {0.00f, 1.0f, 1.0f, 1.0f, 1.0f, 2232001f49Smrg 0.33f, 1.0f, 0.0f, 0.0f, 1.0f, 2332001f49Smrg 0.66f, 0.0f, 1.0f, 0.0f, 1.0f, 2432001f49Smrg 1.00f, 0.0f, 0.0f, 1.0f, 1.0f}; 2532001f49Smrg VGfloat linearGradient[4] = {100.0f, 100.0f, 300.0f, 300.0f}; 2632001f49Smrg 2732001f49Smrg path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0, 2832001f49Smrg VG_PATH_CAPABILITY_APPEND_TO); 2932001f49Smrg vgAppendPathData(path, 5, sqrCmds, sqrCoords); 3032001f49Smrg 3132001f49Smrg fill = vgCreatePaint(); 3232001f49Smrg vgSetPaint(fill, VG_FILL_PATH); 3332001f49Smrg 3432001f49Smrg vgSetParameteri(fill, VG_PAINT_TYPE, VG_PAINT_TYPE_LINEAR_GRADIENT); 3532001f49Smrg vgSetParameteri(fill, VG_PAINT_COLOR_RAMP_SPREAD_MODE, spread); 3632001f49Smrg vgSetParameterfv(fill, VG_PAINT_LINEAR_GRADIENT, 4, linearGradient); 3732001f49Smrg vgSetParameterfv(fill, VG_PAINT_COLOR_RAMP_STOPS, 20, rampStop); 3832001f49Smrg 3932001f49Smrg vgSetfv(VG_CLEAR_COLOR, 4, white_color); 4032001f49Smrg} 4132001f49Smrg 4232001f49Smrg/* new window size or exposure */ 4332001f49Smrgstatic void 4432001f49Smrgreshape(int w, int h) 4532001f49Smrg{ 4632001f49Smrg vgLoadIdentity(); 4732001f49Smrg} 4832001f49Smrg 4932001f49Smrgstatic void 5032001f49Smrgdraw(void) 5132001f49Smrg{ 5232001f49Smrg vgClear(0, 0, window_width(), window_height()); 5332001f49Smrg 5432001f49Smrg vgDrawPath(path, VG_FILL_PATH); 5532001f49Smrg 5632001f49Smrg vgFlush(); 5732001f49Smrg} 5832001f49Smrg 5932001f49Smrg 6032001f49Smrgint main(int argc, char **argv) 6132001f49Smrg{ 6232001f49Smrg if (argc > 1) { 6332001f49Smrg const char *arg = argv[1]; 6432001f49Smrg if (!strcmp("-pad", arg)) 6532001f49Smrg spread = VG_COLOR_RAMP_SPREAD_PAD; 6632001f49Smrg else if (!strcmp("-repeat", arg)) 6732001f49Smrg spread = VG_COLOR_RAMP_SPREAD_REPEAT; 6832001f49Smrg else if (!strcmp("-reflect", arg)) 6932001f49Smrg spread = VG_COLOR_RAMP_SPREAD_REFLECT; 7032001f49Smrg } 7132001f49Smrg 7232001f49Smrg switch(spread) { 7332001f49Smrg case VG_COLOR_RAMP_SPREAD_PAD: 7432001f49Smrg printf("Using spread mode: pad\n"); 7532001f49Smrg break; 7632001f49Smrg case VG_COLOR_RAMP_SPREAD_REPEAT: 7732001f49Smrg printf("Using spread mode: repeat\n"); 7832001f49Smrg break; 7932001f49Smrg case VG_COLOR_RAMP_SPREAD_REFLECT: 8032001f49Smrg printf("Using spread mode: reflect\n"); 8132001f49Smrg } 8232001f49Smrg 8332001f49Smrg set_window_size(400, 400); 8432001f49Smrg 8532001f49Smrg return run(argc, argv, init, reshape, 8632001f49Smrg draw, 0); 8732001f49Smrg} 88