Skip to content

Commit acba13f

Browse files
committed
Add Scene.point_to_mobject
1 parent 61aec60 commit acba13f

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

manimlib/scene/scene.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def interact(self):
104104
self.quit_interaction = False
105105
self.lock_static_mobject_data()
106106
while not (self.window.is_closing or self.quit_interaction):
107-
self.update_frame()
107+
self.update_frame(1 / self.camera.frame_rate)
108108
if self.window.is_closing:
109109
self.window.destroy()
110110
if self.quit_interaction:
@@ -248,6 +248,18 @@ def get_mobjects(self):
248248
def get_mobject_copies(self):
249249
return [m.copy() for m in self.mobjects]
250250

251+
def point_to_mobject(self, point, search_set=None, buff=0):
252+
"""
253+
E.g. if clicking on the scene, this returns the top layer mobject
254+
under a given point
255+
"""
256+
if search_set is None:
257+
search_set = self.mobjects
258+
for mobject in reversed(search_set):
259+
if mobject.is_point_touching(point, buff=buff):
260+
return mobject
261+
return None
262+
251263
# Related to skipping
252264
def update_skipping_status(self):
253265
if self.start_at_animation_number is not None:

0 commit comments

Comments
 (0)