summaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorChunEon Park <hermet@hermet.pe.kr>2015-04-03 16:31:20 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-04-03 16:31:20 +0200
commit99166ff5f60fd61dec8191b5681f766563c9f67d (patch)
tree59b1536b66a581c50e2e76c5e7d5824f68aa3ff0 /src/examples
parent4f98cab04dc653904235eb2637d1bed9e14a23f3 (diff)
evas: add evas_vg_simple example.
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/evas/Makefile.am17
-rw-r--r--src/examples/evas/evas-vg-simple.c617
2 files changed, 629 insertions, 5 deletions
diff --git a/src/examples/evas/Makefile.am b/src/examples/evas/Makefile.am
index ad1893c..165d789 100644
--- a/src/examples/evas/Makefile.am
+++ b/src/examples/evas/Makefile.am
@@ -7,12 +7,12 @@ AM_CPPFLAGS = \
7-I$(top_builddir)/src/lib/efl/interfaces \ 7-I$(top_builddir)/src/lib/efl/interfaces \
8-I$(top_srcdir)/src/lib/eina \ 8-I$(top_srcdir)/src/lib/eina \
9-I$(top_srcdir)/src/lib/eo \ 9-I$(top_srcdir)/src/lib/eo \
10-I$(top_srcdir)/src/lib/evas \
11-I$(top_srcdir)/src/lib/ector \ 10-I$(top_srcdir)/src/lib/ector \
11-I$(top_srcdir)/src/lib/evas \
12-I$(top_builddir)/src/lib/eina \ 12-I$(top_builddir)/src/lib/eina \
13-I$(top_builddir)/src/lib/eo \ 13-I$(top_builddir)/src/lib/eo \
14-I$(top_builddir)/src/lib/evas \
15-I$(top_builddir)/src/lib/ector \ 14-I$(top_builddir)/src/lib/ector \
15-I$(top_builddir)/src/lib/evas \
16@EVAS_CFLAGS@ 16@EVAS_CFLAGS@
17 17
18EDCS = aspect.edc 18EDCS = aspect.edc
@@ -54,11 +54,11 @@ ECORE_EVAS_COMMON_LDADD = \
54$(top_builddir)/src/lib/efl/libefl.la \ 54$(top_builddir)/src/lib/efl/libefl.la \
55$(top_builddir)/src/lib/eina/libeina.la \ 55$(top_builddir)/src/lib/eina/libeina.la \
56$(top_builddir)/src/lib/eo/libeo.la \ 56$(top_builddir)/src/lib/eo/libeo.la \
57$(top_builddir)/src/lib/ector/libector.la \
58$(top_builddir)/src/lib/ecore/libecore.la \ 57$(top_builddir)/src/lib/ecore/libecore.la \
59$(top_builddir)/src/lib/ecore_file/libecore_file.la \ 58$(top_builddir)/src/lib/ecore_file/libecore_file.la \
60$(top_builddir)/src/lib/ecore_input/libecore_input.la \ 59$(top_builddir)/src/lib/ecore_input/libecore_input.la \
61$(top_builddir)/src/lib/ecore_evas/libecore_evas.la \ 60$(top_builddir)/src/lib/ecore_evas/libecore_evas.la \
61$(top_builddir)/src/lib/ector/libector.la \
62$(top_builddir)/src/lib/evas/libevas.la \ 62$(top_builddir)/src/lib/evas/libevas.la \
63@EVAS_LDFLAGS@ -lm 63@EVAS_LDFLAGS@ -lm
64 64
@@ -71,7 +71,9 @@ EDJE_COMMON_CPPFLAGS = \
71-I$(top_builddir)/src/lib/eo \ 71-I$(top_builddir)/src/lib/eo \
72-I$(top_srcdir)/src/lib/eet \ 72-I$(top_srcdir)/src/lib/eet \
73-I$(top_builddir)/src/lib/eet \ 73-I$(top_builddir)/src/lib/eet \
74-I$(top_srcdir)/src/lib/ector \
74-I$(top_srcdir)/src/lib/evas \ 75-I$(top_srcdir)/src/lib/evas \
76-I$(top_builddir)/src/lib/ector \
75-I$(top_builddir)/src/lib/evas \ 77-I$(top_builddir)/src/lib/evas \
76-I$(top_srcdir)/src/lib/ecore \ 78-I$(top_srcdir)/src/lib/ecore \
77-I$(top_builddir)/src/lib/ecore \ 79-I$(top_builddir)/src/lib/ecore \
@@ -96,7 +98,6 @@ EDJE_COMMON_LDADD = \
96$(top_builddir)/src/lib/eina/libeina.la \ 98$(top_builddir)/src/lib/eina/libeina.la \
97$(top_builddir)/src/lib/eo/libeo.la \ 99$(top_builddir)/src/lib/eo/libeo.la \
98$(top_builddir)/src/lib/eet/libeet.la \ 100$(top_builddir)/src/lib/eet/libeet.la \
99$(top_builddir)/src/lib/ector/libector.la \
100$(top_builddir)/src/lib/evas/libevas.la \ 101$(top_builddir)/src/lib/evas/libevas.la \
101$(top_builddir)/src/lib/ecore/libecore.la \ 102$(top_builddir)/src/lib/ecore/libecore.la \
102$(top_builddir)/src/lib/ecore_evas/libecore_evas.la \ 103$(top_builddir)/src/lib/ecore_evas/libecore_evas.la \
@@ -288,6 +289,11 @@ evas_gl_SOURCES = evas-gl.c
288evas_gl_LDADD = $(ECORE_EVAS_COMMON_LDADD) @EFL_PTHREAD_LIBS@ 289evas_gl_LDADD = $(ECORE_EVAS_COMMON_LDADD) @EFL_PTHREAD_LIBS@
289evas_gl_CPPFLAGS = $(ECORE_EVAS_COMMON_CPPFLAGS) 290evas_gl_CPPFLAGS = $(ECORE_EVAS_COMMON_CPPFLAGS)
290 291
292EXTRA_PROGRAMS += evas_vg_simple
293evas_vg_simple_SOURCES = evas-vg-simple.c
294evas_vg_simple_LDADD = $(ECORE_EVAS_COMMON_LDADD)
295evas_vg_simple_CPPFLAGS = $(ECORE_EVAS_COMMON_CPPFLAGS)
296
291.edc.edj: 297.edc.edj:
292 $(AM_V_EDJ)$(EDJE_CC) $(EDJE_CC_FLAGS) $< $(builddir)/$(@F) 298 $(AM_V_EDJ)$(EDJE_CC) $(EDJE_CC_FLAGS) $< $(builddir)/$(@F)
293 299
@@ -330,7 +336,8 @@ evas-smart-object.c \
330evas-stacking.c \ 336evas-stacking.c \
331evas-table.c \ 337evas-table.c \
332evas-multi-touch.c \ 338evas-multi-touch.c \
333evas-text.c 339evas-text.c \
340evas-vg-simple.c
334 341
335DATA_FILES = \ 342DATA_FILES = \
336resources/images/enlightenment.png \ 343resources/images/enlightenment.png \
diff --git a/src/examples/evas/evas-vg-simple.c b/src/examples/evas/evas-vg-simple.c
new file mode 100644
index 0000000..d90932f
--- /dev/null
+++ b/src/examples/evas/evas-vg-simple.c
@@ -0,0 +1,617 @@
1/**
2 * Simple Evas example illustrating a custom Evas box object
3 *
4 * You'll need at least one engine built for it (excluding the buffer
5 * one). See stdout/stderr for output.
6 *
7 * @verbatim
8 * gcc -o evas-box evas-box.c `pkg-config --libs --cflags evas ecore ecore-evas eina ector eo efl`
9 * @endverbatim
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#else
15#define PACKAGE_EXAMPLES_DIR "."
16#endif
17
18#define WIDTH 400
19#define HEIGHT 400
20
21#ifndef EFL_BETA_API_SUPPORT
22#define EFL_BETA_API_SUPPORT 1
23#endif
24
25#ifndef EFL_EO_API_SUPPORT
26#define EFL_EO_API_SUPPORT 1
27#endif
28
29#include <Eo.h>
30#include <Efl.h>
31#include <Evas.h>
32#include <Ecore.h>
33#include <Ecore_Evas.h>
34
35
36#include <math.h>
37#include <Eina.h>
38
39#define PATH_KAPPA 0.5522847498
40#define PI 3.1415926535
41
42typedef struct _Bezier
43{
44float x1, y1, x2, y2, x3, y3, x4, y4;
45}Bezier;
46
47typedef struct _Point
48{
49 int x;
50 int y;
51}Point;
52
53static
54Bezier bezierFromPoints(Point p1, Point p2,
55 Point p3, Point p4)
56{
57 Bezier b;
58 b.x1 = p1.x;
59 b.y1 = p1.y;
60 b.x2 = p2.x;
61 b.y2 = p2.y;
62 b.x3 = p3.x;
63 b.y3 = p3.y;
64 b.x4 = p4.x;
65 b.y4 = p4.y;
66 return b;
67}
68
69inline void
70parameterSplitLeft(Bezier *b, float t, Bezier *left)
71{
72 left->x1 = b->x1;
73 left->y1 = b->y1;
74
75 left->x2 = b->x1 + t * ( b->x2 - b->x1 );
76 left->y2 = b->y1 + t * ( b->y2 - b->y1 );
77
78 left->x3 = b->x2 + t * ( b->x3 - b->x2 ); // temporary holding spot
79 left->y3 = b->y2 + t * ( b->y3 - b->y2 ); // temporary holding spot
80
81 b->x3 = b->x3 + t * ( b->x4 - b->x3 );
82 b->y3 = b->y3 + t * ( b->y4 - b->y3 );
83
84 b->x2 = left->x3 + t * ( b->x3 - left->x3);
85 b->y2 = left->y3 + t * ( b->y3 - left->y3);
86
87 left->x3 = left->x2 + t * ( left->x3 - left->x2 );
88 left->y3 = left->y2 + t * ( left->y3 - left->y2 );
89
90 left->x4 = b->x1 = left->x3 + t * (b->x2 - left->x3);
91 left->y4 = b->y1 = left->y3 + t * (b->y2 - left->y3);
92}
93static
94Bezier bezierOnInterval(Bezier *b, float t0, float t1)
95{
96 if (t0 == 0 && t1 == 1)
97 return *b;
98
99 Bezier result;
100 parameterSplitLeft(b, t0, &result);
101 float trueT = (t1-t0)/(1-t0);
102 parameterSplitLeft(b, trueT, &result);
103
104 return result;
105}
106
107inline void
108_bezier_coefficients(float t, float *ap, float *bp, float *cp, float *dp)
109{
110 float a,b,c,d;
111 float m_t = 1. - t;
112 b = m_t * m_t;
113 c = t * t;
114 d = c * t;
115 a = b * m_t;
116 b *= 3. * t;
117 c *= 3. * m_t;
118 *ap = a;
119 *bp = b;
120 *cp = c;
121 *dp = d;
122}
123
124static
125float _t_for_arc_angle(float angle)
126{
127 if (angle < 0.00001)
128 return 0;
129
130 if (angle == 90.0)
131 return 1;
132
133 float radians = PI * angle / 180;
134 float cosAngle = cos(radians);
135 float sinAngle = sin(radians);
136
137 // initial guess
138 float tc = angle / 90;
139 // do some iterations of newton's method to approximate cosAngle
140 // finds the zero of the function b.pointAt(tc).x() - cosAngle
141 tc -= ((((2-3*PATH_KAPPA) * tc + 3*(PATH_KAPPA-1)) * tc) * tc + 1 - cosAngle) // value
142 / (((6-9*PATH_KAPPA) * tc + 6*(PATH_KAPPA-1)) * tc); // derivative
143 tc -= ((((2-3*PATH_KAPPA) * tc + 3*(PATH_KAPPA-1)) * tc) * tc + 1 - cosAngle) // value
144 / (((6-9*PATH_KAPPA) * tc + 6*(PATH_KAPPA-1)) * tc); // derivative
145
146 // initial guess
147 float ts = tc;
148 // do some iterations of newton's method to approximate sinAngle
149 // finds the zero of the function b.pointAt(tc).y() - sinAngle
150 ts -= ((((3*PATH_KAPPA-2) * ts - 6*PATH_KAPPA + 3) * ts + 3*PATH_KAPPA) * ts - sinAngle)
151 / (((9*PATH_KAPPA-6) * ts + 12*PATH_KAPPA - 6) * ts + 3*PATH_KAPPA);
152 ts -= ((((3*PATH_KAPPA-2) * ts - 6*PATH_KAPPA + 3) * ts + 3*PATH_KAPPA) * ts - sinAngle)
153 / (((9*PATH_KAPPA-6) * ts + 12*PATH_KAPPA - 6) * ts + 3*PATH_KAPPA);
154
155 // use the average of the t that best approximates cosAngle
156 // and the t that best approximates sinAngle
157 float t = 0.5 * (tc + ts);
158 return t;
159}
160
161static void
162_find_ellipse_coords(int x, int y, int w, int h, float angle, float length,
163 Point* startPoint, Point *endPoint)
164{
165 if (!w || !h ) {
166 if (startPoint)
167 startPoint->x = 0 , startPoint->y = 0;
168 if (endPoint)
169 endPoint->x = 0 , endPoint->y = 0;
170 return;
171 }
172
173 int w2 = w / 2;
174 int h2 = h / 2;
175
176 float angles[2] = { angle, angle + length };
177 Point *points[2] = { startPoint, endPoint };
178 int i =0;
179 for (i = 0; i < 2; ++i) {
180 if (!points[i])
181 continue;
182
183 float theta = angles[i] - 360 * floor(angles[i] / 360);
184 float t = theta / 90;
185 // truncate
186 int quadrant = (int)t;
187 t -= quadrant;
188
189 t = _t_for_arc_angle(90 * t);
190
191 // swap x and y?
192 if (quadrant & 1)
193 t = 1 - t;
194
195 float a, b, c, d;
196 _bezier_coefficients(t, &a, &b, &c, &d);
197 float px = a + b + c*PATH_KAPPA;
198 float py = d + c + b*PATH_KAPPA;
199
200 // left quadrants
201 if (quadrant == 1 || quadrant == 2)
202 px = -px;
203
204 // top quadrants
205 if (quadrant == 0 || quadrant == 1)
206 py = -py;
207 int cx = x+w/2;
208 int cy = y+h/2;
209 points[i]->x = cx + w2 * px;
210 points[i]->y = cy + h2 * py;
211 }
212}
213
214
215//// The return value is the starting point of the arc
216static
217Point _curves_for_arc(int x, int y, int w, int h,
218 float startAngle, float sweepLength,
219 Point *curves, int *point_count)
220{
221 *point_count = 0;
222 int w2 = w / 2;
223 int w2k = w2 * PATH_KAPPA;
224
225 int h2 = h / 2;
226 int h2k = h2 * PATH_KAPPA;
227
228 Point points[16] =
229 {
230 // start point
231 x + w, y + h2,
232
233 // 0 -> 270 degrees
234 x + w, y + h2 + h2k,
235 x + w2 + w2k, y + h,
236 x + w2, y + h,
237
238 // 270 -> 180 degrees
239 x + w2 - w2k, y + h,
240 x, y + h2 + h2k,
241 x, y + h2,
242
243 // 180 -> 90 degrees
244 x, y + h2 - h2k,
245 x + w2 - w2k, y,
246 x + w2, y,
247
248 // 90 -> 0 degrees
249 x + w2 + w2k, y,
250 x + w, y + h2 - h2k,
251 x + w, y + h2
252 };
253
254 if (sweepLength > 360) sweepLength = 360;
255 else if (sweepLength < -360) sweepLength = -360;
256
257 // Special case fast paths
258 if (startAngle == 0) {
259 if (sweepLength == 360) {
260 int i;
261 for (i = 11; i >= 0; --i)
262 curves[(*point_count)++] = points[i];
263 return points[12];
264 } else if (sweepLength == -360) {
265 int i ;
266 for (i = 1; i <= 12; ++i)
267 curves[(*point_count)++] = points[i];
268 return points[0];
269 }
270 }
271
272 int startSegment = (int)(floor(startAngle / 90));
273 int endSegment = (int)(floor((startAngle + sweepLength) / 90));
274
275 float startT = (startAngle - startSegment * 90) / 90;
276 float endT = (startAngle + sweepLength - endSegment * 90) / 90;
277
278 int delta = sweepLength > 0 ? 1 : -1;
279 if (delta < 0) {
280 startT = 1 - startT;
281 endT = 1 - endT;
282 }
283
284 // avoid empty start segment
285 if (startT == 1.0) {
286 startT = 0;
287 startSegment += delta;
288 }
289
290 // avoid empty end segment
291 if (endT == 0) {
292 endT = 1;
293 endSegment -= delta;
294 }
295
296 startT = _t_for_arc_angle(startT * 90);
297 endT = _t_for_arc_angle(endT * 90);
298
299 Eina_Bool splitAtStart = !(fabs(startT) <= 0.00001f);
300 Eina_Bool splitAtEnd = !(fabs(endT - 1.0) <= 0.00001f);
301
302 const int end = endSegment + delta;
303
304 // empty arc?
305 if (startSegment == end) {
306 const int quadrant = 3 - ((startSegment % 4) + 4) % 4;
307 const int j = 3 * quadrant;
308 return delta > 0 ? points[j + 3] : points[j];
309 }
310
311
312 Point startPoint, endPoint;
313 _find_ellipse_coords(x, y, w, h, startAngle, sweepLength, &startPoint, &endPoint);
314 int i;
315 for (i = startSegment; i != end; i += delta) {
316 const int quadrant = 3 - ((i % 4) + 4) % 4;
317 const int j = 3 * quadrant;
318
319 Bezier b;
320 if (delta > 0)
321 b = bezierFromPoints(points[j + 3], points[j + 2], points[j + 1], points[j]);
322 else
323 b = bezierFromPoints(points[j], points[j + 1], points[j + 2], points[j + 3]);
324
325 // empty arc?
326 if (startSegment == endSegment && (startT == endT))
327 return startPoint;
328
329 if (i == startSegment) {
330 if (i == endSegment && splitAtEnd)
331 b = bezierOnInterval(&b, startT, endT);
332 else if (splitAtStart)
333 b = bezierOnInterval(&b, startT, 1);
334 } else if (i == endSegment && splitAtEnd) {
335 b = bezierOnInterval(&b, 0, endT);
336 }
337
338 // push control points
339 curves[(*point_count)].x = b.x2;
340 curves[(*point_count)++].y = b.y2;
341 curves[(*point_count)].x = b.x3;
342 curves[(*point_count)++].y = b.y3;
343 curves[(*point_count)].x = b.x4;
344 curves[(*point_count)++].y = b.y4;
345 }
346
347 curves[*(point_count)-1] = endPoint;
348
349 return startPoint;
350}
351
352void _arcto(Efl_Graphics_Path_Command **path_cmd, double **points,int x, int y, int width, int height, int startAngle, int sweepLength)
353{
354 int point_count;
355
356 Point pts[15];
357 Point curve_start = _curves_for_arc(x,y,width,height, startAngle, sweepLength, pts, &point_count);
358 int cx = x + (width)/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;
365 for (i=0; i<point_count; i+=3) {
366 efl_gfx_path_append_cubic_to(path_cmd, points,
367 pts[i+2].x, pts[i+2].y,
368 pts[i].x, pts[i].y,
369 pts[i+1].x, pts[i+1].y);
370 }
371 efl_gfx_path_append_close(path_cmd, points);
372}
373
374void _rect_add(Efl_Graphics_Path_Command **path_cmd, double **points,int x, int y, int w, int h)
375{
376 efl_gfx_path_append_move_to(path_cmd, points, x, y);
377 efl_gfx_path_append_line_to(path_cmd, points, x + w, y);
378 efl_gfx_path_append_line_to(path_cmd, points, x + w, y +h);
379 efl_gfx_path_append_line_to(path_cmd, points, x, y +h);
380 efl_gfx_path_append_close(path_cmd, points);
381}
382
383
384struct example_data
385{
386 Ecore_Evas *ee;
387 Evas *evas;
388 Evas_Object *bg;
389 Evas_Object *vg;
390};
391
392static struct example_data d;
393
394static void
395_on_delete(Ecore_Evas *ee EINA_UNUSED)
396{
397 ecore_main_loop_quit();
398}
399
400static void /* adjust canvas' contents on resizes */
401_canvas_resize_cb(Ecore_Evas *ee)
402{
403 int w, h;
404
405 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
406 evas_object_resize(d.bg, w, h);
407 evas_object_resize(d.vg, w, h);
408}
409
410static void
411vector_set(int x, int y, int w, int h)
412{
413 Efl_Graphics_Path_Command *path_cmd = NULL;
414 double *points = NULL;
415 int vg_w = w, vg_h = h;
416
417 //Create VG Object
418
419 Evas_Object *tmp = evas_object_rectangle_add(d.evas);
420 evas_object_resize(tmp, vg_w, vg_h);
421 evas_object_color_set(tmp, 255, 128,50, 100);
422 evas_object_move(tmp, x,y);
423 evas_object_show(tmp);
424
425 d.vg = evas_object_vg_add(d.evas);
426 evas_object_resize(d.vg, vg_w, vg_h);
427 evas_object_move(d.vg, x,y);
428 evas_object_show(d.vg);
429 evas_object_clip_set(d.vg, tmp);
430
431 // Applying map on the evas_object_vg
432// Evas_Map *m = evas_map_new(4);
433// evas_map_smooth_set(m, EINA_TRUE);
434// evas_map_util_points_populate_from_object_full(m, d.vg, 0);
435// evas_map_util_rotate(m, 10, 0,0);
436// evas_object_map_enable_set(d.vg, EINA_TRUE);
437// evas_object_map_set(d.vg, m);
438
439 // apply some transformation
440 double radian = 30.0 * 2 * 3.141 / 360.0;
441 Eina_Matrix3 matrix;
442 eina_matrix3_rotate(&matrix, radian);
443
444 Evas_VG_Node *root = evas_object_vg_root_node_get(d.vg);
445 //eo_do(root, evas_vg_node_transformation_set(&matrix));
446
447 Evas_VG_Node *bg = eo_add(EVAS_VG_SHAPE_CLASS, root);
448 _rect_add(&path_cmd, &points, 0, 0 , vg_w, vg_h);
449 eo_do(bg,
450 evas_vg_node_origin_set(0, 0),
451 efl_gfx_shape_stroke_width_set(1.0),
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
461 Evas_VG_Node *shape = eo_add(EVAS_VG_SHAPE_CLASS, root);
462 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);
464
465 _arcto(&path_cmd, &points, 0, 0, 100, 100, 25, 330);
466
467Efl_Graphics_Gradient_Stop stops[3];
468 stops[0].r = 255;
469 stops[0].g = 0;
470 stops[0].b = 0;
471 stops[0].a = 255;
472 stops[0].offset = 0;
473 stops[1].r = 0;
474 stops[1].g = 255;
475 stops[1].b = 0;
476 stops[1].a = 255;
477 stops[1].offset = 0.5;
478 stops[2].r = 0;
479 stops[2].g = 0;
480 stops[2].b = 255;
481 stops[2].a = 255;
482 stops[2].offset = 1;
483
484 eo_do(rgradient,
485 evas_vg_node_origin_set(10,10),
486 efl_gfx_gradient_stop_set(stops, 3),
487 efl_gfx_gradient_spread_set(EFL_GFX_GRADIENT_SPREAD_REFLECT),
488 efl_gfx_gradient_stop_set(stops, 3),
489 efl_gfx_gradient_radial_center_set(30, 30),
490 efl_gfx_gradient_radial_radius_set(80)
491 );
492
493 eo_do(lgradient,
494 evas_vg_node_origin_set(10,10),
495 efl_gfx_gradient_stop_set(stops, 3),
496 efl_gfx_gradient_spread_set(EFL_GFX_GRADIENT_SPREAD_REFLECT),
497 efl_gfx_gradient_stop_set(stops, 3),
498 efl_gfx_gradient_linear_start_set(10,10),
499 efl_gfx_gradient_linear_end_set(50,50)
500 );
501
502 eo_do(shape,
503 evas_vg_node_origin_set(10, 10),
504 evas_vg_shape_fill_set(rgradient),
505 efl_gfx_shape_stroke_scale_set(2.0),
506 efl_gfx_shape_stroke_width_set(1.0),
507 efl_gfx_color_set(0, 0, 255, 255),
508 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
517 Evas_VG_Node *rect = eo_add(EVAS_VG_SHAPE_CLASS, root);
518 _rect_add(&path_cmd, &points, 0, 0 , 100, 100);
519 eo_do(rect,
520 evas_vg_node_origin_set(100, 100),
521 evas_vg_shape_fill_set(lgradient),
522 efl_gfx_shape_stroke_width_set(2.0),
523 efl_gfx_shape_stroke_join_set(EFL_GFX_JOIN_ROUND),
524 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
532
533 Evas_VG_Node *rect1 = eo_add(EVAS_VG_SHAPE_CLASS, root);
534 _rect_add(&path_cmd, &points, 0, 0 , 70, 70);
535 eo_do(rect1,
536 evas_vg_node_origin_set(50, 70),
537 efl_gfx_shape_stroke_scale_set(2),
538 efl_gfx_shape_stroke_width_set(8.0),
539 efl_gfx_shape_stroke_join_set(EFL_GFX_JOIN_ROUND),
540 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
551 Evas_VG_Node *circle = eo_add(EVAS_VG_SHAPE_CLASS, root);
552 _arcto(&path_cmd, &points, 0, 0, 250, 100, 30, 300);
553 eo_do(circle,
554 evas_vg_shape_fill_set(lgradient),
555 //evas_vg_node_transformation_set(&matrix),
556 evas_vg_node_origin_set(50,50),
557 efl_gfx_color_set(255, 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
565 // Foreground
566 Evas_VG_Node *fg = eo_add(EVAS_VG_SHAPE_CLASS, root);
567 _rect_add(&path_cmd, &points, 0, 0 , vg_w, vg_h);
568 eo_do(fg,
569 evas_vg_node_origin_set(0, 0),
570 efl_gfx_shape_stroke_width_set(5.0),
571 efl_gfx_shape_stroke_join_set(EFL_GFX_JOIN_ROUND),
572 efl_gfx_shape_stroke_color_set(255, 255, 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}
581
582int
583main(void)
584{
585 if (!ecore_evas_init())
586 return EXIT_FAILURE;
587
588 /* this will give you a window with an Evas canvas under the first
589 * engine available */
590 d.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
591 if (!d.ee)
592 goto error;
593
594 ecore_evas_callback_delete_request_set(d.ee, _on_delete);
595 ecore_evas_callback_resize_set(d.ee, _canvas_resize_cb);
596 ecore_evas_show(d.ee);
597
598 d.evas = ecore_evas_get(d.ee);
599
600 d.bg = evas_object_rectangle_add(d.evas);
601 evas_object_color_set(d.bg, 70, 70, 70, 255); /* white bg */
602 evas_object_show(d.bg);
603
604 _canvas_resize_cb(d.ee);
605
606 vector_set(50, 50, 300 ,300);
607 //vector_set(30, 90, 300 ,300);
608
609 ecore_main_loop_begin();
610 ecore_evas_shutdown();
611 return 0;
612
613error:
614 ecore_evas_shutdown();
615 return -1;
616}
617