Skip to content

Commit dc0540f

Browse files
committed
feat: add example for settings
1 parent 8d71722 commit dc0540f

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

examples/settings.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import neuroglancer
2+
import numpy as np
3+
4+
from neuroglancer_utils.viewer_utils import (
5+
launch_nglancer,
6+
open_browser,
7+
)
8+
9+
from time import sleep
10+
11+
12+
def add_image_layer(state):
13+
data = np.full(shape=(10,) * 3, fill_value=255, dtype=np.uint8)
14+
dimensions = neuroglancer.CoordinateSpace(
15+
names=["x", "y", "z"], units="nm", scales=[1, 1, 1]
16+
)
17+
local_volume = neuroglancer.LocalVolume(data, dimensions)
18+
state.layers["image"] = neuroglancer.ImageLayer(
19+
source=local_volume,
20+
volume_rendering=True,
21+
shader="""
22+
void main() {
23+
emitRGBA(vec4(1.0, 1.0, 1.0, 0.001));
24+
}
25+
""",
26+
)
27+
state.show_axis_lines = False
28+
state.projection_scale = 1e-8
29+
state.position = [5, 5, 5]
30+
state.showSlices = True
31+
state.hideCrossSectionBackground3D = True
32+
33+
34+
if __name__ == "__main__":
35+
viewer = launch_nglancer()
36+
open_browser(viewer, hang=False)
37+
sleep(2)
38+
39+
with viewer.txn() as s:
40+
add_image_layer(s)

0 commit comments

Comments
 (0)