
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/plot_logo.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_auto_examples_plot_logo.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_plot_logo.py:


Generate the splinebox logo
---------------------------

This example shows how the `S` of the splinebox logo is
constructed using a B3 spline.

.. GENERATED FROM PYTHON SOURCE LINES 8-52



.. image-sg:: /auto_examples/images/sphx_glr_plot_logo_001.png
   :alt: plot logo
   :srcset: /auto_examples/images/sphx_glr_plot_logo_001.png
   :class: sphx-glr-single-img





.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np
    import splinebox.basis_functions
    import splinebox.spline_curves

    points = np.array([[1.5, 1.5], [1, 2], [0, 2], [0, 1], [1, 1], [1, 0], [0, 0], [-0.5, 0.5]])
    points = points[:, ::-1]
    M = len(points)
    padded_points = np.concatenate(
        [
            np.array([[1.5, 1.5]]),
            points,
            np.array([[0.5, -0.5]]),
        ]
    )
    basis_function = splinebox.basis_functions.B3()
    spline = splinebox.spline_curves.Spline(M=M, basis_function=basis_function, closed=False, control_points=padded_points)

    t = np.linspace(0.8, M - 1.5, 100)

    vals = spline.eval(t)
    curvature = spline.curvature(t)
    normals = spline.normal(t)

    # You can limit the max height of the curvature comb using the factor d.
    max_comb_height = 0.3
    d = max_comb_height / np.max(np.abs(curvature))

    comb = vals + d * curvature[:, np.newaxis] * normals

    # color1 = "#f5bc47"
    color1 = "#568b22"
    color2 = "#568b22"
    linewidth1 = 3
    linewidth2 = 6

    plt.plot(comb[:, 1], comb[:, 0], label="Curvature comb", color=color1, linewidth=linewidth1)
    for p in range(len(comb)):
        plt.plot([vals[p, 1], comb[p, 1]], [vals[p, 0], comb[p, 0]], color=color1, linewidth=linewidth1)
    plt.plot(vals[:, 1], vals[:, 0], linewidth=linewidth2, color=color2)
    plt.gca().set_aspect("equal", "box")
    plt.savefig("box.pdf")
    plt.show()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 0.308 seconds)


.. _sphx_glr_download_auto_examples_plot_logo.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_logo.ipynb <plot_logo.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_logo.py <plot_logo.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_logo.zip <plot_logo.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
