from k3d import K3D
from ipywidgets import interact, FloatSlider
view_matrix = (
0.9, 0.1, -0.4, 0.0,
0.0, 0.9, 0.4, 0.0,
0.4, -0.4, 0.9, 0.0,
0.0, 0.0, 0.0, 1.0
)
positions = (
-10.0, -15.0, 0.0,
-10.0, 5.0, 0.0,
10.0, 5.0, 0.0,
-10.0, -15.0, 0.0,
10.0, -15.0, 0.0,
-10.0, 5.0, 0.0,
0.0, 15.0, 0.0,
10.0, 5.0, 0.0,
10.0, -15.0, 0.0
)
line = K3D.line((0, 0, 0, 5, 10, 15))
lines = K3D.line(positions, view_matrix=view_matrix, color=0xff0000, width=2.5) + line
plot = K3D(antialias=True, camera_auto_fit=True)
plot += lines
plot.display()
# plot.camera_auto_fit = False # uncomment in order to keep camera at fixed distance on changes
@interact(width=FloatSlider(value=line.line_width, min=0.1, max=4.0, step=0.1))
def update(width):
line.line_width = width