A Manim implementation for data structures
Project description
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
Other Links
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for manim_data_structures-0.1.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84e777c9e34fbc6e114dcbc00b821d41cec991d0ace5464f8bc569cb25063ca4 |
|
MD5 | 2ac38d4b1628bcf67f168087ab07cf09 |
|
BLAKE2b-256 | 5ed82c886681eb56448ece1ab91d97fcf3e9ebd0b603a28e50d4b0346f3a33d7 |
Close
Hashes for manim_data_structures-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e828148a4cbfcae164ec4690af912a3e09a4b242e4d3db932810bdcf6ee0d3c7 |
|
MD5 | c38b5b722820c50e3e47821a4821d1af |
|
BLAKE2b-256 | 656b6864b59f8c061807d1581fe6fe1811e829296adf6c3e13d7cf258c10cced |