|
1 |
| -<<div id="glowscript" class="glowscript"> |
| 1 | +<div id="glowscript" class="glowscript"> |
2 | 2 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
3 | 3 | <link type="text/css" href="css/redmond/2.1/jquery-ui.custom.css" rel="stylesheet" />
|
4 | 4 | <link type="text/css" href="css/ide.css" rel="stylesheet" />
|
|
11 | 11 | // START JAVASCRIPT
|
12 | 12 | ;(function() {;
|
13 | 13 | var ρσ_modules = {};
|
| 14 | +var running, col, currentobject; |
14 | 15 | ρσ_modules.pythonize = {};
|
15 | 16 |
|
16 | 17 | (function(){
|
|
50 | 51 | var display = canvas;
|
51 | 52 | var scene = canvas();
|
52 | 53 |
|
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; |
54 | 55 | version = ρσ_list_decorate([ "3.2", "glowscript" ]);
|
55 | 56 | Array.prototype['+'] = function(r) {return this.concat(r)}
|
56 | 57 | Array.prototype['*'] = function(r) {return __array_times_number(this, r)}
|
|
63 | 64 |
|
64 | 65 | strings();
|
65 | 66 | "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 | + } |
75 | 283 | };
|
76 | 284 | if (!__main__.__module__) Object.defineProperties(__main__, {
|
77 | 285 | __module__ : {value: null}
|
|
0 commit comments