Skip to content

Commit d5ce0dc

Browse files
committed
Needed preamble in runtime.js
1 parent a1085b1 commit d5ce0dc

File tree

9 files changed

+234
-43
lines changed

9 files changed

+234
-43
lines changed

GlowScriptOffline/GlowScript.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
<script type="text/javascript" src="glowscript_libraries/jquery.min.js"></script>
4343
<script type="text/javascript" src="glowscript_libraries/jquery-ui.custom.min.js"></script>
4444
<script type="text/javascript" src="glowscript_libraries/editor.js"></script>
45-
<script type="text/javascript" src="glowscript_libraries/RSrun.3.1.min.js"></script>
46-
<script type="text/javascript" src="glowscript_libraries/glow.3.1.min.js" charset="UTF-8"></script>
45+
<script type="text/javascript" src="glowscript_libraries/RSrun.3.2.min.js"></script>
46+
<script type="text/javascript" src="glowscript_libraries/glow.3.2.min.js" charset="UTF-8"></script>
4747
<script type="text/javascript" src="glowscript_libraries/split.min.js"></script>
4848
<script type="text/javascript" src="glowscript_libraries/Roboto_Medium_ttf_sans.js"></script>
4949
<script type="text/javascript" src="glowscript_libraries/NimbusRomNo9L_Med_otf_serif.js"></script>
@@ -60,7 +60,7 @@
6060
<input type="file" id="read_local_file"/>
6161

6262
<script>
63-
var gsversion = '3.1'
63+
var gsversion = '3.2'
6464
var printpane = false
6565
var exporting = false // not currently in export mode
6666
var lastprintwidth = null

GlowScriptOffline/glowscript_libraries/RSrun.3.2.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GlowScriptOffline3.2.zip

108 Bytes
Binary file not shown.

lib/compiling/GScompiler.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ Build embedded compiler: (from "Embedding the RapydScript compiler in your webpa
5757
5858
Move new files to glowscript source:
5959
5) Copy the file release/baselib-plain-pretty.js to lib/rapydscript runtime.js.
60-
6) Copy the file embed/rapydscript.js to lib/rapydscript/compiler.js.
60+
6) Copy the file embed/rapydscript.js to lib/rapydscript/compiler.js and insert this at start of file:
61+
var ρσ_iterator_symbol = (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") ? Symbol.iterator : "iterator-Symbol-5d0927e5554349048cf0e3762a228256";
62+
var ρσ_kwargs_symbol = (typeof Symbol === "function") ? Symbol("kwargs-object") : "kwargs-object-Symbol-5d0927e5554349048cf0e3762a228256";
63+
var ρσ_cond_temp, ρσ_expr_temp, ρσ_last_exception;
64+
var ρσ_object_counter = 0;
6165
6266
However you obtain the two RapydScript-NG files, you need to make the following changes
6367
in order to enable tests for two vectors being equal or unequal:

lib/rapydscript/runtime.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
var ρσ_iterator_symbol = (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") ? Symbol.iterator : "iterator-Symbol-5d0927e5554349048cf0e3762a228256";
2+
var ρσ_kwargs_symbol = (typeof Symbol === "function") ? Symbol("kwargs-object") : "kwargs-object-Symbol-5d0927e5554349048cf0e3762a228256";
3+
var ρσ_cond_temp, ρσ_expr_temp, ρσ_last_exception;
4+
var ρσ_object_counter = 0;
15
var ρσ_len;
26
function ρσ_bool(val) {
37
return !!val;

package/RSrun.3.2.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package/symbols.3.2.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test.html

Lines changed: 219 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<<div id="glowscript" class="glowscript">
1+
<div id="glowscript" class="glowscript">
22
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
33
<link type="text/css" href="css/redmond/2.1/jquery-ui.custom.css" rel="stylesheet" />
44
<link type="text/css" href="css/ide.css" rel="stylesheet" />
@@ -11,6 +11,7 @@
1111
// START JAVASCRIPT
1212
;(function() {;
1313
var ρσ_modules = {};
14+
var running, col, currentobject;
1415
ρσ_modules.pythonize = {};
1516

1617
(function(){
@@ -50,7 +51,7 @@
5051
var display = canvas;
5152
var scene = canvas();
5253

53-
var version, print, arange, __name__, type, ρσ_ls, c;
54+
var version, print, arange, __name__, type, ρσ_ls, running, box_object, cone_object, pyramid_object, cylinder_object, col, currentobject, cbutton, sl, wt, r1, r2, dt;
5455
version = ρσ_list_decorate([ "3.2", "glowscript" ]);
5556
Array.prototype['+'] = function(r) {return this.concat(r)}
5657
Array.prototype['*'] = function(r) {return __array_times_number(this, r)}
@@ -63,15 +64,222 @@
6364

6465
strings();
6566
"2";
66-
c = ρσ_interpolate_kwargs.call(this, box, [ρσ_desugar_kwargs({texture: (function(){
67-
var ρσ_d = ρσ_dict();
68-
ρσ_d["file"] = textures.stones
69-
ρσ_d["bumpmap"] = bumpmaps.stones
70-
//ρσ_d.set("file", textures.stones);
71-
//ρσ_d.set("bumpmap", bumpmaps.stones);
72-
console.log(ρσ_d)
73-
return ρσ_d;
74-
}).call(this)})]);
67+
scene.width = 350;
68+
"3";
69+
scene.height = 300;
70+
"4";
71+
scene.range = 1.3;
72+
"5";
73+
scene.title = "Widgets (buttons, etc.)\n";
74+
"7";
75+
running = true;
76+
"9";
77+
async function Run(b) {
78+
"10";
79+
"11";
80+
running = !running;
81+
"12";
82+
if (running) {
83+
b.text = "Pause";
84+
} else {
85+
b.text = "Run";
86+
}
87+
};
88+
if (!Run.__argnames__) Object.defineProperties(Run, {
89+
__argnames__ : {value: ["b"]},
90+
__module__ : {value: null}
91+
});
92+
93+
"15";
94+
ρσ_interpolate_kwargs.call(this, button, [ρσ_desugar_kwargs({text: "Pause", pos: scene.title_anchor, bind: Run})]);
95+
"17";
96+
box_object = ρσ_interpolate_kwargs.call(this, box, [ρσ_desugar_kwargs({visible: true})]);
97+
"18";
98+
cone_object = ρσ_interpolate_kwargs.call(this, cone, [ρσ_desugar_kwargs({visible: false, radius: .5})]);
99+
"19";
100+
pyramid_object = ρσ_interpolate_kwargs.call(this, pyramid, [ρσ_desugar_kwargs({visible: false})]);
101+
"20";
102+
cylinder_object = ρσ_interpolate_kwargs.call(this, cylinder, [ρσ_desugar_kwargs({visible: false, radius: .5})]);
103+
"22";
104+
col = color.cyan;
105+
"23";
106+
currentobject = box_object;
107+
"24";
108+
currentobject.color = col;
109+
"26";
110+
async function Color(c) {
111+
"27";
112+
"28";
113+
if (col.equals(color.cyan)) {
114+
"29";
115+
currentobject.color = col = color.red;
116+
"30";
117+
c.text = "<b>Cyan<\/b>";
118+
"31";
119+
c.color = color.cyan;
120+
"32";
121+
c.background = color.red;
122+
"33";
123+
r1.checked = false;
124+
"34";
125+
r2.checked = true;
126+
"35";
127+
} else {
128+
"36";
129+
currentobject.color = col = color.cyan;
130+
"37";
131+
c.text = "<b>Red</b>";
132+
"38";
133+
c.color = color.red;
134+
"39";
135+
c.background = color.cyan;
136+
"40";
137+
r1.checked = true;
138+
"41";
139+
r2.checked = false;
140+
}
141+
};
142+
if (!Color.__argnames__) Object.defineProperties(Color, {
143+
__argnames__ : {value: ["c"]},
144+
__module__ : {value: null}
145+
});
146+
147+
"43";
148+
async function cc(c) {
149+
"44";
150+
"45";
151+
if (col.equals(color.cyan)) {
152+
"46";
153+
currentobject.color = col = color.red;
154+
"47";
155+
cbutton.text = "<b>Cyan</b>";
156+
"48";
157+
cbutton.color = color.cyan;
158+
"49";
159+
cbutton.background = color.red;
160+
"50";
161+
} else {
162+
"51";
163+
currentobject.color = col = color.cyan;
164+
"52";
165+
cbutton.text = "<b>Red</b>";
166+
"53";
167+
cbutton.color = color.red;
168+
"54";
169+
cbutton.background = color.cyan;
170+
}
171+
};
172+
if (!cc.__argnames__) Object.defineProperties(cc, {
173+
__argnames__ : {value: ["c"]},
174+
__module__ : {value: null}
175+
});
176+
177+
"56";
178+
cbutton = ρσ_interpolate_kwargs.call(this, button, [ρσ_desugar_kwargs({text: "<b>Red</b>", color: color.red, background: color.cyan, pos: scene.title_anchor, bind: Color})]);
179+
"58";
180+
scene.caption = "Vary the rotation speed: \n\n";
181+
"60";
182+
async function setspeed(s) {
183+
"61";
184+
wt.text = "{:1.2f}".format(s.value);
185+
};
186+
if (!setspeed.__argnames__) Object.defineProperties(setspeed, {
187+
__argnames__ : {value: ["s"]},
188+
__module__ : {value: null}
189+
});
190+
191+
"63";
192+
sl = ρσ_interpolate_kwargs.call(this, slider, [ρσ_desugar_kwargs({min: .3, max: 3, value: 1.5, length: 220, bind: setspeed, right: 15})]);
193+
"65";
194+
wt = ρσ_interpolate_kwargs.call(this, wtext, [ρσ_desugar_kwargs({text: "{:1.2f}".format(sl.value)})]);
195+
"67";
196+
scene.append_to_caption(" radians/s\n");
197+
"69";
198+
r1 = ρσ_interpolate_kwargs.call(this, radio, [ρσ_desugar_kwargs({bind: cc, checked: true, text: "Cyan", name: "rads"})]);
199+
"71";
200+
scene.append_to_caption(" ");
201+
"73";
202+
async function M(m) {
203+
var ρσ_ls, op, currentaxis, val;
204+
"74";
205+
"75";
206+
op = currentobject.opacity;
207+
"76";
208+
currentaxis = currentobject.axis;
209+
"77";
210+
currentobject.visible = false;
211+
"78";
212+
val = m.selected;
213+
"79";
214+
if ((val === "box" || typeof val === "object" && ρσ_equals(val, "box"))) {
215+
"80";
216+
currentobject = box_object;
217+
"81";
218+
} else if ((val === "cone" || typeof val === "object" && ρσ_equals(val, "cone"))) {
219+
"82";
220+
currentobject = cone_object;
221+
"83";
222+
} else if ((val === "pyramid" || typeof val === "object" && ρσ_equals(val, "pyramid"))) {
223+
"84";
224+
currentobject = pyramid_object;
225+
"85";
226+
} else if ((val === "cylinder" || typeof val === "object" && ρσ_equals(val, "cylinder"))) {
227+
"86";
228+
currentobject = cylinder_object;
229+
}
230+
"87";
231+
currentobject.color = col;
232+
"88";
233+
currentobject.axis = currentaxis;
234+
"89";
235+
currentobject.visible = true;
236+
"90";
237+
currentobject.opacity = op;
238+
};
239+
if (!M.__argnames__) Object.defineProperties(M, {
240+
__argnames__ : {value: ["m"]},
241+
__module__ : {value: null}
242+
});
243+
244+
"92";
245+
ρσ_interpolate_kwargs.call(this, menu, [ρσ_desugar_kwargs({choices: ρσ_list_decorate([ "Choose an object", "box", "cone", "pyramid", "cylinder" ]), index: 0, bind: M})]);
246+
"94";
247+
scene.append_to_caption("\n");
248+
"96";
249+
r2 = ρσ_interpolate_kwargs.call(this, radio, [ρσ_desugar_kwargs({bind: cc, text: "Red", name: "rads"})]);
250+
"98";
251+
scene.append_to_caption(" ");
252+
"100";
253+
async function transparency(b) {
254+
"101";
255+
if (b.checked) {
256+
"102";
257+
currentobject.opacity = .5;
258+
"103";
259+
} else {
260+
"104";
261+
currentobject.opacity = 1;
262+
}
263+
};
264+
if (!transparency.__argnames__) Object.defineProperties(transparency, {
265+
__argnames__ : {value: ["b"]},
266+
__module__ : {value: null}
267+
});
268+
269+
"106";
270+
ρσ_interpolate_kwargs.call(this, checkbox, [ρσ_desugar_kwargs({bind: transparency, text: "Transparent"})]);
271+
"108";
272+
dt = .01;
273+
"109";
274+
while (true) {
275+
"110";
276+
(await rate(1["/"](dt)));
277+
"111";
278+
if (running) {
279+
"112";
280+
ρσ_interpolate_kwargs.call(currentobject, currentobject.rotate, [ρσ_desugar_kwargs({angle: sl.value["*"](dt), axis: vector(0, 1, 0)})]);
281+
}
282+
}
75283
};
76284
if (!__main__.__module__) Object.defineProperties(__main__, {
77285
__module__ : {value: null}

test_run_in_glowscript.html

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)