Mercurial > MadButterfly
annotate src/shape_path.c @ 616:7d70a811829b openvg
mbe_fill_preserve() and mbe_reset_scissoring() for OpenVG
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 08 Jul 2010 11:37:33 +0800 |
parents | e95598916dfb |
children | 594827d0f3e5 |
rev | line source |
---|---|
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1 #include <stdio.h> |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
2 #include <stdlib.h> |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 #include <ctype.h> |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
4 #include <string.h> |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
270
diff
changeset
|
5 #include "mb_graph_engine.h" |
186
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
185
diff
changeset
|
6 #include "mb_types.h" |
530bb7728546
Move header files to $(top_srcdir)/include/ and prefixed with 'mb_'.
Thinker K.F. Li <thinker@branda.to>
parents:
185
diff
changeset
|
7 #include "mb_redraw_man.h" |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
8 |
8 | 9 /*! \brief Implement respective objects for SVG path tag. |
10 * | |
11 * In user_data or dev_data, 0x00 bytes are padding after commands. | |
12 * No commands other than 0x00 can resident after 0x00 itself. | |
13 * It means command processing code can skip commands after a 0x00. | |
12 | 14 * |
15 * Shapes should check if shape_t::geo is assigned. Once transformation | |
16 * matrics are changed, shape objects should update shape_t::geo if | |
17 * it is assigned. | |
8 | 18 */ |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
19 typedef struct _sh_path { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
20 shape_t shape; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
21 int cmd_len; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
22 int pnt_len; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
23 int float_arg_len; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
24 char *user_data; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
25 char *dev_data; /* device space data */ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
26 } sh_path_t; |
10 | 27 #define RESERVED_AIXS sizeof(co_aix[2]) |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
28 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
29 #define ASSERT(x) |
11
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
30 #define SKIP_SPACE(x) while(*(x) && (isspace(*(x)) || *(x) == ',')) { (x)++; } |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
31 #define SKIP_NUM(x) \ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
32 while(*(x) && \ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
33 (isdigit(*(x)) || \ |
112
abb5511c23f7
Accept exponent of float point
Thinker K.F. Li <thinker@branda.to>
parents:
101
diff
changeset
|
34 *(x) == 'e' || \ |
abb5511c23f7
Accept exponent of float point
Thinker K.F. Li <thinker@branda.to>
parents:
101
diff
changeset
|
35 *(x) == 'E' || \ |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
36 *(x) == '-' || \ |
11
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
37 *(x) == '+' || \ |
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
38 *(x) == '.')) { \ |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
39 (x)++; \ |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
40 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
41 #define OK 0 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
42 #define ERR -1 |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
43 #define PI 3.1415926535897931 |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
44 |
235 | 45 #ifdef UNITTEST |
46 #undef rdman_shape_man | |
47 #define rdman_shape_man(x, y) | |
48 #endif | |
49 | |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
50 /* ============================================================ |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
51 * Implement arc in path. |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
52 */ |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
53 #include <math.h> |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
54 /*! \brief Calculate center of the ellipse of an arc. |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
55 * |
269
c96f38ad4bb6
Fix mis-behavior of translate_path_data() on arc.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
56 * Origin of our coordination is left-top corner, and y-axis are grown |
c96f38ad4bb6
Fix mis-behavior of translate_path_data() on arc.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
57 * to down-side. |
c96f38ad4bb6
Fix mis-behavior of translate_path_data() on arc.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
58 * |
c96f38ad4bb6
Fix mis-behavior of translate_path_data() on arc.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
59 * Space of the arc is transformed to space that correspondent |
c96f38ad4bb6
Fix mis-behavior of translate_path_data() on arc.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
60 * ellipse containing the arc is mapped into an unit circle. |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
61 * - ux0 = x0 / rx |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
62 * - uy0 = y0 / ry |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
63 * - ux = x / rx |
269
c96f38ad4bb6
Fix mis-behavior of translate_path_data() on arc.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
64 * - uy = y / ry |
c96f38ad4bb6
Fix mis-behavior of translate_path_data() on arc.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
65 * ux0, uy0, ux, uy are got by transforming (x0, y0) and (x, y) into points |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
66 * on the unit circle. The center of unit circle are (ucx, ucy): |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
67 * - umx = (ux0 + ux) / 2 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
68 * - umy = (uy0 + uy) / 2 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
69 * - udcx = ucx - umx |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
70 * - udcy = ucy - umy |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
71 * - udx = ux - umx |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
72 * - udy = uy - umy |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
73 * |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
74 * - udx * udcx + udy * udcy = 0 |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
75 * |
269
c96f38ad4bb6
Fix mis-behavior of translate_path_data() on arc.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
76 * - udl2 = udx ** 2 + udy ** 2 |
c96f38ad4bb6
Fix mis-behavior of translate_path_data() on arc.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
77 * |
c96f38ad4bb6
Fix mis-behavior of translate_path_data() on arc.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
78 * For drawing small arc in clockwise |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
79 * - udx * udcy - udy * udcx = sqrt((1 - udl2) * udl2) |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
80 * |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
81 * - udcy = -udcx * udx / udy |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
82 * - -udcx * (udx ** 2) / udy - udy * udcx = sqrt((1 - udl2) * udl2) |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
83 * - -udcx * ((udx ** 2) / udy + udy) = sqrt((1 - udl2) * udl2) |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
84 * - udcx = -sqrt((1 - udl2) * udl2) / ((udx ** 2) / udy + udy) |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
85 * or |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
86 * - udcx = -udcy * udy / udx |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
87 * - udx * udcy + udcy * (udy ** 2) / udx = sqrt((1 - udl2) * udl2) |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
88 * - udcy * (udx + (udy ** 2) / udx) = sqrt((1 - udl2) * udl2) |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
89 * - udcy = sqrt((1 - udl2) * udl2) / (udx + (udy ** 2) / udx) |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
90 * |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
91 * - cx = rx * ucx |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
92 * - cx = rx * (udcx + umx) |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
93 * - cy = ry * ucy |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
94 * - cy = ry * (udcy + umy) |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
95 */ |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
96 static int _calc_center(co_aix x0, co_aix y0, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
97 co_aix x, co_aix y, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
98 co_aix rx, co_aix ry, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
99 co_aix x_rotate, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
100 int large, int sweep, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
101 co_aix *cx, co_aix *cy) { |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
102 co_aix nrx, nry, nrx0, nry0; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
103 co_aix udx, udy, udx2, udy2; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
104 co_aix umx, umy; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
105 co_aix udcx, udcy; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
106 co_aix nrcx, nrcy; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
107 co_aix udl2; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
108 float _sin = sinf(x_rotate); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
109 float _cos = cosf(x_rotate); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
110 int reflect; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
111 |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
112 /* Compute center of the ellipse */ |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
113 nrx = x * _cos + y * _sin; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
114 nry = x * -_sin + y * _cos; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
115 nrx0 = x0 * _cos + y0 * _sin; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
116 nry0 = x0 * -_sin + y0 * _cos; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
117 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
118 udx = (nrx - nrx0) / 2 / rx; /* ux - umx */ |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
119 udy = (nry - nry0) / 2 / ry; /* uy - umy */ |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
120 umx = (nrx + nrx0) / 2 / rx; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
121 umy = (nry + nry0) / 2 / ry; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
122 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
123 udx2 = udx * udx; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
124 udy2 = udy * udy; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
125 udl2 = udx2 + udy2; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
126 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
127 if(udy != 0) { |
269
c96f38ad4bb6
Fix mis-behavior of translate_path_data() on arc.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
128 /* center is at left-side of arc */ |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
129 udcx = -sqrtf((1 - udl2) * udl2) / (udy + udx2 / udy); |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
130 udcy = -udcx * udx / udy; |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
131 } else { |
269
c96f38ad4bb6
Fix mis-behavior of translate_path_data() on arc.
Thinker K.F. Li <thinker@branda.to>
parents:
235
diff
changeset
|
132 /* center is at down-side of arc */ |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
133 udcx = 0; |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
134 udcy = sqrtf((1 - udl2) * udl2) / udx; |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
135 } |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
136 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
137 reflect = 0; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
138 if(large) |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
139 reflect ^= 1; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
140 if(sweep != 1) |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
141 reflect ^= 1; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
142 if(reflect) { |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
143 udcx = -udcx; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
144 udcy = -udcy; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
145 } |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
146 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
147 nrcx = rx * (udcx + umx); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
148 nrcy = ry * (udcy + umy); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
149 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
150 *cx = nrcx * _cos - nrcy * _sin; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
151 *cy = nrcx * _sin + nrcy * _cos; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
152 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
153 return OK; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
154 } |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
155 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
156 |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
157 static co_aix _angle_rotated_ellipse(co_aix x, co_aix y, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
158 co_aix rx, co_aix ry, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
159 co_aix x_rotate) { |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
160 co_aix nrx, nry; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
161 co_aix _sin, _cos; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
162 co_aix xy_tan; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
163 co_aix angle; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
164 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
165 _sin = sinf(x_rotate); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
166 _cos = cosf(x_rotate); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
167 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
168 nrx = (x * _cos + y * _sin) / rx; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
169 nry = (-x * _sin + y * _cos) / ry; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
170 xy_tan = nry / nrx; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
171 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
172 angle = atan(xy_tan); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
173 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
174 if(nrx < 0) |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
175 angle = PI + angle; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
176 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
177 return angle; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
178 } |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
179 |
459
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
180 static void _rotate(co_aix *x, co_aix *y, co_aix _sin, co_aix _cos) { |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
181 co_aix nx, ny; |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
182 |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
183 nx = *x * _cos - *y * _sin; |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
184 ny = *x * _sin + *y * _cos; |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
185 |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
186 *x = nx; |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
187 *y = ny; |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
188 } |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
189 |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
190 #define TAKE_NUM(r) do { \ |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
191 SKIP_SPACE(p); \ |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
192 old = p; \ |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
193 SKIP_NUM(p); \ |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
194 if(p == old) \ |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
195 return ERR; \ |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
196 r = atof(old); \ |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
197 } while(0); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
198 |
459
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
199 static int _sh_path_arc_cmd_arg_fill(char cmd, char **cmds_p, |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
200 const char **data_p, |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
201 co_aix **pnts_p, |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
202 co_aix **float_args_p) { |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
203 co_aix rx, ry; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
204 co_aix x_rotate; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
205 int large, sweep; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
206 co_aix x, y, x0, y0, cx, cy; |
459
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
207 co_aix corners[4][2]; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
208 co_aix angle_start, angle_stop; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
209 co_aix *pnts = *pnts_p; |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
210 const char *old; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
211 const char *p; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
212 char *cmds; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
213 co_aix *float_args; |
459
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
214 co_aix _sin, _cos; |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
215 int i; |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
216 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
217 p = *data_p; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
218 cmds = *cmds_p; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
219 float_args = *float_args_p; |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
220 while(*p) { |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
221 SKIP_SPACE(p); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
222 old = p; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
223 SKIP_NUM(p); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
224 if(p == old) |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
225 break; |
99
4aa1c9673363
Arc in path pass the test in example svg2code_ex.
Thinker K.F. Li <thinker@branda.to>
parents:
98
diff
changeset
|
226 rx = atof(old); |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
227 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
228 TAKE_NUM(ry); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
229 TAKE_NUM(x_rotate); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
230 TAKE_NUM(large); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
231 TAKE_NUM(sweep); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
232 TAKE_NUM(x); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
233 TAKE_NUM(y) |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
234 |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
235 x0 = *(pnts - 2); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
236 y0 = *(pnts - 1); |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
237 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
238 if(islower(cmd)) { |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
239 x += x0; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
240 y += y0; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
241 } |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
242 |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
243 _calc_center(x0, y0, x, y, rx, ry, x_rotate, large, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
244 sweep, &cx, &cy); |
459
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
245 |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
246 /* Compute positions for four corners. |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
247 * These four corners form a bounding box for the arc. |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
248 */ |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
249 _sin = sinf(x_rotate); |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
250 _cos = cosf(x_rotate); |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
251 corners[0][0] = -rx; |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
252 corners[0][1] = -ry; |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
253 corners[1][0] = rx; |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
254 corners[1][1] = -ry; |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
255 corners[2][0] = rx; |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
256 corners[2][1] = ry; |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
257 corners[3][0] = -rx; |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
258 corners[3][1] = ry; |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
259 for(i = 0; i < 4; i++) { |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
260 _rotate(&corners[i][0], &corners[i][1], _sin, _cos); |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
261 *pnts++ = corners[i][0] + cx; |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
262 *pnts++ = corners[i][1] + cy; |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
263 } |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
264 |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
265 *(pnts++) = x; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
266 *(pnts++) = y; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
267 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
268 angle_start = _angle_rotated_ellipse(x0 - cx, y0 - cy, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
269 rx, ry, x_rotate); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
270 angle_stop = _angle_rotated_ellipse(x - cx, y - cy, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
271 rx, ry, x_rotate); |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
272 |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
273 if(sweep && angle_start > angle_stop) |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
274 angle_stop += 2 * PI; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
275 else if((!sweep) && angle_start < angle_stop) |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
276 angle_start += 2 * PI; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
277 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
278 *float_args++ = cx; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
279 *float_args++ = cy; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
280 *float_args++ = rx; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
281 *float_args++ = ry; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
282 *float_args++ = angle_start; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
283 *float_args++ = angle_stop; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
284 *float_args++ = x_rotate; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
285 |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
286 *cmds++ = toupper(cmd); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
287 } |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
288 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
289 *data_p = p; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
290 *pnts_p = pnts; |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
291 *cmds_p = cmds; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
292 *float_args_p = float_args; |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
293 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
294 return OK; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
295 } |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
296 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
297 #define INNER(x1, y1, x2, y2) ((x1) * (x2) + (y1) * (y2)) |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
298 #define CROSS(x1, y1, x2, y2) ((x1) * (y2) - (y1) * (x2)) |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
299 |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
300 static co_aix distance_pow2(co_aix x, co_aix y) { |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
301 return x * x + y * y; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
302 } |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
303 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
304 static co_aix angle_diff(co_aix sx, co_aix sy, co_aix dx, co_aix dy) { |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
305 co_aix inner, cross; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
306 co_aix angle; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
307 co_aix rd2, rd; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
308 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
309 rd2 = distance_pow2(dx, dy); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
310 rd = sqrtf(rd2); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
311 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
312 inner = INNER(sx, sy, dx, dy); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
313 cross = CROSS(sx, sy, dx, dy); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
314 angle = acos(inner / rd); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
315 if(cross < 0) |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
316 angle = 2 * PI - angle; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
317 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
318 return angle; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
319 } |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
320 |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
321 /*! \brief Make path for arcs in a path. |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
322 */ |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
323 void _sh_path_arc_path(mbe_t *cr, sh_path_t *path, const co_aix **pnts_p, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
324 const co_aix **float_args_p) { |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
325 co_aix cx, cy, x0, y0, x, y; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
326 co_aix rx, ry; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
327 co_aix xyratio; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
328 co_aix angle_start, angle_stop; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
329 co_aix x_rotate; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
330 const co_aix *pnts; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
331 const co_aix *float_args; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
332 co_aix matrix[6]; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
333 co_aix dev_matrix[6]; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
334 co_aix *aggr; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
335 co_aix _sin, _cos; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
336 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
337 pnts = *pnts_p; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
338 float_args = *float_args_p; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
339 x0 = *(pnts - 2); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
340 y0 = *(pnts - 1); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
341 pnts += 8; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
342 x = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
343 y = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
344 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
345 cx = *float_args++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
346 cy = *float_args++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
347 rx = *float_args++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
348 ry = *float_args++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
349 angle_start = *float_args++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
350 angle_stop = *float_args++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
351 x_rotate = *float_args++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
352 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
353 _sin = sinf(x_rotate); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
354 _cos = cosf(x_rotate); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
355 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
356 xyratio = ry / rx; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
357 aggr = sh_get_aggr_matrix((shape_t *)path); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
358 matrix[0] = _cos; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
359 matrix[1] = -_sin * xyratio; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
360 matrix[2] = cx; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
361 matrix[3] = _sin; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
362 matrix[4] = _cos * xyratio; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
363 matrix[5] = cy; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
364 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
365 matrix_mul(aggr, matrix, dev_matrix); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
366 mbe_save(cr); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
367 mbe_transform(cr, dev_matrix); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
368 mbe_arc(cr, 0, 0, rx, angle_start, angle_stop); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
369 mbe_restore(cr); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
370 |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
371 *pnts_p = pnts; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
372 *float_args_p = float_args; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
373 } |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
374 |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
375 /* ============================================================ */ |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
376 |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
377 static void sh_path_free(shape_t *shape) { |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
378 sh_path_t *path = (sh_path_t *)shape; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
379 if(path->user_data) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
380 free(path->user_data); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
381 free(path); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
382 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
383 |
86
7d0580f89468
Fix bug of dealing matrix().
Thinker K.F. Li <thinker@branda.to>
parents:
73
diff
changeset
|
384 /*! \brief Count number of arguments. |
7d0580f89468
Fix bug of dealing matrix().
Thinker K.F. Li <thinker@branda.to>
parents:
73
diff
changeset
|
385 * |
7d0580f89468
Fix bug of dealing matrix().
Thinker K.F. Li <thinker@branda.to>
parents:
73
diff
changeset
|
386 * \todo Notify programmers that syntax or value error of path data. |
7d0580f89468
Fix bug of dealing matrix().
Thinker K.F. Li <thinker@branda.to>
parents:
73
diff
changeset
|
387 */ |
492
e95598916dfb
Make path data constant.
Thinker K.F. Li <thinker@branda.to>
parents:
460
diff
changeset
|
388 static int sh_path_cmd_arg_cnt(const char *data, int *cmd_cntp, int *pnt_cntp, |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
389 int *float_arg_cntp) { |
492
e95598916dfb
Make path data constant.
Thinker K.F. Li <thinker@branda.to>
parents:
460
diff
changeset
|
390 const char *p, *old; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
391 int cmd_cnt, pnt_cnt, float_arg_cnt; |
96 | 392 int i; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
393 |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
394 cmd_cnt = pnt_cnt = float_arg_cnt = 0; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
395 p = data; |
11
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
396 SKIP_SPACE(p); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
397 while(*p) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
398 switch(*p++) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
399 case 'c': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
400 case 'C': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
401 while(*p) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
402 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
403 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
404 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
405 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
406 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
407 break; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
408 pnt_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
409 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
410 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
411 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
412 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
413 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
414 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
415 pnt_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
416 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
417 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
418 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
419 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
420 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
421 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
422 pnt_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
423 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
424 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
425 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
426 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
427 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
428 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
429 pnt_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
430 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
431 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
432 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
433 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
434 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
435 pnt_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
436 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
437 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
438 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
439 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
440 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
441 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
442 pnt_cnt++; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
443 |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
444 cmd_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
445 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
446 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
447 case 's': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
448 case 'S': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
449 case 'q': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
450 case 'Q': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
451 while(*p) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
452 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
453 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
454 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
455 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
456 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
457 break; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
458 pnt_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
459 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
460 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
461 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
462 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
463 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
464 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
465 pnt_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
466 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
467 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
468 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
469 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
470 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
471 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
472 pnt_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
473 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
474 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
475 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
476 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
477 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
478 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
479 pnt_cnt++; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
480 |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
481 cmd_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
482 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
483 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
484 case 'm': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
485 case 'M': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
486 case 'l': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
487 case 'L': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
488 case 't': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
489 case 'T': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
490 while(*p) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
491 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
492 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
493 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
494 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
495 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
496 break; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
497 pnt_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
498 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
499 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
500 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
501 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
502 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
503 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
504 pnt_cnt++; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
505 |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
506 cmd_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
507 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
508 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
509 case 'h': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
510 case 'H': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
511 case 'v': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
512 case 'V': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
513 while(*p) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
514 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
515 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
516 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
517 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
518 break; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
519 pnt_cnt += 2; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
520 |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
521 cmd_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
522 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
523 break; |
96 | 524 case 'A': |
525 case 'a': | |
526 while(*p) { | |
527 SKIP_SPACE(p); | |
528 old = p; | |
529 SKIP_NUM(p); | |
530 if(p == old) | |
531 break; | |
532 | |
533 for(i = 0; i < 6; i++) { | |
534 SKIP_SPACE(p); | |
535 old = p; | |
536 SKIP_NUM(p); | |
537 if(p == old) | |
538 return ERR; | |
539 } | |
540 | |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
541 pnt_cnt += 10; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
542 float_arg_cnt += 7; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
543 |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
544 cmd_cnt++; |
96 | 545 } |
546 break; | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
547 case 'z': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
548 case 'Z': |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
549 cmd_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
550 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
551 default: |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
552 return ERR; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
553 } |
96 | 554 /*! \todo cmd_cnt should be increased for each implicit repeating. */ |
11
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
555 SKIP_SPACE(p); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
556 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
557 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
558 *cmd_cntp = cmd_cnt; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
559 *pnt_cntp = pnt_cnt; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
560 *float_arg_cntp = float_arg_cnt; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
561 return OK; |
96 | 562 } |
563 | |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
564 #define TO_ABSX islower(cmd)? x + atof(old): atof(old) |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
565 #define TO_ABSY islower(cmd)? y + atof(old): atof(old) |
10 | 566 |
492
e95598916dfb
Make path data constant.
Thinker K.F. Li <thinker@branda.to>
parents:
460
diff
changeset
|
567 static int sh_path_cmd_arg_fill(const char *data, sh_path_t *path) { |
e95598916dfb
Make path data constant.
Thinker K.F. Li <thinker@branda.to>
parents:
460
diff
changeset
|
568 const char *p, *old; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
569 char *cmds; |
7
569f3168ba53
Clear background & tranform relative pos into absolute ones
Thinker K.F. Li <thinker@branda.to>
parents:
6
diff
changeset
|
570 char cmd; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
571 co_aix *pnts; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
572 co_aix *float_args; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
573 co_aix x, y; |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
574 int r; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
575 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
576 cmds = path->user_data; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
577 pnts = (co_aix *)(cmds + path->cmd_len); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
578 float_args = (co_aix *)(cmds + path->cmd_len + |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
579 path->pnt_len * sizeof(co_aix)); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
580 p = data; |
11
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
581 SKIP_SPACE(p); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
582 while(*p) { |
7
569f3168ba53
Clear background & tranform relative pos into absolute ones
Thinker K.F. Li <thinker@branda.to>
parents:
6
diff
changeset
|
583 /* Transform all relative to absolute, */ |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
584 x = *(pnts - 2); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
585 y = *(pnts - 1); |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
586 |
7
569f3168ba53
Clear background & tranform relative pos into absolute ones
Thinker K.F. Li <thinker@branda.to>
parents:
6
diff
changeset
|
587 switch((cmd = *p++)) { |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
588 case 'c': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
589 case 'C': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
590 while(*p) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
591 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
592 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
593 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
594 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
595 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
596 break; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
597 *pnts = TO_ABSX; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
598 pnts++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
599 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
600 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
601 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
602 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
603 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
604 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
605 *pnts = TO_ABSY; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
606 pnts++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
607 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
608 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
609 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
610 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
611 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
612 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
613 *pnts = TO_ABSX; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
614 pnts++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
615 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
616 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
617 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
618 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
619 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
620 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
621 *pnts = TO_ABSY; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
622 pnts++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
623 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
624 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
625 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
626 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
627 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
628 *pnts = TO_ABSX; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
629 pnts++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
630 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
631 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
632 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
633 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
634 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
635 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
636 *pnts = TO_ABSY; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
637 pnts++; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
638 |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
639 *cmds++ = toupper(cmd); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
640 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
641 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
642 case 's': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
643 case 'S': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
644 case 'q': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
645 case 'Q': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
646 while(*p) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
647 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
648 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
649 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
650 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
651 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
652 break; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
653 *pnts = TO_ABSX; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
654 pnts++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
655 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
656 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
657 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
658 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
659 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
660 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
661 *pnts = TO_ABSY; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
662 pnts++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
663 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
664 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
665 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
666 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
667 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
668 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
669 *pnts = TO_ABSX; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
670 pnts++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
671 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
672 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
673 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
674 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
675 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
676 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
677 *pnts = TO_ABSY; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
678 pnts++; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
679 |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
680 *cmds++ = toupper(cmd); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
681 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
682 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
683 case 'm': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
684 case 'M': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
685 case 'l': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
686 case 'L': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
687 case 't': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
688 case 'T': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
689 while(*p) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
690 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
691 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
692 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
693 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
694 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
695 break; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
696 *pnts = TO_ABSX; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
697 pnts++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
698 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
699 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
700 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
701 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
702 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
703 return ERR; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
704 *pnts = TO_ABSY; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
705 pnts++; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
706 |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
707 *cmds++ = toupper(cmd); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
708 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
709 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
710 case 'h': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
711 case 'H': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
712 case 'v': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
713 case 'V': |
58 | 714 /*! \todo implement h, H, v, V comamnds for path. */ |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
715 return ERR; |
96 | 716 |
717 case 'A': | |
718 case 'a': | |
459
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
719 r = _sh_path_arc_cmd_arg_fill(cmd, &cmds, |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
720 (const char **)&p, &pnts, |
8b155b77fa14
Count positions an arc being for bounding box of the path.
Thinker K.F. Li <thinker@branda.to>
parents:
458
diff
changeset
|
721 &float_args); |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
722 if(r != OK) |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
723 return ERR; |
96 | 724 break; |
725 | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
726 case 'z': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
727 case 'Z': |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
728 *cmds++ = toupper(cmd); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
729 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
730 default: |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
731 return ERR; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
732 } |
11
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
733 SKIP_SPACE(p); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
734 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
735 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
736 return OK; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
737 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
738 |
9 | 739 /*! \brief Create a path from value of 'data' of SVG path. |
740 */ | |
492
e95598916dfb
Make path data constant.
Thinker K.F. Li <thinker@branda.to>
parents:
460
diff
changeset
|
741 shape_t *rdman_shape_path_new(redraw_man_t *rdman, const char *data) { |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
742 sh_path_t *path; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
743 int cmd_cnt, pnt_cnt, float_arg_cnt; |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
744 int msz; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
745 int r; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
746 |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
747 r = sh_path_cmd_arg_cnt(data, &cmd_cnt, &pnt_cnt, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
748 &float_arg_cnt); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
749 if(r == ERR) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
750 return NULL; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
751 |
8 | 752 /* Align at 4's boundary and keep 2 unused co_aix space |
753 * to make logic of transformation from relative to absolute | |
754 * simple. | |
755 */ | |
10 | 756 cmd_cnt += RESERVED_AIXS; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
757 cmd_cnt = (cmd_cnt + 3) & ~0x3; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
758 |
149 | 759 /*! \todo Use elmpool to manage sh_path_t objects. */ |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
760 path = (sh_path_t *)malloc(sizeof(sh_path_t)); |
146
e96a584487af
Use elmpool to manage paint_color_t objects.
Thinker K.F. Li <thinker@branda.to>
parents:
145
diff
changeset
|
761 /*! \todo Remove this memset()? */ |
12 | 762 memset(&path->shape, 0, sizeof(shape_t)); |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
202
diff
changeset
|
763 mb_obj_init(path, MBO_PATH); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
764 path->cmd_len = cmd_cnt; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
765 path->pnt_len = pnt_cnt; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
766 path->float_arg_len = float_arg_cnt; |
145
609ed47a58f2
Decrease number of malloc().
Thinker K.F. Li <thinker@branda.to>
parents:
112
diff
changeset
|
767 |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
768 msz = cmd_cnt + sizeof(co_aix) * pnt_cnt + |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
769 sizeof(co_aix) * float_arg_cnt; |
145
609ed47a58f2
Decrease number of malloc().
Thinker K.F. Li <thinker@branda.to>
parents:
112
diff
changeset
|
770 path->user_data = (char *)malloc(msz * 2); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
771 if(path->user_data == NULL) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
772 free(path); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
773 return NULL; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
774 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
775 |
145
609ed47a58f2
Decrease number of malloc().
Thinker K.F. Li <thinker@branda.to>
parents:
112
diff
changeset
|
776 path->dev_data = path->user_data + msz; |
609ed47a58f2
Decrease number of malloc().
Thinker K.F. Li <thinker@branda.to>
parents:
112
diff
changeset
|
777 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
778 r = sh_path_cmd_arg_fill(data, path); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
779 if(r == ERR) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
780 free(path->user_data); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
781 free(path); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
782 return NULL; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
783 } |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
784 memcpy(path->dev_data, path->user_data, msz); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
785 |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
786 path->shape.free = sh_path_free; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
787 |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
149
diff
changeset
|
788 rdman_shape_man(rdman, (shape_t *)path); |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
149
diff
changeset
|
789 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
790 return (shape_t *)path; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
791 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
792 |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
793 shape_t *rdman_shape_path_new_from_binary(redraw_man_t *rdman, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
794 char *commands, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
795 co_aix *pnts, int pnt_cnt, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
796 co_aix *float_args, |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
797 int float_arg_cnt) { |
197
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
798 sh_path_t *path; |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
799 int msz; |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
800 int cmd_cnt = strlen(commands); |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
801 |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
802 /*! \todo Use elmpool to manage sh_path_t objects. */ |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
803 path = (sh_path_t *)malloc(sizeof(sh_path_t)); |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
804 /*! \todo Remove this memset()? */ |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
805 memset(&path->shape, 0, sizeof(shape_t)); |
224
29e1b2bffe4c
X backend only sent EVT_MOUSE_MOVE_RAW to MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents:
202
diff
changeset
|
806 mb_obj_init(path, MBO_PATH); |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
807 cmd_cnt = (cmd_cnt + 3) & ~0x3; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
808 path->cmd_len = cmd_cnt; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
809 path->pnt_len = pnt_cnt; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
810 path->float_arg_len = float_arg_cnt; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
811 msz = cmd_cnt + sizeof(co_aix) * pnt_cnt + |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
812 sizeof(co_aix) * float_arg_cnt; |
197
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
813 path->user_data = (char *)malloc(msz * 2); |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
814 if(path->user_data == NULL) { |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
815 free(path); |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
816 return NULL; |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
817 } |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
818 |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
819 path->dev_data = path->user_data + msz; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
820 memcpy(path->user_data, commands, strlen(commands)); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
821 memcpy(path->user_data + cmd_cnt, pnts, sizeof(co_aix) * pnt_cnt); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
822 memcpy(path->user_data + cmd_cnt + pnt_cnt * sizeof(co_aix), |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
823 float_args, sizeof(co_aix) * float_arg_cnt); |
197
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
824 memcpy(path->dev_data, path->user_data, msz); |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
825 |
197
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
826 path->shape.free = sh_path_free; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
827 |
197
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
828 rdman_shape_man(rdman, (shape_t *)path); |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
829 |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
830 return (shape_t *)path; |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
831 } |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
832 |
bcad1ccdf45c
Translate the path string into binary array to save the parsing in the runtime. It can reduce the size as well.
wycc@wycc-desktop
parents:
186
diff
changeset
|
833 |
9 | 834 /*! \brief Transform a path from user space to device space. |
835 * | |
836 */ | |
12 | 837 void sh_path_transform(shape_t *shape) { |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
838 sh_path_t *path; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
839 co_aix *pnts, *dev_pnts; |
12 | 840 co_aix (*poses)[2]; |
26
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
22
diff
changeset
|
841 area_t *area; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
842 int pnt_len; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
843 int i; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
844 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
845 ASSERT(shape->type == SHT_PATH); |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
846 ASSERT((shape->pnt_len & 0x1) == 0); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
847 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
848 path = (sh_path_t *)shape; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
849 pnts = (co_aix *)(path->user_data + path->cmd_len); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
850 dev_pnts = (co_aix *)(path->dev_data + path->cmd_len); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
851 pnt_len = path->pnt_len; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
852 for(i = 0; i < pnt_len; i += 2) { |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
853 dev_pnts[0] = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
854 dev_pnts[1] = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
855 coord_trans_pos(shape->coord, dev_pnts, dev_pnts + 1); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
856 dev_pnts += 2; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
857 } |
12 | 858 |
859 if(path->shape.geo) { | |
860 poses = (co_aix (*)[2])(path->dev_data + path->cmd_len); | |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
861 geo_from_positions(path->shape.geo, pnt_len / 2, poses); |
26
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
22
diff
changeset
|
862 area = shape->geo->cur_area; |
270
cd6af7da32c9
Fix the problem that clean_canvas() can not clean canvas cleanly.
Thinker K.F. Li <thinker@branda.to>
parents:
269
diff
changeset
|
863 area->x -= shape->stroke_width / 2 + 0.5; |
cd6af7da32c9
Fix the problem that clean_canvas() can not clean canvas cleanly.
Thinker K.F. Li <thinker@branda.to>
parents:
269
diff
changeset
|
864 area->y -= shape->stroke_width / 2 + 0.5; |
cd6af7da32c9
Fix the problem that clean_canvas() can not clean canvas cleanly.
Thinker K.F. Li <thinker@branda.to>
parents:
269
diff
changeset
|
865 area->w += shape->stroke_width + 1; |
cd6af7da32c9
Fix the problem that clean_canvas() can not clean canvas cleanly.
Thinker K.F. Li <thinker@branda.to>
parents:
269
diff
changeset
|
866 area->h += shape->stroke_width + 1; |
12 | 867 } |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
868 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
869 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
270
diff
changeset
|
870 static void sh_path_path(shape_t *shape, mbe_t *cr) { |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
871 sh_path_t *path; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
872 int cmd_len; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
873 char *cmds, cmd; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
874 const co_aix *pnts; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
875 const co_aix *float_args; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
876 co_aix x, y, x1, y1, x2, y2; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
877 int i; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
878 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
879 ASSERT(shape->type == SHT_PATH); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
880 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
881 path = (sh_path_t *)shape; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
882 cmd_len = path->cmd_len; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
883 cmds = path->dev_data; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
884 pnts = (co_aix *)(cmds + cmd_len); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
885 float_args = (co_aix *)(cmds + cmd_len + path->pnt_len * sizeof(co_aix)); |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
12
diff
changeset
|
886 x = y = x1 = y1 = x2 = y2 = 0; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
887 for(i = 0; i < cmd_len; i++) { |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
888 /* All path commands and arguments are transformed |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
889 * to absoluted form. |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
890 */ |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
891 cmd = *cmds++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
892 switch(cmd) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
893 case 'M': |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
894 x = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
895 y = *pnts++; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
270
diff
changeset
|
896 mbe_move_to(cr, x, y); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
897 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
898 case 'L': |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
899 x = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
900 y = *pnts++; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
270
diff
changeset
|
901 mbe_line_to(cr, x, y); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
902 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
903 case 'C': |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
904 x1 = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
905 y1 = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
906 x2 = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
907 y2 = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
908 x = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
909 y = *pnts++; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
270
diff
changeset
|
910 mbe_curve_to(cr, x1, y1, x2, y2, x, y); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
911 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
912 case 'S': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
913 x1 = x + x - x2; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
914 y1 = y + y - y2; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
915 x2 = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
916 y2 = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
917 x = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
918 y = *pnts++; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
270
diff
changeset
|
919 mbe_curve_to(cr, x1, y1, x2, y2, x, y); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
920 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
921 case 'Q': |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
922 x1 = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
923 y1 = *pnts++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
924 x2 = x1; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
925 y2 = y1; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
926 x = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
927 y = *pnts++; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
270
diff
changeset
|
928 mbe_curve_to(cr, x1, y1, x2, y2, x, y); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
929 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
930 case 'T': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
931 x1 = x + x - x2; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
932 y1 = y + y - y2; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
933 x2 = x1; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
934 y2 = y1; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
935 x = *pnts++; |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
936 y = *pnts++; |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
270
diff
changeset
|
937 mbe_curve_to(cr, x1, y1, x2, y2, x, y); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
938 break; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
939 case 'A': |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
940 _sh_path_arc_path(cr, path, &pnts, &float_args); |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
941 break; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
942 case 'Z': |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
270
diff
changeset
|
943 mbe_close_path(cr); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
944 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
945 case '\x0': |
8 | 946 i = cmd_len; /* padding! Skip remain ones. */ |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
947 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
948 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
949 } |
22 | 950 } |
6
772511b8b9be
Cairo specify RGB values in range 0.0 ~ 1.0.
Thinker K.F. Li <thinker@branda.to>
parents:
5
diff
changeset
|
951 |
448
16116d84bc5e
Replace Cairo with a abstract layer mb_graph_engine.
Thinker K.F. Li <thinker@branda.to>
parents:
270
diff
changeset
|
952 void sh_path_draw(shape_t *shape, mbe_t *cr) { |
30
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
26
diff
changeset
|
953 sh_path_path(shape, cr); |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
26
diff
changeset
|
954 } |
e06a4a667ce2
Accept mouse/pointer event and hint the shape that the pointer is over.
Thinker K.F. Li <thinker@branda.to>
parents:
26
diff
changeset
|
955 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
956 #ifdef UNITTEST |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
957 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
958 #include <CUnit/Basic.h> |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
959 |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
149
diff
changeset
|
960 void test_rdman_shape_path_new(void) { |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
961 sh_path_t *path; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
962 co_aix *pnts; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
963 |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
149
diff
changeset
|
964 path = (sh_path_t *)rdman_shape_path_new(NULL, "M 33 25l33 55c 33 87 44 22 55 99L33 77z"); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
965 CU_ASSERT(path != NULL); |
10 | 966 CU_ASSERT(path->cmd_len == ((5 + RESERVED_AIXS + 3) & ~0x3)); |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
967 CU_ASSERT(path->pnt_len == 12); |
145
609ed47a58f2
Decrease number of malloc().
Thinker K.F. Li <thinker@branda.to>
parents:
112
diff
changeset
|
968 CU_ASSERT(strncmp(path->user_data, "MLCLZ", 5) == 0); |
609ed47a58f2
Decrease number of malloc().
Thinker K.F. Li <thinker@branda.to>
parents:
112
diff
changeset
|
969 CU_ASSERT(strncmp(path->dev_data, "MLCLZ", 5) == 0); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
970 |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
971 pnts = (co_aix *)(path->user_data + path->cmd_len); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
972 CU_ASSERT(pnts[0] == 33); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
973 CU_ASSERT(pnts[1] == 25); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
974 CU_ASSERT(pnts[2] == 66); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
975 CU_ASSERT(pnts[3] == 80); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
976 CU_ASSERT(pnts[4] == 99); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
977 CU_ASSERT(pnts[5] == 167); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
978 CU_ASSERT(pnts[6] == 110); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
979 CU_ASSERT(pnts[7] == 102); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
980 CU_ASSERT(pnts[8] == 121); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
981 CU_ASSERT(pnts[9] == 179); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
982 CU_ASSERT(pnts[10] == 33); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
983 CU_ASSERT(pnts[11] == 77); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
984 sh_path_free((shape_t *)path); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
985 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
986 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
987 void test_path_transform(void) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
988 sh_path_t *path; |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
989 co_aix *pnts; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
990 coord_t coord; |
12 | 991 geo_t geo; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
992 |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
149
diff
changeset
|
993 path = (sh_path_t *)rdman_shape_path_new(NULL, "M 33 25l33 55C 33 87 44 22 55 99L33 77z"); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
994 CU_ASSERT(path != NULL); |
10 | 995 CU_ASSERT(path->cmd_len == ((5 + RESERVED_AIXS + 3) & ~0x3)); |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
996 CU_ASSERT(path->pnt_len == 12); |
145
609ed47a58f2
Decrease number of malloc().
Thinker K.F. Li <thinker@branda.to>
parents:
112
diff
changeset
|
997 CU_ASSERT(strncmp(path->user_data, "MLCLZ", 5) == 0); |
609ed47a58f2
Decrease number of malloc().
Thinker K.F. Li <thinker@branda.to>
parents:
112
diff
changeset
|
998 CU_ASSERT(strncmp(path->dev_data, "MLCLZ", 5) == 0); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
999 |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
1000 geo_init(&geo); |
12 | 1001 path->shape.geo = &geo; |
1002 geo.shape = (shape_t *)path; | |
1003 | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1004 coord.aggr_matrix[0] = 1; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1005 coord.aggr_matrix[1] = 0; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1006 coord.aggr_matrix[2] = 1; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1007 coord.aggr_matrix[3] = 0; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1008 coord.aggr_matrix[4] = 2; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1009 coord.aggr_matrix[5] = 0; |
12 | 1010 path->shape.coord = &coord; |
1011 sh_path_transform((shape_t *)path); | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1012 |
458
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
1013 pnts = (co_aix *)(path->dev_data + path->cmd_len); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
1014 CU_ASSERT(pnts[0] == 34); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
1015 CU_ASSERT(pnts[1] == 50); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
1016 CU_ASSERT(pnts[2] == 67); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
1017 CU_ASSERT(pnts[3] == 160); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
1018 CU_ASSERT(pnts[4] == 34); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
1019 CU_ASSERT(pnts[5] == 174); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
1020 CU_ASSERT(pnts[6] == 45); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
1021 CU_ASSERT(pnts[7] == 44); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
1022 CU_ASSERT(pnts[8] == 56); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
1023 CU_ASSERT(pnts[9] == 198); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
1024 CU_ASSERT(pnts[10] == 34); |
bb4f651090bf
Use cairo to transform and draw arc.
Thinker K.F. Li <thinker@branda.to>
parents:
448
diff
changeset
|
1025 CU_ASSERT(pnts[11] == 154); |
12 | 1026 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1027 sh_path_free((shape_t *)path); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1028 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1029 |
11
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
1030 void test_spaces_head_tail(void) { |
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
1031 sh_path_t *path; |
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
1032 |
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
1033 path = (sh_path_t *) |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
149
diff
changeset
|
1034 rdman_shape_path_new(NULL, |
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
149
diff
changeset
|
1035 " M 33 25l33 55C 33 87 44 22 55 99L33 77z "); |
11
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
1036 CU_ASSERT(path != NULL); |
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
1037 sh_path_free((shape_t *)path); |
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
1038 } |
128af06c876c
Fix the bug that data of a path end with white spaces would make system down
Thinker K.F. Li <thinker@branda.to>
parents:
10
diff
changeset
|
1039 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1040 CU_pSuite get_shape_path_suite(void) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1041 CU_pSuite suite; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1042 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1043 suite = CU_add_suite("Suite_shape_path", NULL, NULL); |
159
b90abd31a281
Postponse free of coords, shapes, and paints when the rdman is dirty.
Thinker K.F. Li <thinker@branda.to>
parents:
149
diff
changeset
|
1044 CU_ADD_TEST(suite, test_rdman_shape_path_new); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1045 CU_ADD_TEST(suite, test_path_transform); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1046 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1047 return suite; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1048 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1049 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1050 #endif /* UNITTEST */ |