Mercurial > MadButterfly
comparison src/shape_path.c @ 8:94b4b5bd8810
-
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sat, 26 Jul 2008 03:20:49 +0800 |
parents | 569f3168ba53 |
children | 6eecdd331fe7 |
comparison
equal
deleted
inserted
replaced
7:569f3168ba53 | 8:94b4b5bd8810 |
---|---|
3 #include <ctype.h> | 3 #include <ctype.h> |
4 #include <string.h> | 4 #include <string.h> |
5 #include <cairo.h> | 5 #include <cairo.h> |
6 #include "mb_types.h" | 6 #include "mb_types.h" |
7 | 7 |
8 /*! \brief Implement respective objects for SVG path tag. | |
9 * | |
10 * In user_data or dev_data, 0x00 bytes are padding after commands. | |
11 * No commands other than 0x00 can resident after 0x00 itself. | |
12 * It means command processing code can skip commands after a 0x00. | |
13 */ | |
8 typedef struct _sh_path { | 14 typedef struct _sh_path { |
9 shape_t shape; | 15 shape_t shape; |
10 int cmd_len; | 16 int cmd_len; |
11 int arg_len; | 17 int arg_len; |
12 char *user_data; | 18 char *user_data; |
318 | 324 |
319 r = sh_path_cmd_arg_cnt(data, &cmd_cnt, &arg_cnt); | 325 r = sh_path_cmd_arg_cnt(data, &cmd_cnt, &arg_cnt); |
320 if(r == ERR) | 326 if(r == ERR) |
321 return NULL; | 327 return NULL; |
322 | 328 |
329 /* Align at 4's boundary and keep 2 unused co_aix space | |
330 * to make logic of transformation from relative to absolute | |
331 * simple. | |
332 */ | |
333 cmd_cnt += sizeof(co_aix) * 2; | |
323 cmd_cnt = (cmd_cnt + 3) & ~0x3; | 334 cmd_cnt = (cmd_cnt + 3) & ~0x3; |
324 | 335 |
325 path = (sh_path_t *)malloc(sizeof(sh_path_t)); | 336 path = (sh_path_t *)malloc(sizeof(sh_path_t)); |
326 path->shape.sh_type = SHT_PATH; | 337 path->shape.sh_type = SHT_PATH; |
327 path->cmd_len = cmd_cnt; | 338 path->cmd_len = cmd_cnt; |
483 case 'Z': | 494 case 'Z': |
484 case 'z': | 495 case 'z': |
485 cairo_close_path(cr); | 496 cairo_close_path(cr); |
486 break; | 497 break; |
487 case '\x0': | 498 case '\x0': |
499 i = cmd_len; /* padding! Skip remain ones. */ | |
488 break; | 500 break; |
489 } | 501 } |
490 } | 502 } |
491 | 503 |
492 cairo_fill(cr); | 504 cairo_fill(cr); |