Spaces:
Sleeping
Sleeping
kolibril13
commited on
Commit
•
7e5c044
1
Parent(s):
04ad805
add start question
Browse files- pages/01_molecule.ipynb +50 -38
pages/01_molecule.ipynb
CHANGED
@@ -12,46 +12,58 @@
|
|
12 |
"\n",
|
13 |
"light_position = solara.reactive(3)\n",
|
14 |
"\n",
|
|
|
|
|
|
|
|
|
15 |
"@solara.component\n",
|
16 |
"def Page():\n",
|
17 |
-
" solara.
|
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 |
"\n",
|
56 |
"Page()"
|
57 |
]
|
|
|
12 |
"\n",
|
13 |
"light_position = solara.reactive(3)\n",
|
14 |
"\n",
|
15 |
+
"\n",
|
16 |
+
"\n",
|
17 |
+
"start_button = solara.reactive(False)\n",
|
18 |
+
"\n",
|
19 |
"@solara.component\n",
|
20 |
"def Page():\n",
|
21 |
+
" checkbox = solara.Checkbox(label=\"Start Rendering?\", value=start_button)\n",
|
22 |
+
" if not start_button.value:\n",
|
23 |
+
" solara.Warning(\"Rendering is off, you might want to turn it on\")\n",
|
24 |
+
" else:\n",
|
25 |
+
" solara.Success(\"Rendering started. Takes about 10 Seconds\")\n",
|
26 |
+
"\n",
|
27 |
+
"\n",
|
28 |
+
"\n",
|
29 |
+
" solara.SliderInt(\"Pos:\", value=light_position, min=0, max=10)\n",
|
30 |
+
" \n",
|
31 |
+
" # Delete all mesh objects from the scene\n",
|
32 |
+
" bpy.ops.object.select_all(action=\"DESELECT\")\n",
|
33 |
+
" bpy.ops.object.select_by_type(type=\"MESH\")\n",
|
34 |
+
" bpy.ops.object.delete()\n",
|
35 |
+
" \n",
|
36 |
+
" # Add a torus\n",
|
37 |
+
" bpy.ops.mesh.primitive_torus_add(\n",
|
38 |
+
" major_radius=1.5,\n",
|
39 |
+
" minor_radius=0.75,\n",
|
40 |
+
" major_segments=48 * 4,\n",
|
41 |
+
" minor_segments=12 * 4,\n",
|
42 |
+
" align=\"WORLD\",\n",
|
43 |
+
" location=(0, 1, 1),\n",
|
44 |
+
" )\n",
|
45 |
+
" \n",
|
46 |
+
" # # Light\n",
|
47 |
+
" light = bpy.data.objects[\"Light\"]\n",
|
48 |
+
" light.location = (light_position.value, 0, 2) # Position the light\n",
|
49 |
+
" \n",
|
50 |
+
" # # Camera\n",
|
51 |
+
" camera = bpy.data.objects[\"Camera\"]\n",
|
52 |
+
" camera.location = (5, -3, 4)\n",
|
53 |
+
" camera.data.dof.use_dof = True\n",
|
54 |
+
" camera.data.dof.focus_distance = 5\n",
|
55 |
+
" camera.data.dof.aperture_fstop = 4\n",
|
56 |
+
" \n",
|
57 |
+
" # # Render\n",
|
58 |
+
" path = \"test.png\"\n",
|
59 |
+
" bpy.context.scene.render.resolution_x = 400\n",
|
60 |
+
" bpy.context.scene.render.resolution_y = 200\n",
|
61 |
+
" bpy.context.scene.render.image_settings.file_format = \"PNG\"\n",
|
62 |
+
" bpy.context.scene.render.filepath = path\n",
|
63 |
+
" bpy.ops.render.render(write_still=True)\n",
|
64 |
+
" bpy.data.images[\"Render Result\"].save_render(filepath=bpy.context.scene.render.filepath)\n",
|
65 |
+
" \n",
|
66 |
+
" display(Image(path))\n",
|
67 |
"\n",
|
68 |
"Page()"
|
69 |
]
|