Commit 0d8a627e authored by Julian Stirling's avatar Julian Stirling 🐧

Interactive layer view

parent a8d3a419
This diff is collapsed.
import swomppy as sp
from IPython.display import HTML,display
import pyx
pyx.unit.set(defaultunit='mm')
import ipywidgets as widgets
from ipywidgets import interactive
def showsvg(canvas):
canvas.writeSVGfile('/tmp/1.svg')
display(HTML(open(f'/tmp/1.svg').read()))
def showpath(path):
print_plot = pyx.canvas.canvas()
print_plot.stroke(path.np,[pyx.color.rgb.blue, pyx.style.linewidth(0.3)])
if type(path) is sp.spath:
path = [path]
for p in path:
print_plot.stroke(p.np,[pyx.color.rgb.blue, pyx.style.linewidth(0.3)])
showsvg(print_plot)
def showlayer(layer):
......@@ -18,4 +24,10 @@ def showlayer(layer):
print_plot.stroke(layer.brimPaths.as_normpath(),[pyx.color.rgb.blue, pyx.style.linewidth(0.3)])
print_plot.stroke(layer.allShells.as_normpath(),[pyx.color.rgb.green, pyx.style.linewidth(0.3)])
print_plot.stroke(layer.fillPaths.as_normpath(),[pyx.color.rgb.red, pyx.style.linewidth(0.3)])
showsvg(print_plot)
\ No newline at end of file
showsvg(print_plot)
def interactiveview(layers):
def showing(n):
showlayer(layers[n])
int_view = interactive(showing,n=widgets.IntSlider(min=-0,max=len(layers)-1,step=1,value=10))
display(int_view)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment