Mercurial > MadButterfly
comparison src/shape_path.c @ 96:ca94493b75bb
-
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sat, 30 Aug 2008 00:32:05 +0800 |
parents | 7d0580f89468 |
children | 9453e68092b5 |
comparison
equal
deleted
inserted
replaced
95:7dfa4e60b26d | 96:ca94493b75bb |
---|---|
51 * \todo Notify programmers that syntax or value error of path data. | 51 * \todo Notify programmers that syntax or value error of path data. |
52 */ | 52 */ |
53 static int sh_path_cmd_arg_cnt(char *data, int *cmd_cntp, int *arg_cntp) { | 53 static int sh_path_cmd_arg_cnt(char *data, int *cmd_cntp, int *arg_cntp) { |
54 char *p, *old; | 54 char *p, *old; |
55 int cmd_cnt, arg_cnt; | 55 int cmd_cnt, arg_cnt; |
56 int i; | |
56 | 57 |
57 cmd_cnt = arg_cnt = 0; | 58 cmd_cnt = arg_cnt = 0; |
58 p = data; | 59 p = data; |
59 SKIP_SPACE(p); | 60 SKIP_SPACE(p); |
60 while(*p) { | 61 while(*p) { |
174 if(p == old) | 175 if(p == old) |
175 break; | 176 break; |
176 arg_cnt += 2; | 177 arg_cnt += 2; |
177 } | 178 } |
178 break; | 179 break; |
180 case 'A': | |
181 case 'a': | |
182 while(*p) { | |
183 SKIP_SPACE(p); | |
184 old = p; | |
185 SKIP_NUM(p); | |
186 if(p == old) | |
187 break; | |
188 | |
189 for(i = 0; i < 6; i++) { | |
190 SKIP_SPACE(p); | |
191 old = p; | |
192 SKIP_NUM(p); | |
193 if(p == old) | |
194 return ERR; | |
195 } | |
196 | |
197 arg_cnt += 6; | |
198 } | |
199 break; | |
179 case 'z': | 200 case 'z': |
180 case 'Z': | 201 case 'Z': |
181 break; | 202 break; |
182 default: | 203 default: |
183 return ERR; | 204 return ERR; |
184 } | 205 } |
206 /*! \todo cmd_cnt should be increased for each implicit repeating. */ | |
185 cmd_cnt++; | 207 cmd_cnt++; |
186 SKIP_SPACE(p); | 208 SKIP_SPACE(p); |
187 } | 209 } |
188 | 210 |
189 *cmd_cntp = cmd_cnt; | 211 *cmd_cntp = cmd_cnt; |
190 *arg_cntp = arg_cnt; | 212 *arg_cntp = arg_cnt; |
213 return OK; | |
214 } | |
215 | |
216 static int calc_center_and_x_aix(co_aix x0, co_aix y0, | |
217 co_aix x, co_aix y, | |
218 co_aix x_rotate, | |
219 int large, int sweep, | |
220 co_aix *cx, co_aix *cy, | |
221 co_aix *xx, co_aix *xy) { | |
222 | |
223 } | |
224 | |
225 | |
226 static int sh_path_arc_cmd_arg_fill(char cmd, const char *data, | |
227 co_aix **args_p, const char **old_p) { | |
228 co_aix rx, ry; | |
229 co_aix x_rotate; | |
230 int large, sweep; | |
231 co_aix x, y, x0, y0, cx, cy, xx, xy; | |
232 co_aix *args = *args_p; | |
233 const char *old = *old_p; | |
234 const char *p; | |
235 | |
236 p = data; | |
237 while(*p) { | |
238 SKIP_SPACE(p); | |
239 old = p; | |
240 SKIP_NUM(p); | |
241 if(p == old) | |
242 break; | |
243 rx = atof(old); | |
244 | |
245 SKIP_SPACE(p); | |
246 old = p; | |
247 SKIP_NUM(p); | |
248 if(p == old) | |
249 return ERR; | |
250 ry = atof(old); | |
251 | |
252 SKIP_SPACE(p); | |
253 old = p; | |
254 SKIP_NUM(p); | |
255 if(p == old) | |
256 return ERR; | |
257 x_rotate = atof(old); | |
258 | |
259 SKIP_SPACE(p); | |
260 old = p; | |
261 SKIP_NUM(p); | |
262 if(p == old) | |
263 return ERR; | |
264 large = atoi(old); | |
265 | |
266 SKIP_SPACE(p); | |
267 old = p; | |
268 SKIP_NUM(p); | |
269 if(p == old) | |
270 return ERR; | |
271 sweep = atoi(old); | |
272 | |
273 SKIP_SPACE(p); | |
274 old = p; | |
275 SKIP_NUM(p); | |
276 if(p == old) | |
277 return ERR; | |
278 x = atof(old); | |
279 | |
280 SKIP_SPACE(p); | |
281 old = p; | |
282 SKIP_NUM(p); | |
283 if(p == old) | |
284 return ERR; | |
285 y = atof(old); | |
286 | |
287 x0 = *(args - 2); | |
288 y0 = *(args - 1); | |
289 | |
290 if(islower(cmd)) { | |
291 x += x0; | |
292 y += y0; | |
293 } | |
294 | |
295 calc_center_and_x_aix(x0, y0, x, y, | |
296 x_rotate, large, sweep, | |
297 &cx, &cy, &xx, &xy); | |
298 | |
299 *(args++) = cx; | |
300 *(args++) = cy; | |
301 *(args++) = xx; | |
302 *(args++) = xy; | |
303 *(args++) = x; | |
304 *(args++) = y; | |
305 } | |
306 | |
307 *old_p = old; | |
308 | |
191 return OK; | 309 return OK; |
192 } | 310 } |
193 | 311 |
194 #define TO_ABS islower(cmd)? *(args - 2) + atof(old): atof(old) | 312 #define TO_ABS islower(cmd)? *(args - 2) + atof(old): atof(old) |
195 | 313 |
327 case 'H': | 445 case 'H': |
328 case 'v': | 446 case 'v': |
329 case 'V': | 447 case 'V': |
330 /*! \todo implement h, H, v, V comamnds for path. */ | 448 /*! \todo implement h, H, v, V comamnds for path. */ |
331 return ERR; | 449 return ERR; |
450 | |
451 case 'A': | |
452 case 'a': | |
453 | |
454 break; | |
455 | |
332 case 'z': | 456 case 'z': |
333 case 'Z': | 457 case 'Z': |
334 break; | 458 break; |
335 default: | 459 default: |
336 return ERR; | 460 return ERR; |