Skip to content

Commit

Permalink
Release 0.1.6 (#6)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
drageelr authored Dec 26, 2022
1 parent ff92e11 commit 421b18c
Show file tree
Hide file tree
Showing 9 changed files with 1,147 additions and 160 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.6] - 2022-12-26

### PRS

- [#5](https://github.com/drageelr/manim-data-structures/pull/5)
- `MArrayElement` & `MArray` & `MVariable`play animations by themselves.
- `MArrayPointer` added.

## [0.1.5] - 2022-12-10

### PRs
Expand Down
45 changes: 45 additions & 0 deletions docs/source/example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Example Gallery
===============

.. currentmodule:: manim_data_structures.m_array

Find Pair Sum In Sorted MArray
------------------------------

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]``.

.. manim:: MainScene
:quality: low

from manim_data_structures import *

class MainScene(Scene):
def isPairSumAnim(self, arr, n, val):
p_i = MArrayPointer(self, arr, 0, 'i', mob_arrow_args={'color': GREEN}, mob_label_args={'color': GREEN})
p_j = MArrayPointer(self, arr, n - 1, 'j', mob_arrow_args={'color': YELLOW}, mob_label_args={'color': YELLOW})
pair_sum = MVariable(self, 0, label='Sum')
pair_sum.shift(DOWN * 2)

self.play(Create(pair_sum))
self.play(Create(p_i), Create(p_j))

while (p_i.fetch_index() < p_j.fetch_index()):
pair_sum.update_value(arr.fetch_arr()[p_i.fetch_index()] + arr.fetch_arr()[p_j.fetch_index()])

if (pair_sum.fetch_value() == val):
pair_sum.fetch_mob_square().set(fill_color=GREEN)
return True
elif(pair_sum.fetch_value() < val):
p_i.shift_to_elem(p_i.fetch_index() + 1)
else:
p_j.shift_to_elem(p_j.fetch_index() - 1)

pair_sum.fetch_mob_square().set(fill_color=RED)
return False

def construct(self):
arr = MArray(self, [2, 3, 5, 8, 9, 10, 11], label='Array')
arr.shift(UP + LEFT * 2)
self.add(arr)
self.isPairSumAnim(arr, 7, 17)
self.wait(1)
Loading

0 comments on commit 421b18c

Please sign in to comment.