Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

added DashedLine and CurvesAsSubmobjects example to docs (#833)

kolibril133d293ab64b39
diff --git a/docs/source/examples.rst b/docs/source/examples.rst
index 1a914d08a..a42f5510e 100644
--- a/docs/source/examples.rst
+++ b/docs/source/examples.rst
@@ -49,18 +49,6 @@ Basic Concepts
self.add(logo)
-.. manim:: GradientImageFromArray
- :save_last_frame:
- :ref_classes: ImageMobject
-
- class GradientImageFromArray(Scene):
- def construct(self):
- n = 256
- imageArray = np.uint8(
- [[i * 256 / n for i in range(0, n)] for _ in range(0, n)]
- )
- image = ImageMobject(imageArray).scale(2)
- self.add(image)
.. manim:: BraceAnnotation
:save_last_frame:
@@ -91,6 +79,19 @@ Basic Concepts
tip_text = Text('(2, 2)').next_to(arrow.get_end(), RIGHT)
self.add(numberplane, dot, arrow, origin_text, tip_text)
+.. manim:: GradientImageFromArray
+ :save_last_frame:
+ :ref_classes: ImageMobject
+
+ class GradientImageFromArray(Scene):
+ def construct(self):
+ n = 256
+ imageArray = np.uint8(
+ [[i * 256 / n for i in range(0, n)] for _ in range(0, n)]
+ )
+ image = ImageMobject(imageArray).scale(2)
+ self.add(image)
+
.. manim:: BezierSpline
:save_last_frame:
:ref_classes: Line VGroup
diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.py
index c3cf17f24..347ced43e 100644
--- a/manim/mobject/geometry.py
+++ b/manim/mobject/geometry.py
@@ -710,6 +710,20 @@ class Line(TipableVMobject):
class DashedLine(Line):
+ """A dashed Line.
+
+ Examples
+ --------
+ .. manim:: DashedLineExample
+ :save_last_frame:
+
+ class DashedLineExample(Scene):
+ def construct(self):
+ dashed_line = DashedLine(config.frame_width/2*LEFT, 4*RIGHT)
+ self.add(dashed_line)
+
+ """
+
def __init__(
self,
*args,
diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py
index fc7f719f5..a74d7e4ea 100644
--- a/manim/mobject/types/vectorized_mobject.py
+++ b/manim/mobject/types/vectorized_mobject.py
@@ -1458,6 +1458,22 @@ class VectorizedPoint(VMobject):
class CurvesAsSubmobjects(VGroup):
+ """Convert a curve's elements to submobjects.
+
+ Examples
+ --------
+ .. manim:: LineGradientExample
+ :save_last_frame:
+
+ class LineGradientExample(Scene):
+ def construct(self):
+ curve = ParametricFunction(lambda t: [t, np.sin(t), 0], t_min = -PI, t_max=PI,stroke_width=10)
+ new_curve = CurvesAsSubmobjects(curve)
+ new_curve.set_color_by_gradient(BLUE, RED)
+ self.add(new_curve.shift(UP), curve)
+
+ """
+
def __init__(self, vmobject, **kwargs):
VGroup.__init__(self, **kwargs)
tuples = vmobject.get_cubic_bezier_tuples()