Skip to content

Commit 4a963c4

Browse files
add note in docstring of ManimColor about class constructors (#3554)
1 parent 472eaae commit 4a963c4

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

manim/utils/color/core.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,33 @@ class ManimColor:
7575
Be careful when passing strings to ManimColor it can create a big overhead for the color processing.
7676
7777
If you want to parse a list of colors use the function :meth:`parse` in :class:`ManimColor` which assumes that
78-
you are going to pass a list of color so arrays will not bei interpreted as a single color.
78+
you are going to pass a list of color so arrays will not be interpreted as a single color.
7979
8080
.. warning::
8181
If you pass an array of numbers to :meth:`parse` it will interpret the r,g,b,a numbers in that array as colors
8282
so instead of the expect singular color you get and array with 4 colors.
8383
84-
For conversion behaviors see the _internal functions for further documentation
84+
For conversion behaviors see the ``_internal`` functions for further documentation
85+
86+
You can create a ``ManimColor`` instance via its classmethods. See the respective methods for more info.
87+
88+
.. code-block:: python
89+
90+
mycolor = ManimColor.from_rgb((0, 1, 0.4, 0.5))
91+
myothercolor = ManimColor.from_rgb((153, 255, 255))
92+
93+
You can also convert between different color spaces:
94+
95+
.. code-block:: python
96+
97+
mycolor_hex = mycolor.to_hex()
98+
myoriginalcolor = ManimColor.from_hex(mycolor_hex).to_hsv()
8599
86100
Parameters
87101
----------
88102
value
89103
Some representation of a color (e.g., a string or
90-
a suitable tuple).
104+
a suitable tuple). The default ``None`` is ``BLACK``.
91105
alpha
92106
The opacity of the color. By default, colors are
93107
fully opaque (value 1.0).

0 commit comments

Comments
 (0)