Mercurial > MadButterfly
comparison src/coord.c @ 138:9f4fc9ecfd1f
Make shapes and coords drawed in post-order of tree.
1. Add opacity for each coord.
2. Trival and draw tree of shapes and coords in post-order.
3. Coords have a before_pmem member variable to note it's order been draw.
It is relative to it's siblings and member shapes of parent coord.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 22 Sep 2008 11:45:00 +0800 |
parents | da770188a44d |
children | 1695a4b02b14 |
comparison
equal
deleted
inserted
replaced
137:5dcfaafd1a9c | 138:9f4fc9ecfd1f |
---|---|
121 } | 121 } |
122 | 122 |
123 coord_t *preorder_coord_subtree(coord_t *root, coord_t *last) { | 123 coord_t *preorder_coord_subtree(coord_t *root, coord_t *last) { |
124 coord_t *next; | 124 coord_t *next; |
125 | 125 |
126 ASSERT(last == NULL); | 126 ASSERT(last != NULL); |
127 | 127 |
128 if(STAILQ_HEAD(last->children)) | 128 if(STAILQ_HEAD(last->children)) |
129 next = STAILQ_HEAD(last->children); | 129 next = STAILQ_HEAD(last->children); |
130 else { | 130 else { |
131 next = last; | 131 next = last; |
138 } | 138 } |
139 | 139 |
140 return next; | 140 return next; |
141 } | 141 } |
142 | 142 |
143 coord_t *postorder_coord_subtree(coord_t *root, coord_t *last) { | |
144 coord_t *next; | |
145 | |
146 if(root == last) | |
147 return NULL; | |
148 | |
149 if(last == NULL) { | |
150 /* Go most left leaf. */ | |
151 next = root; | |
152 while(STAILQ_HEAD(next->children)) | |
153 next = STAILQ_HEAD(next->children); | |
154 return next; | |
155 } | |
156 | |
157 next = last; | |
158 if(STAILQ_NEXT(coord_t, sibling, next) == NULL) /* most right */ | |
159 return next->parent; | |
160 | |
161 /* Go most left leaf of right sibling sub-tree. */ | |
162 next = STAILQ_NEXT(coord_t, sibling, next); | |
163 while(STAILQ_HEAD(next->children)) | |
164 next = STAILQ_HEAD(next->children); | |
165 | |
166 return next; | |
167 } | |
168 | |
143 void sh_attach_coord(shape_t *sh, coord_t *coord) { | 169 void sh_attach_coord(shape_t *sh, coord_t *coord) { |
144 STAILQ_INS_TAIL(coord->members, shape_t, coord_mem_next, sh); | 170 STAILQ_INS_TAIL(coord->members, shape_t, coord_mem_next, sh); |
145 sh->coord = coord; | 171 sh->coord = coord; |
146 } | 172 } |
147 | 173 |