@@ -45,7 +45,7 @@ def create_package_zip(module_name="webgpu"):
4545_id_counter = itertools .count ()
4646
4747
48- def _init_html (scene , width , height ):
48+ def _init_html (scene , width , height , flex = None ):
4949 from IPython .display import HTML , display
5050
5151 if isinstance (scene , Renderer ):
@@ -55,6 +55,10 @@ def _init_html(scene, width, height):
5555
5656 id_ = f"__webgpu_{ next (_id_counter )} _"
5757
58+ style = f"background-color: #d0d0d0; width: { width } px; height: { height } px;"
59+ if flex is not None :
60+ style += f" flex: { flex } ;"
61+
5862 display (
5963 HTML (
6064 f"""
@@ -63,7 +67,7 @@ def _init_html(scene, width, height):
6367 >
6468 <canvas
6569 id='{ id_ } canvas'
66- style='background-color: #d0d0d0; flex: 3; width: { width } px; height: { height } px; '
70+ style='{ style } '
6771 >
6872 </canvas>
6973 <div id='{ id_ } lilgui'
@@ -123,10 +127,15 @@ def _DrawHTML(
123127
124128def Draw (
125129 scene : Scene | list [Renderer ] | Renderer ,
126- width = 640 ,
127- height = 640 ,
130+ width : int | None = None ,
131+ height : int | None = None ,
128132):
129- scene , id_ = _init_html (scene , width , height )
133+ flex = 3 if width is None else None
134+
135+ width = width if width is not None else 640
136+ height = height if height is not None else 640
137+
138+ scene , id_ = _init_html (scene , width , height , flex )
130139 _draw_scene (scene , width , height , id_ )
131140 return scene
132141
0 commit comments