Polygram#
Qualified name: manim.mobject.geometry.polygram.Polygram
- class Polygram(*vertex_groups, color='#58C4DD', **kwargs)[source]#
Bases:
manim.mobject.types.vectorized_mobject.VMobject
A generalized
Polygon
, allowing for disconnected sets of edges.- Parameters
Examples
Example: PolygramExample ¶
from manim import * import numpy as np class PolygramExample(Scene): def construct(self): hexagram = Polygram( [[0, 2, 0], [-np.sqrt(3), -1, 0], [np.sqrt(3), -1, 0]], [[-np.sqrt(3), 1, 0], [0, -2, 0], [np.sqrt(3), 1, 0]], ) self.add(hexagram) dot = Dot() self.play(MoveAlongPath(dot, hexagram), run_time=5, rate_func=linear) self.remove(dot) self.wait()
Methods
Gets the vertex groups of the
Polygram
.Gets the vertices of the
Polygram
.Rounds off the corners of the
Polygram
.Attributes
animate
Used to animate the application of any method of
self
.animation_overrides
color
depth
The depth of the mobject.
fill_color
If there are multiple colors (for gradient) this returns the first one
height
The height of the mobject.
sheen_factor
stroke_color
width
The width of the mobject.
- get_vertex_groups()[source]#
Gets the vertex groups of the
Polygram
.- Returns
The vertex groups of the
Polygram
.- Return type
numpy.ndarray
Examples
>>> poly = Polygram([ORIGIN, RIGHT, UP], [LEFT, LEFT + UP, 2 * LEFT]) >>> poly.get_vertex_groups() array([[[ 0., 0., 0.], [ 1., 0., 0.], [ 0., 1., 0.]], [[-1., 0., 0.], [-1., 1., 0.], [-2., 0., 0.]]])
- get_vertices()[source]#
Gets the vertices of the
Polygram
.- Returns
The vertices of the
Polygram
.- Return type
numpy.ndarray
Examples
>>> sq = Square() >>> sq.get_vertices() array([[ 1., 1., 0.], [-1., 1., 0.], [-1., -1., 0.], [ 1., -1., 0.]])
- round_corners(radius=0.5)[source]#
Rounds off the corners of the
Polygram
.- Parameters
radius (float) – The curvature of the corners of the
Polygram
.
See also
RoundedRectangle
Examples
Example: PolygramRoundCorners ¶
from manim import * class PolygramRoundCorners(Scene): def construct(self): star = Star(outer_radius=2) shapes = VGroup(star) shapes.add(star.copy().round_corners(radius=0.1)) shapes.add(star.copy().round_corners(radius=0.25)) shapes.arrange(RIGHT) self.add(shapes)