git @ Cat's Eye Technologies Erratic-Turtle-Graphics / 59f2b34
Show/allow editing of "Logo" program in a textarea. Chris Pressey 2 years ago
1 changed file(s) with 18 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
33 */
44
55 function launch(config) {
6 var div=DAM.maker('div'), button=DAM.maker('button'), canvas=DAM.maker('canvas');
6 var div=DAM.maker('div'), button=DAM.maker('button'), textarea=DAM.maker('textarea'), canvas=DAM.maker('canvas');
77
88 var can = canvas({ width: 1000, height: 400 });
99 config.container.appendChild(can);
2323 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 ]"
2424 },
2525 {
26 text: 'Stars',
27 value: "seterr 0 0 setxyp 0.125 0.666 lt 90 lt 18 repeat 7 [ repeat 500 [ fd 150 lt 144 ] shiftxyp 0.125 0.0 shifterr 0.00375 0.3 ]"
28 },
29 {
2630 text: 'Circle Chain',
2731 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 ]"
2832 }
3741 interpretInstrs(i, turtle);
3842 }
3943
40 run();
41
44 var programTextarea = textarea({ rows: 4, cols: 80 }, program);
4245 var controlPanel = div(
4346 div(
4447 DAM.makeSelect({
4649 options: options,
4750 onchange: function(option) {
4851 program = option.value;
52 programTextarea.innerHTML = program;
4953 run();
5054 }
5155 })
5256 ),
5357 div(
54 button("Re-roll", { onclick: function() { run(); }})
58 programTextarea,
59 ),
60 div(
61 button("Run", {
62 onclick: function() {
63 program = programTextarea.value;
64 program = run();
65 }
66 })
5567 )
5668 );
5769 config.container.appendChild(controlPanel);
70
71 run();
5872 }