Example #1
0
void key(unsigned char key, int x, int y)
{
  glutPostRedisplay();
  
  if (key == BACKSPACE) {
    /* Reset value */
    switch (mode) {
    case 't':
      tx = 0;
      ty = 0;
      break;
    case 'x':
      sx = 1.0f;
      break;
    case 'y':
      sy = 1.0f;
      break;
    }
    updateOverlayString();
    return;
  }
    

  switch (tolower(key)) {
  case 't':
  case 'x':
  case 'y':
    break;
    
  case TAB:
    
    /* Cycle spread mode */
    tindex = (tindex+1) % tsize;
    createPattern();
    switch(tindex) {
    case 0: testOverlayString("Pattern Tiling mode: FILL\n"); break;
    case 1: testOverlayString("Pattern Tiling mode: PAD\n"); break;
    case 2: testOverlayString("Pattern Tiling mode: REPEAT\n"); break;
    case 3: testOverlayString("Pattern Tiling mode: REFLECT\n"); break;
    }return;
    
  case 'h':
    /* Show help */
    testOverlayString(commands);
    return;
    
  default:
    return;
  }
  
  /* Switch mode */
  mode = tolower(key);
  updateOverlayString();
}
Example #2
0
void key(unsigned char code, int x, int y)
{
  switch (tolower(code)) {
  case 'z':
  case 'p':
    break;
    
  case ' ':
    /* Toggle animation */
    animate = !animate;
    testOverlayString("%s\n", animate ? "Play" : "Pause");
    return;
    
  case 'h':
    /* Show help */
    testOverlayString(commands);
    return;
    
  default:
    return;
  }
  
  /* Switch mode */
  mode = tolower(code);
  updateOverlayString();
}
Example #3
0
void drag(int x, int y)
{
  VGfloat dx, dy;
  y = testHeight() - y;
  dx = x - clickX;
  dy = y - clickY;
  
  switch (mode) {
  case 'z':
    sx = startY + dy * 0.01;
    sy = sx;
    break;
  case 'p':
    tx = startX + dx;
    ty = startY + dy;
    break;
  }
  
  updateOverlayString();
}
Example #4
0
void drag(int x, int y)
{
  VGfloat dx, dy;
  y = testHeight() - y;
  dx = x - clickX;
  dy = y - clickY;
  
  switch(mode) {
  case 'c': {
    VGfloat dcx, dcy;
    dcx = startX + dx - cx;
    dcy = startY + dy - cy;
    cx = startX + dx;
    cy = startY + dy;
    fx += dcx;
    fy += dcy;
    createRadial();
    break; }
  case 'f':
    fx = startX + dx;
    fy = startY + dy;
    createRadial();
    break;
  case 'r':
    r = startY + dy;
    createRadial();
    break;
  case 'x':
    sx = startY + dy * 0.01f;
    break;
  case 'y':
    sy = startY + dy * 0.01f;
    break;
  }
  
  updateOverlayString();
  glutPostRedisplay();
}
Example #5
0
void drag(int x, int y)
{
  VGfloat dx, dy;
  y = testHeight() - y;
  dx = x - clickX;
  dy = y - clickY;
  
  switch(mode) {
  case 't': {
      tx = startX + dx;
      ty = startY + dy;
      break;}
  case 'x':
    sx = startY + dy * 0.01;
    break;
  case 'y':
    sy = startY + dy * 0.01;
    break;
  }
  
  updateOverlayString();
  glutPostRedisplay();
}
Example #6
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();
}