Fix initially selected program.
Chris Pressey
5 years ago
9 | 9 | config.container.appendChild(can); |
10 | 10 | |
11 | 11 | var turtle = (new ErraticTurtle()).init({ canvas: can }); |
12 | var program = "seterr 0 0 setxyp 0.125 0.5 lt 90 repeat 7 [ repeat 50 [ fd 150 lt 180 ] shiftxyp 0.125 0.0 shifterr 0.01 2.0 ]"; | |
12 | var options = [ | |
13 | { | |
14 | text: 'Lines', | |
15 | value: "seterr 0 0 setxyp 0.125 0.666 lt 90 repeat 7 [ repeat 50 [ fd 150 lt 180 ] shiftxyp 0.125 0.0 shifterr 0.00375 0.3 ]" | |
16 | }, | |
17 | { | |
18 | text: 'Boxes', | |
19 | value: "seterr 0 0 setxyp 0.125 0.666 lt 90 repeat 7 [ repeat 400 [ fd 50 lt 90 ] shiftxyp 0.125 0.0 shifterr 0.0015 0.3 ]" | |
20 | }, | |
21 | { | |
22 | text: 'Circles', | |
23 | value: "seterr 0 0 setxyp 0.125 0.5 lt 90 repeat 7 [ repeat 4500 [ fd 1.0 lt 4 ] shiftxyp 0.125 0.0 shifterr 0.00375 0.05 ]" | |
24 | }, | |
25 | { | |
26 | text: 'Circle Chain', | |
27 | value: "seterr 0 0 setxyp 1.0 0.5 lt 90 repeat 7 [ repeat 1845 [ fd 2.0 lt 4 ] lt 180 shifterr 0.00375 0.225 ] repeat 7 [ repeat 1845 [ fd 2.0 lt 4 ] lt 180 shifterr -0.00375 -0.225 ]" | |
28 | } | |
29 | ]; | |
30 | var program = options[0].value; | |
13 | 31 | |
14 | 32 | function run() { |
15 | 33 | turtle.reset(); |
25 | 43 | div( |
26 | 44 | DAM.makeSelect({ |
27 | 45 | title: "Form", |
28 | options: [ | |
29 | { | |
30 | text: 'Lines', | |
31 | value: "seterr 0 0 setxyp 0.125 0.666 lt 90 repeat 7 [ repeat 50 [ fd 150 lt 180 ] shiftxyp 0.125 0.0 shifterr 0.00375 0.3 ]" | |
32 | }, | |
33 | { | |
34 | text: 'Boxes', | |
35 | value: "seterr 0 0 setxyp 0.125 0.666 lt 90 repeat 7 [ repeat 400 [ fd 50 lt 90 ] shiftxyp 0.125 0.0 shifterr 0.0015 0.3 ]" | |
36 | }, | |
37 | { | |
38 | text: 'Circles', | |
39 | value: "seterr 0 0 setxyp 0.125 0.5 lt 90 repeat 7 [ repeat 4500 [ fd 1.0 lt 4 ] shiftxyp 0.125 0.0 shifterr 0.00375 0.05 ]" | |
40 | }, | |
41 | { | |
42 | text: 'Circle Chain', | |
43 | value: "seterr 0 0 setxyp 1.0 0.5 lt 90 repeat 7 [ repeat 1845 [ fd 2.0 lt 4 ] lt 180 shifterr 0.00375 0.225 ] repeat 7 [ repeat 1845 [ fd 2.0 lt 4 ] lt 180 shifterr -0.00375 -0.225 ]" | |
44 | } | |
45 | ], | |
46 | options: options, | |
46 | 47 | onchange: function(option) { |
47 | 48 | program = option.value; |
48 | 49 | run(); |