Skip to content

Commit

Permalink
add note in docstring of ManimColor about class constructors (#3554)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 authored Dec 28, 2023
1 parent 472eaae commit 4a963c4
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions manim/utils/color/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,33 @@ class ManimColor:
Be careful when passing strings to ManimColor it can create a big overhead for the color processing.
If you want to parse a list of colors use the function :meth:`parse` in :class:`ManimColor` which assumes that
you are going to pass a list of color so arrays will not bei interpreted as a single color.
you are going to pass a list of color so arrays will not be interpreted as a single color.
.. warning::
If you pass an array of numbers to :meth:`parse` it will interpret the r,g,b,a numbers in that array as colors
so instead of the expect singular color you get and array with 4 colors.
For conversion behaviors see the _internal functions for further documentation
For conversion behaviors see the ``_internal`` functions for further documentation
You can create a ``ManimColor`` instance via its classmethods. See the respective methods for more info.
.. code-block:: python
mycolor = ManimColor.from_rgb((0, 1, 0.4, 0.5))
myothercolor = ManimColor.from_rgb((153, 255, 255))
You can also convert between different color spaces:
.. code-block:: python
mycolor_hex = mycolor.to_hex()
myoriginalcolor = ManimColor.from_hex(mycolor_hex).to_hsv()
Parameters
----------
value
Some representation of a color (e.g., a string or
a suitable tuple).
a suitable tuple). The default ``None`` is ``BLACK``.
alpha
The opacity of the color. By default, colors are
fully opaque (value 1.0).
Expand Down

0 comments on commit 4a963c4

Please sign in to comment.