Skip to content

Commit

Permalink
Add Scene.point_to_mobject
Browse files Browse the repository at this point in the history
  • Loading branch information
3b1b committed Aug 22, 2021
1 parent 61aec60 commit acba13f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion manimlib/scene/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def interact(self):
self.quit_interaction = False
self.lock_static_mobject_data()
while not (self.window.is_closing or self.quit_interaction):
self.update_frame()
self.update_frame(1 / self.camera.frame_rate)
if self.window.is_closing:
self.window.destroy()
if self.quit_interaction:
Expand Down Expand Up @@ -248,6 +248,18 @@ def get_mobjects(self):
def get_mobject_copies(self):
return [m.copy() for m in self.mobjects]

def point_to_mobject(self, point, search_set=None, buff=0):
"""
E.g. if clicking on the scene, this returns the top layer mobject
under a given point
"""
if search_set is None:
search_set = self.mobjects
for mobject in reversed(search_set):
if mobject.is_point_touching(point, buff=buff):
return mobject
return None

# Related to skipping
def update_skipping_status(self):
if self.start_at_animation_number is not None:
Expand Down

0 comments on commit acba13f

Please sign in to comment.