| 1 |
""" |
| 2 |
.. _blurring_example: |
| 3 |
|
| 4 |
Blurring |
| 5 |
~~~~~~~~ |
| 6 |
This example shows how you can use :func:`add_blurring |
| 7 |
<pyvista.Plotter.add_blurring>` to blur a plot, or use |
| 8 |
:func:`enable_depth_of_field <pyvista.Plotter.enable_depth_of_field>` |
| 9 |
to highlight part of your plot. |
| 10 |
|
| 11 |
""" |
| 12 |
|
| 13 |
import pyvista as pv |
| 14 |
|
| 15 |
# sphinx_gallery_start_ignore |
| 16 |
# blurring does not work in interactive examples probably because interactive |
| 17 |
# plot resets some properties of the camera. |
| 18 |
PYVISTA_GALLERY_FORCE_STATIC_IN_DOCUMENT = True |
| 19 |
# sphinx_gallery_end_ignore |
| 20 |
|
| 21 |
# %% |
| 22 |
# Create several spheres |
| 23 |
# ~~~~~~~~~~~~~~~~~~~~~~ |
| 24 |
|
| 25 |
# We use a uniform grid here simply to create equidistantly spaced points for |
| 26 |
# our glyph filter |
| 27 |
grid = pv.ImageData(dimensions=(4, 4, 4), spacing=(1, 1, 1)) |
| 28 |
|
| 29 |
spheres = grid.glyph(geom=pv.Sphere(), scale=False, orient=False) |
| 30 |
|
| 31 |
|
| 32 |
# %% |
| 33 |
# Blur the plot |
| 34 |
# ~~~~~~~~~~~~~ |
| 35 |
# Add a few blur passes to blur the plot |
| 36 |
|
| 37 |
pl = pv.Plotter() |
| 38 |
pl.add_mesh(spheres, smooth_shading=True, show_edges=True) |
| 39 |
pl.add_blurring() |
| 40 |
pl.add_blurring() |
| 41 |
pl.add_blurring() |
| 42 |
pl.camera.zoom(1.5) |
| 43 |
pl.enable_anti_aliasing('ssaa') |
| 44 |
pl.show() |
| 45 |
|
| 46 |
|
| 47 |
# %% |
| 48 |
# Note how this is different than selectively blurring part of the mesh behind |
| 49 |
# the focal plane |
| 50 |
|
| 51 |
pl = pv.Plotter() |
| 52 |
pl.add_mesh(spheres, smooth_shading=True, show_edges=True) |
| 53 |
pl.enable_depth_of_field() |
| 54 |
pl.camera.zoom(1.5) |
| 55 |
pl.enable_anti_aliasing('ssaa') |
| 56 |
pl.show() |
| 57 |
# %% |
| 58 |
# .. tags:: plot |