git @ Cat's Eye Technologies Pixley / 93fa9b5
Support mixing orientations. Cat's Eye Technologies 10 years ago
1 changed file(s) with 26 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
109109 * some details about how to depict them on the canvas, mainly
110110 * the width and the height which the s-expression will occupy.
111111 */
112 this.decorateSexp = function(x, y, sexp) {
112 this.decorateSexp = function(x, y, sexp, parentOrientation) {
113 parentOrientation = !!parentOrientation; // ensure it is a boolean
113114 /*
114115 * Determine if we have a Cons cell or an Atom.
115116 */
150151 }
151152 var len = children.length;
152153
154 /*
155 * Determine the orientation of this sexp.
156 */
157
158 // STYLE 1: only cond and let* bindings are vertical
159 origSexp.horizontal = true;
160 if (!origSexp.startsWithAtom) {
161 origSexp.horizontal = false;
162 }
163 if (origSexp.startsWithAtom && head.text === 'cond') {
164 origSexp.horizontal = false;
165 }
166
167 // STYLE 2: orientation is opposite of parent's
168 /*
169 origSexp.horizontal = !parentOrientation;
170 */
171
172 // STYLE 3: orientation is random!
173 /*
174 origSexp.horizontal = (Math.random() > 0.5 ? true : false);
175 */
176
153177 for (var i = 0; i < len; i++) {
154 this.decorateSexp(x, y, children[i]);
178 this.decorateSexp(x, y, children[i], origSexp.horizontal);
155179 }
156180
157181 var w = 0;
158182 var h = 0;
159
160 origSexp.horizontal = false;
161183 for (var i = 0; i < len; i++) {
162184 // alert(i + '...' + w);
163185 if (origSexp.horizontal) {
172194 }
173195 }
174196 }
175
176197 if (origSexp.horizontal) {
177198 w = w + margin * (len + 1);
178199 } else {