taichi.ui.window
#
- class taichi.ui.window.Window(name, res, vsync=False, show_window=True, fps_limit=1000, pos=(100, 100))#
The window class.
- Parameters:
name (str) – Window title.
res (tuple[int]) – resolution (width, height) of the window, in pixels.
vsync (bool) – whether or not vertical sync should be enabled.
show_window (bool) – where or not display the window after initialization.
pos (tuple[int]) – position (left to right, up to bottom) of the window which origins from the left-top of your main screen, in pixels.
- destroy(self)#
Destroy this window. The window will be unavailable then.
- get_canvas(self)#
Returns a canvas handle. See :class`~taichi.ui.canvas.Canvas`
- get_cursor_pos(self)#
Get current cursor position, in the range [0, 1] x [0, 1].
- get_depth_buffer(self, depth)#
- fetch the depth information of current scene to ti.ndarray/ti.field
(support copy from vulkan to cuda/cpu which is a faster version)
- Parameters:
depth (ti.ndarray/ti.field) – [window_width, window_height] carries depth information.
- get_depth_buffer_as_numpy(self)#
Get the depth information of current scene to numpy array.
- Returns:
[width, height] with (0.0~1.0) float-format.
- Return type:
2d numpy array
- get_event(self, tag=None)#
Returns whether or not a event that matches tag has occurred.
If tag is None, then no filters are applied. If this function returns True, the event property of the window will be set to the corresponding event.
- get_events(self, tag=None)#
Get the current list of unprocessed events.
- Parameters:
tag (str) – A tag used for filtering events. If it is None, then all events are returned.
- get_gui(self)#
Returns a IMGUI handle. See :class`~taichi.ui.ui.Gui`
- get_image_buffer_as_numpy(self)#
Get the window content to numpy array.
- Returns:
[width, height, channels] with (0.0~1.0) float-format color.
- Return type:
3d numpy array
- get_window_shape(self)#
Return the shape of window. :returns: (width, height) :rtype: tuple
- is_pressed(self, *keys)#
Checks if any of a set of specified keys is pressed.
- Parameters:
keys (list[
constants
]) – The keys to be matched.- Returns:
True if any key among keys is pressed, else False.
- Return type:
bool
- save_image(self, filename)#
Save the window content to an image file.
- Parameters:
filename (str) – output filename.
- show(self)#
Display this window.