Ejemplo n.º 1
0
    def test_plot_hull_section_colours(self):
        """
        Test :func:`colour.plotting.section.plot_hull_section_colours`
        definition.
        """

        if not is_trimesh_installed:  # pragma: no cover
            return

        import trimesh

        vertices, faces, _outline = primitive_cube(1, 1, 1, 64, 64, 64)
        XYZ_vertices = RGB_to_XYZ(
            vertices["position"] + 0.5,
            RGB_COLOURSPACE_sRGB.whitepoint,
            RGB_COLOURSPACE_sRGB.whitepoint,
            RGB_COLOURSPACE_sRGB.matrix_RGB_to_XYZ,
        )
        hull = trimesh.Trimesh(XYZ_vertices, faces, process=False)

        figure, axes = plot_hull_section_colours(hull)

        self.assertIsInstance(figure, Figure)
        self.assertIsInstance(axes, Axes)

        figure, axes = plot_hull_section_colours(hull, axis="+x")

        self.assertIsInstance(figure, Figure)
        self.assertIsInstance(axes, Axes)

        figure, axes = plot_hull_section_colours(hull, axis="+y")

        self.assertIsInstance(figure, Figure)
        self.assertIsInstance(axes, Axes)
def RGB_colourspace_volume_visual(colourspace=PRIMARY_COLOURSPACE,
                                  colourspace_model=COLOURSPACE_MODEL,
                                  segments=16,
                                  wireframe=False):
    """
    Returns a RGB colourspace volume visual geometry formatted as *JSON*.

    Parameters
    ----------
    colourspace : unicode, optional
        RGB colourspace used to generate the visual geometry.
    colourspace_model : unicode, optional
        Colourspace model used to generate the visual geometry.
    segments : int, optional
        Segments count per side of the *box* used to generate the visual
        geometry.
    wireframe : bool, optional
        Whether the visual geometry must represent a wireframe visual.

    Returns
    -------
    unicode
        RGB colourspace volume visual geometry formatted as *JSON*.
    """

    colourspace = first_item(
        filter_RGB_colourspaces(re.escape(colourspace)).values())

    cube = conform_primitive_dtype(
        primitive_cube(width_segments=segments,
                       height_segments=segments,
                       depth_segments=segments))

    vertices = cube[0]['position'] + 0.5
    faces = colourspace_model_faces_reorder(np.reshape(cube[1], (-1, 1)),
                                            colourspace_model)
    RGB = cube[0]['colour']

    XYZ = RGB_to_XYZ(
        vertices,
        colourspace.whitepoint,
        colourspace.whitepoint,
        colourspace.matrix_RGB_to_XYZ,
    )
    vertices = colourspace_model_axis_reorder(
        XYZ_to_colourspace_model(
            XYZ,
            colourspace.whitepoint,
            colourspace_model,
        ), colourspace_model)

    return buffer_geometry(position=vertices, color=RGB, index=faces)
Ejemplo n.º 3
0
def plot_RGB_colourspace_section(
    colourspace: Union[RGB_Colourspace, str, Sequence[Union[RGB_Colourspace,
                                                            str]]],
    model: Union[Literal["CAM02LCD", "CAM02SCD", "CAM02UCS", "CAM16LCD",
                         "CAM16SCD", "CAM16UCS", "CIE XYZ", "CIE xyY",
                         "CIE Lab", "CIE Luv", "CIE UCS", "CIE UVW", "DIN99",
                         "Hunter Lab", "Hunter Rdab", "ICaCb", "ICtCp", "IPT",
                         "IgPgTg", "Jzazbz", "OSA UCS", "Oklab", "hdr-CIELAB",
                         "hdr-IPT", ], str, ] = "CIE xyY",
    axis: Union[Literal["+z", "+x", "+y"], str] = "+z",
    origin: Floating = 0.5,
    normalise: Boolean = True,
    show_section_colours: Boolean = True,
    show_section_contour: Boolean = True,
    **kwargs: Any,
) -> Tuple[plt.Figure, plt.Axes]:
    """
    Plot given *RGB* colourspace section colours along given axis and origin.

    Parameters
    ----------
    colourspace
        *RGB* colourspace of the *RGB* array. ``colourspace`` can be of any
        type or form supported by the
        :func:`colour.plotting.filter_RGB_colourspaces` definition.
    model
        Colourspace model, see :attr:`colour.COLOURSPACE_MODELS` attribute for
        the list of supported colourspace models.
    axis
        Axis the hull section will be normal to.
    origin
        Coordinate along ``axis`` at which to plot the hull section.
    normalise
        Whether to normalise ``axis`` to the extent of the hull along it.
    show_section_colours
        Whether to show the hull section colours.
    show_section_contour
        Whether to show the hull section contour.

    Other Parameters
    ----------------
    kwargs
        {:func:`colour.plotting.artist`,
        :func:`colour.plotting.render`,
        :func:`colour.plotting.section.plot_hull_section_colours`
        :func:`colour.plotting.section.plot_hull_section_contour`},
        See the documentation of the previously listed definitions.

    Returns
    -------
    :class:`tuple`
        Current figure and axes.

    Examples
    --------
    >>> from colour.utilities import is_trimesh_installed
    >>> if is_trimesh_installed:
    ...     plot_RGB_colourspace_section(
    ...         'sRGB', section_colours='RGB', section_opacity=0.15)
    ...     # doctest: +ELLIPSIS
    (<Figure size ... with 1 Axes>, <...AxesSubplot...>)

    .. image:: ../_static/Plotting_Plot_RGB_Colourspace_Section.png
        :align: center
        :alt: plot_RGB_colourspace_section
    """

    import trimesh

    settings: Dict[str, Any] = {"uniform": True}
    settings.update(kwargs)

    _figure, axes = artist(**settings)

    colourspace = cast(
        RGB_Colourspace,
        first_item(filter_RGB_colourspaces(colourspace).values()),
    )

    vertices, faces, _outline = primitive_cube(1, 1, 1, 64, 64, 64)
    XYZ_vertices = RGB_to_XYZ(
        vertices["position"] + 0.5,
        colourspace.whitepoint,
        colourspace.whitepoint,
        colourspace.matrix_RGB_to_XYZ,
    )
    hull = trimesh.Trimesh(XYZ_vertices, faces, process=False)

    if show_section_colours:
        settings = {"axes": axes}
        settings.update(kwargs)
        settings["standalone"] = False

        plot_hull_section_colours(hull, model, axis, origin, normalise,
                                  **settings)

    if show_section_contour:
        settings = {"axes": axes}
        settings.update(kwargs)
        settings["standalone"] = False

        plot_hull_section_contour(hull, model, axis, origin, normalise,
                                  **settings)

    title = (f"{colourspace.name} Section - "
             f"{f'{origin * 100}%' if normalise else origin} - "
             f"{model}")

    plane = MAPPING_AXIS_TO_PLANE[axis]

    labels = np.array(COLOURSPACE_MODELS_AXIS_LABELS[model])[as_int_array(
        colourspace_model_axis_reorder([0, 1, 2], model))]
    x_label, y_label = labels[plane[0]], labels[plane[1]]

    settings.update({
        "axes": axes,
        "standalone": True,
        "title": title,
        "x_label": x_label,
        "y_label": y_label,
    })
    settings.update(kwargs)

    return render(**settings)
Ejemplo n.º 4
0
    def test_primitive_cube(self):
        """
        Tests :func:`colour.geometry.primitives.primitive_cube`
        definition.
        """

        vertices, faces, outline = primitive_cube()
        np.testing.assert_almost_equal(
            vertices['position'],
            np.array([
                [-0.5, 0.5, -0.5],
                [0.5, 0.5, -0.5],
                [-0.5, -0.5, -0.5],
                [0.5, -0.5, -0.5],
                [-0.5, 0.5, 0.5],
                [0.5, 0.5, 0.5],
                [-0.5, -0.5, 0.5],
                [0.5, -0.5, 0.5],
                [0.5, -0.5, -0.5],
                [0.5, -0.5, 0.5],
                [-0.5, -0.5, -0.5],
                [-0.5, -0.5, 0.5],
                [0.5, 0.5, -0.5],
                [0.5, 0.5, 0.5],
                [-0.5, 0.5, -0.5],
                [-0.5, 0.5, 0.5],
                [-0.5, -0.5, 0.5],
                [-0.5, 0.5, 0.5],
                [-0.5, -0.5, -0.5],
                [-0.5, 0.5, -0.5],
                [0.5, -0.5, 0.5],
                [0.5, 0.5, 0.5],
                [0.5, -0.5, -0.5],
                [0.5, 0.5, -0.5],
            ]),
            decimal=7)

        np.testing.assert_almost_equal(
            vertices['uv'],
            np.array([
                [0, 1],
                [1, 1],
                [0, 0],
                [1, 0],
                [0, 1],
                [1, 1],
                [0, 0],
                [1, 0],
                [0, 1],
                [1, 1],
                [0, 0],
                [1, 0],
                [0, 1],
                [1, 1],
                [0, 0],
                [1, 0],
                [0, 1],
                [1, 1],
                [0, 0],
                [1, 0],
                [0, 1],
                [1, 1],
                [0, 0],
                [1, 0],
            ]),
            decimal=7)

        np.testing.assert_almost_equal(
            vertices['normal'],
            np.array([
                [0, 0, -1.],
                [0, 0, -1],
                [0, 0, -1],
                [0, 0, -1],
                [0, 0, 1],
                [0, 0, 1],
                [0, 0, 1],
                [0, 0, 1],
                [0, -1, 0],
                [0, -1, 0],
                [0, -1, 0],
                [0, -1, 0],
                [0, 1, 0],
                [0, 1, 0],
                [0, 1, 0],
                [0, 1, 0],
                [-1, 0, 0],
                [-1, 0, 0],
                [-1, 0, 0],
                [-1, 0, 0],
                [1, 0, 0],
                [1, 0, 0],
                [1, 0, 0],
                [1, 0, 0],
            ]),
            decimal=7)

        np.testing.assert_almost_equal(
            vertices['colour'],
            np.array([
                [0, 1, 0, 1],
                [1, 1, 0, 1],
                [0, 0, 0, 1],
                [1, 0, 0, 1],
                [0, 1, 1, 1],
                [1, 1, 1, 1],
                [0, 0, 1, 1],
                [1, 0, 1, 1],
                [1, 0, 0, 1],
                [1, 0, 1, 1],
                [0, 0, 0, 1],
                [0, 0, 1, 1],
                [1, 1, 0, 1],
                [1, 1, 1, 1],
                [0, 1, 0, 1],
                [0, 1, 1, 1],
                [0, 0, 1, 1],
                [0, 1, 1, 1],
                [0, 0, 0, 1],
                [0, 1, 0, 1],
                [1, 0, 1, 1],
                [1, 1, 1, 1],
                [1, 0, 0, 1],
                [1, 1, 0, 1],
            ]),
            decimal=7)

        np.testing.assert_equal(
            faces,
            np.array([
                [1, 2, 0],
                [1, 3, 2],
                [4, 6, 5],
                [6, 7, 5],
                [9, 10, 8],
                [9, 11, 10],
                [12, 14, 13],
                [14, 15, 13],
                [17, 18, 16],
                [17, 19, 18],
                [20, 22, 21],
                [22, 23, 21],
            ]))

        np.testing.assert_equal(
            outline,
            np.array([
                [0, 2],
                [2, 3],
                [3, 1],
                [1, 0],
                [4, 6],
                [6, 7],
                [7, 5],
                [5, 4],
                [8, 10],
                [10, 11],
                [11, 9],
                [9, 8],
                [12, 14],
                [14, 15],
                [15, 13],
                [13, 12],
                [16, 18],
                [18, 19],
                [19, 17],
                [17, 16],
                [20, 22],
                [22, 23],
                [23, 21],
                [21, 20],
            ]))

        vertices, faces, outline = primitive_cube(
            width=0.2,
            height=0.4,
            depth=0.6,
            width_segments=1,
            height_segments=2,
            depth_segments=3)

        np.testing.assert_almost_equal(
            vertices['position'],
            np.array([
                [-0.10000000, 0.30000001, -0.20000000],
                [0.10000000, 0.30000001, -0.20000000],
                [-0.10000000, 0.10000000, -0.20000000],
                [0.10000000, 0.10000000, -0.20000000],
                [-0.10000000, -0.10000000, -0.20000000],
                [0.10000000, -0.10000000, -0.20000000],
                [-0.10000000, -0.30000001, -0.20000000],
                [0.10000000, -0.30000001, -0.20000000],
                [-0.10000000, 0.30000001, 0.20000000],
                [0.10000000, 0.30000001, 0.20000000],
                [-0.10000000, 0.10000000, 0.20000000],
                [0.10000000, 0.10000000, 0.20000000],
                [-0.10000000, -0.10000000, 0.20000000],
                [0.10000000, -0.10000000, 0.20000000],
                [-0.10000000, -0.30000001, 0.20000000],
                [0.10000000, -0.30000001, 0.20000000],
                [0.10000000, -0.30000001, -0.20000000],
                [0.10000000, -0.30000001, 0.00000000],
                [0.10000000, -0.30000001, 0.20000000],
                [-0.10000000, -0.30000001, -0.20000000],
                [-0.10000000, -0.30000001, 0.00000000],
                [-0.10000000, -0.30000001, 0.20000000],
                [0.10000000, 0.30000001, -0.20000000],
                [0.10000000, 0.30000001, 0.00000000],
                [0.10000000, 0.30000001, 0.20000000],
                [-0.10000000, 0.30000001, -0.20000000],
                [-0.10000000, 0.30000001, 0.00000000],
                [-0.10000000, 0.30000001, 0.20000000],
                [-0.10000000, -0.30000001, 0.20000000],
                [-0.10000000, -0.10000000, 0.20000000],
                [-0.10000000, 0.10000000, 0.20000000],
                [-0.10000000, 0.30000001, 0.20000000],
                [-0.10000000, -0.30000001, -0.00000000],
                [-0.10000000, -0.10000000, -0.00000000],
                [-0.10000000, 0.10000000, -0.00000000],
                [-0.10000000, 0.30000001, -0.00000000],
                [-0.10000000, -0.30000001, -0.20000000],
                [-0.10000000, -0.10000000, -0.20000000],
                [-0.10000000, 0.10000000, -0.20000000],
                [-0.10000000, 0.30000001, -0.20000000],
                [0.10000000, -0.30000001, 0.20000000],
                [0.10000000, -0.10000000, 0.20000000],
                [0.10000000, 0.10000000, 0.20000000],
                [0.10000000, 0.30000001, 0.20000000],
                [0.10000000, -0.30000001, -0.00000000],
                [0.10000000, -0.10000000, -0.00000000],
                [0.10000000, 0.10000000, -0.00000000],
                [0.10000000, 0.30000001, -0.00000000],
                [0.10000000, -0.30000001, -0.20000000],
                [0.10000000, -0.10000000, -0.20000000],
                [0.10000000, 0.10000000, -0.20000000],
                [0.10000000, 0.30000001, -0.20000000],
            ]),
            decimal=7)

        np.testing.assert_almost_equal(
            vertices['uv'],
            np.array([
                [0.00000000, 1.00000000],
                [1.00000000, 1.00000000],
                [0.00000000, 0.66666669],
                [1.00000000, 0.66666669],
                [0.00000000, 0.33333334],
                [1.00000000, 0.33333334],
                [0.00000000, 0.00000000],
                [1.00000000, 0.00000000],
                [0.00000000, 1.00000000],
                [1.00000000, 1.00000000],
                [0.00000000, 0.66666669],
                [1.00000000, 0.66666669],
                [0.00000000, 0.33333334],
                [1.00000000, 0.33333334],
                [0.00000000, 0.00000000],
                [1.00000000, 0.00000000],
                [0.00000000, 1.00000000],
                [0.50000000, 1.00000000],
                [1.00000000, 1.00000000],
                [0.00000000, 0.00000000],
                [0.50000000, 0.00000000],
                [1.00000000, 0.00000000],
                [0.00000000, 1.00000000],
                [0.50000000, 1.00000000],
                [1.00000000, 1.00000000],
                [0.00000000, 0.00000000],
                [0.50000000, 0.00000000],
                [1.00000000, 0.00000000],
                [0.00000000, 1.00000000],
                [0.33333334, 1.00000000],
                [0.66666669, 1.00000000],
                [1.00000000, 1.00000000],
                [0.00000000, 0.50000000],
                [0.33333334, 0.50000000],
                [0.66666669, 0.50000000],
                [1.00000000, 0.50000000],
                [0.00000000, 0.00000000],
                [0.33333334, 0.00000000],
                [0.66666669, 0.00000000],
                [1.00000000, 0.00000000],
                [0.00000000, 1.00000000],
                [0.33333334, 1.00000000],
                [0.66666669, 1.00000000],
                [1.00000000, 1.00000000],
                [0.00000000, 0.50000000],
                [0.33333334, 0.50000000],
                [0.66666669, 0.50000000],
                [1.00000000, 0.50000000],
                [0.00000000, 0.00000000],
                [0.33333334, 0.00000000],
                [0.66666669, 0.00000000],
                [1.00000000, 0.00000000],
            ]),
            decimal=7)

        np.testing.assert_almost_equal(
            vertices['normal'],
            np.array([
                [-0., -0., -1.],
                [0, 0, -1],
                [0, 0, -1],
                [0, 0, -1],
                [0, 0, -1],
                [0, 0, -1],
                [0, 0, -1],
                [0, 0, -1],
                [0, 0, 1],
                [0, 0, 1],
                [0, 0, 1],
                [0, 0, 1],
                [0, 0, 1],
                [0, 0, 1],
                [0, 0, 1],
                [0, 0, 1],
                [0, -1, 0],
                [0, -1, 0],
                [0, -1, 0],
                [0, -1, 0],
                [0, -1, 0],
                [0, -1, 0],
                [0, 1, 0],
                [0, 1, 0],
                [0, 1, 0],
                [0, 1, 0],
                [0, 1, 0],
                [0, 1, 0],
                [-1, 0, 0],
                [-1, 0, 0],
                [-1, 0, 0],
                [-1, 0, 0],
                [-1, 0, 0],
                [-1, 0, 0],
                [-1, 0, 0],
                [-1, 0, 0],
                [-1, 0, 0],
                [-1, 0, 0],
                [-1, 0, 0],
                [-1, 0, 0],
                [1, 0, 0],
                [1, 0, 0],
                [1, 0, 0],
                [1, 0, 0],
                [1, 0, 0],
                [1, 0, 0],
                [1, 0, 0],
                [1, 0, 0],
                [1, 0, 0],
                [1, 0, 0],
                [1, 0, 0],
                [1, 0, 0],
            ]),
            decimal=7)

        np.testing.assert_almost_equal(
            vertices['colour'],
            np.array([
                [0.33333334, 1.00000000, 0.16666667, 1.00000000],
                [0.66666669, 1.00000000, 0.16666667, 1.00000000],
                [0.33333334, 0.66666669, 0.16666667, 1.00000000],
                [0.66666669, 0.66666669, 0.16666667, 1.00000000],
                [0.33333334, 0.33333334, 0.16666667, 1.00000000],
                [0.66666669, 0.33333334, 0.16666667, 1.00000000],
                [0.33333334, 0.00000000, 0.16666667, 1.00000000],
                [0.66666669, 0.00000000, 0.16666667, 1.00000000],
                [0.33333334, 1.00000000, 0.83333331, 1.00000000],
                [0.66666669, 1.00000000, 0.83333331, 1.00000000],
                [0.33333334, 0.66666669, 0.83333331, 1.00000000],
                [0.66666669, 0.66666669, 0.83333331, 1.00000000],
                [0.33333334, 0.33333334, 0.83333331, 1.00000000],
                [0.66666669, 0.33333334, 0.83333331, 1.00000000],
                [0.33333334, 0.00000000, 0.83333331, 1.00000000],
                [0.66666669, 0.00000000, 0.83333331, 1.00000000],
                [0.66666669, 0.00000000, 0.16666667, 1.00000000],
                [0.66666669, 0.00000000, 0.50000000, 1.00000000],
                [0.66666669, 0.00000000, 0.83333331, 1.00000000],
                [0.33333334, 0.00000000, 0.16666667, 1.00000000],
                [0.33333334, 0.00000000, 0.50000000, 1.00000000],
                [0.33333334, 0.00000000, 0.83333331, 1.00000000],
                [0.66666669, 1.00000000, 0.16666667, 1.00000000],
                [0.66666669, 1.00000000, 0.50000000, 1.00000000],
                [0.66666669, 1.00000000, 0.83333331, 1.00000000],
                [0.33333334, 1.00000000, 0.16666667, 1.00000000],
                [0.33333334, 1.00000000, 0.50000000, 1.00000000],
                [0.33333334, 1.00000000, 0.83333331, 1.00000000],
                [0.33333334, 0.00000000, 0.83333331, 1.00000000],
                [0.33333334, 0.33333334, 0.83333331, 1.00000000],
                [0.33333334, 0.66666669, 0.83333331, 1.00000000],
                [0.33333334, 1.00000000, 0.83333331, 1.00000000],
                [0.33333334, 0.00000000, 0.50000000, 1.00000000],
                [0.33333334, 0.33333334, 0.50000000, 1.00000000],
                [0.33333334, 0.66666669, 0.50000000, 1.00000000],
                [0.33333334, 1.00000000, 0.50000000, 1.00000000],
                [0.33333334, 0.00000000, 0.16666667, 1.00000000],
                [0.33333334, 0.33333334, 0.16666667, 1.00000000],
                [0.33333334, 0.66666669, 0.16666667, 1.00000000],
                [0.33333334, 1.00000000, 0.16666667, 1.00000000],
                [0.66666669, 0.00000000, 0.83333331, 1.00000000],
                [0.66666669, 0.33333334, 0.83333331, 1.00000000],
                [0.66666669, 0.66666669, 0.83333331, 1.00000000],
                [0.66666669, 1.00000000, 0.83333331, 1.00000000],
                [0.66666669, 0.00000000, 0.50000000, 1.00000000],
                [0.66666669, 0.33333334, 0.50000000, 1.00000000],
                [0.66666669, 0.66666669, 0.50000000, 1.00000000],
                [0.66666669, 1.00000000, 0.50000000, 1.00000000],
                [0.66666669, 0.00000000, 0.16666667, 1.00000000],
                [0.66666669, 0.33333334, 0.16666667, 1.00000000],
                [0.66666669, 0.66666669, 0.16666667, 1.00000000],
                [0.66666669, 1.00000000, 0.16666667, 1.00000000],
            ]),
            decimal=7)

        np.testing.assert_equal(
            faces,
            np.array([
                [1, 2, 0],
                [1, 3, 2],
                [3, 4, 2],
                [3, 5, 4],
                [5, 6, 4],
                [5, 7, 6],
                [8, 10, 9],
                [10, 11, 9],
                [10, 12, 11],
                [12, 13, 11],
                [12, 14, 13],
                [14, 15, 13],
                [17, 19, 16],
                [17, 20, 19],
                [18, 20, 17],
                [18, 21, 20],
                [22, 25, 23],
                [25, 26, 23],
                [23, 26, 24],
                [26, 27, 24],
                [29, 32, 28],
                [29, 33, 32],
                [30, 33, 29],
                [30, 34, 33],
                [31, 34, 30],
                [31, 35, 34],
                [33, 36, 32],
                [33, 37, 36],
                [34, 37, 33],
                [34, 38, 37],
                [35, 38, 34],
                [35, 39, 38],
                [40, 44, 41],
                [44, 45, 41],
                [41, 45, 42],
                [45, 46, 42],
                [42, 46, 43],
                [46, 47, 43],
                [44, 48, 45],
                [48, 49, 45],
                [45, 49, 46],
                [49, 50, 46],
                [46, 50, 47],
                [50, 51, 47],
            ]))

        np.testing.assert_equal(
            outline,
            np.array([
                [0, 2],
                [2, 3],
                [3, 1],
                [1, 0],
                [2, 4],
                [4, 5],
                [5, 3],
                [3, 2],
                [4, 6],
                [6, 7],
                [7, 5],
                [5, 4],
                [8, 10],
                [10, 11],
                [11, 9],
                [9, 8],
                [10, 12],
                [12, 13],
                [13, 11],
                [11, 10],
                [12, 14],
                [14, 15],
                [15, 13],
                [13, 12],
                [16, 19],
                [19, 20],
                [20, 17],
                [17, 16],
                [17, 20],
                [20, 21],
                [21, 18],
                [18, 17],
                [22, 25],
                [25, 26],
                [26, 23],
                [23, 22],
                [23, 26],
                [26, 27],
                [27, 24],
                [24, 23],
                [28, 32],
                [32, 33],
                [33, 29],
                [29, 28],
                [29, 33],
                [33, 34],
                [34, 30],
                [30, 29],
                [30, 34],
                [34, 35],
                [35, 31],
                [31, 30],
                [32, 36],
                [36, 37],
                [37, 33],
                [33, 32],
                [33, 37],
                [37, 38],
                [38, 34],
                [34, 33],
                [34, 38],
                [38, 39],
                [39, 35],
                [35, 34],
                [40, 44],
                [44, 45],
                [45, 41],
                [41, 40],
                [41, 45],
                [45, 46],
                [46, 42],
                [42, 41],
                [42, 46],
                [46, 47],
                [47, 43],
                [43, 42],
                [44, 48],
                [48, 49],
                [49, 45],
                [45, 44],
                [45, 49],
                [49, 50],
                [50, 46],
                [46, 45],
                [46, 50],
                [50, 51],
                [51, 47],
                [47, 46],
            ]))

        for plane in PLANE_TO_AXIS_MAPPING.keys():
            np.testing.assert_almost_equal(
                primitive_cube(planes=[plane])[0]['position'],
                primitive_cube(
                    planes=[PLANE_TO_AXIS_MAPPING[plane]])[0]['position'],
                decimal=7)
Ejemplo n.º 5
0
    def test_hull_section(self):
        """Test :func:`colour.geometry.section.hull_section` definition."""

        if not is_trimesh_installed:  # pragma: no cover
            return

        import trimesh

        vertices, faces, _outline = primitive_cube(1, 1, 1, 2, 2, 2)
        hull = trimesh.Trimesh(vertices["position"], faces, process=False)

        np.testing.assert_almost_equal(
            hull_section(hull, origin=0),
            np.array([
                [0.0, -0.5, 0.0],
                [0.5, -0.5, 0.0],
                [0.5, 0.0, 0.0],
                [0.5, 0.5, 0.0],
                [0.0, 0.5, 0.0],
                [-0.5, 0.5, 0.0],
                [-0.5, 0.0, 0.0],
                [-0.5, -0.5, 0.0],
                [0.0, -0.5, 0.0],
            ]),
        )

        np.testing.assert_almost_equal(
            hull_section(hull, axis="+x", origin=0),
            np.array([
                [0.0, 0.0, -0.5],
                [0.0, 0.5, -0.5],
                [0.0, 0.5, 0.0],
                [0.0, 0.5, 0.5],
                [0.0, 0.0, 0.5],
                [0.0, -0.5, 0.5],
                [0.0, -0.5, 0.0],
                [0.0, -0.5, -0.5],
                [0.0, 0.0, -0.5],
            ]),
        )

        np.testing.assert_almost_equal(
            hull_section(hull, axis="+y", origin=0),
            np.array([
                [0.0, 0.0, -0.5],
                [-0.5, 0.0, -0.5],
                [-0.5, 0.0, 0.0],
                [-0.5, 0.0, 0.5],
                [0.0, 0.0, 0.5],
                [0.5, 0.0, 0.5],
                [0.5, 0.0, 0.0],
                [0.5, 0.0, -0.5],
                [0.0, 0.0, -0.5],
            ]),
        )

        hull.vertices = (hull.vertices + 0.5) * 2
        np.testing.assert_almost_equal(
            hull_section(hull, origin=0.5, normalise=True),
            np.array([
                [1.0, 0.0, 1.0],
                [2.0, 0.0, 1.0],
                [2.0, 1.0, 1.0],
                [2.0, 2.0, 1.0],
                [1.0, 2.0, 1.0],
                [0.0, 2.0, 1.0],
                [0.0, 1.0, 1.0],
                [0.0, 0.0, 1.0],
                [1.0, 0.0, 1.0],
            ]),
        )

        self.assertRaises(ValueError, hull_section, hull, origin=-1)
Ejemplo n.º 6
0
def generate_documentation_plots(output_directory: str):
    """
    Generate documentation plots.

    Parameters
    ----------
    output_directory
        Output directory.
    """

    filter_warnings()

    colour_style()

    np.random.seed(0)

    # *************************************************************************
    # "README.rst"
    # *************************************************************************
    filename = os.path.join(
        output_directory, "Examples_Colour_Automatic_Conversion_Graph.png"
    )
    plot_automatic_colour_conversion_graph(filename)

    arguments = {
        "tight_layout": True,
        "transparent_background": True,
        "filename": os.path.join(
            output_directory, "Examples_Plotting_Visible_Spectrum.png"
        ),
    }
    plt.close(
        plot_visible_spectrum(
            "CIE 1931 2 Degree Standard Observer", **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Examples_Plotting_Illuminant_F1_SD.png"
    )
    plt.close(plot_single_illuminant_sd("FL1", **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Examples_Plotting_Blackbodies.png"
    )
    blackbody_sds = [
        sd_blackbody(i, SpectralShape(0, 10000, 10))
        for i in range(1000, 15000, 1000)
    ]
    plt.close(
        plot_multi_sds(
            blackbody_sds,
            y_label="W / (sr m$^2$) / m",
            plot_kwargs={"use_sd_colours": True, "normalise_sd_colours": True},
            legend_location="upper right",
            bounding_box=(0, 1250, 0, 2.5e6),
            **arguments,
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Examples_Plotting_Cone_Fundamentals.png"
    )
    plt.close(
        plot_single_cmfs(
            "Stockman & Sharpe 2 Degree Cone Fundamentals",
            y_label="Sensitivity",
            bounding_box=(390, 870, 0, 1.1),
            **arguments,
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Examples_Plotting_Luminous_Efficiency.png"
    )
    plt.close(
        plot_multi_sds(
            (
                sd_mesopic_luminous_efficiency_function(0.2),
                SDS_LEFS_PHOTOPIC["CIE 1924 Photopic Standard Observer"],
                SDS_LEFS_SCOTOPIC["CIE 1951 Scotopic Standard Observer"],
            ),
            y_label="Luminous Efficiency",
            legend_location="upper right",
            y_tighten=True,
            margins=(0, 0, 0, 0.1),
            **arguments,
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Examples_Plotting_BabelColor_Average.png"
    )
    plt.close(
        plot_multi_sds(
            SDS_COLOURCHECKERS["BabelColor Average"].values(),
            plot_kwargs={"use_sd_colours": True},
            title=("BabelColor Average - " "Spectral Distributions"),
            **arguments,
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Examples_Plotting_ColorChecker_2005.png"
    )
    plt.close(
        plot_single_colour_checker(
            "ColorChecker 2005", text_kwargs={"visible": False}, **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Examples_Plotting_Chromaticities_Prediction.png"
    )
    plt.close(
        plot_corresponding_chromaticities_prediction(
            2, "Von Kries", **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Examples_Plotting_Chromaticities_CIE_1931_Chromaticity_Diagram.png",
    )
    RGB = np.random.random((32, 32, 3))
    plt.close(
        plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931(
            RGB,
            "ITU-R BT.709",
            colourspaces=["ACEScg", "S-Gamut"],
            show_pointer_gamut=True,
            **arguments,
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Examples_Plotting_CRI.png"
    )
    plt.close(
        plot_single_sd_colour_rendering_index_bars(
            SDS_ILLUMINANTS["FL2"], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Examples_Plotting_Colour_Rendition_Report.png"
    )
    plt.close(
        plot_single_sd_colour_rendition_report(
            SDS_ILLUMINANTS["FL2"], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Examples_Plotting_Plot_Visible_Spectrum_Section.png"
    )
    plt.close(
        plot_visible_spectrum_section(
            section_colours="RGB", section_opacity=0.15, **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Examples_Plotting_Plot_RGB_Colourspace_Section.png"
    )
    plt.close(
        plot_RGB_colourspace_section(
            "sRGB", section_colours="RGB", section_opacity=0.15, **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Examples_Plotting_CCT_CIE_1960_UCS_Chromaticity_Diagram.png",
    )
    plt.close(
        plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS(
            ["A", "B", "C"], **arguments
        )[0]
    )

    # *************************************************************************
    # Documentation
    # *************************************************************************
    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_CVD_Simulation_Machado2009.png"
    )
    plt.close(plot_cvd_simulation_Machado2009(RGB, **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Single_Colour_Checker.png"
    )
    plt.close(plot_single_colour_checker("ColorChecker 2005", **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Multi_Colour_Checkers.png"
    )
    plt.close(
        plot_multi_colour_checkers(
            ["ColorChecker 1976", "ColorChecker 2005"], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Single_SD.png"
    )
    data = {
        500: 0.0651,
        520: 0.0705,
        540: 0.0772,
        560: 0.0870,
        580: 0.1128,
        600: 0.1360,
    }
    sd = SpectralDistribution(data, name="Custom")
    plt.close(plot_single_sd(sd, **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Multi_SDS.png"
    )
    data_1 = {
        500: 0.004900,
        510: 0.009300,
        520: 0.063270,
        530: 0.165500,
        540: 0.290400,
        550: 0.433450,
        560: 0.594500,
    }
    data_2 = {
        500: 0.323000,
        510: 0.503000,
        520: 0.710000,
        530: 0.862000,
        540: 0.954000,
        550: 0.994950,
        560: 0.995000,
    }
    spd1 = SpectralDistribution(data_1, name="Custom 1")
    spd2 = SpectralDistribution(data_2, name="Custom 2")
    plt.close(plot_multi_sds([spd1, spd2], **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Single_CMFS.png"
    )
    plt.close(
        plot_single_cmfs("CIE 1931 2 Degree Standard Observer", **arguments)[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Multi_CMFS.png"
    )
    cmfs = (
        "CIE 1931 2 Degree Standard Observer",
        "CIE 1964 10 Degree Standard Observer",
    )
    plt.close(plot_multi_cmfs(cmfs, **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Single_Illuminant_SD.png"
    )
    plt.close(plot_single_illuminant_sd("A", **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Multi_Illuminant_SDS.png"
    )
    plt.close(plot_multi_illuminant_sds(["A", "B", "C"], **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Visible_Spectrum.png"
    )
    plt.close(plot_visible_spectrum(**arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Single_Lightness_Function.png"
    )
    plt.close(plot_single_lightness_function("CIE 1976", **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Multi_Lightness_Functions.png"
    )
    plt.close(
        plot_multi_lightness_functions(
            ["CIE 1976", "Wyszecki 1963"], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Single_Luminance_Function.png"
    )
    plt.close(plot_single_luminance_function("CIE 1976", **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Multi_Luminance_Functions.png"
    )
    plt.close(
        plot_multi_luminance_functions(
            ["CIE 1976", "Newhall 1943"], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Blackbody_Spectral_Radiance.png"
    )
    plt.close(
        plot_blackbody_spectral_radiance(
            3500, blackbody="VY Canis Major", **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Blackbody_Colours.png"
    )
    plt.close(
        plot_blackbody_colours(SpectralShape(150, 12500, 50), **arguments)[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Single_Colour_Swatch.png"
    )
    RGB = ColourSwatch((0.45620519, 0.03081071, 0.04091952))
    plt.close(plot_single_colour_swatch(RGB, **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Multi_Colour_Swatches.png"
    )
    RGB_1 = ColourSwatch((0.45293517, 0.31732158, 0.26414773))
    RGB_2 = ColourSwatch((0.77875824, 0.57726450, 0.50453169))
    plt.close(plot_multi_colour_swatches([RGB_1, RGB_2], **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Single_Function.png"
    )
    plt.close(plot_single_function(lambda x: x ** (1 / 2.2), **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Multi_Functions.png"
    )
    functions = {
        "Gamma 2.2": lambda x: x ** (1 / 2.2),
        "Gamma 2.4": lambda x: x ** (1 / 2.4),
        "Gamma 2.6": lambda x: x ** (1 / 2.6),
    }
    plt.close(plot_multi_functions(functions, **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Image.png"
    )
    path = os.path.join(
        colour.__path__[0],
        "examples",
        "plotting",
        "resources",
        "Ishihara_Colour_Blindness_Test_Plate_3.png",
    )
    plt.close(plot_image(read_image(str(path)), **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_Corresponding_Chromaticities_Prediction.png",
    )
    plt.close(
        plot_corresponding_chromaticities_prediction(
            1, "Von Kries", **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Spectral_Locus.png"
    )
    plt.close(
        plot_spectral_locus(spectral_locus_colours="RGB", **arguments)[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Chromaticity_Diagram_Colours.png"
    )
    plt.close(
        plot_chromaticity_diagram_colours(diagram_colours="RGB", **arguments)[
            0
        ]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Chromaticity_Diagram.png"
    )
    plt.close(plot_chromaticity_diagram(**arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Chromaticity_Diagram_CIE1931.png"
    )
    plt.close(plot_chromaticity_diagram_CIE1931(**arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Chromaticity_Diagram_CIE1960UCS.png"
    )
    plt.close(plot_chromaticity_diagram_CIE1960UCS(**arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Chromaticity_Diagram_CIE1976UCS.png"
    )
    plt.close(plot_chromaticity_diagram_CIE1976UCS(**arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_SDS_In_Chromaticity_Diagram.png"
    )
    A = SDS_ILLUMINANTS["A"]
    D65 = SDS_ILLUMINANTS["D65"]
    plt.close(plot_sds_in_chromaticity_diagram([A, D65], **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_SDS_In_Chromaticity_Diagram_CIE1931.png",
    )
    plt.close(
        plot_sds_in_chromaticity_diagram_CIE1931([A, D65], **arguments)[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_SDS_In_Chromaticity_Diagram_CIE1960UCS.png",
    )
    plt.close(
        plot_sds_in_chromaticity_diagram_CIE1960UCS([A, D65], **arguments)[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_SDS_In_Chromaticity_Diagram_CIE1976UCS.png",
    )
    plt.close(
        plot_sds_in_chromaticity_diagram_CIE1976UCS([A, D65], **arguments)[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Pointer_Gamut.png"
    )
    plt.close(plot_pointer_gamut(**arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_RGB_Colourspaces_In_Chromaticity_Diagram.png",
    )
    plt.close(
        plot_RGB_colourspaces_in_chromaticity_diagram(
            ["ITU-R BT.709", "ACEScg", "S-Gamut"], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_RGB_Colourspaces_In_Chromaticity_Diagram_CIE1931.png",
    )
    plt.close(
        plot_RGB_colourspaces_in_chromaticity_diagram_CIE1931(
            ["ITU-R BT.709", "ACEScg", "S-Gamut"], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_RGB_Colourspaces_In_"
        "Chromaticity_Diagram_CIE1960UCS.png",
    )
    plt.close(
        plot_RGB_colourspaces_in_chromaticity_diagram_CIE1960UCS(
            ["ITU-R BT.709", "ACEScg", "S-Gamut"], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_RGB_Colourspaces_In_"
        "Chromaticity_Diagram_CIE1976UCS.png",
    )
    plt.close(
        plot_RGB_colourspaces_in_chromaticity_diagram_CIE1976UCS(
            ["ITU-R BT.709", "ACEScg", "S-Gamut"], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_RGB_Chromaticities_In_" "Chromaticity_Diagram.png",
    )
    RGB = np.random.random((128, 128, 3))
    plt.close(
        plot_RGB_chromaticities_in_chromaticity_diagram(
            RGB, "ITU-R BT.709", **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_RGB_Chromaticities_In_"
        "Chromaticity_Diagram_CIE1931.png",
    )
    plt.close(
        plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931(
            RGB, "ITU-R BT.709", **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_RGB_Chromaticities_In_"
        "Chromaticity_Diagram_CIE1960UCS.png",
    )
    plt.close(
        plot_RGB_chromaticities_in_chromaticity_diagram_CIE1960UCS(
            RGB, "ITU-R BT.709", **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_RGB_Chromaticities_In_"
        "Chromaticity_Diagram_CIE1976UCS.png",
    )
    plt.close(
        plot_RGB_chromaticities_in_chromaticity_diagram_CIE1976UCS(
            RGB, "ITU-R BT.709", **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_Ellipses_MacAdam1942_In_Chromaticity_Diagram.png",
    )
    plt.close(
        plot_ellipses_MacAdam1942_in_chromaticity_diagram(**arguments)[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_Ellipses_MacAdam1942_In_"
        "Chromaticity_Diagram_CIE1931.png",
    )
    plt.close(
        plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1931(**arguments)[
            0
        ]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_Ellipses_MacAdam1942_In_"
        "Chromaticity_Diagram_CIE1960UCS.png",
    )
    plt.close(
        plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1960UCS(
            **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_Ellipses_MacAdam1942_In_"
        "Chromaticity_Diagram_CIE1976UCS.png",
    )
    plt.close(
        plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1976UCS(
            **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Single_CCTF.png"
    )
    plt.close(plot_single_cctf("ITU-R BT.709", **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Multi_CCTFs.png"
    )
    plt.close(plot_multi_cctfs(["ITU-R BT.709", "sRGB"], **arguments)[0])

    data = np.array(
        [
            [
                None,
                np.array([0.95010000, 1.00000000, 1.08810000]),
                np.array([0.40920000, 0.28120000, 0.30600000]),
                np.array(
                    [
                        [0.02495100, 0.01908600, 0.02032900],
                        [0.10944300, 0.06235900, 0.06788100],
                        [0.27186500, 0.18418700, 0.19565300],
                        [0.48898900, 0.40749400, 0.44854600],
                    ]
                ),
                None,
            ],
            [
                None,
                np.array([0.95010000, 1.00000000, 1.08810000]),
                np.array([0.30760000, 0.48280000, 0.42770000]),
                np.array(
                    [
                        [0.02108000, 0.02989100, 0.02790400],
                        [0.06194700, 0.11251000, 0.09334400],
                        [0.15255800, 0.28123300, 0.23234900],
                        [0.34157700, 0.56681300, 0.47035300],
                    ]
                ),
                None,
            ],
            [
                None,
                np.array([0.95010000, 1.00000000, 1.08810000]),
                np.array([0.39530000, 0.28120000, 0.18450000]),
                np.array(
                    [
                        [0.02436400, 0.01908600, 0.01468800],
                        [0.10331200, 0.06235900, 0.02854600],
                        [0.26311900, 0.18418700, 0.12109700],
                        [0.43158700, 0.40749400, 0.39008600],
                    ]
                ),
                None,
            ],
            [
                None,
                np.array([0.95010000, 1.00000000, 1.08810000]),
                np.array([0.20510000, 0.18420000, 0.57130000]),
                np.array(
                    [
                        [0.03039800, 0.02989100, 0.06123300],
                        [0.08870000, 0.08498400, 0.21843500],
                        [0.18405800, 0.18418700, 0.40111400],
                        [0.32550100, 0.34047200, 0.50296900],
                        [0.53826100, 0.56681300, 0.80010400],
                    ]
                ),
                None,
            ],
            [
                None,
                np.array([0.95010000, 1.00000000, 1.08810000]),
                np.array([0.35770000, 0.28120000, 0.11250000]),
                np.array(
                    [
                        [0.03678100, 0.02989100, 0.01481100],
                        [0.17127700, 0.11251000, 0.01229900],
                        [0.30080900, 0.28123300, 0.21229800],
                        [0.52976000, 0.40749400, 0.11720000],
                    ]
                ),
                None,
            ],
        ]
    )
    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Constant_Hue_Loci.png"
    )
    plt.close(plot_constant_hue_loci(data, "IPT", **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Single_Munsell_Value_Function.png"
    )
    plt.close(plot_single_munsell_value_function("ASTM D1535", **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Multi_Munsell_Value_Functions.png"
    )
    plt.close(
        plot_multi_munsell_value_functions(
            ["ASTM D1535", "McCamy 1987"], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Single_SD_Rayleigh_Scattering.png"
    )
    plt.close(plot_single_sd_rayleigh_scattering(**arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_The_Blue_Sky.png"
    )
    plt.close(plot_the_blue_sky(**arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Colour_Quality_Bars.png"
    )
    illuminant = SDS_ILLUMINANTS["FL2"]
    light_source = SDS_LIGHT_SOURCES["Kinoton 75P"]
    light_source = light_source.copy().align(SpectralShape(360, 830, 1))
    cqs_i = colour_quality_scale(illuminant, additional_data=True)
    cqs_l = colour_quality_scale(light_source, additional_data=True)
    plt.close(plot_colour_quality_bars([cqs_i, cqs_l], **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_Single_SD_Colour_Rendering_Index_Bars.png",
    )
    illuminant = SDS_ILLUMINANTS["FL2"]
    plt.close(
        plot_single_sd_colour_rendering_index_bars(illuminant, **arguments)[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_Multi_SDS_Colour_Rendering_Indexes_Bars.png",
    )
    light_source = SDS_LIGHT_SOURCES["Kinoton 75P"]
    plt.close(
        plot_multi_sds_colour_rendering_indexes_bars(
            [illuminant, light_source], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_Single_SD_Colour_Quality_Scale_Bars.png",
    )
    illuminant = SDS_ILLUMINANTS["FL2"]
    plt.close(
        plot_single_sd_colour_quality_scale_bars(illuminant, **arguments)[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_Multi_SDS_Colour_Quality_Scales_Bars.png",
    )
    light_source = SDS_LIGHT_SOURCES["Kinoton 75P"]
    plt.close(
        plot_multi_sds_colour_quality_scales_bars(
            [illuminant, light_source], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Hull_Section_Colours.png"
    )
    vertices, faces, _outline = primitive_cube(1, 1, 1, 64, 64, 64)
    XYZ_vertices = RGB_to_XYZ(
        vertices["position"] + 0.5,
        RGB_COLOURSPACE_sRGB.whitepoint,
        RGB_COLOURSPACE_sRGB.whitepoint,
        RGB_COLOURSPACE_sRGB.matrix_RGB_to_XYZ,
    )
    hull = trimesh.Trimesh(XYZ_vertices, faces, process=False)
    plt.close(
        plot_hull_section_colours(hull, section_colours="RGB", **arguments)[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Hull_Section_Contour.png"
    )
    plt.close(
        plot_hull_section_contour(hull, section_colours="RGB", **arguments)[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Visible_Spectrum_Section.png"
    )
    plt.close(
        plot_visible_spectrum_section(
            section_colours="RGB", section_opacity=0.15, **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_RGB_Colourspace_Section.png"
    )
    plt.close(
        plot_RGB_colourspace_section(
            "sRGB", section_colours="RGB", section_opacity=0.15, **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_Planckian_Locus.png"
    )
    plt.close(
        plot_planckian_locus(planckian_locus_colours="RGB", **arguments)[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_Planckian_Locus_In_Chromaticity_Diagram.png",
    )
    plt.close(
        plot_planckian_locus_in_chromaticity_diagram(
            ["A", "B", "C"], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_Planckian_Locus_In_Chromaticity_Diagram_CIE1931.png",
    )
    plt.close(
        plot_planckian_locus_in_chromaticity_diagram_CIE1931(
            ["A", "B", "C"], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_Planckian_Locus_In_Chromaticity_Diagram_CIE1960UCS.png",
    )
    plt.close(
        plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS(
            ["A", "B", "C"], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_Single_SD_Colour_Rendition_Report_Full.png",
    )
    plt.close(
        plot_single_sd_colour_rendition_report(
            SDS_ILLUMINANTS["FL2"], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_Single_SD_Colour_Rendition_Report_Intermediate.png",
    )
    plt.close(
        plot_single_sd_colour_rendition_report(
            SDS_ILLUMINANTS["FL2"], "Intermediate", **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory,
        "Plotting_Plot_Single_SD_Colour_Rendition_Report_Simple.png",
    )
    plt.close(
        plot_single_sd_colour_rendition_report(
            SDS_ILLUMINANTS["FL2"], "Simple", **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_RGB_Colourspaces_Gamuts.png"
    )
    plt.close(
        plot_RGB_colourspaces_gamuts(
            ["ITU-R BT.709", "ACEScg", "S-Gamut"], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_RGB_Colourspaces_Gamuts.png"
    )
    plt.close(
        plot_RGB_colourspaces_gamuts(
            ["ITU-R BT.709", "ACEScg", "S-Gamut"], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Plotting_Plot_RGB_Scatter.png"
    )
    plt.close(plot_RGB_scatter(RGB, "ITU-R BT.709", **arguments)[0])

    filename = os.path.join(
        output_directory, "Plotting_Plot_Colour_Automatic_Conversion_Graph.png"
    )
    plot_automatic_colour_conversion_graph(filename)

    # *************************************************************************
    # "tutorial.rst"
    # *************************************************************************
    arguments["filename"] = os.path.join(
        output_directory, "Tutorial_Visible_Spectrum.png"
    )
    plt.close(plot_visible_spectrum(**arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Tutorial_Sample_SD.png"
    )
    sample_sd_data = {
        380: 0.048,
        385: 0.051,
        390: 0.055,
        395: 0.060,
        400: 0.065,
        405: 0.068,
        410: 0.068,
        415: 0.067,
        420: 0.064,
        425: 0.062,
        430: 0.059,
        435: 0.057,
        440: 0.055,
        445: 0.054,
        450: 0.053,
        455: 0.053,
        460: 0.052,
        465: 0.052,
        470: 0.052,
        475: 0.053,
        480: 0.054,
        485: 0.055,
        490: 0.057,
        495: 0.059,
        500: 0.061,
        505: 0.062,
        510: 0.065,
        515: 0.067,
        520: 0.070,
        525: 0.072,
        530: 0.074,
        535: 0.075,
        540: 0.076,
        545: 0.078,
        550: 0.079,
        555: 0.082,
        560: 0.087,
        565: 0.092,
        570: 0.100,
        575: 0.107,
        580: 0.115,
        585: 0.122,
        590: 0.129,
        595: 0.134,
        600: 0.138,
        605: 0.142,
        610: 0.146,
        615: 0.150,
        620: 0.154,
        625: 0.158,
        630: 0.163,
        635: 0.167,
        640: 0.173,
        645: 0.180,
        650: 0.188,
        655: 0.196,
        660: 0.204,
        665: 0.213,
        670: 0.222,
        675: 0.231,
        680: 0.242,
        685: 0.251,
        690: 0.261,
        695: 0.271,
        700: 0.282,
        705: 0.294,
        710: 0.305,
        715: 0.318,
        720: 0.334,
        725: 0.354,
        730: 0.372,
        735: 0.392,
        740: 0.409,
        745: 0.420,
        750: 0.436,
        755: 0.450,
        760: 0.462,
        765: 0.465,
        770: 0.448,
        775: 0.432,
        780: 0.421,
    }

    sd = SpectralDistribution(sample_sd_data, name="Sample")
    plt.close(plot_single_sd(sd, **arguments)[0])

    arguments["filename"] = os.path.join(
        output_directory, "Tutorial_SD_Interpolation.png"
    )
    sd_copy = sd.copy()
    sd_copy.interpolate(SpectralShape(400, 770, 1))
    plt.close(
        plot_multi_sds(
            [sd, sd_copy], bounding_box=[730, 780, 0.25, 0.5], **arguments
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Tutorial_Sample_Swatch.png"
    )
    sd = SpectralDistribution(sample_sd_data)
    cmfs = MSDS_CMFS_STANDARD_OBSERVER["CIE 1931 2 Degree Standard Observer"]
    illuminant = SDS_ILLUMINANTS["D65"]
    with domain_range_scale("1"):
        XYZ = sd_to_XYZ(sd, cmfs, illuminant)
        RGB = XYZ_to_sRGB(XYZ)
    plt.close(
        plot_single_colour_swatch(
            ColourSwatch(RGB, "Sample"),
            text_kwargs={"size": "x-large"},
            **arguments,
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Tutorial_Neutral5.png"
    )
    patch_name = "neutral 5 (.70 D)"
    patch_sd = SDS_COLOURCHECKERS["ColorChecker N Ohta"][patch_name]
    with domain_range_scale("1"):
        XYZ = sd_to_XYZ(patch_sd, cmfs, illuminant)
        RGB = XYZ_to_sRGB(XYZ)
    plt.close(
        plot_single_colour_swatch(
            ColourSwatch(RGB, patch_name.title()),
            text_kwargs={"size": "x-large"},
            **arguments,
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Tutorial_Colour_Checker.png"
    )
    plt.close(
        plot_single_colour_checker(
            colour_checker="ColorChecker 2005",
            text_kwargs={"visible": False},
            **arguments,
        )[0]
    )

    arguments["filename"] = os.path.join(
        output_directory, "Tutorial_CIE_1931_Chromaticity_Diagram.png"
    )
    xy = XYZ_to_xy(XYZ)
    plot_chromaticity_diagram_CIE1931(standalone=False)
    x, y = xy
    plt.plot(x, y, "o-", color="white")
    # Annotating the plot.
    plt.annotate(
        patch_sd.name.title(),
        xy=xy,
        xytext=(-50, 30),
        textcoords="offset points",
        arrowprops=dict(arrowstyle="->", connectionstyle="arc3, rad=-0.2"),
    )
    plt.close(
        render(
            standalone=True,
            limits=(-0.1, 0.9, -0.1, 0.9),
            x_tighten=True,
            y_tighten=True,
            **arguments,
        )[0]
    )

    # *************************************************************************
    # "basics.rst"
    # *************************************************************************
    arguments["filename"] = os.path.join(
        output_directory, "Basics_Logo_Small_001_CIE_XYZ.png"
    )
    RGB = read_image(os.path.join(output_directory, "Logo_Small_001.png"))[
        ..., 0:3
    ]
    XYZ = sRGB_to_XYZ(RGB)
    plt.close(
        plot_image(XYZ, text_kwargs={"text": "sRGB to XYZ"}, **arguments)[0]
    )