Skip to content

Fix formatting of color space documentation #4274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions manim/utils/color/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,35 @@
To implement a custom color space, you must subclass :class:`ManimColor` and implement
three important methods:

- :attr:`~.ManimColor._internal_value`: a ``@property`` implemented on
:class:`ManimColor` with the goal of keeping a consistent internal representation
which can be referenced by other functions in :class:`ManimColor`. This property acts
as a proxy to whatever representation you need in your class.
- :attr:`~.ManimColor._internal_value`: a ``@property`` implemented on
:class:`ManimColor` with the goal of keeping a consistent internal representation
which can be referenced by other functions in :class:`ManimColor`. This property acts
as a proxy to whatever representation you need in your class.

- The getter should always return a NumPy array in the format ``[r,g,b,a]``, in
accordance with the type :class:`ManimColorInternal`.
- The getter should always return a NumPy array in the format ``[r,g,b,a]``, in
accordance with the type :class:`ManimColorInternal`.

- The setter should always accept a value in the format ``[r,g,b,a]`` which can be
converted to whatever attributes you need.
- The setter should always accept a value in the format ``[r,g,b,a]`` which can be
converted to whatever attributes you need.

- :attr:`~ManimColor._internal_space`: a read-only ``@property`` implemented on
:class:`ManimColor` with the goal of providing a useful representation which can be
used by operators, interpolation and color transform functions.
- :attr:`~ManimColor._internal_space`: a read-only ``@property`` implemented on
:class:`ManimColor` with the goal of providing a useful representation which can be
used by operators, interpolation and color transform functions.

The only constraints on this value are:
The only constraints on this value are:

- It must be a NumPy array.
- It must be a NumPy array.

- The last value must be the opacity in a range ``0.0`` to ``1.0``.
- The last value must be the opacity in a range ``0.0`` to ``1.0``.

Additionally, your ``__init__`` must support this format as an initialization value
without additional parameters to ensure correct functionality of all other methods in
:class:`ManimColor`.
Additionally, your ``__init__`` must support this format as an initialization value
without additional parameters to ensure correct functionality of all other methods in
:class:`ManimColor`.

- :meth:`~ManimColor._from_internal`: a ``@classmethod`` which converts an
``[r,g,b,a]`` value into suitable parameters for your ``__init__`` method and calls
the ``cls`` parameter.

- :meth:`~ManimColor._from_internal`: a ``@classmethod`` which converts an
``[r,g,b,a]`` value into suitable parameters for your ``__init__`` method and calls
the ``cls`` parameter.
"""

from __future__ import annotations
Expand Down