Skip to content

Conversation

mathsvisualization
Copy link

Motivation

Currently, some methods were implemented only in Arrow even though they are
more general and applicable to all Line-based objects (including StrokeArrow).
This caused:

  • Code duplication (same logic repeated in Arrow).
  • Inconsistency (methods unavailable in StrokeArrow).
  • Bugs (e.g., set_path_arc in Line did not behave correctly).

This PR moves/refactors these methods into the Line class so that they can be
reused consistently across all inheriting classes.


Proposed changes

  • Moved reset_points_around_ends from ArrowLine.
  • Fixed and generalized set_path_arc in Line so that it works for both
    Arrow and StrokeArrow.
  • Moved set_perpendicular_to_camera from ArrowLine.
  • Removed redundant implementations from Arrow.
  • Added missing type hint import:
  from typing import Tuple

Code

from manimlib import *

class TestInsertLine(InteractiveScene):
    def construct(self):
        # Line with arc
        line = Line(LEFT, RIGHT, path_arc=PI, color=BLUE)
        line.always.set_perpendicular_to_camera(self.frame)
        self.add(line)
        line.set_path_arc(PI/2)

        # Arrow inherits Line functionality
        arrow = Arrow(LEFT, RIGHT, path_arc=-PI/4, color=RED)
        arrow.always.set_perpendicular_to_camera(self.frame)
        self.add(arrow)
        arrow.set_path_arc(-PI/2)

        # StrokeArrow also inherits Line functionality
        stroke_arrow = StrokeArrow(LEFT, RIGHT, path_arc=PI/3, color=GREEN)
        stroke_arrow.always.set_perpendicular_to_camera(self.frame)
        self.add(stroke_arrow)
        stroke_arrow.set_path_arc(PI/2)

Result:

  • All three (Line, Arrow, and StrokeArrow) correctly reset around their ends.
  • set_path_arc now applies consistently to both Arrow and StrokeArrow.
  • set_perpendicular_to_camera works for all classes without duplication.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant