Skip to content

Commit

Permalink
Merge pull request #273 from jcoady/jupyterlab4
Browse files Browse the repository at this point in the history
Added some demos from webvpython
  • Loading branch information
jcoady committed Mar 16, 2024
2 parents 4f6c952 + 2302c8a commit c147192
Show file tree
Hide file tree
Showing 7 changed files with 421 additions and 1 deletion.
1 change: 1 addition & 0 deletions Demos/CORS.ipynb
@@ -0,0 +1 @@
{"metadata":{"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.12.2","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":5,"nbformat":4,"cells":[{"id":"1ce368bf-81e1-4832-8f46-605e44d885f6","cell_type":"code","source":"from vpython import *\nscene = canvas() # This is needed in Jupyter notebook and lab to make programs easily rerunnable\nscene.range = 1\nscene.forward = vector(-1,-.5,-1)\nbox(texture=\"https://s3.amazonaws.com/glowscript/textures/flower_texture.jpg\")\n\ns = 'This illustrates the use of an image from another web site as a texture.\\n'\ns += 'This is an example of CORS, \"Cross-Origin Resource Sharing\".\\n'\nscene.caption = s\n\nscene.append_to_caption(\"\"\"\nTo rotate \"camera\", drag with right button or Ctrl-drag.\nTo zoom, drag with middle button or Alt/Option depressed, or use scroll wheel.\n On a two-button mouse, middle is left + right.\nTo pan left/right and up/down, Shift-drag.\nTouch screen: pinch/extend to zoom, swipe or two-finger rotate.\"\"\")","metadata":{"trusted":false},"outputs":[{"metadata":{},"output_type":"display_data","data":{"text/html":"<div id=\"glowscript\" class=\"glowscript\"></div>","text/plain":"<IPython.core.display.HTML object>"}},{"metadata":{},"output_type":"display_data","data":{"application/javascript":"if (typeof Jupyter !== \"undefined\") { window.__context = { glowscript_container: $(\"#glowscript\").removeAttr(\"id\")};}else{ element.textContent = ' ';}","text/plain":"<IPython.core.display.Javascript object>"}},{"metadata":{},"output_type":"display_data","data":{"text/plain":"<IPython.core.display.HTML object>","text/html":"<div id=\"glowscript\" class=\"glowscript\"></div>"}},{"data":{"text/plain":"<IPython.core.display.Javascript object>","application/javascript":"if (typeof Jupyter !== \"undefined\") { window.__context = { glowscript_container: $(\"#glowscript\").removeAttr(\"id\")};}else{ element.textContent = ' ';}"},"metadata":{},"output_type":"display_data"}],"execution_count":1},{"id":"eeec5bc6-e4c1-4ca8-81af-d8a97c6ab412","cell_type":"code","source":"","metadata":{"trusted":false},"outputs":[],"execution_count":null}]}
1 change: 1 addition & 0 deletions Demos/Conch.ipynb
@@ -0,0 +1 @@
{"metadata":{"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"file_extension":".py","nbconvert_exporter":"python","codemirror_mode":{"name":"ipython","version":3},"name":"python","pygments_lexer":"ipython3","mimetype":"text/x-python","version":"3.12.1"}},"nbformat_minor":5,"nbformat":4,"cells":[{"id":"9c2f0c0c-4898-4122-9c2a-f0f77ea52094","cell_type":"code","source":"from vpython import *\nscene = canvas() # This is needed in Jupyter notebook and lab to make programs easily rerunnable\n# Kadir Haldenbilen, Feb. 2011\n\nscene.height = scene.width = 600\nscene.background = color.gray(0.7)\nscene.range = 3\nscene.ambient = 0.5*color.white\n\nscene.caption = \"\"\"To rotate \"camera\", drag with right button or Ctrl-drag.\nTo zoom, drag with middle button or Alt/Option depressed, or use scroll wheel.\n On a two-button mouse, middle is left + right.\nTo pan left/right and up/down, Shift-drag.\nTouch screen: pinch/extend to zoom, swipe or two-finger rotate.\"\"\"\n\ndef spiral(nloop=1, tightness=1.0, dir=1, scale=1):\n spr = []\n scale = []\n clrs = []\n zd = 0.01\n for t in range(1, 1024*nloop, 16):\n t *= 0.01\n x = tightness/10 * t * cos(t)*dir\n y = tightness/10 * t * sin(t)\n sc = sqrt(x*x+y*y)\n z = t/7\n spr.append(vector(x,y,z))\n clr = vector(z*cos(t), abs(sin(t)), abs(cos(t*2))).norm()\n clrs.append(clr)\n scale.append(sc)\n return spr, scale, clrs\n\npath, scale, clrs = spiral(nloop=2, tightness=0.8)\nelps = shapes.circle(radius=0.69, thickness=0.01)\n\nee = extrusion(shape=elps, path=path, color=clrs, scale=scale, texture=textures.rock)\nee.rotate(angle=pi/2)\nscene.center = ee.pos-vec(0,.5,0)\n\n","metadata":{"trusted":false},"outputs":[{"data":{"text/html":"<div id=\"glowscript\" class=\"glowscript\"></div>","text/plain":"<IPython.core.display.HTML object>"},"metadata":{},"output_type":"display_data"},{"metadata":{},"data":{"application/javascript":"if (typeof Jupyter !== \"undefined\") { window.__context = { glowscript_container: $(\"#glowscript\").removeAttr(\"id\")};}else{ element.textContent = ' ';}","text/plain":"<IPython.core.display.Javascript object>"},"output_type":"display_data"},{"data":{"text/plain":"<IPython.core.display.HTML object>","text/html":"<div id=\"glowscript\" class=\"glowscript\"></div>"},"metadata":{},"output_type":"display_data"},{"metadata":{},"output_type":"display_data","data":{"text/plain":"<IPython.core.display.Javascript object>","application/javascript":"if (typeof Jupyter !== \"undefined\") { window.__context = { glowscript_container: $(\"#glowscript\").removeAttr(\"id\")};}else{ element.textContent = ' ';}"}}],"execution_count":1},{"id":"d01c51ea-d6a6-4d7f-aac1-de28cf657c72","cell_type":"code","source":"","metadata":{"trusted":false},"outputs":[],"execution_count":null}]}

0 comments on commit c147192

Please sign in to comment.