Mercurial > MadButterfly
annotate src/shape_path.c @ 243:6c6b62d342ee
Add scene.svg
author | wycc |
---|---|
date | Wed, 31 Dec 2008 22:39:28 +0800 |
parents | 65cabbdd5284 |
children | c96f38ad4bb6 |
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> |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
5 #include <cairo.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; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
22 int arg_len; |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
23 int fix_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 |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
43 #define PI 3.1415926 |
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 * |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
56 * - 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
|
57 * - 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
|
58 * - ux = x / rx |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
59 * - uy = y / rx |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
60 * ux0, uy0, ux, yu are got by transforming (x0, y0) and (x, y) into points |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
61 * 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
|
62 * - 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
|
63 * - 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
|
64 * - 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
|
65 * - 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
|
66 * - 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
|
67 * - 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
|
68 * |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
69 * - 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
|
70 * |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
71 * - udl2 = udx ** 2 + udy ** 2; |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
72 * - 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
|
73 * |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
74 * - 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
|
75 * - -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
|
76 * - -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
|
77 * - 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
|
78 * or |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
79 * - 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
|
80 * - 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
|
81 * - 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
|
82 * - 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
|
83 * |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
84 * - 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
|
85 * - 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
|
86 * - 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
|
87 * - 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
|
88 */ |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
89 static int calc_center_and_x_aix(co_aix x0, co_aix y0, |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
90 co_aix x, co_aix y, |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
91 co_aix rx, co_aix ry, |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
92 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
|
93 int large, int sweep, |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
94 co_aix *cx, co_aix *cy, |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
95 co_aix *xx, co_aix *xy) { |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 int reflect; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
105 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
106 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
|
107 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
|
108 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
|
109 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
|
110 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
111 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
|
112 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
|
113 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
|
114 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
|
115 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
116 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
|
117 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
|
118 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
|
119 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
120 if(udy != 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
|
121 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
|
122 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
|
123 } else { |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
124 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
|
125 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
|
126 } |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
127 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
128 reflect = 0; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
129 if(large) |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
130 reflect ^= 1; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
131 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
|
132 reflect ^= 1; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
133 if(reflect) { |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
134 udcx = -udcx; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
135 udcy = -udcy; |
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 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
138 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
|
139 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
|
140 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
141 *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
|
142 *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
|
143 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
144 *xx = rx * _cos + *cx; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
145 *xy = rx * _sin + *cy; |
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 return OK; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
148 } |
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 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
151 #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
|
152 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
|
153 old = p; \ |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
154 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
|
155 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
|
156 return ERR; \ |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
157 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
|
158 } while(0); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
159 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
160 static int sh_path_arc_cmd_arg_fill(char cmd, char **cmds_p, |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
161 const char **data_p, |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
162 co_aix **args_p, |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
163 int **fix_args_p) { |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
164 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
|
165 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
|
166 int large, sweep; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
167 co_aix x, y, x0, y0, cx, cy, xx, xy; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
168 co_aix *args = *args_p; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
169 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
|
170 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
|
171 char *cmds; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
172 int *fix_args; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
173 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
174 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
|
175 cmds = *cmds_p; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
176 fix_args = *fix_args_p; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
177 while(*p) { |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
178 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
|
179 old = p; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
180 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
|
181 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
|
182 break; |
99
4aa1c9673363
Arc in path pass the test in example svg2code_ex.
Thinker K.F. Li <thinker@branda.to>
parents:
98
diff
changeset
|
183 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
|
184 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
185 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
|
186 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
|
187 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
|
188 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
|
189 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
|
190 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
|
191 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
192 x0 = *(args - 2); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
193 y0 = *(args - 1); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
194 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
195 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
|
196 x += x0; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
197 y += y0; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
198 } |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
199 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
200 calc_center_and_x_aix(x0, y0, x, y, |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
201 rx, ry, |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
202 x_rotate, large, sweep, |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
203 &cx, &cy, &xx, &xy); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
204 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
205 *(args++) = cx; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
206 *(args++) = cy; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
207 *(args++) = xx; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
208 *(args++) = xy; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
209 *(args++) = x; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
210 *(args++) = y; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
211 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
212 *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
|
213 *fix_args++ = sweep; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
214 } |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
215 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
216 *data_p = p; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
217 *args_p = args; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
218 *cmds_p = cmds; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
219 *fix_args_p = fix_args; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
220 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
221 return OK; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
222 } |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
223 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
224 #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
|
225 #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
|
226 |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
227 /*! \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
|
228 */ |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
229 void sh_path_arc_path(cairo_t *cr, const co_aix **args_p, |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
230 const int **fix_args_p) { |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
231 co_aix cx, cy, x0, y0, x, y, xx, xy; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
232 co_aix dx, dy, dx0, dy0, dxx, dxy; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
233 co_aix xyratio; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
234 co_aix rx; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
235 co_aix rx2; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
236 co_aix inner0, cross0; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
237 co_aix circle_h0; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
238 co_aix inner, cross; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
239 co_aix angle, angle0; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
240 co_aix rotate; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
241 const co_aix *args = *args_p; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
242 const int *fix_args = *fix_args_p; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
243 int sweep; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
244 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
245 x0 = *(args - 2); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
246 y0 = *(args - 1); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
247 cx = *args++; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
248 cy = *args++; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
249 xx = *args++; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
250 xy = *args++; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
251 x = *args++; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
252 y = *args++; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
253 sweep = *fix_args++; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
254 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
255 dx = x - cx; |
99
4aa1c9673363
Arc in path pass the test in example svg2code_ex.
Thinker K.F. Li <thinker@branda.to>
parents:
98
diff
changeset
|
256 dy = y - cy; |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
257 dx0 = x0 - cx; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
258 dy0 = y0 - cy; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
259 dxx = xx - cx; |
99
4aa1c9673363
Arc in path pass the test in example svg2code_ex.
Thinker K.F. Li <thinker@branda.to>
parents:
98
diff
changeset
|
260 dxy = xy - cy; |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
261 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
262 rx2 = dxx * dxx + dxy * dxy; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
263 rx = sqrtf(rx2); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
264 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
265 /*! \note Why we calculate these numbers there? |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
266 * If we compute it when filling arguments, sh_path_arc_cmd_arg_fill(), |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
267 * we can avoid to recompute it for every drawing. But, transforming of |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
268 * coordinate can effect value of the numbers. |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
269 */ |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
270 inner0 = INNER(dxx, dxy, dx0, dy0); |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
271 cross0 = CROSS(dxx, dxy, dx0, dy0); |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
272 circle_h0 = sqrtf(rx2 - inner0 * inner0 / rx2); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
273 xyratio = cross0 / rx / circle_h0; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
274 if(xyratio < 0) |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
275 xyratio = -xyratio; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
276 |
99
4aa1c9673363
Arc in path pass the test in example svg2code_ex.
Thinker K.F. Li <thinker@branda.to>
parents:
98
diff
changeset
|
277 angle0 = acos(inner0 / rx2); |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
278 if(cross0 < 0) |
99
4aa1c9673363
Arc in path pass the test in example svg2code_ex.
Thinker K.F. Li <thinker@branda.to>
parents:
98
diff
changeset
|
279 angle0 = PI * 2 - angle0; /* 3rd, 4th Quadrant */ |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
280 |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
281 inner = INNER(dxx, dxy, dx, dy); |
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
282 cross = CROSS(dxx, dxy, dx, dy); |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
283 angle = acos(inner / rx2); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
284 if(cross < 0) |
99
4aa1c9673363
Arc in path pass the test in example svg2code_ex.
Thinker K.F. Li <thinker@branda.to>
parents:
98
diff
changeset
|
285 angle = PI * 2 - angle; /* 3rd, 4th Quadrant */ |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
286 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
287 /* Make a path for arc */ |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
288 rotate = acos(dxx / rx); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
289 cairo_save(cr); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
290 cairo_translate(cr, cx, cy); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
291 cairo_rotate(cr, rotate); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
292 cairo_scale(cr, 1.0, xyratio); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
293 if(sweep) |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
294 cairo_arc(cr, 0, 0, rx, angle0, angle); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
295 else |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
296 cairo_arc_negative(cr, 0, 0, rx, angle0, angle); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
297 cairo_restore(cr); |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
298 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
299 *args_p = args; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
300 *fix_args_p = fix_args; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
301 } |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
302 |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
303 /* ============================================================ */ |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
304 |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
305 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
|
306 sh_path_t *path = (sh_path_t *)shape; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
307 if(path->user_data) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
308 free(path->user_data); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
309 free(path); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
310 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
311 |
86
7d0580f89468
Fix bug of dealing matrix().
Thinker K.F. Li <thinker@branda.to>
parents:
73
diff
changeset
|
312 /*! \brief Count number of arguments. |
7d0580f89468
Fix bug of dealing matrix().
Thinker K.F. Li <thinker@branda.to>
parents:
73
diff
changeset
|
313 * |
7d0580f89468
Fix bug of dealing matrix().
Thinker K.F. Li <thinker@branda.to>
parents:
73
diff
changeset
|
314 * \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
|
315 */ |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
316 static int sh_path_cmd_arg_cnt(char *data, int *cmd_cntp, int *arg_cntp, |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
317 int *fix_arg_cntp) { |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
318 char *p, *old; |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
319 int cmd_cnt, arg_cnt, fix_arg_cnt; |
96 | 320 int i; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
321 |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
322 cmd_cnt = arg_cnt = fix_arg_cnt = 0; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
323 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
|
324 SKIP_SPACE(p); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
325 while(*p) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
326 switch(*p++) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
327 case 'c': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
328 case 'C': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
329 while(*p) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
330 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
331 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
332 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
333 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
334 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
335 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
336 arg_cnt++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
337 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
338 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
339 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
340 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
341 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
342 return ERR; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
343 arg_cnt++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
344 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
345 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
346 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
347 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
348 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
349 return ERR; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
350 arg_cnt++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
351 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
352 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
353 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
354 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
355 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
356 return ERR; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
357 arg_cnt++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
358 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
359 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
360 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
361 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
362 return ERR; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
363 arg_cnt++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
364 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
365 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
366 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
367 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
368 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
369 return ERR; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
370 arg_cnt++; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
371 |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
372 cmd_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
373 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
374 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
375 case 's': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
376 case 'S': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
377 case 'q': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
378 case 'Q': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
379 while(*p) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
380 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
381 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
382 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
383 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
384 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
385 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
386 arg_cnt++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
387 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
388 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
389 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
390 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
391 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
392 return ERR; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
393 arg_cnt++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
394 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
395 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
396 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
397 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
398 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
399 return ERR; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
400 arg_cnt++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
401 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
402 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
403 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
404 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
405 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
406 return ERR; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
407 arg_cnt++; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
408 |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
409 cmd_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
410 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
411 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
412 case 'm': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
413 case 'M': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
414 case 'l': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
415 case 'L': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
416 case 't': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
417 case 'T': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
418 while(*p) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
419 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
420 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
421 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
422 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
423 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
424 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
425 arg_cnt++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
426 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
427 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
428 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
429 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
430 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
431 return ERR; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
432 arg_cnt++; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
433 |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
434 cmd_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
435 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
436 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
437 case 'h': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
438 case 'H': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
439 case 'v': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
440 case 'V': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
441 while(*p) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
442 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
443 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
444 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
445 if(p == old) |
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 arg_cnt += 2; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
448 |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
449 cmd_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
450 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
451 break; |
96 | 452 case 'A': |
453 case 'a': | |
454 while(*p) { | |
455 SKIP_SPACE(p); | |
456 old = p; | |
457 SKIP_NUM(p); | |
458 if(p == old) | |
459 break; | |
460 | |
461 for(i = 0; i < 6; i++) { | |
462 SKIP_SPACE(p); | |
463 old = p; | |
464 SKIP_NUM(p); | |
465 if(p == old) | |
466 return ERR; | |
467 } | |
468 | |
469 arg_cnt += 6; | |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
470 fix_arg_cnt++; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
471 |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
472 cmd_cnt++; |
96 | 473 } |
474 break; | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
475 case 'z': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
476 case 'Z': |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
477 cmd_cnt++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
478 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
479 default: |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
480 return ERR; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
481 } |
96 | 482 /*! \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
|
483 SKIP_SPACE(p); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
484 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
485 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
486 *cmd_cntp = cmd_cnt; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
487 *arg_cntp = 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
|
488 *fix_arg_cntp = fix_arg_cnt; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
489 return OK; |
96 | 490 } |
491 | |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
492 #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
|
493 #define TO_ABSY islower(cmd)? y + atof(old): atof(old) |
10 | 494 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
495 static int sh_path_cmd_arg_fill(char *data, sh_path_t *path) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
496 char *p, *old; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
497 char *cmds; |
7
569f3168ba53
Clear background & tranform relative pos into absolute ones
Thinker K.F. Li <thinker@branda.to>
parents:
6
diff
changeset
|
498 char cmd; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
499 co_aix *args; |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
500 int *fix_args; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
501 co_aix x, y; |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
502 int r; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
503 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
504 cmds = path->user_data; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
505 args = (co_aix *)(cmds + path->cmd_len); |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
506 fix_args = (int *)(cmds + path->cmd_len + |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
507 path->arg_len * sizeof(co_aix)); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
508 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
|
509 SKIP_SPACE(p); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
510 while(*p) { |
7
569f3168ba53
Clear background & tranform relative pos into absolute ones
Thinker K.F. Li <thinker@branda.to>
parents:
6
diff
changeset
|
511 /* Transform all relative to absolute, */ |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
512 x = *(args - 2); |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
513 y = *(args - 1); |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
514 |
7
569f3168ba53
Clear background & tranform relative pos into absolute ones
Thinker K.F. Li <thinker@branda.to>
parents:
6
diff
changeset
|
515 switch((cmd = *p++)) { |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
516 case 'c': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
517 case 'C': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
518 while(*p) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
519 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
520 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
521 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
522 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
523 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
524 break; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
525 *args = TO_ABSX; |
10 | 526 args++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
527 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
528 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
529 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
530 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
531 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
532 return ERR; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
533 *args = TO_ABSY; |
10 | 534 args++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
535 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
536 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
537 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
538 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
539 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
540 return ERR; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
541 *args = TO_ABSX; |
10 | 542 args++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
543 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
544 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
545 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
546 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
547 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
548 return ERR; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
549 *args = TO_ABSY; |
10 | 550 args++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
551 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
552 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
553 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
554 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
555 return ERR; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
556 *args = TO_ABSX; |
10 | 557 args++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
558 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
559 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
560 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
561 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
562 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
563 return ERR; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
564 *args = TO_ABSY; |
10 | 565 args++; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
566 |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
567 *cmds++ = toupper(cmd); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
568 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
569 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
570 case 's': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
571 case 'S': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
572 case 'q': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
573 case 'Q': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
574 while(*p) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
575 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
576 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
577 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
578 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
579 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
580 break; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
581 *args = TO_ABSX; |
10 | 582 args++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
583 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
584 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
585 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
586 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
587 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
588 return ERR; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
589 *args = TO_ABSY; |
10 | 590 args++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
591 |
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 return ERR; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
597 *args = TO_ABSX; |
10 | 598 args++; |
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; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
605 *args = TO_ABSY; |
10 | 606 args++; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
607 |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
608 *cmds++ = toupper(cmd); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
609 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
610 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
611 case 'm': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
612 case 'M': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
613 case 'l': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
614 case 'L': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
615 case 't': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
616 case 'T': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
617 while(*p) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
618 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
619 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
620 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
621 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
622 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
623 break; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
624 *args = TO_ABSX; |
10 | 625 args++; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
626 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
627 SKIP_SPACE(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
628 old = p; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
629 SKIP_NUM(p); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
630 if(p == old) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
631 return ERR; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
632 *args = TO_ABSY; |
10 | 633 args++; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
634 |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
635 *cmds++ = toupper(cmd); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
636 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
637 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
638 case 'h': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
639 case 'H': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
640 case 'v': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
641 case 'V': |
58 | 642 /*! \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
|
643 return ERR; |
96 | 644 |
645 case 'A': | |
646 case 'a': | |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
647 r = sh_path_arc_cmd_arg_fill(cmd, &cmds, |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
648 (const char **)&p, &args, |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
649 &fix_args); |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
650 if(r != OK) |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
651 return ERR; |
96 | 652 break; |
653 | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
654 case 'z': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
655 case 'Z': |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
656 *cmds++ = toupper(cmd); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
657 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
658 default: |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
659 return ERR; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
660 } |
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
|
661 SKIP_SPACE(p); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
662 } |
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 return OK; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
665 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
666 |
9 | 667 /*! \brief Create a path from value of 'data' of SVG path. |
668 */ | |
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
|
669 shape_t *rdman_shape_path_new(redraw_man_t *rdman, char *data) { |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
670 sh_path_t *path; |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
671 int cmd_cnt, arg_cnt, fix_arg_cnt; |
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
672 int msz; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
673 int r; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
674 |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
675 r = sh_path_cmd_arg_cnt(data, &cmd_cnt, &arg_cnt, &fix_arg_cnt); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
676 if(r == ERR) |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
677 return NULL; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
678 |
8 | 679 /* Align at 4's boundary and keep 2 unused co_aix space |
680 * to make logic of transformation from relative to absolute | |
681 * simple. | |
682 */ | |
10 | 683 cmd_cnt += RESERVED_AIXS; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
684 cmd_cnt = (cmd_cnt + 3) & ~0x3; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
685 |
149 | 686 /*! \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
|
687 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
|
688 /*! \todo Remove this memset()? */ |
12 | 689 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
|
690 mb_obj_init(path, MBO_PATH); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
691 path->cmd_len = cmd_cnt; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
692 path->arg_len = 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
|
693 path->fix_arg_len = fix_arg_cnt; |
145
609ed47a58f2
Decrease number of malloc().
Thinker K.F. Li <thinker@branda.to>
parents:
112
diff
changeset
|
694 |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
695 msz = cmd_cnt + sizeof(co_aix) * arg_cnt + sizeof(int) * fix_arg_cnt; |
145
609ed47a58f2
Decrease number of malloc().
Thinker K.F. Li <thinker@branda.to>
parents:
112
diff
changeset
|
696 path->user_data = (char *)malloc(msz * 2); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
697 if(path->user_data == NULL) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
698 free(path); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
699 return NULL; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
700 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
701 |
145
609ed47a58f2
Decrease number of malloc().
Thinker K.F. Li <thinker@branda.to>
parents:
112
diff
changeset
|
702 path->dev_data = path->user_data + msz; |
609ed47a58f2
Decrease number of malloc().
Thinker K.F. Li <thinker@branda.to>
parents:
112
diff
changeset
|
703 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
704 r = sh_path_cmd_arg_fill(data, path); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
705 if(r == ERR) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
706 free(path->user_data); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
707 free(path); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
708 return NULL; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
709 } |
100
1a1dda98730c
Fix the bug of order of cross & inner product of vectors
Thinker K.F. Li <thinker@branda.to>
parents:
99
diff
changeset
|
710 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
|
711 |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
712 path->shape.free = sh_path_free; |
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
713 |
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
|
714 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
|
715 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
716 return (shape_t *)path; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
717 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
718 |
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
|
719 shape_t *rdman_shape_path_new_from_binary(redraw_man_t *rdman, char *commands, co_aix *arg,int arg_cnt,int *fix_arg,int fix_arg_cnt) { |
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
|
720 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
|
721 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
|
722 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
|
723 |
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
|
724 /*! \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
|
725 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
|
726 /*! \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
|
727 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
|
728 mb_obj_init(path, MBO_PATH); |
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
|
729 path->cmd_len = 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
|
730 path->arg_len = arg_cnt; |
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
|
731 path->fix_arg_len = fix_arg_cnt; |
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
|
732 msz = cmd_cnt + sizeof(co_aix) * arg_cnt + sizeof(int) * fix_arg_cnt; |
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
|
733 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
|
734 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
|
735 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
|
736 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
|
737 } |
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
|
738 |
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
|
739 path->dev_data = path->user_data + 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
|
740 memcpy(path->user_data,commands,cmd_cnt); |
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
|
741 memcpy(path->user_data+cmd_cnt,arg, sizeof(co_aix)*arg_cnt); |
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
|
742 memcpy(path->user_data+cmd_cnt+arg_cnt*sizeof(co_aix),fix_arg, sizeof(int)*fix_arg_cnt); |
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
|
743 memcpy(path->dev_data, path->user_data, 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
|
744 |
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
|
745 path->shape.free = sh_path_free; |
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
|
746 |
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
|
747 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
|
748 |
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
|
749 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
|
750 } |
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
|
751 |
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
|
752 |
9 | 753 /*! \brief Transform a path from user space to device space. |
754 * | |
755 */ | |
12 | 756 void sh_path_transform(shape_t *shape) { |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
757 sh_path_t *path; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
758 co_aix *user_args, *dev_args; |
12 | 759 co_aix (*poses)[2]; |
26
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
22
diff
changeset
|
760 area_t *area; |
12 | 761 int arg_len; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
762 int i; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
763 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
764 ASSERT(shape->type == SHT_PATH); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
765 ASSERT((shape->arg_len & 0x1) == 0); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
766 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
767 path = (sh_path_t *)shape; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
768 user_args = (co_aix *)(path->user_data + path->cmd_len); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
769 dev_args = (co_aix *)(path->dev_data + path->cmd_len); |
12 | 770 arg_len = path->arg_len; |
771 for(i = 0; i < arg_len; i += 2) { | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
772 dev_args[0] = *user_args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
773 dev_args[1] = *user_args++; |
12 | 774 coord_trans_pos(shape->coord, dev_args, dev_args + 1); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
775 dev_args += 2; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
776 } |
12 | 777 |
778 if(path->shape.geo) { | |
779 poses = (co_aix (*)[2])(path->dev_data + path->cmd_len); | |
17
41f0907b27ac
Unittest for rdman_redraw_changed().
Thinker K.F. Li <thinker@branda.to>
parents:
15
diff
changeset
|
780 geo_from_positions(path->shape.geo, arg_len / 2, poses); |
26
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
22
diff
changeset
|
781 area = shape->geo->cur_area; |
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
22
diff
changeset
|
782 area->x -= shape->stroke_width/2 + 1; |
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
22
diff
changeset
|
783 area->y -= shape->stroke_width/2 + 1; |
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
22
diff
changeset
|
784 area->w += shape->stroke_width + 2; |
d50f33040de6
Set line width for path.
Thinker K.F. Li <thinker@branda.to>
parents:
22
diff
changeset
|
785 area->h += shape->stroke_width + 2; |
12 | 786 } |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
787 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
788 |
22 | 789 static void sh_path_path(shape_t *shape, cairo_t *cr) { |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
790 sh_path_t *path; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
791 int cmd_len; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
792 char *cmds, cmd; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
793 const co_aix *args; |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
794 const int *fix_args; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
795 co_aix x, y, x1, y1, x2, y2; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
796 int i; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
797 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
798 ASSERT(shape->type == SHT_PATH); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
799 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
800 path = (sh_path_t *)shape; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
801 cmd_len = path->cmd_len; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
802 cmds = path->dev_data; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
803 args = (co_aix *)(cmds + cmd_len); |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
804 fix_args = (int *)(cmds + cmd_len + path->arg_len * sizeof(co_aix)); |
15
c2ce186a5c37
X_main uses rdman_redraw_all()
Thinker K.F. Li <thinker@branda.to>
parents:
12
diff
changeset
|
805 x = y = x1 = y1 = x2 = y2 = 0; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
806 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
|
807 /* 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
|
808 * to absoluted form. |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
809 */ |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
810 cmd = *cmds++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
811 switch(cmd) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
812 case 'M': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
813 x = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
814 y = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
815 cairo_move_to(cr, x, y); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
816 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
817 case 'L': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
818 x = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
819 y = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
820 cairo_line_to(cr, x, y); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
821 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
822 case 'C': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
823 x1 = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
824 y1 = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
825 x2 = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
826 y2 = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
827 x = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
828 y = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
829 cairo_curve_to(cr, x1, y1, x2, y2, x, y); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
830 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
831 case 'S': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
832 x1 = x + x - x2; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
833 y1 = y + y - y2; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
834 x2 = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
835 y2 = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
836 x = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
837 y = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
838 cairo_curve_to(cr, x1, y1, x2, y2, x, y); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
839 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
840 case 'Q': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
841 x1 = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
842 y1 = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
843 x2 = x1; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
844 y2 = y1; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
845 x = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
846 y = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
847 cairo_curve_to(cr, x1, y1, x2, y2, x, y); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
848 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
849 case 'T': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
850 x1 = x + x - x2; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
851 y1 = y + y - y2; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
852 x2 = x1; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
853 y2 = y1; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
854 x = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
855 y = *args++; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
856 cairo_curve_to(cr, x1, y1, x2, y2, x, y); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
857 break; |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
858 case 'A': |
98
688f76b8e71c
Implement arc for path, but it is still under testing
Thinker K.F. Li <thinker@branda.to>
parents:
97
diff
changeset
|
859 sh_path_arc_path(cr, &args, &fix_args); |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
860 break; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
861 case 'Z': |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
862 cairo_close_path(cr); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
863 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
864 case '\x0': |
8 | 865 i = cmd_len; /* padding! Skip remain ones. */ |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
866 break; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
867 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
868 } |
22 | 869 } |
6
772511b8b9be
Cairo specify RGB values in range 0.0 ~ 1.0.
Thinker K.F. Li <thinker@branda.to>
parents:
5
diff
changeset
|
870 |
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
|
871 void sh_path_draw(shape_t *shape, cairo_t *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
|
872 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
|
873 } |
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
|
874 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
875 #ifdef UNITTEST |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
876 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
877 #include <CUnit/Basic.h> |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
878 |
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
|
879 void test_rdman_shape_path_new(void) { |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
880 sh_path_t *path; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
881 co_aix *args; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
882 |
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
|
883 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
|
884 CU_ASSERT(path != NULL); |
10 | 885 CU_ASSERT(path->cmd_len == ((5 + RESERVED_AIXS + 3) & ~0x3)); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
886 CU_ASSERT(path->arg_len == 12); |
145
609ed47a58f2
Decrease number of malloc().
Thinker K.F. Li <thinker@branda.to>
parents:
112
diff
changeset
|
887 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
|
888 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
|
889 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
890 args = (co_aix *)(path->user_data + path->cmd_len); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
891 CU_ASSERT(args[0] == 33); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
892 CU_ASSERT(args[1] == 25); |
9 | 893 CU_ASSERT(args[2] == 66); |
894 CU_ASSERT(args[3] == 80); | |
97
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
895 CU_ASSERT(args[4] == 99); |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
896 CU_ASSERT(args[5] == 167); |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
897 CU_ASSERT(args[6] == 110); |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
898 CU_ASSERT(args[7] == 102); |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
899 CU_ASSERT(args[8] == 121); |
9453e68092b5
Fix bug of translation relative to absolute points
Thinker K.F. Li <thinker@branda.to>
parents:
96
diff
changeset
|
900 CU_ASSERT(args[9] == 179); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
901 CU_ASSERT(args[10] == 33); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
902 CU_ASSERT(args[11] == 77); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
903 sh_path_free((shape_t *)path); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
904 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
905 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
906 void test_path_transform(void) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
907 sh_path_t *path; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
908 co_aix *args; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
909 coord_t coord; |
12 | 910 geo_t geo; |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
911 |
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
|
912 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
|
913 CU_ASSERT(path != NULL); |
10 | 914 CU_ASSERT(path->cmd_len == ((5 + RESERVED_AIXS + 3) & ~0x3)); |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
915 CU_ASSERT(path->arg_len == 12); |
145
609ed47a58f2
Decrease number of malloc().
Thinker K.F. Li <thinker@branda.to>
parents:
112
diff
changeset
|
916 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
|
917 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
|
918 |
73
9ab15ebc9061
Observer for mouse events
Thinker K.F. Li <thinker@branda.to>
parents:
58
diff
changeset
|
919 geo_init(&geo); |
12 | 920 path->shape.geo = &geo; |
921 geo.shape = (shape_t *)path; | |
922 | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
923 coord.aggr_matrix[0] = 1; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
924 coord.aggr_matrix[1] = 0; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
925 coord.aggr_matrix[2] = 1; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
926 coord.aggr_matrix[3] = 0; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
927 coord.aggr_matrix[4] = 2; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
928 coord.aggr_matrix[5] = 0; |
12 | 929 path->shape.coord = &coord; |
930 sh_path_transform((shape_t *)path); | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
931 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
932 args = (co_aix *)(path->dev_data + path->cmd_len); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
933 CU_ASSERT(args[0] == 34); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
934 CU_ASSERT(args[1] == 50); |
9 | 935 CU_ASSERT(args[2] == 67); |
936 CU_ASSERT(args[3] == 160); | |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
937 CU_ASSERT(args[4] == 34); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
938 CU_ASSERT(args[5] == 174); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
939 CU_ASSERT(args[6] == 45); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
940 CU_ASSERT(args[7] == 44); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
941 CU_ASSERT(args[8] == 56); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
942 CU_ASSERT(args[9] == 198); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
943 CU_ASSERT(args[10] == 34); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
944 CU_ASSERT(args[11] == 154); |
12 | 945 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
946 sh_path_free((shape_t *)path); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
947 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
948 |
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
|
949 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
|
950 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
|
951 |
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
|
952 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
|
953 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
|
954 " 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
|
955 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
|
956 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
|
957 } |
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
|
958 |
5
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
959 CU_pSuite get_shape_path_suite(void) { |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
960 CU_pSuite suite; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
961 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
962 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
|
963 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
|
964 CU_ADD_TEST(suite, test_path_transform); |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
965 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
966 return suite; |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
967 } |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
968 |
9c331ec9e210
SVG path is partially supported
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
969 #endif /* UNITTEST */ |