PMobject

Qualified name: manim.mobject.types.point\_cloud\_mobject.PMobject

class PMobject(stroke_width=4, **kwargs)[source]

Bases: Mobject

A disc made of a cloud of Dots

Examples

Example: PMobjectExample

../_images/PMobjectExample-1.png
from manim import *

class PMobjectExample(Scene):
    def construct(self):

        pG = PGroup()  # This is just a collection of PMobject's

        # As the scale factor increases, the number of points
        # removed increases.
        for sf in range(1, 9 + 1):
            p = PointCloudDot(density=20, radius=1).thin_out(sf)
            # PointCloudDot is a type of PMobject
            # and can therefore be added to a PGroup
            pG.add(p)

        # This organizes all the shapes in a grid.
        pG.arrange_in_grid()

        self.add(pG)
class PMobjectExample(Scene):
    def construct(self):

        pG = PGroup()  # This is just a collection of PMobject's

        # As the scale factor increases, the number of points
        # removed increases.
        for sf in range(1, 9 + 1):
            p = PointCloudDot(density=20, radius=1).thin_out(sf)
            # PointCloudDot is a type of PMobject
            # and can therefore be added to a PGroup
            pG.add(p)

        # This organizes all the shapes in a grid.
        pG.arrange_in_grid()

        self.add(pG)

Methods

add_points

Add points.

align_points_with_larger

fade_to

filter_out

get_all_rgbas

get_array_attrs

get_color

Returns the color of the Mobject

get_mobject_type_class

Return the base class of this mobject type.

get_point_mobject

The simplest Mobject to be transformed to or from self.

get_stroke_width

ingest_submobjects

interpolate_color

match_colors

point_from_proportion

pointwise_become_partial

reset_points

Sets points to be an empty array.

set_color

Condition is function which takes in one arguments, (x, y, z).

set_color_by_gradient

set_colors_by_radial_gradient

set_stroke_width

sort_points

Function is any map from R^3 to R

thin_out

Removes all but every nth point for n = factor

Attributes

always

Call a method on a mobject every frame.

animate

Used to animate the application of any method of self.

animation_overrides

depth

The depth of the mobject.

height

The height of the mobject.

width

The width of the mobject.

Parameters:
  • stroke_width (int)

  • kwargs (Any)

_original__init__(stroke_width=4, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

Parameters:
  • stroke_width (int)

  • kwargs (Any)

Return type:

None

add_points(points, rgbas=None, color=None, alpha=1.0)[source]

Add points.

Points must be a Nx3 numpy array. Rgbas must be a Nx4 numpy array if it is not None.

Parameters:
Return type:

Self

get_color()[source]

Returns the color of the Mobject

Examples

>>> from manim import Square, RED
>>> Square(color=RED).get_color() == RED
True
Return type:

ManimColor

static get_mobject_type_class()[source]

Return the base class of this mobject type.

Return type:

type[PMobject]

get_point_mobject(center=None)[source]

The simplest Mobject to be transformed to or from self. Should by a point of the appropriate type

Parameters:

center (TypeAliasForwardRef('~manim.typing.Point3DLike') | None)

Return type:

Point

reset_points()[source]

Sets points to be an empty array.

Return type:

Self

set_color(color=ManimColor('#FFFF00'), family=True)[source]

Condition is function which takes in one arguments, (x, y, z). Here it just recurses to submobjects, but in subclasses this should be further implemented based on the the inner workings of color

Parameters:
Return type:

Self

set_color_by_gradient(*colors)[source]
Parameters:
  • colors (ParsableManimColor) – The colors to use for the gradient. Use like set_color_by_gradient(RED, BLUE, GREEN).

  • ManimColor.parse(color) (self.color =)

  • self (return)

Return type:

Self

sort_points(function=<function PMobject.<lambda>>)[source]

Function is any map from R^3 to R

Parameters:

function (Callable[[npt.NDArray[ManimFloat]], float])

Return type:

Self

thin_out(factor=5)[source]

Removes all but every nth point for n = factor

Parameters:

factor (int)

Return type:

Self