Add new animation TraceColor (Name for debate) and Graph.set_edge_color()#3533
Open
MrDiver wants to merge 4 commits intoManimCommunity:mainfrom
Open
Add new animation TraceColor (Name for debate) and Graph.set_edge_color()#3533MrDiver wants to merge 4 commits intoManimCommunity:mainfrom
TraceColor (Name for debate) and Graph.set_edge_color()#3533MrDiver wants to merge 4 commits intoManimCommunity:mainfrom
Conversation
MrDiver
commented
Dec 17, 2023
JasonGrace2282
requested changes
May 2, 2024
Member
JasonGrace2282
left a comment
There was a problem hiding this comment.
I like the animation idea!
Left some comments and questions on the implementation. Additionally, it would be nice to add some tests to make sure the methods are working properly.
| """ | ||
|
|
||
| def __init__( | ||
| self, mobject: "VMobject", color: ParsableManimColor, **kwargs |
Member
There was a problem hiding this comment.
Is there a reason VMobject is in quotations?
| self.suspend_mobject_updating: bool = suspend_mobject_updating | ||
| self.lag_ratio: float = lag_ratio | ||
| self._on_finish: Callable[[Scene], None] = _on_finish | ||
| self.mobject: VMobject |
Member
There was a problem hiding this comment.
Suggested change
| self.mobject: VMobject |
Is this neccessary?
| anim_args = {} | ||
| animation = anim_args.pop("animation", TraceColor) | ||
|
|
||
| mobj = self.get_edge(vertices) # Will error on DiGraph if edge is wrong way |
Member
There was a problem hiding this comment.
Might be a good idea to add a warning either in the code (via logger.warning) or in the docstring about DiGraph.
Same for the part below saying "this will not work on DiGraph"
| The order of the vertices is relevant here. | ||
| """ | ||
| try: | ||
| return self._edges[edge] |
Member
There was a problem hiding this comment.
Suggested change
| return self._edges[edge] | |
| return self.edges[edge] |
Typo?
| ) -> None: | ||
| super().__init__() | ||
|
|
||
| self.edges = {} |
Member
There was a problem hiding this comment.
Suggested change
| self.edges = {} | |
| self.edges: dict[tuple[Hashable, Hashable], Mobject] = {} |
This way linters can raise errors about setting/getting stuff from this attribute.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds some functionality which should simplify the usage of Graphs and animating the edges.
get_edge()now returns the Edge no matter if it is flipped or not. But only forGraphnot forDiGraphTraceColornow exists which can smoothly transition from one color to another over a shapeset_edge_coloron GenericGraph is overriden with an Animation such that it produces aTraceColoreffect when animating edge colors.SetEdgeColor.mp4
Where
TraceColoritself has the following behaviorTraceColorExample.mp4
There are still some problems with the z_indices of objects in the graph but the concept works