Git Product home page Git Product logo

manim-data-structures's Introduction

Light Mode Logo

PyPI Latest Release MIT License Code style: black Documentation Status Downloads

A plugin that contains common data structures to create Manimations.

Installation

To install, simply run the following command:

pip install manim-data-structures

Importing

Simply use the following line of code to import the package:

from manim_data_structures import *

Usage

Code

class MainScene(Scene):
    def construct(self):
        # Create an array
        arr = MArray([8, 7, 6, 5, 4])
        self.play(Create(arr))

        # Animate array
        self.play(arr.animate.shift(UP * 2.5 + LEFT * 5))

        # Animate array element
        self.play(arr.animate_elem(3).shift(DOWN * 0.5))

        # Animate array element mobjects
        self.play(arr.animate_elem_square(0).set_fill(BLACK), arr.animate_elem_value(0).rotate(PI / 2).set_fill(RED), arr.animate_elem_index(0).rotate(PI / 2))

        # Display array with hex values
        arr2 = MArray([0, 2, 4, 6, 8], index_hex_display=True, index_offset=4)
        self.play(Create(arr2))
        self.play(arr2.animate.shift(DOWN * 2.5 + LEFT * 5))

        # Create customized array
        arr3 = MArray([1, 1, 2], mob_square_args={'color': GRAY_A, 'fill_color': RED_E, 'side_length': 0.5}, mob_value_args={'color': GOLD_A, 'font_size': 28}, mob_index_args={'color': RED_E, 'font_size': 22})
        self.play(Create(arr3))

        # Append element
        self.play(Write(arr2.append_elem(10)))

        # Append customized element
        self.play(Write(arr2.append_elem(12, mob_square_args={'fill_color': BLACK})))

        # Update value of element
        self.play(Write(arr2.update_elem_value(3, 0, mob_value_args={'color': RED})), arr2.animate_elem_square(3).set_fill(WHITE))

        self.wait()

Output

Array_Example.mp4

Other Links

manim-data-structures's People

Contributors

drageelr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.