Skip to content

Commit

Permalink
fix: update transfer function example
Browse files Browse the repository at this point in the history
  • Loading branch information
seankmartin committed Apr 19, 2024
1 parent 3448c2f commit 79068f3
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions examples/single_data_point_transfer_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,31 @@
launch_nglancer,
open_browser,
)
from neuroglancer_utils.layer_utils import add_render_panel

from time import sleep


def colormap_version(viewer):
shader = """
#uicontrol invlerp normalized
#uicontrol transferFunction colormap
void main() {
emitRGBA(colormap());
}
"""
shaderControls = {
"normalized": {
"range": [0, 100],
"window": [0, 100],
"channel": [],
},
"colormap": {
"controlPoints": [
{"input": 0, "color": "#000000", "opacity": 0.0},
{"input": 84, "color": "#ffffff", "opacity": 1.0},
],
"range": [100, 0],
"controlPoints": [[0, "#000000", 0.0], [84, "#ffffff", 1.0]],
"window": [0, 100],
"channel": [],
"color": "#ff00ff",
}
"defaultColor": "#ff00ff",
},
}
with viewer.txn() as s:
s.dimensions = neuroglancer.CoordinateSpace(
Expand All @@ -39,6 +43,7 @@ def colormap_version(viewer):
dimensions=s.dimensions,
data=np.full(shape=(1, 1), dtype=np.uint32, fill_value=42),
),
panels=[add_render_panel()],
),
visible=True,
shader=shader,
Expand All @@ -57,6 +62,11 @@ def colormap_version(viewer):
sleep(2)
colormap_version(viewer)

with viewer.txn() as s:
layer = s.layers[0]
print(layer.shader_controls["normalized"])
print(layer.shader_controls["colormap"])

# inp = input("Press enter when ready to change the shader controls...")
# with viewer.txn() as s:
# layer = s.layers[0]
Expand Down

0 comments on commit 79068f3

Please sign in to comment.