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

    Click :ref:`here <sphx_glr_download_auto_tutorials_01_introductory_viz_texture.py>` to download the full example code
.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_tutorials_01_introductory_viz_texture.py:


===============
Sphere Texture
===============
In this tutorial, we will show how to create a sphere with a texture.


.. code-block:: default


    import numpy as np
    from fury import window, actor, utils, primitive, io
    from fury.data import read_viz_textures, fetch_viz_textures







Create a scene to start.


.. code-block:: default


    scene = window.Scene()







Load an image (png, bmp, jpeg or jpg) using ``io.load_image``. In this
example, we will use ``read_viz_textures`` to access an image of the
Earth's surface from the fury Github after using ''fetch_viz_textures()''
to download the available textures.


.. code-block:: default


    fetch_viz_textures()
    filename = read_viz_textures("1_earth_8k.jpg")
    image = io.load_image(filename)





.. rst-class:: sphx-glr-script-out

 Out:

 .. code-block:: none

    Dataset is already in place. If you want to fetch it again please first remove the folder /Users/koudoro/.fury/textures 



Next, use ``actor.texture_on_sphere`` to add a sphere with the texture from
your loaded image to the already existing scene.
To add a texture to your scene as visualized on a plane, use
``actor.texture`` instead.


.. code-block:: default


    scene.add(actor.texture_on_sphere(image))







Lastly, record the scene, or set interactive to True if you would like to
manipulate your new sphere.


.. code-block:: default


    interactive = False
    if interactive:
        window.show(scene, size=(600, 600), reset_camera=False)
    window.record(scene, size=(900, 768), out_path="viz_texture.png")



.. image:: /auto_tutorials/01_introductory/images/sphx_glr_viz_texture_001.png
    :class: sphx-glr-single-img





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

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


.. _sphx_glr_download_auto_tutorials_01_introductory_viz_texture.py:


.. only :: html

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



  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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


.. only:: html

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

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