Skip to content

Instantly share code, notes, and snippets.

@uwezi
Last active July 4, 2024 17:51
Show Gist options
  • Save uwezi/89f4b63d87e4c8a59cc3abd345ab9e16 to your computer and use it in GitHub Desktop.
Save uwezi/89f4b63d87e4c8a59cc3abd345ab9e16 to your computer and use it in GitHub Desktop.
[Mark lines] mark lines with orthogonal tick marks. #manim #geometry #line
from manim import *
# https://discord.com/channels/581738731934056449/1174899083949899866/1175046975662604358
# by Abulafia
def mark_line(line, n_marks=1, length=0.3, distance=0.1, color=RED):
marks = VGroup(*[Line(ORIGIN, length*UP, color=color) for _ in range(n_marks)])
marks.arrange(RIGHT, buff=distance)
marks.rotate(line.get_angle())
marks.move_to(line.get_center())
return marks
class Test(MovingCameraScene):
def construct(self):
triangle = Polygon(ORIGIN, 2*RIGHT, 2*RIGHT+UP, color=BLUE).rotate(20*DEGREES).scale(2)
self.add(triangle)
sides = []
for i in range(3):
sides.append(Line(triangle.get_vertices()[i], triangle.get_vertices()[(i+1)%3]))
for i, side in enumerate(sides):
self.add(mark_line(side, n_marks=i+1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment