Skip to content

Instantly share code, notes, and snippets.

@uwezi
Last active March 19, 2023 13:43
Show Gist options
  • Save uwezi/15b23a51226ef11a0e0ec09bc4a7a436 to your computer and use it in GitHub Desktop.
Save uwezi/15b23a51226ef11a0e0ec09bc4a7a436 to your computer and use it in GitHub Desktop.
[Custom labels on a PolarPlane] Putting your own labels onto a PolarPlane. #manim #polarplane #labels
# https://discord.com/channels/581738731934056449/1023856228377563227/1024233361130135552
from manim import *
class ClockFaces(Scene):
def draw_text_lines(self, line1, line2, offset=np.array([3.5, 0.5, 0])):
text_heading = Text(line1)
text_heading.shift(offset)
text_body = Text(line2)
text_body.next_to(text_heading, DOWN)
return text_heading, text_body
def construct(self):
line, _ = self.draw_text_lines("Imagine a clockface", "")
self.play(FadeIn(line))
self.wait()
### DRAW 12HR CLOCK
plane = PolarPlane(radius_max=2,
azimuth_step=12,
azimuth_units='degrees',
azimuth_direction='CW',
radius_config={
"stroke_width": 0,
"include_ticks": False
},
azimuth_offset=np.pi / 2) #.add_coordinates()
plane.shift(np.array([-3.5, 0, 0]))
self.play(LaggedStart(Write(plane), run_time=3, lag_ratio=0.5))
self.wait()
for i in range(12):
self.play(Write(Text("{}".format(i+1), font_size=20, color=BLUE).move_to(plane.polar_to_point(2.2,(2-i)*360*DEGREES/12))))
self.wait(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment