Exemplo n.º 1
0
void loadTiger()
{
  int i;
  VGPath temp;
  
  temp = testCreatePath();  
  tigerPaths = (VGPath*)malloc(pathCount * sizeof(VGPath));
  vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
  vgTranslate(-100,100);
  vgScale(1,-1);
  
  for (i=0; i<pathCount; ++i) {
    
    vgClearPath(temp, VG_PATH_CAPABILITY_ALL);
    vgAppendPathData(temp, commandCounts[i],
                     commandArrays[i], dataArrays[i]);
    
    tigerPaths[i] = testCreatePath();
    vgTransformPath(tigerPaths[i], temp);
  }
  
  tigerStroke = vgCreatePaint();
  tigerFill = vgCreatePaint();
  vgSetPaint(tigerStroke, VG_STROKE_PATH);
  vgSetPaint(tigerFill, VG_FILL_PATH);
  vgLoadIdentity();
  vgDestroyPath(temp);
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
0
int main(int argc, char **argv)
{
  testInit(argc, argv, 400,400, "ShivaVG: Linear 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);
  testCallback(TEST_CALLBACK_RESHAPE, (CallbackFunc)reshape);
  
  p = testCreatePath();
  org = testCreatePath();
  
  blackFill = vgCreatePaint();
  vgSetParameterfv(blackFill, VG_PAINT_COLOR, 4, black);
  
  backImage = createImageFromJpeg(IMAGE_DIR"test_img_violin.jpg");
  patternImage = createImageFromJpeg(IMAGE_DIR"test_img_shivavg.jpg");
  patternFill = vgCreatePaint();
  
  createSquare(p);
  createOrigin(org);
  createPattern();
  
  testOverlayString("Press H for a list of commands");
  testOverlayColor(1,1,1,1);
  testRun();
  
  return EXIT_SUCCESS;
}
Exemplo n.º 4
0
void createPrimitives()
{
  VGfloat points[] = {-30,-30, 30,-30, 0,30};
  
  line = testCreatePath();
  vguLine(line, -30,-30,30,30);
  primitives[0] = line;
  
  polyOpen = testCreatePath();
  vguPolygon(polyOpen, points, 3, VG_FALSE);
  primitives[1] = polyOpen;
  
  polyClosed = testCreatePath();
  vguPolygon(polyClosed, points, 3, VG_TRUE);
  primitives[2] = polyClosed;
  
  rect = testCreatePath();
  vguRect(rect, -50,-30, 100,60);
  primitives[3] = rect;
  
  rectRound = testCreatePath();
  vguRoundRect(rectRound, -50,-30, 100,60, 30,30);
  primitives[4] = rectRound;
  
  ellipse = testCreatePath();
  vguEllipse(ellipse, 0,0, 100, 100);
  primitives[5] = ellipse;
  
  arcOpen = testCreatePath();
  vguArc(arcOpen, 0,0, 100,60, 0, 270, VGU_ARC_OPEN);
  primitives[6] = arcOpen;
  
  arcChord = testCreatePath();
  vguArc(arcChord, 0,0, 100,60, 0, 270, VGU_ARC_CHORD);
  primitives[7] = arcChord;
  
  
  arcPie = testCreatePath();
  vguArc(arcPie, 0,0, 100,60, 0, 270, VGU_ARC_PIE);
  primitives[8] = arcPie;
  
}
Exemplo n.º 5
0
void createApple(VGPath p)
{
  VGPath temp;

  VGubyte segs[] = {
    VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS,
    VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS,
    VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CLOSE_PATH,
    VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CLOSE_PATH };

  VGfloat data[] = {
    1.53125,-44.681982, -3.994719,-44.681982, -8.0085183,-50.562501,
    -26.5625,-50.562501, -42.918439,-50.562501, -56.46875,-34.239393,
    -56.46875,-12.187501, -56.46875,26.520416, -34.65822,61.731799,
    -16.84375,61.812499, -7.1741233,61.812499, -2.9337937,55.656199,
    4.15625,55.656199, 11.746294,55.656199, 17.981627,62.281199,
    25.4375,62.281199, 33.88615,62.281199, 50.53251,44.282999,
    58.75,15.718799, 47.751307,9.086518, 40.999985,-0.228074,
    41,-13.046574, 41,-27.849147, 46.64686,-34.763001,
    52.4375,-39.937501, 46.111827,-47.219094, 39.0413,-50.503784,
    29.09375,-50.446384, 11.146487,-50.342824, 8.6341912,-44.681982,
    1.53125,-44.681982,

    0.23972344,-52.075169, -2.8344902,-69.754133, 5.9303785,-81.915323,
    24.152707,-86.881406, 23.71828,-70.367255, 15.114064,-58.365865,
    0.23972344,-52.075169 };

  temp = testCreatePath();
  vgAppendPathData(temp, sizeof(segs), segs, data);

  vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
  vgLoadIdentity();
  vgScale(1,-1);
  vgTransformPath(p, temp);
  vgDestroyPath(temp);
}
Exemplo n.º 6
0
void createPear(VGPath p)
{
  VGPath temp;

  VGubyte segs[] = {
    VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS,
    VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS,
    VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CLOSE_PATH,
    VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_CUBIC_TO_ABS, VG_CLOSE_PATH };

  VGfloat data[] = {
    0.0625,-90.625001, -29.44062,-89.191161, -23.07159,-32.309301,
    -30.5625,-14.062501, -38.29681,4.7771994, -56.8077,20.767199,
    -56.46875,42.812499, -56.1298,64.502999, -40.15822,79.731799,
    -22.34375,79.812499, -4.17446,79.893199, -1.93369,71.113999,
    4.15625,71.156199, 10.49619,71.198499, 13.70293,80.336799,
    30.4375,80.281199, 42.49257,80.241199, 53.53251,70.782999,
    58.75,58.218799, 47.0442,54.768499, 38.5,43.943499,
    38.5,31.124999, 38.50001,22.754099, 42.14686,15.236999,
    47.9375,10.062499, 42.2834,1.5737994, 36.5413,-6.6199006,
    34.09375,-14.062501, 28.48694,-31.111801, 32.99356,-90.265511,
    1.5,-90.625001,

    5.1056438,-97.8762, -12.766585,-99.48239, -22.244878,-111.09615,
    -22.325466,-129.98288, -6.486451,-125.28908, 2.8790668,-113.87186,
    5.1056438,-97.8762 };

  temp = testCreatePath();
  vgAppendPathData(temp, sizeof(segs), segs, data);

  vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
  vgLoadIdentity();
  vgScale(1,-1);
  vgTransformPath(p, temp);
  vgDestroyPath(temp);
}
Exemplo n.º 7
0
}

#ifdef __cplusplus
}
#endif /* __cplusplus */

/* ------------- JNI ------------- */

JNIEXPORT jint JNICALL
Java_com_example_applevg_DemoRenderer_nativeStart(JNIEnv* env, jobject this, jint width, jint height)
{
	int argc;
	char **argv;
	testInit(argc, argv, width, height, "ShivaVG: Path Interpolation Test");

	iApple = testCreatePath();
	createApple(iApple);
	iPear = testCreatePath();
	createPear(iPear);
	iMorph = testCreatePath();

	fill = vgCreatePaint();
	vgSetParameterfv(fill, VG_PAINT_COLOR, 4, white);
	vgSetPaint(fill, VG_FILL_PATH);

	testOverlayColor(1,1,1,1);

	return 0;
}

JNIEXPORT void JNICALL