forked from microsoft/maker.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspiral.js
More file actions
32 lines (22 loc) · 971 Bytes
/
spiral.js
File metadata and controls
32 lines (22 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var makerjs = require('./../target/js/node.maker.js');
function Spiral(loops, startRadius, spacing) {
if (spacing == 0) loops = 1;
function revolution(r) {
this.paths = {
arc1: new makerjs.paths.Arc([0, 0], r, 0, 90),
arc2: new makerjs.paths.Arc([0, -spacing], r + spacing, 90, 180),
arc3: new makerjs.paths.Arc([2 * spacing, -spacing], r + 3 * spacing, 180, 270),
arc4: new makerjs.paths.Arc([2 * spacing, 0], r + 4 * spacing, 270, 360)
};
}
this.models = {};
for (var i = 0; i < loops; i++) {
this.models['loop' + i] = new revolution(startRadius + i * spacing * 6);
}
}
Spiral.metaParameters = [
{ title: "loops", type: "range", min: 1, max: 60, step: 1, value: 1 },
{ title: "start radius", type: "range", min: 0, max: 10, step: .01, value: 0.33 },
{ title: "spacing", type: "range", min: 0, max: 1, step: .01, value: 1 }
];
module.exports = Spiral;