Skip to content

Commit 0fdd90b

Browse files
committed
vpython: improve the capture implementation
1 parent c47d45d commit 0fdd90b

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

vpython/vpython.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3138,17 +3138,18 @@ def pixel_to_world(self):
31383138
def pixel_to_world(self, value):
31393139
raise AttributeError('pixel_to_world is read-only')
31403140

3141-
def capture(self, *s):
3142-
if len(s) == 0:
3143-
raise AttributeError('scene.capture requires at least one argument.')
3144-
filename = s[0]
3145-
if not isinstance(filename, str): raise AttributeError('A capture file name must be a string.')
3146-
if '.png' not in filename: filename += '.png'
3141+
def capture(self, filename, capture_labels=None):
3142+
if not isinstance(filename, str):
3143+
raise TypeError("'filename' for Capture must be a string.")
3144+
3145+
if filename[-4:] != ".png":
3146+
filename += ".png"
3147+
31473148
include_labels = "T"
3148-
if len(s) == 2:
3149-
if s[1] == True: include_labels = "T"
3150-
else: include_labels = "F"
3151-
self.addmethod('capture', include_labels+filename)
3149+
if capture_labels is not None:
3150+
include_labels = "T" if capture_labels else "F"
3151+
3152+
self.addmethod("capture", include_labels + filename)
31523153

31533154
@property
31543155
def objects(self):

0 commit comments

Comments
 (0)