Ejemplo n.º 1
0
//Display functions
void display(float interval)
{
  int i;
  const VGfloat *style;
  VGfloat clearColor[] = {1,1,1,1};
  
  if (animate) {
    ang += interval * 360 * 0.1f;
    if (ang > 360) ang -= 360;
  }
  
  vgSetfv(VG_CLEAR_COLOR, 4, clearColor);
  vgClear(0,0,testWidth(),testHeight());
  
  vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
  vgLoadIdentity();
  vgTranslate(testWidth()/2 + tx,testHeight()/2 + ty);
  vgScale(sx, sy);
  vgRotate(ang);
  
  for (i=0; i<pathCount; ++i) {
    
    style = styleArrays[i];
    vgSetParameterfv(tigerStroke, VG_PAINT_COLOR, 4, &style[0]);
    vgSetParameterfv(tigerFill, VG_PAINT_COLOR, 4, &style[4]);
    vgSetf(VG_STROKE_LINE_WIDTH, style[8]);
    vgDrawPath(tigerPaths[i], (VGint)style[9]); // Bingo!!, Draw it!! 
  }
  vgFlush();
}
Ejemplo n.º 2
0
void display(float interval)
{
  VGfloat cc[] = {0,0,0,1};
  
  vgSetfv(VG_CLEAR_COLOR, 4, cc);
  vgClear(0,0,testWidth(),testHeight());
  
  vgSeti(VG_MATRIX_MODE, VG_MATRIX_FILL_PAINT_TO_USER);
  vgLoadIdentity();
  vgTranslate(tx, ty);
  vgRotate(ang);
  vgScale(sx, sy);
  
  vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
  vgLoadIdentity();
  
  vgSetPaint(radialFill, VG_FILL_PATH);
  vgDrawPath(p, VG_FILL_PATH);
  
  vgTranslate(tx, ty);
  vgRotate(ang);
  vgScale(sx, sy);
  
  vgSetPaint(blackFill, VG_FILL_PATH | VG_STROKE_PATH);
  vgDrawPath(radius, VG_STROKE_PATH);
  vgDrawPath(center, VG_STROKE_PATH);
  vgDrawPath(focus, VG_FILL_PATH);
}
Ejemplo n.º 3
0
int main(int argc, char **argv)
{
  testInit(argc, argv, 400,400, "ShivaVG: Radial Gradient Test");
  testCallback(TEST_CALLBACK_DISPLAY, (CallbackFunc)display);
  testCallback(TEST_CALLBACK_BUTTON, (CallbackFunc)click);
  testCallback(TEST_CALLBACK_DRAG, (CallbackFunc)drag);
  testCallback(TEST_CALLBACK_KEY, (CallbackFunc)key);
  
  p = testCreatePath();
  center = testCreatePath();
  focus = testCreatePath();
  radius = testCreatePath();
  
  cx = testWidth()/2;
  cy = testHeight()/2;
  fx = cx;
  fy = cy;
  r = sqx/2;
  
  radialFill = vgCreatePaint();
  blackFill = vgCreatePaint();
  vgSetParameterfv(blackFill, VG_PAINT_COLOR, 4, black);
  
  createSquare(p);
  createRadial();
  
  testOverlayString("Press H for a list of commands");
  testOverlayColor(1,1,1,1);
  testRun();
  
  return EXIT_SUCCESS;
}
Ejemplo n.º 4
0
void display(float interval)
{
  VGfloat cc[] = {0,0,0,1};
  
  vgSetfv(VG_CLEAR_COLOR, 4, cc);
  vgClear(0,0,testWidth(),testHeight());
  
  vgSeti(VG_MATRIX_MODE, VG_MATRIX_FILL_PAINT_TO_USER);
  vgLoadIdentity();
  vgTranslate(tx, ty);
  vgScale(sx, sy);
  vgRotate(a);
  
  vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
  vgLoadIdentity();
  
  vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
  vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY);
  vgLoadIdentity();
  
  vgSetPaint(patternFill, VG_FILL_PATH);
  /*vgDrawPath(p, VG_FILL_PATH);*/
  vgDrawImage(backImage);
  
  vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
  vgLoadIdentity();
  vgTranslate(tx, ty);
  vgScale(sx, sy);
  vgRotate(a);
  
  vgSetPaint(blackFill, VG_FILL_PATH | VG_STROKE_PATH);
  vgDrawPath(org, VG_FILL_PATH);
}
Ejemplo n.º 5
0
void createSquare(VGPath p)
{
  testMoveTo(p, (testWidth()-sqx)/2, (testHeight()-sqy)/2, VG_ABSOLUTE);
  testLineTo(p, sqx, 0, VG_RELATIVE);
  testLineTo(p, 0, sqy, VG_RELATIVE);
  testLineTo(p, -sqx, 0, VG_RELATIVE);
  testClosePath(p);
}
Ejemplo n.º 6
0
void display(float interval)
{
  VGfloat cc[] = {0,0,0,1};

  angle += interval * 0.4 * PI;
  if (angle > 2*PI) angle -= 2*PI;
  amount = (sin(angle) + 1) * 0.5f;
  createMorph();

  vgSetfv(VG_CLEAR_COLOR, 4, cc);
  vgClear(0,0,testWidth(),testHeight());

  vgLoadIdentity();
  vgTranslate(testWidth()/2, testHeight()/2);
  vgScale(1.5, 1.5);
  vgDrawPath(iMorph, VG_FILL_PATH);
}
Ejemplo n.º 7
0
void display(float interval)
{
  int x,y,p;
  VGfloat white[] = {1,1,1,1};
  
  vgSetfv(VG_CLEAR_COLOR, 4, white);
  vgClear(0, 0, testWidth(), testHeight());
  
  vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
  
  for (y=0, p=0; y<3; ++y) {
    for (x=0; x<3; ++x, ++p) {
      if (p > NUM_PRIMITIVES) break;
      
      vgLoadIdentity();
      vgTranslate(100 + x*150, 100 + y*150);
      vgDrawPath(primitives[p], VG_STROKE_PATH);
    }
  }
}
Ejemplo n.º 8
0
void key(unsigned char key, int x, int y)
{
  glutPostRedisplay();
  
  if (key == BACKSPACE) {
    /* Reset value */
    switch(mode) {
    case 'c':
      cx = testWidth()/2;
      cy = testHeight()/2;
      fx = cx; fy = cy;
      createRadial();
      break;
    case 'f':
      fx = cx; fy = cy;
      createRadial();
      break;
    case 'r':
      r = sqx;
      createRadial();
      break;
    case 'x':
      sx = 1.0f;
      break;
    case 'y':
      sy = 1.0f;
      break;
    }
    updateOverlayString();
    return;
  }
  
  switch (tolower(key)) {
  case 'c':
  case 'f':
  case 'r':
  case 'x':
  case 'y':
    break;
    
  case TAB:
    
    /* Cycle spread mode */
    sindex = (sindex+1) % ssize;
    createRadial();
    switch(sindex) {
    case 0: testOverlayString("Gradient Spread mode: PAD"); break;
    case 1: testOverlayString("Gradient Spread mode: REPEAT"); break;
    case 2: testOverlayString("Gradient Spread mode: REFLECT"); break;
    }return;
    
  case 'h':
    /* Show help */
    testOverlayString(commands);
    return;
    
  default:
    return;
  }
  
  /* Switch mode */
  mode = tolower(key);
  updateOverlayString();
}