annotate src/shape_path.c @ 234:889cdc5f23c5

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