Team Ai
Datasetpublic

shekhar98/manim_community_and_documentation_code

Dataset Description: Manim Code Examples Overview:This dataset consists of 210 code examples demonstrating the usage of Manim, a powerful mathematical animation engine for creating precise and visually appealing animations. Each example is structured as a JSON object containing three key components: a prompt, a response, and metadata. The dataset serves as a comprehensive resource for learning, teaching, or experimenting with Manim's capabilities in animating mathematical… See the full description on the dataset page: https://huggingface.co/datasets/shekhar98/manim_community_and_documentation_code.

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes4downloads
Dataset Card

Dataset Description: Manim Code Examples

Overview: This dataset consists of 210 code examples demonstrating the usage of Manim, a powerful mathematical animation engine for creating precise and visually appealing animations. Each example is structured as a JSON object containing three key components: a prompt, a response, and metadata. The dataset serves as a comprehensive resource for learning, teaching, or experimenting with Manim's capabilities in animating mathematical concepts, geometric shapes, and other visual elements.


Structure of the Dataset:

Each entry in the dataset follows this format:

json
{
  "prompt": "A concise description of the task or concept being demonstrated.",
  "response": "The corresponding Python code snippet using Manim to achieve the described task.",
  "metadata": {
    "source": "The URL or reference where the example originates from.",
    "original_name": "The name or identifier of the specific feature or class being demonstrated."
  }
}

Key Components:

  1. 1.Prompt (`prompt`):
  2. 2.A short, descriptive explanation of the animation or feature being showcased.
  3. 3.Provides context for the code snippet and helps users understand its purpose.
  4. 4.Examples:
  5. 5."Demonstrate how a square's FadeIn animation can be overridden to instead create the shape from scratch."
  6. 6."Show surrounding rectangle and add three texts over it with Succession animation."
  1. 1.Response (`response`):
  2. 2.A Python code snippet written using the Manim library.
  3. 3.Implements the concept or task described in the prompt.
  4. 4.Includes imports, custom classes (if necessary), and the main animation logic.
  5. 5.Examples:
  6. 6.Overriding the FadeIn animation to use Create instead.
  7. 7.Animating a group of dots with varying lag ratios and labeling them.
  1. 1.Metadata (`metadata`):
  2. 2.Contains additional information about the source and context of the example.
  3. 3.Fields:
  4. 4.source: The URL or documentation reference where the example is derived from (e.g., Manim's official documentation).
  5. 5.original_name: The name of the specific feature, class, or method being demonstrated (e.g., Animation, Add, FadeIn).

Example Entries:

Example 1: Overriding Animation
json
{
  "prompt": "Demonstrate how a square's FadeIn animation can be overridden to instead create the shape from scratch.",
  "response": "from manim import *\n\nclass MySquare(Square):\n    @override_animation(FadeIn)\n    def _fade_in_override(self, **kwargs):\n        return Create(self, **kwargs)\n\nclass OverrideAnimationExample(Scene):\n    def construct(self):\n        self.play(FadeIn(MySquare()))",
  "metadata": {
    "source": "https://docs.manim.community/en/stable/reference/manim.animation.animation.html",
    "original_name": "animation"
  }
}
Example 2: Surrounding Rectangle with Succession Animation
json
{
  "prompt": "Show surrounding rectangle and add three texts over it with Succession animation.",
  "response": "from manim import *\n\nclass DefaultAddScene(Scene):\n    def construct(self):\n        text_1 = Text(\"I was added with Add!\")\n        text_2 = Text(\"Me too!\")\n        text_3 = Text(\"And me!\")\n        texts = VGroup(text_1, text_2, text_3).arrange(DOWN)\n        rect = SurroundingRectangle(texts, buff=0.5)\n\n        self.play(\n            Create(rect, run_time=3.0),\n            Succession(\n                Wait(1.0),\n                Add(text_1),\n                Wait(1.0),\n                Add(text_2, text_3),\n            ),\n        )\n        self.wait()",
  "metadata": {
    "source": "https://docs.manim.community/en/stable/reference/manim.animation.animation.Add.html",
    "original_name": "Add"
  }
}
Example 3: Lag Ratios in Dot Animations
json
{
  "prompt": "Demonstrate the animation of dot groups with varying lag ratios and vertical shifts, displaying corresponding text labels.",
  "response": "from manim import *\n\nclass LagRatios(Scene):\n    def construct(self):\n        ratios = [0, 0.1, 0.5, 1, 2]  # demonstrated lag_ratios\n\n        # Create dot groups\n        group = VGroup(*[Dot() for _ in range(4)]).arrange_submobjects()\n        groups = VGroup(*[group.copy() for _ in ratios]).arrange_submobjects(buff=1)\n        self.add(groups)\n\n        # Label groups\n        self.add(Text(\"lag_ratio = \", font_size=36).next_to(groups, UP, buff=1.5))\n        for group, ratio in zip(groups, ratios):\n            self.add(Text(str(ratio), font_size=36).next_to(group, UP))\n\n        #Animate groups with different lag_ratios\n        self.play(AnimationGroup(*[\n            group.animate(lag_ratio=ratio, run_time=1.5).shift(DOWN * 2)\n            for group, ratio in zip(groups, ratios)\n        ]))\n\n        # lag_ratio also works recursively on nested submobjects:\n        self.play(groups.animate(run_time=1, lag_ratio=0.1).shift(UP * 2))",
  "metadata": {
    "source": "https://docs.manim.community/en/stable/reference/manim.animation.animation.Animation.html",
    "original_name": "Animation"
  }
}

Use Cases:

  1. 1.Learning Manim:
  2. 2.Ideal for beginners and intermediate users who want to explore Manim's features through practical examples.
  3. 3.Helps users understand how to implement specific animations and customize them.
  1. 1.Teaching and Tutorials:
  2. 2.Can be used by educators to create lesson plans or tutorials on mathematical animations.
  1. 1.Experimentation and Prototyping:
  2. 2.Developers can experiment with the provided code snippets to prototype new animations or modify existing ones.
  1. 1.Documentation and Reference:
  2. 2.Serves as a supplementary resource for Manim's official documentation, offering concrete examples for each feature.

Dataset Highlights:

  • —Comprehensive Coverage: The dataset includes a wide variety of animations, ranging from basic shape manipulations to advanced techniques like overriding animations and recursive lag ratios.
  • —Real-World Context: Each example is grounded in a practical use case, making it easier for users to relate the code to real-world applications.
  • —Traceable Sources: Every example is linked to its original source, ensuring transparency and enabling users to explore further documentation if needed.

Size and Scope:

  • —Number of Examples: 210
  • —Primary Library: Manim
  • —Programming Language: Python
  • —Topics Covered:
  • —Basic animations (e.g., FadeIn, Create, Transform)
  • —Advanced techniques (e.g., overriding animations, lag ratios)
  • —Scene construction and customization
  • —Text and shape manipulations

Conclusion:

This dataset is a valuable resource for anyone interested in mastering Manim or exploring the art of mathematical animations. With its diverse range of examples, clear structure, and traceable sources, it provides a solid foundation for both learning and innovation in the field of animated visualizations. --- license: mit ---