-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Port Graph to OpenGL #1202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Port Graph to OpenGL #1202
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ab8b92d
Tex working with artifacts
eulertour 752dce3
Add OpenGLTex
eulertour e3153f7
Add OpenGLText
eulertour 0c7e98a
Add OpenGLText and related classes
eulertour c61bf02
Add OpenGLText and related classes
eulertour 1f010ac
Merge remote-tracking branch 'origin/master' into opengl-tex
eulertour bf3dba2
Undo changes to example code
eulertour 2a861d0
Checks
eulertour 7393b36
Add OpenGLGraph, OpenGLLabelledDot
eulertour File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -206,7 +206,10 @@ def __deepcopy__(self, clone_from_id): | |||||
return result | ||||||
|
||||||
def __repr__(self): | ||||||
return str(self.name) | ||||||
if config["use_opengl_renderer"]: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return super().__repr__() | ||||||
else: | ||||||
return str(self.name) | ||||||
|
||||||
def reset_points(self): | ||||||
"""Sets :attr:`points` to be an empty array.""" | ||||||
|
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -352,6 +352,57 @@ def __init__(self, radius=DEFAULT_SMALL_DOT_RADIUS, **kwargs): | |||||
super().__init__(radius=radius, **kwargs) | ||||||
|
||||||
|
||||||
class OpenGLLabeledDot(OpenGLDot): | ||||||
"""A :class:`Dot` containing a label in its center. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
Parameters | ||||||
---------- | ||||||
label : Union[:class:`str`, :class:`~.SingleStringMathTex`, :class:`~.Text`, :class:`~.Tex`] | ||||||
The label of the :class:`Dot`. This is rendered as :class:`~.MathTex` | ||||||
by default (i.e., when passing a :class:`str`), but other classes | ||||||
representing rendered strings like :class:`~.Text` or :class:`~.Tex` | ||||||
can be passed as well. | ||||||
|
||||||
radius : :class:`float` | ||||||
The radius of the :class:`Dot`. If ``None`` (the default), the radius | ||||||
is calculated based on the size of the ``label``. | ||||||
|
||||||
Examples | ||||||
-------- | ||||||
|
||||||
.. manim:: SeveralLabeledDots | ||||||
:save_last_frame: | ||||||
|
||||||
class SeveralLabeledDots(Scene): | ||||||
def construct(self): | ||||||
sq = Square(fill_color=RED, fill_opacity=1) | ||||||
self.add(sq) | ||||||
dot1 = LabeledDot(Tex("42", color=RED)) | ||||||
dot2 = LabeledDot(MathTex("a", color=GREEN)) | ||||||
dot3 = LabeledDot(Text("ii", color=BLUE)) | ||||||
dot4 = LabeledDot("3") | ||||||
dot1.next_to(sq, UL) | ||||||
dot2.next_to(sq, UR) | ||||||
dot3.next_to(sq, DL) | ||||||
dot4.next_to(sq, DR) | ||||||
self.add(dot1, dot2, dot3, dot4) | ||||||
""" | ||||||
|
||||||
def __init__(self, label, radius=None, **kwargs) -> None: | ||||||
if isinstance(label, str): | ||||||
from ..mobject.svg.opengl_tex_mobject import OpenGLMathTex | ||||||
|
||||||
rendered_label = OpenGLMathTex(label, color=BLACK) | ||||||
else: | ||||||
rendered_label = label | ||||||
|
||||||
if radius is None: | ||||||
radius = 0.1 + max(rendered_label.width, rendered_label.height) / 2 | ||||||
OpenGLDot.__init__(self, radius=radius, **kwargs) | ||||||
rendered_label.move_to(self.get_center()) | ||||||
self.add(rendered_label) | ||||||
|
||||||
|
||||||
class OpenGLEllipse(OpenGLCircle): | ||||||
def __init__(self, width=2, height=1, **kwargs): | ||||||
super().__init__(**kwargs) | ||||||
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.