Skip to content

Commit 421b18c

Browse files
authored
Release 0.1.6 (#6)
* BREAKING CHANGE: MArrayElement & MArray & MVariable play animations by themselves + MArrayPointer added (#5) * perf: MArrayElement automatically plays animations on update calls * perf: MArray can now play animations + refactored functions to improve readability * perf: MVaraible can now play animations * fix: deepcopy implemented for MArrayElement & MArray + MArray label for even elements resolved * docs: updated docs according to recent changes * feat: MArrayPointer added * fix: MArrayPointer spawn & shift error resolved * docs: added docs for MArrayPointer & Example Gallery * docs: updated changelog for release 0.1.6
1 parent ff92e11 commit 421b18c

9 files changed

Lines changed: 1147 additions & 160 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.1.6] - 2022-12-26
9+
10+
### PRS
11+
12+
- [#5](https://github.com/drageelr/manim-data-structures/pull/5)
13+
- `MArrayElement` & `MArray` & `MVariable`play animations by themselves.
14+
- `MArrayPointer` added.
15+
816
## [0.1.5] - 2022-12-10
917

1018
### PRs

docs/source/example.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Example Gallery
2+
===============
3+
4+
.. currentmodule:: manim_data_structures.m_array
5+
6+
Find Pair Sum In Sorted MArray
7+
------------------------------
8+
9+
The code snippet below uses the famous two pointer technique to find the pair sum ``17`` in the sorted array ``[2, 3, 5, 8, 9, 10, 11]``.
10+
11+
.. manim:: MainScene
12+
:quality: low
13+
14+
from manim_data_structures import *
15+
16+
class MainScene(Scene):
17+
def isPairSumAnim(self, arr, n, val):
18+
p_i = MArrayPointer(self, arr, 0, 'i', mob_arrow_args={'color': GREEN}, mob_label_args={'color': GREEN})
19+
p_j = MArrayPointer(self, arr, n - 1, 'j', mob_arrow_args={'color': YELLOW}, mob_label_args={'color': YELLOW})
20+
pair_sum = MVariable(self, 0, label='Sum')
21+
pair_sum.shift(DOWN * 2)
22+
23+
self.play(Create(pair_sum))
24+
self.play(Create(p_i), Create(p_j))
25+
26+
while (p_i.fetch_index() < p_j.fetch_index()):
27+
pair_sum.update_value(arr.fetch_arr()[p_i.fetch_index()] + arr.fetch_arr()[p_j.fetch_index()])
28+
29+
if (pair_sum.fetch_value() == val):
30+
pair_sum.fetch_mob_square().set(fill_color=GREEN)
31+
return True
32+
elif(pair_sum.fetch_value() < val):
33+
p_i.shift_to_elem(p_i.fetch_index() + 1)
34+
else:
35+
p_j.shift_to_elem(p_j.fetch_index() - 1)
36+
37+
pair_sum.fetch_mob_square().set(fill_color=RED)
38+
return False
39+
40+
def construct(self):
41+
arr = MArray(self, [2, 3, 5, 8, 9, 10, 11], label='Array')
42+
arr.shift(UP + LEFT * 2)
43+
self.add(arr)
44+
self.isPairSumAnim(arr, 7, 17)
45+
self.wait(1)

0 commit comments

Comments
 (0)