{ "cells": [ { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "import k3d\n", "from ipywidgets import interact, IntSlider" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model_matrix = [\n", " 0.9, 0.1, -0.4, 0.0,\n", " 0.0, 0.9, 0.4, 0.0,\n", " 0.4, -0.4, 0.9, 0.0,\n", " 0.0, 0.0, 0.0, 1.0\n", "]\n", "\n", "vertices = [\n", " -10.0, -15.0, 0.0,\n", " -10.0, 5.0, 0.0,\n", " 10.0, 5.0, 0.0,\n", " -10.0, -15.0, 0.0,\n", " 10.0, -15.0, 0.0,\n", " -10.0, 5.0, 0.0,\n", " 0.0, 15.0, 0.0,\n", " 10.0, 5.0, 0.0,\n", " 10.0, -15.0, 0.0\n", "]\n", "\n", "line = k3d.line((0, 0, 0, 5, 10, 15), shader=\"simple\")\n", "lines = k3d.line(vertices, model_matrix=model_matrix, color=0xff0000, width=2.5, shader=\"simple\") + line\n", "\n", "plot = k3d.plot(antialias=True, camera_auto_fit=True)\n", "plot += lines\n", "#plot.display()" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "3c0bc865dd9342fabd39ca2740b55618", "version_major": 2, "version_minor": 0 }, "text/plain": [ "interactive(children=(IntSlider(value=255, description='color', max=16777215), Output()), _dom_classes=('widge…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# plot.camera_auto_fit = False # uncomment in order to keep camera at fixed distance on changes\n", "@interact(color=IntSlider(value=line.color, min=0, max=0xffffff))\n", "def update(color):\n", " line.color = color" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Not all implementations of WebGL support line width, this may not work:\n", "line.width = 5" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot -= line" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.objects" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot -= lines" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "2" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ipywidgets " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ipywidgets.version_info" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" }, "nbTranslate": { "displayLangs": [ "en", "pl" ], "hotkey": "alt-t", "langInMainMenu": true, "sourceLang": "pl", "targetLang": "en", "useGoogleTranslate": true } }, "nbformat": 4, "nbformat_minor": 4 }