|
1 | 1 | import numpy as np
|
2 | 2 | import fastplotlib as fpl
|
3 |
| - |
| 3 | +from fastplotlib.ui import DebugWindow |
| 4 | +import pygfx |
| 5 | +from icecream import ic |
4 | 6 |
|
5 | 7 | xs = np.linspace(0, 10 * np.pi, 1000)
|
6 | 8 | ys = np.sin(xs)
|
|
16 | 18 | fig.show(maintain_aspect=False)
|
17 | 19 | fig[0, 0].auto_scale(zoom=0.4)
|
18 | 20 |
|
19 |
| -rs = fig[0, 0].add_reference_space(scale=(1, 500, 1)) |
| 21 | +rs = fig[0, 0].add_reference_frame( |
| 22 | + scale=(1, 500, 1), |
| 23 | +) |
20 | 24 | l2 = fig[0, 0].add_line(l2, reference_space=rs, colors="r")
|
21 | 25 | l2.add_axes(rs)
|
22 |
| -l2.axes.y.line.material.color = "r" |
| 26 | +l2.axes.y.line.material.color = "m" |
| 27 | + |
| 28 | + |
| 29 | +@fig.renderer.add_event_handler("key_down") |
| 30 | +def change_y_scale(ev: pygfx.KeyboardEvent): |
| 31 | + if ev.key != "1": |
| 32 | + return |
| 33 | + |
| 34 | + rs.controller.remove_camera(rs.camera) |
| 35 | + rs.controller.add_camera(rs.camera, include_state={"height"}) |
| 36 | + |
| 37 | + fig[0, 0].controller.enabled = False |
| 38 | + |
| 39 | + |
| 40 | +@fig.renderer.add_event_handler("key_down") |
| 41 | +def change_y_scale(ev: pygfx.KeyboardEvent): |
| 42 | + if ev.key != "0": |
| 43 | + return |
| 44 | + |
| 45 | + rs.controller.remove_camera(rs.camera) |
| 46 | + rs.controller.add_camera(rs.camera) |
| 47 | + fig[0, 0].controller.enabled = True |
| 48 | + |
| 49 | + |
| 50 | +debug_objs = [ |
| 51 | + fig[0, 0].camera.get_state, |
| 52 | + rs.camera.get_state |
| 53 | +] |
| 54 | + |
| 55 | +debug_window = DebugWindow(debug_objs) |
| 56 | +fig.add_gui(debug_window) |
| 57 | + |
23 | 58 |
|
24 | 59 | fpl.loop.run()
|
0 commit comments