.. include:: ../substitutions

.. oe:namespace:: OEGrapheme

.. meta::
   :keywords: OEDrawColorGradient

.. oe:function:: OEDrawColorGradient

   .. oe:language:: c++ java csharp

      .. oe:api::

         void OEDrawColorGradient(OEDepict::OEImageBase& image,
                                  const OESystem::OEColorGradientBase& colorg)
         void OEDrawColorGradient(OEDepict::OEImageBase& image,
                                  const OESystem::OEColorGradientBase& colorg,
                                  const OEColorGradientDisplayOptions& opts)

   .. oe:language:: python

      .. oe:api:: python

         OEDrawColorGradient(image: OEImageBase, colorg: OEColorGradientBase) -> None
         OEDrawColorGradient(image: OEImageBase, colorg: OEColorGradientBase,
                             opts: OEColorGradientDisplayOptions) -> None


   Draws a color gradient.

   *image*
      The image on which the color gradient is drawn.

   *colorg*
      The color gradient being drawn.

   *opts*
      The :ref:`OEColorGradientDisplayOptions <OEGrapheme_OEColorGradientDisplayOptions>` object that
      stores the parameters that determine how the color gradient is drawn.

   The following code snippet shows how to use the :oe:func:`OEGrapheme::OEDrawColorGradient`
   function. The image created is shown in
   :ref:`Figure: Example of using the OEDrawColorGradient function<figure_draw_color_gradient>`.

   .. oe:source:: DrawColorGradient.py
      :language: python
      :noindent:
      :frag:     SNIPPET-DRAW-COLOR-GRADIENT

   .. oe:language:: python

      :ref:`Full listing. <listing-DrawColorGradient.py>`


   .. oe:source:: DrawColorGradient.cpp
      :language: c++
      :noindent:
      :frag:     SNIPPET-DRAW-COLOR-GRADIENT

   .. oe:source:: DrawColorGradient.java
      :language: java
      :noindent:
      :frag:     SNIPPET-DRAW-COLOR-GRADIENT

   .. oe:source:: DrawColorGradient.cs
      :language: csharp
      :noindent:
      :frag:     SNIPPET-DRAW-COLOR-GRADIENT

   .. _figure_draw_color_gradient:

   .. figure:: ../images/DrawColorGradient.*
      :align:  center

      **Example of using the OEDrawColorGradient function**

   The orientation (*i.e.*, whether the color gradient is rendered vertically or
   horizontally) depends on the width and height of the :ref:`OEImageBase <OEDepict_OEImageBase>` object.
   If the width is greater than the height, then the color gradient is drawn
   horizontally; otherwise it is rendered vertically .
   See examples in :ref:`Figure: Example of rendering the same color gradient into different dimensions<figure_draw_color_gradient_orientation>`.

   .. _figure_draw_color_gradient_orientation:

   .. figure:: ../images/OEDrawColorGradient_Orientation.*
      :align:  center

      **Example of rendering the same color gradient into different dimensions**

   The :oe:func:`OEGrapheme::OEDrawColorGradient` function can depict any color gradient
   derived from the :ref:`OEColorGradientBase <OESystem_OEColorGradientBase>` base class.
   See examples in :ref:`Figure: Example of rendering various color gradients<figure_draw_color_gradient_non_linear>`.

   .. _figure_draw_color_gradient_non_linear:

   .. figure:: ../images/OEDrawColorGradient_NonLinear.*
      :align:  center

      **Example of rendering various color gradients**

   .. seealso::

      * :ref:`OEColorGradientDisplayOptions <OEGrapheme_OEColorGradientDisplayOptions>` class
      * :ref:`OEColorGradientBase <OESystem_OEColorGradientBase>` base class
      * :ref:`OELinearColorGradient <OESystem_OELinearColorGradient>`,
        :ref:`OEExponentialColorGradient <OESystem_OEExponentialColorGradient>`,
        :ref:`OELogarithmicColorGradient <OESystem_OELogarithmicColorGradient>`, and
        :ref:`OEExponentColorGradient <OESystem_OEExponentColorGradient>` concrete classes


