You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| `"position"` | Vector2Int | The anchor position of the UI element in pixels. x is lateral, y is vertical. The anchor position is not the true pixel position. For example, if the anchor is {"x": 0, "y": 0} and the position is {"x": 0, "y": 0}, the UI element will be in the bottom-left of the screen. | {"x": 0, "y": 0} |
11087
+
| `"id"` | int | The unique ID of the UI element. | |
11088
+
| `"canvas_id"` | int | The unique ID of the UI canvas. | 0 |
To move a UI image or text, call `ui.set_position(id, position)`, which sends [`set_ui_element_position`](../../api/command_api.md#set_ui_element_position).
262
+
263
+
In this example, an image with a "mask" is added to the scene. This image is larger than the screen size so that it can be moved while still covering the entire screen:
264
+
265
+
```python
266
+
from io import BytesIO
267
+
fromPILimport Image, ImageDraw
268
+
from tdw.controller import Controller
269
+
from tdw.add_ons.third_person_camera import ThirdPersonCamera
270
+
from tdw.add_ons.ui importUI
271
+
from tdw.add_ons.image_capture import ImageCapture
272
+
from tdw.backend.paths importEXAMPLE_CONTROLLER_OUTPUT_PATH
273
+
274
+
275
+
c = Controller()
276
+
# Add the UI add-on and the camera.
277
+
camera = ThirdPersonCamera(position={"x": 0, "y": 0, "z": -1.2},
-[anchors_and_pivots.py](https://github.com/threedworld-mit/tdw/blob/master/Python/example_controllers/ui/anchors_and_pivots.py) Anchor text to the top-left corner of the screen.
255
354
-[image.py](https://github.com/threedworld-mit/tdw/blob/master/Python/example_controllers/ui/image.py) Add a UI image.
355
+
-[mask.py](https://github.com/threedworld-mit/tdw/blob/master/Python/example_controllers/ui/mask.py) Create black background with a circular "hole" in it and move the image around.
0 commit comments