forked from vpython/glowscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
292 lines (279 loc) · 9.64 KB
/
test.html
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<div id="glowscript" class="glowscript">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link type="text/css" href="css/redmond/2.1/jquery-ui.custom.css" rel="stylesheet" />
<link type="text/css" href="css/ide.css" rel="stylesheet" />
<script type="text/javascript" src="lib/jquery/2.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/jquery/2.1/jquery-ui.custom.min.js"></script>
<script type="text/javascript" src="package/glow.3.2.min.js"></script>
<script type="text/javascript" src="package/RSrun.3.2.min.js"></script>
<script type="text/javascript"><!--//--><![CDATA[//><!--
// START JAVASCRIPT
;(function() {;
var ρσ_modules = {};
var running, col, currentobject;
ρσ_modules.pythonize = {};
(function(){
function strings() {
var string_funcs, exclude, name;
string_funcs = set("capitalize strip lstrip rstrip islower isupper isspace lower upper swapcase center count endswith startswith find rfind index rindex format join ljust rjust partition rpartition replace split rsplit splitlines zfill".split(" "));
if (!arguments.length) {
exclude = (function(){
var s = ρσ_set();
s.jsset.add("split");
s.jsset.add("replace");
return s;
})();
} else if (arguments[0]) {
exclude = Array.prototype.slice.call(arguments);
} else {
exclude = null;
}
if (exclude) {
string_funcs = string_funcs.difference(set(exclude));
}
var ρσ_Iter0 = string_funcs;
ρσ_Iter0 = ((typeof ρσ_Iter0[Symbol.iterator] === "function") ? (ρσ_Iter0 instanceof Map ? ρσ_Iter0.keys() : ρσ_Iter0) : Object.keys(ρσ_Iter0));
for (var ρσ_Index0 of ρσ_Iter0) {
name = ρσ_Index0;
(ρσ_expr_temp = String.prototype)[(typeof name === "number" && name < 0) ? ρσ_expr_temp.length + name : name] = (ρσ_expr_temp = ρσ_str.prototype)[(typeof name === "number" && name < 0) ? ρσ_expr_temp.length + name : name];
}
};
if (!strings.__module__) Object.defineProperties(strings, {
__module__ : {value: "pythonize"}
});
ρσ_modules.pythonize.strings = strings;
})();
async function __main__() {
"use strict";
var display = canvas;
var scene = canvas();
var version, print, arange, __name__, type, ρσ_ls, running, box_object, cone_object, pyramid_object, cylinder_object, col, currentobject, cbutton, sl, wt, r1, r2, dt;
version = ρσ_list_decorate([ "3.2", "glowscript" ]);
Array.prototype['+'] = function(r) {return this.concat(r)}
Array.prototype['*'] = function(r) {return __array_times_number(this, r)}
window.__GSlang = "vpython";
print = GSprint;
arange = range;
__name__ = "__main__";
type = pytype;
var strings = ρσ_modules.pythonize.strings;
strings();
"2";
scene.width = 350;
"3";
scene.height = 300;
"4";
scene.range = 1.3;
"5";
scene.title = "Widgets (buttons, etc.)\n";
"7";
running = true;
"9";
async function Run(b) {
"10";
"11";
running = !running;
"12";
if (running) {
b.text = "Pause";
} else {
b.text = "Run";
}
};
if (!Run.__argnames__) Object.defineProperties(Run, {
__argnames__ : {value: ["b"]},
__module__ : {value: null}
});
"15";
ρσ_interpolate_kwargs.call(this, button, [ρσ_desugar_kwargs({text: "Pause", pos: scene.title_anchor, bind: Run})]);
"17";
box_object = ρσ_interpolate_kwargs.call(this, box, [ρσ_desugar_kwargs({visible: true})]);
"18";
cone_object = ρσ_interpolate_kwargs.call(this, cone, [ρσ_desugar_kwargs({visible: false, radius: .5})]);
"19";
pyramid_object = ρσ_interpolate_kwargs.call(this, pyramid, [ρσ_desugar_kwargs({visible: false})]);
"20";
cylinder_object = ρσ_interpolate_kwargs.call(this, cylinder, [ρσ_desugar_kwargs({visible: false, radius: .5})]);
"22";
col = color.cyan;
"23";
currentobject = box_object;
"24";
currentobject.color = col;
"26";
async function Color(c) {
"27";
"28";
if (col.equals(color.cyan)) {
"29";
currentobject.color = col = color.red;
"30";
c.text = "<b>Cyan<\/b>";
"31";
c.color = color.cyan;
"32";
c.background = color.red;
"33";
r1.checked = false;
"34";
r2.checked = true;
"35";
} else {
"36";
currentobject.color = col = color.cyan;
"37";
c.text = "<b>Red</b>";
"38";
c.color = color.red;
"39";
c.background = color.cyan;
"40";
r1.checked = true;
"41";
r2.checked = false;
}
};
if (!Color.__argnames__) Object.defineProperties(Color, {
__argnames__ : {value: ["c"]},
__module__ : {value: null}
});
"43";
async function cc(c) {
"44";
"45";
if (col.equals(color.cyan)) {
"46";
currentobject.color = col = color.red;
"47";
cbutton.text = "<b>Cyan</b>";
"48";
cbutton.color = color.cyan;
"49";
cbutton.background = color.red;
"50";
} else {
"51";
currentobject.color = col = color.cyan;
"52";
cbutton.text = "<b>Red</b>";
"53";
cbutton.color = color.red;
"54";
cbutton.background = color.cyan;
}
};
if (!cc.__argnames__) Object.defineProperties(cc, {
__argnames__ : {value: ["c"]},
__module__ : {value: null}
});
"56";
cbutton = ρσ_interpolate_kwargs.call(this, button, [ρσ_desugar_kwargs({text: "<b>Red</b>", color: color.red, background: color.cyan, pos: scene.title_anchor, bind: Color})]);
"58";
scene.caption = "Vary the rotation speed: \n\n";
"60";
async function setspeed(s) {
"61";
wt.text = "{:1.2f}".format(s.value);
};
if (!setspeed.__argnames__) Object.defineProperties(setspeed, {
__argnames__ : {value: ["s"]},
__module__ : {value: null}
});
"63";
sl = ρσ_interpolate_kwargs.call(this, slider, [ρσ_desugar_kwargs({min: .3, max: 3, value: 1.5, length: 220, bind: setspeed, right: 15})]);
"65";
wt = ρσ_interpolate_kwargs.call(this, wtext, [ρσ_desugar_kwargs({text: "{:1.2f}".format(sl.value)})]);
"67";
scene.append_to_caption(" radians/s\n");
"69";
r1 = ρσ_interpolate_kwargs.call(this, radio, [ρσ_desugar_kwargs({bind: cc, checked: true, text: "Cyan", name: "rads"})]);
"71";
scene.append_to_caption(" ");
"73";
async function M(m) {
var ρσ_ls, op, currentaxis, val;
"74";
"75";
op = currentobject.opacity;
"76";
currentaxis = currentobject.axis;
"77";
currentobject.visible = false;
"78";
val = m.selected;
"79";
if ((val === "box" || typeof val === "object" && ρσ_equals(val, "box"))) {
"80";
currentobject = box_object;
"81";
} else if ((val === "cone" || typeof val === "object" && ρσ_equals(val, "cone"))) {
"82";
currentobject = cone_object;
"83";
} else if ((val === "pyramid" || typeof val === "object" && ρσ_equals(val, "pyramid"))) {
"84";
currentobject = pyramid_object;
"85";
} else if ((val === "cylinder" || typeof val === "object" && ρσ_equals(val, "cylinder"))) {
"86";
currentobject = cylinder_object;
}
"87";
currentobject.color = col;
"88";
currentobject.axis = currentaxis;
"89";
currentobject.visible = true;
"90";
currentobject.opacity = op;
};
if (!M.__argnames__) Object.defineProperties(M, {
__argnames__ : {value: ["m"]},
__module__ : {value: null}
});
"92";
ρσ_interpolate_kwargs.call(this, menu, [ρσ_desugar_kwargs({choices: ρσ_list_decorate([ "Choose an object", "box", "cone", "pyramid", "cylinder" ]), index: 0, bind: M})]);
"94";
scene.append_to_caption("\n");
"96";
r2 = ρσ_interpolate_kwargs.call(this, radio, [ρσ_desugar_kwargs({bind: cc, text: "Red", name: "rads"})]);
"98";
scene.append_to_caption(" ");
"100";
async function transparency(b) {
"101";
if (b.checked) {
"102";
currentobject.opacity = .5;
"103";
} else {
"104";
currentobject.opacity = 1;
}
};
if (!transparency.__argnames__) Object.defineProperties(transparency, {
__argnames__ : {value: ["b"]},
__module__ : {value: null}
});
"106";
ρσ_interpolate_kwargs.call(this, checkbox, [ρσ_desugar_kwargs({bind: transparency, text: "Transparent"})]);
"108";
dt = .01;
"109";
while (true) {
"110";
(await rate(1["/"](dt)));
"111";
if (running) {
"112";
ρσ_interpolate_kwargs.call(currentobject, currentobject.rotate, [ρσ_desugar_kwargs({angle: sl.value["*"](dt), axis: vector(0, 1, 0)})]);
}
}
};
if (!__main__.__module__) Object.defineProperties(__main__, {
__module__ : {value: null}
});
;$(function(){ window.__context = { glowscript_container: $("#glowscript").removeAttr("id") }; __main__() })})()
// END JAVASCRIPT
//--><!]]></script>
</div>