summaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-04-03 16:31:23 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-04-03 16:31:23 +0200
commita104344d7e641372db1856183b23e7e638c435b9 (patch)
tree486ced147c4aeec38d4dc63717219ed06712c363 /src/examples
parent99166ff5f60fd61dec8191b5681f766563c9f67d (diff)
evas: fix Evas_VG examples to match new API.
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/evas/evas-vg-simple.c222
1 files changed, 89 insertions, 133 deletions
diff --git a/src/examples/evas/evas-vg-simple.c b/src/examples/evas/evas-vg-simple.c
index d90932f..698db11 100644
--- a/src/examples/evas/evas-vg-simple.c
+++ b/src/examples/evas/evas-vg-simple.c
@@ -227,28 +227,28 @@ Point _curves_for_arc(int x, int y, int w, int h,
227 227
228 Point points[16] = 228 Point points[16] =
229 { 229 {
230 // start point 230 // start point
231 x + w, y + h2, 231 { x + w, y + h2 },
232 232
233 // 0 -> 270 degrees 233 // 0 -> 270 degrees
234 x + w, y + h2 + h2k, 234 { x + w, y + h2 + h2k },
235 x + w2 + w2k, y + h, 235 { x + w2 + w2k, y + h },
236 x + w2, y + h, 236 { x + w2, y + h },
237 237
238 // 270 -> 180 degrees 238 // 270 -> 180 degrees
239 x + w2 - w2k, y + h, 239 { x + w2 - w2k, y + h },
240 x, y + h2 + h2k, 240 { x, y + h2 + h2k },
241 x, y + h2, 241 { x, y + h2 },
242 242
243 // 180 -> 90 degrees 243 // 180 -> 90 degrees
244 x, y + h2 - h2k, 244 { x, y + h2 - h2k },
245 x + w2 - w2k, y, 245 { x + w2 - w2k, y },
246 x + w2, y, 246 { x + w2, y },
247 247
248 // 90 -> 0 degrees 248 // 90 -> 0 degrees
249 x + w2 + w2k, y, 249 { x + w2 + w2k, y },
250 x + w, y + h2 - h2k, 250 { x + w, y + h2 - h2k },
251 x + w, y + h2 251 { x + w, y + h2 }
252 }; 252 };
253 253
254 if (sweepLength > 360) sweepLength = 360; 254 if (sweepLength > 360) sweepLength = 360;
@@ -349,35 +349,37 @@ Point _curves_for_arc(int x, int y, int w, int h,
349 return startPoint; 349 return startPoint;
350} 350}
351 351
352void _arcto(Efl_Graphics_Path_Command **path_cmd, double **points,int x, int y, int width, int height, int startAngle, int sweepLength) 352void _arcto(Evas_VG_Node *obj, int x, int y, int width, int height, int startAngle, int sweepLength)
353{ 353{
354 int point_count; 354 int point_count;
355 355
356 Point pts[15]; 356 Point pts[15];
357 Point curve_start = _curves_for_arc(x,y,width,height, startAngle, sweepLength, pts, &point_count); 357 Point curve_start = _curves_for_arc(x, y, width, height, startAngle, sweepLength, pts, &point_count);
358 int cx = x + (width)/2; 358 int cx = x + (width)/2;
359 int cy = y + (height)/2; 359 int cy = y + (height)/2;
360
361 efl_gfx_path_append_move_to(path_cmd, points, cx, cy);
362
363 efl_gfx_path_append_line_to(path_cmd, points, curve_start.x, curve_start.y);
364 int i; 360 int i;
365 for (i=0; i<point_count; i+=3) { 361
366 efl_gfx_path_append_cubic_to(path_cmd, points, 362 eo_do(obj,
367 pts[i+2].x, pts[i+2].y, 363 efl_gfx_shape_append_move_to(cx, cy);
368 pts[i].x, pts[i].y, 364
369 pts[i+1].x, pts[i+1].y); 365 efl_gfx_shape_append_line_to(curve_start.x, curve_start.y);
370 } 366 for (i = 0; i < point_count; i += 3)
371 efl_gfx_path_append_close(path_cmd, points); 367 {
368 efl_gfx_shape_append_cubic_to(pts[i+2].x, pts[i+2].y,
369 pts[i].x, pts[i].y,
370 pts[i+1].x, pts[i+1].y);
371 }
372 efl_gfx_shape_append_close());
372} 373}
373 374
374void _rect_add(Efl_Graphics_Path_Command **path_cmd, double **points,int x, int y, int w, int h) 375void _rect_add(Evas_VG_Node *obj, int x, int y, int w, int h)
375{ 376{
376 efl_gfx_path_append_move_to(path_cmd, points, x, y); 377 eo_do(obj,
377 efl_gfx_path_append_line_to(path_cmd, points, x + w, y); 378 efl_gfx_shape_append_move_to(x, y);
378 efl_gfx_path_append_line_to(path_cmd, points, x + w, y +h); 379 efl_gfx_shape_append_line_to(x + w, y);
379 efl_gfx_path_append_line_to(path_cmd, points, x, y +h); 380 efl_gfx_shape_append_line_to(x + w, y +h);
380 efl_gfx_path_append_close(path_cmd, points); 381 efl_gfx_shape_append_line_to(x, y +h);
382 efl_gfx_shape_append_close());
381} 383}
382 384
383 385
@@ -410,15 +412,13 @@ _canvas_resize_cb(Ecore_Evas *ee)
410static void 412static void
411vector_set(int x, int y, int w, int h) 413vector_set(int x, int y, int w, int h)
412{ 414{
413 Efl_Graphics_Path_Command *path_cmd = NULL;
414 double *points = NULL;
415 int vg_w = w, vg_h = h; 415 int vg_w = w, vg_h = h;
416 416
417 //Create VG Object 417 //Create VG Object
418 418
419 Evas_Object *tmp = evas_object_rectangle_add(d.evas); 419 Evas_Object *tmp = evas_object_rectangle_add(d.evas);
420 evas_object_resize(tmp, vg_w, vg_h); 420 evas_object_resize(tmp, vg_w, vg_h);
421 evas_object_color_set(tmp, 255, 128,50, 100); 421 evas_object_color_set(tmp, 100, 100, 50, 100);
422 evas_object_move(tmp, x,y); 422 evas_object_move(tmp, x,y);
423 evas_object_show(tmp); 423 evas_object_show(tmp);
424 424
@@ -445,59 +445,50 @@ vector_set(int x, int y, int w, int h)
445 //eo_do(root, evas_vg_node_transformation_set(&matrix)); 445 //eo_do(root, evas_vg_node_transformation_set(&matrix));
446 446
447 Evas_VG_Node *bg = eo_add(EVAS_VG_SHAPE_CLASS, root); 447 Evas_VG_Node *bg = eo_add(EVAS_VG_SHAPE_CLASS, root);
448 _rect_add(&path_cmd, &points, 0, 0 , vg_w, vg_h); 448 _rect_add(bg, 0, 0 , vg_w, vg_h);
449 eo_do(bg, 449 eo_do(bg,
450 evas_vg_node_origin_set(0, 0), 450 evas_vg_node_origin_set(0, 0),
451 efl_gfx_shape_stroke_width_set(1.0), 451 efl_gfx_shape_stroke_width_set(1.0),
452 efl_gfx_color_set(128, 128, 128, 80), 452 efl_gfx_color_set(128, 128, 128, 80));
453 efl_gfx_shape_path_set(path_cmd, points));
454
455
456 free(path_cmd);
457 free(points);
458 path_cmd = NULL;
459 points = NULL;
460 453
461 Evas_VG_Node *shape = eo_add(EVAS_VG_SHAPE_CLASS, root); 454 Evas_VG_Node *shape = eo_add(EVAS_VG_SHAPE_CLASS, root);
462 Evas_VG_Node *rgradient = eo_add(EVAS_VG_GRADIENT_RADIAL_CLASS, root); 455 Evas_VG_Node *rgradient = eo_add(EVAS_VG_GRADIENT_RADIAL_CLASS, root);
463 Evas_VG_Node *lgradient = eo_add(EVAS_VG_GRADIENT_LINEAR_CLASS, root); 456 Evas_VG_Node *lgradient = eo_add(EVAS_VG_GRADIENT_LINEAR_CLASS, root);
464 457
465 _arcto(&path_cmd, &points, 0, 0, 100, 100, 25, 330); 458 _arcto(shape, 0, 0, 100, 100, 25, 330);
466 459
467Efl_Graphics_Gradient_Stop stops[3]; 460 Efl_Gfx_Gradient_Stop stops[3];
468 stops[0].r = 255; 461 stops[0].r = 255;
469 stops[0].g = 0; 462 stops[0].g = 0;
470 stops[0].b = 0; 463 stops[0].b = 0;
471 stops[0].a = 255; 464 stops[0].a = 255;
472 stops[0].offset = 0; 465 stops[0].offset = 0;
473 stops[1].r = 0; 466 stops[1].r = 0;
474 stops[1].g = 255; 467 stops[1].g = 255;
475 stops[1].b = 0; 468 stops[1].b = 0;
476 stops[1].a = 255; 469 stops[1].a = 255;
477 stops[1].offset = 0.5; 470 stops[1].offset = 0.5;
478 stops[2].r = 0; 471 stops[2].r = 0;
479 stops[2].g = 0; 472 stops[2].g = 0;
480 stops[2].b = 255; 473 stops[2].b = 255;
481 stops[2].a = 255; 474 stops[2].a = 255;
482 stops[2].offset = 1; 475 stops[2].offset = 1;
483 476
484 eo_do(rgradient, 477 eo_do(rgradient,
485 evas_vg_node_origin_set(10,10), 478 evas_vg_node_origin_set(10,10),
486 efl_gfx_gradient_stop_set(stops, 3), 479 efl_gfx_gradient_stop_set(stops, 3),
487 efl_gfx_gradient_spread_set(EFL_GFX_GRADIENT_SPREAD_REFLECT), 480 efl_gfx_gradient_spread_set(EFL_GFX_GRADIENT_SPREAD_REFLECT),
488 efl_gfx_gradient_stop_set(stops, 3), 481 efl_gfx_gradient_stop_set(stops, 3),
489 efl_gfx_gradient_radial_center_set(30, 30), 482 efl_gfx_gradient_radial_center_set(30, 30),
490 efl_gfx_gradient_radial_radius_set(80) 483 efl_gfx_gradient_radial_radius_set(80));
491 ); 484
492 485 eo_do(lgradient,
493 eo_do(lgradient, 486 evas_vg_node_origin_set(10,10),
494 evas_vg_node_origin_set(10,10), 487 efl_gfx_gradient_stop_set(stops, 3),
495 efl_gfx_gradient_stop_set(stops, 3), 488 efl_gfx_gradient_spread_set(EFL_GFX_GRADIENT_SPREAD_REFLECT),
496 efl_gfx_gradient_spread_set(EFL_GFX_GRADIENT_SPREAD_REFLECT), 489 efl_gfx_gradient_stop_set(stops, 3),
497 efl_gfx_gradient_stop_set(stops, 3), 490 efl_gfx_gradient_linear_start_set(10,10),
498 efl_gfx_gradient_linear_start_set(10,10), 491 efl_gfx_gradient_linear_end_set(50,50));
499 efl_gfx_gradient_linear_end_set(50,50)
500 );
501 492
502 eo_do(shape, 493 eo_do(shape,
503 evas_vg_node_origin_set(10, 10), 494 evas_vg_node_origin_set(10, 10),
@@ -505,78 +496,43 @@ Efl_Graphics_Gradient_Stop stops[3];
505 efl_gfx_shape_stroke_scale_set(2.0), 496 efl_gfx_shape_stroke_scale_set(2.0),
506 efl_gfx_shape_stroke_width_set(1.0), 497 efl_gfx_shape_stroke_width_set(1.0),
507 efl_gfx_color_set(0, 0, 255, 255), 498 efl_gfx_color_set(0, 0, 255, 255),
508 efl_gfx_shape_stroke_color_set(0, 0, 255, 128), 499 efl_gfx_shape_stroke_color_set(0, 0, 255, 128));
509 efl_gfx_shape_path_set(path_cmd, points));
510
511
512 free(path_cmd);
513 free(points);
514 path_cmd = NULL;
515 points = NULL;
516 500
517 Evas_VG_Node *rect = eo_add(EVAS_VG_SHAPE_CLASS, root); 501 Evas_VG_Node *rect = eo_add(EVAS_VG_SHAPE_CLASS, root);
518 _rect_add(&path_cmd, &points, 0, 0 , 100, 100); 502 _rect_add(rect, 0, 0, 100, 100);
519 eo_do(rect, 503 eo_do(rect,
520 evas_vg_node_origin_set(100, 100), 504 evas_vg_node_origin_set(100, 100),
521 evas_vg_shape_fill_set(lgradient), 505 evas_vg_shape_fill_set(lgradient),
522 efl_gfx_shape_stroke_width_set(2.0), 506 efl_gfx_shape_stroke_width_set(2.0),
523 efl_gfx_shape_stroke_join_set(EFL_GFX_JOIN_ROUND), 507 efl_gfx_shape_stroke_join_set(EFL_GFX_JOIN_ROUND),
524 efl_gfx_shape_stroke_color_set(255, 255, 255, 255), 508 efl_gfx_shape_stroke_color_set(255, 255, 255, 255));
525 efl_gfx_shape_path_set(path_cmd, points));
526
527 free(path_cmd);
528 free(points);
529 path_cmd = NULL;
530 points = NULL;
531 509
532 510
533 Evas_VG_Node *rect1 = eo_add(EVAS_VG_SHAPE_CLASS, root); 511 Evas_VG_Node *rect1 = eo_add(EVAS_VG_SHAPE_CLASS, root);
534 _rect_add(&path_cmd, &points, 0, 0 , 70, 70); 512 _rect_add(rect1, 0, 0, 70, 70);
535 eo_do(rect1, 513 eo_do(rect1,
536 evas_vg_node_origin_set(50, 70), 514 evas_vg_node_origin_set(50, 70),
537 efl_gfx_shape_stroke_scale_set(2), 515 efl_gfx_shape_stroke_scale_set(2),
538 efl_gfx_shape_stroke_width_set(8.0), 516 efl_gfx_shape_stroke_width_set(8.0),
539 efl_gfx_shape_stroke_join_set(EFL_GFX_JOIN_ROUND), 517 efl_gfx_shape_stroke_join_set(EFL_GFX_JOIN_ROUND),
540 efl_gfx_shape_stroke_color_set(0, 100, 80, 100), 518 efl_gfx_shape_stroke_color_set(0, 100, 80, 100));
541 efl_gfx_shape_path_set(path_cmd, points));
542
543 free(path_cmd);
544 free(points);
545 path_cmd = NULL;
546 points = NULL;
547
548
549
550 519
551 Evas_VG_Node *circle = eo_add(EVAS_VG_SHAPE_CLASS, root); 520 Evas_VG_Node *circle = eo_add(EVAS_VG_SHAPE_CLASS, root);
552 _arcto(&path_cmd, &points, 0, 0, 250, 100, 30, 300); 521 _arcto(circle, 0, 0, 250, 100, 30, 300);
553 eo_do(circle, 522 eo_do(circle,
554 evas_vg_shape_fill_set(lgradient), 523 evas_vg_shape_fill_set(lgradient),
555 //evas_vg_node_transformation_set(&matrix), 524 //evas_vg_node_transformation_set(&matrix),
556 evas_vg_node_origin_set(50,50), 525 evas_vg_node_origin_set(50,50),
557 efl_gfx_color_set(255, 0, 0, 50), 526 efl_gfx_color_set(50, 0, 0, 50));
558 efl_gfx_shape_path_set(path_cmd, points));
559
560 free(path_cmd);
561 free(points);
562 path_cmd = NULL;
563 points = NULL;
564 527
565 // Foreground 528 // Foreground
566 Evas_VG_Node *fg = eo_add(EVAS_VG_SHAPE_CLASS, root); 529 Evas_VG_Node *fg = eo_add(EVAS_VG_SHAPE_CLASS, root);
567 _rect_add(&path_cmd, &points, 0, 0 , vg_w, vg_h); 530 _rect_add(fg, 0, 0, vg_w, vg_h);
568 eo_do(fg, 531 eo_do(fg,
569 evas_vg_node_origin_set(0, 0), 532 evas_vg_node_origin_set(0, 0),
570 efl_gfx_shape_stroke_width_set(5.0), 533 efl_gfx_shape_stroke_width_set(5.0),
571 efl_gfx_shape_stroke_join_set(EFL_GFX_JOIN_ROUND), 534 efl_gfx_shape_stroke_join_set(EFL_GFX_JOIN_ROUND),
572 efl_gfx_shape_stroke_color_set(255, 255, 0, 70), 535 efl_gfx_shape_stroke_color_set(70, 70, 0, 70));
573 efl_gfx_shape_path_set(path_cmd, points));
574
575 free(path_cmd);
576 free(points);
577 path_cmd = NULL;
578 points = NULL;
579
580} 536}
581 537
582int 538int