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