.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/feature_demo/line_basic.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr__gallery_feature_demo_line_basic.py: Line Drawing ============ Some basic line drawing. .. GENERATED FROM PYTHON SOURCE LINES 8-51 .. image-sg:: /_gallery/feature_demo/images/sphx_glr_line_basic_001.png :alt: line basic :srcset: /_gallery/feature_demo/images/sphx_glr_line_basic_001.png :class: sphx-glr-single-img .. code-block:: default import numpy as np from wgpu.gui.auto import WgpuCanvas, run import pygfx as gfx canvas = WgpuCanvas() renderer = gfx.WgpuRenderer(canvas) renderer_svg = gfx.SvgRenderer(640, 480, "~/line.svg") scene = gfx.Scene() positions = [[200 + np.sin(i) * i * 6, 200 + np.cos(i) * i * 6, 0] for i in range(20)] positions += [[np.nan, np.nan, np.nan]] positions += [[400 - np.sin(i) * i * 6, 200 + np.cos(i) * i * 6, 0] for i in range(20)] positions += [[np.nan, np.nan, np.nan]] positions += [ [450, 400, 0], [375, 400, 0], [300, 400, 0], [400, 370, 0], [300, 340, 0], ] # Spiral away in z (to make the depth buffer less boring) for i in range(len(positions)): positions[i][2] = i line = gfx.Line( gfx.Geometry(positions=positions), gfx.LineMaterial(thickness=12.0, color=(0.8, 0.7, 0.0)), ) scene.add(line) camera = gfx.OrthographicCamera(600, 500) camera.local.position = (300, 250, 0) controller = gfx.PanZoomController(camera, register_events=renderer) if __name__ == "__main__": renderer_svg.render(scene, camera) canvas.request_draw(lambda: renderer.render(scene, camera)) run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.214 seconds) .. _sphx_glr_download__gallery_feature_demo_line_basic.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: line_basic.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: line_basic.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_