class_docstr: Helper class to convert between different color representations used in the pyvista library.
  
  Many pyvista methods accept :data:`ColorLike` parameters. This helper class
  is used to convert such parameters to the necessary format, used by
  underlying (VTK) methods. Any color name (``str``), hex string (``str``)
  or RGB(A) sequence (``tuple``, ``list`` or ``numpy.ndarray`` of ``int``
  or ``float``) is considered a :data:`ColorLike` parameter and can be converted
  by this class.
  See :attr:`Color.name` for a list of supported color names.
  
  Parameters
  ----------
  color : ColorLike, optional
      Either a string, RGB sequence, RGBA sequence, or hex color string.
      RGB(A) sequences should either be provided as floats between 0 and 1
      or as ints between 0 and 255. Hex color strings can contain optional
      ``'#'`` or ``'0x'`` prefixes. If no opacity is provided, the
      ``default_opacity`` will be used. If ``color`` is ``None``, the
      ``default_color`` is used instead.
      The following examples all denote the color 'white':
  
      * ``'white'``
      * ``'w'``
      * ``[1.0, 1.0, 1.0]``
      * ``[255, 255, 255, 255]``
      * ``'#FFFFFF'``
  
  opacity : int | float | str, optional
      Opacity of the represented color. Overrides any opacity associated
      with the provided ``color``. Allowed opacities are floats between 0
      and 1, ints between 0 and 255 or hexadecimal strings of length 2
      (plus the length of the optional prefix).
      The following examples all denote a fully opaque color:
  
      * ``1.0``
      * ``255``
      * ``'#ff'``
  
  default_color : ColorLike, optional
      Default color to use when ``color`` is ``None``. If this value is
      ``None``, then defaults to the global theme color. Format is
      identical to ``color``.
  
  default_opacity : int | float | str, optional
      Default opacity of the represented color. Used when ``color``
      does not specify an opacity and ``opacity`` is ``None``. Format
      is identical to ``opacity``.
  
  Notes
  -----
  The internally used representation is an integer RGBA sequence (values
  between 0 and 255). This might however change in future releases.
  
  .. raw:: html
  
     <details><summary>Refer to the table below for a list of supported colors.</summary>
  
  .. include:: ../color_table/color_table.rst
  
  .. raw:: html
  
     </details>
  
  Examples
  --------
  Create a transparent green color using a color name, float RGBA sequence,
  integer RGBA sequence and RGBA hexadecimal string.
  
  >>> import pyvista as pv
  >>> pv.Color("green", opacity=0.5)
  Color(name='green', hex='#00800080', opacity=128)
  >>> pv.Color([0.0, 0.5, 0.0, 0.5])
  Color(name='green', hex='#00800080', opacity=128)
  >>> pv.Color([0, 128, 0, 128])
  Color(name='green', hex='#00800080', opacity=128)
  >>> pv.Color("#00800080")
  Color(name='green', hex='#00800080', opacity=128)
docstr: Initialize new instance.
docstr_tok: ["Initialize","new","instance","."]
code: def __init__(
      self,
      color: Optional[ColorLike] = None,
      opacity: Optional[Union[int, float, str]] = None,
      default_color: Optional[ColorLike] = None,
      default_opacity: Union[int, float, str] = 255,
  ):
      """Initialize new instance."""
      self._red, self._green, self._blue, self._opacity = 0, 0, 0, 0
      self._opacity = self.convert_color_channel(default_opacity)
      self._name = None
  
      # Use default color if no color is provided
      if color is None:
          if default_color is None:
              color = pyvista.global_theme.color
          else:
              color = default_color
  
      try:
          if isinstance(color, Color):
              # Create copy of color instance
              (
                  self._red,
                  self._green,
                  self._blue,
                  self._opacity,
              ) = color.int_rgba
          elif isinstance(color, str):
              # From named color or hex string
              self._from_str(color)
          elif isinstance(color, dict):
              # From dictionary
              self._from_dict(color)
          elif isinstance(color, (list, tuple, np.ndarray)):
              # From RGB(A) sequence
              self._from_rgba(color)
          elif isinstance(color, _vtk.vtkColor3ub):
              # From vtkColor3ub instance (can be unpacked as rgb tuple)
              self._from_rgba(color)
          else:
              raise ValueError(f"Unsupported color type: {type(color)}")
          self._name = color_names.get(self.hex_rgb, None)
      except ValueError as e:
          raise ValueError(
              "\n"
              f"\tInvalid color input: ({color})\n"
              "\tMust be a string, rgb(a) sequence, or hex color string.  For example:\n"
              "\t\tcolor='white'\n"
              "\t\tcolor='w'\n"
              "\t\tcolor=[1.0, 1.0, 1.0]\n"
              "\t\tcolor=[255, 255, 255]\n"
              "\t\tcolor='#FFFFFF'"
          ) from e
  
      # Overwrite opacity if it is provided
      try:
          if opacity is not None:
              self._opacity = self.convert_color_channel(opacity)
      except ValueError as e:
          raise ValueError(
              "\n"
              f"\tInvalid opacity input: ({opacity})"
              "\tMust be an integer, float or string.  For example:\n"
              "\t\topacity='1.0'\n"
              "\t\topacity='255'\n"
              "\t\topacity='#FF'"
          ) from e
  
imports: from __future__ import annotations
  import inspect
  from typing import Optional, Tuple, Union
  from cycler import Cycler, cycler
  from matplotlib.colors import ListedColormap
  import matplotlib.pyplot
  import numpy
  import pyvista
  from pyvista.core.utilities.misc import has_module
  from .None import _vtk
  from ._typing import ColorLike
label_desc: Use image node_id 1 to create a new Color object  with example: obj = Color(color, opacity, default_color, default_opacity)