Mercurial > MadButterfly
changeset 9:6eecdd331fe7
Fix bug in testcase
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sat, 26 Jul 2008 04:27:52 +0800 |
parents | 94b4b5bd8810 |
children | 7cfecdce94cc |
files | orgfiles/index.muse src/X_main.c src/shape_path.c |
diffstat | 3 files changed, 24 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/orgfiles/index.muse Sat Jul 26 03:20:49 2008 +0800 +++ b/orgfiles/index.muse Sat Jul 26 04:27:52 2008 +0800 @@ -57,3 +57,9 @@ transform functions of containers, it is called aggregated transform function. The aggregated transform function of elements are computed with [[http://en.wikipedia.org/wiki/Dynamic_programming][dynamic programming]]. + +** Use Absolute +Since we need to tranform positions, positions are transform to +absolute coordinations if they are specified relative. It is +fine when a relative position are rotated or resized. But, it +would be wrong when shifting.
--- a/src/X_main.c Sat Jul 26 03:20:49 2008 +0800 +++ b/src/X_main.c Sat Jul 26 04:27:52 2008 +0800 @@ -11,7 +11,7 @@ shape_t *path; coord_t coord; - path = sh_path_new("m80 80 c 20 5 -30 20 10 30 l -30 0 z"); + path = sh_path_new("m80 80 c 20 5 -30 20 10 30 t -30 0 z"); memset(coord.aggr_matrix, 0, sizeof(co_aix) * 6); coord.aggr_matrix[0] = 1; coord.aggr_matrix[1] = 0.5;
--- a/src/shape_path.c Sat Jul 26 03:20:49 2008 +0800 +++ b/src/shape_path.c Sat Jul 26 04:27:52 2008 +0800 @@ -317,6 +317,8 @@ return OK; } +/*! \brief Create a path from value of 'data' of SVG path. + */ shape_t *sh_path_new(char *data) { sh_path_t *path; int cmd_cnt, arg_cnt; @@ -362,6 +364,11 @@ return (shape_t *)path; } +/*! \brief Transform a path from user space to device space. + * + * TODO: associate coord_t with shape objects and transform them + * automatically. + */ void sh_path_transform(shape_t *shape, coord_t *coord) { sh_path_t *path; co_aix *user_args, *dev_args; @@ -514,16 +521,16 @@ path = (sh_path_t *)sh_path_new("M 33 25l33 55C 33 87 44 22 55 99L33 77z"); CU_ASSERT(path != NULL); - CU_ASSERT(path->cmd_len == 8); + CU_ASSERT(path->cmd_len == ((5 + sizeof(co_aix) * 2 + 3) & ~0x3)); CU_ASSERT(path->arg_len == 12); - CU_ASSERT(strcmp(path->user_data, "MlCLz") == 0); - CU_ASSERT(strcmp(path->dev_data, "MlCLz") == 0); + CU_ASSERT(strcmp(path->user_data, "MLCLZ") == 0); + CU_ASSERT(strcmp(path->dev_data, "MLCLZ") == 0); args = (co_aix *)(path->user_data + path->cmd_len); CU_ASSERT(args[0] == 33); CU_ASSERT(args[1] == 25); - CU_ASSERT(args[2] == 33); - CU_ASSERT(args[3] == 55); + CU_ASSERT(args[2] == 66); + CU_ASSERT(args[3] == 80); CU_ASSERT(args[4] == 33); CU_ASSERT(args[5] == 87); CU_ASSERT(args[6] == 44); @@ -542,10 +549,10 @@ path = (sh_path_t *)sh_path_new("M 33 25l33 55C 33 87 44 22 55 99L33 77z"); CU_ASSERT(path != NULL); - CU_ASSERT(path->cmd_len == 8); + CU_ASSERT(path->cmd_len == ((5 + sizeof(co_aix) * 2 + 3) & ~0x3)); CU_ASSERT(path->arg_len == 12); - CU_ASSERT(strcmp(path->user_data, "MlCLz") == 0); - CU_ASSERT(strcmp(path->dev_data, "MlCLz") == 0); + CU_ASSERT(strcmp(path->user_data, "MLCLZ") == 0); + CU_ASSERT(strcmp(path->dev_data, "MLCLZ") == 0); coord.aggr_matrix[0] = 1; coord.aggr_matrix[1] = 0; @@ -558,8 +565,8 @@ args = (co_aix *)(path->dev_data + path->cmd_len); CU_ASSERT(args[0] == 34); CU_ASSERT(args[1] == 50); - CU_ASSERT(args[2] == 34); - CU_ASSERT(args[3] == 110); + CU_ASSERT(args[2] == 67); + CU_ASSERT(args[3] == 160); CU_ASSERT(args[4] == 34); CU_ASSERT(args[5] == 174); CU_ASSERT(args[6] == 45);