@@ -965,22 +965,47 @@ def draw(self, position, orientation, tilt):
965965 bounding_box = self ._get_new_bounding_box ()
966966 offset_x = bounding_box ["min_x" ] * - 1
967967 offset_y = bounding_box ["min_y" ] * - 1
968- self ._tkPhotoImage = TK .PhotoImage (width = bounding_box ["width" ], height = bounding_box ["height" ])
968+ self ._tkPhotoImage = TK .PhotoImage (width = bounding_box ["width" ],
969+ height = bounding_box ["height" ])
969970
970971 for new_y in range (bounding_box ["height" ]):
971972 for new_x in range (bounding_box ["width" ]):
972- original_x , original_y = self ._transform_coordinates (new_x - offset_x , new_y - offset_y )
973-
974- if 0 <= original_x < self ._originalImage .width () - 1 and 0 <= original_y < self ._originalImage .height () - 1 :
973+ original_x , original_y = self ._transform_coordinates (
974+ new_x - offset_x , new_y - offset_y
975+ )
976+ if (
977+ 0 <= original_x < self ._originalImage .width () - 1
978+ and 0 <= original_y < self ._originalImage .height () - 1
979+ ):
975980 rgb = self ._interpolate_color (original_x , original_y )
976- is_transparent = self ._originalImage .transparency_get (int (original_x ), int (original_y ))
977- self ._tkPhotoImage .put ("#{:02x}{:02x}{:02x}" .format (rgb [0 ], rgb [1 ], rgb [2 ]), (new_x , new_y ))
978- self ._tkPhotoImage .transparency_set (new_x , new_y , is_transparent )
979- elif 0 <= int (original_x ) < self ._originalImage .width () and 0 <= int (original_y ) < self ._originalImage .height ():
980- rgb = self ._originalImage .get (int (original_x ),int (original_y ))
981- is_transparent = self ._originalImage .transparency_get (int (original_x ), int (original_y ))
982- self ._tkPhotoImage .put ("#{:02x}{:02x}{:02x}" .format (rgb [0 ], rgb [1 ], rgb [2 ]), (new_x , new_y ))
983- self ._tkPhotoImage .transparency_set (new_x , new_y , is_transparent )
981+ is_transparent = self ._originalImage .transparency_get (
982+ int (original_x ), int (original_y )
983+ )
984+ self ._tkPhotoImage .put (
985+ "#{:02x}{:02x}{:02x}" .format (rgb [0 ], rgb [1 ], rgb [2 ]),
986+ (new_x , new_y ),
987+ )
988+ self ._tkPhotoImage .transparency_set (
989+ new_x , new_y , is_transparent
990+ )
991+ elif (
992+ 0 <= int (original_x ) < self ._originalImage .width ()
993+ and 0 <= int (original_y ) < self ._originalImage .height ()
994+ ):
995+ rgb = self ._originalImage .get (
996+ int (original_x ), int (original_y )
997+ )
998+ is_transparent = self ._originalImage .transparency_get (
999+ int (original_x ), int (original_y )
1000+ )
1001+ self ._tkPhotoImage .put (
1002+ "#{:02x}{:02x}{:02x}" .format (rgb [0 ], rgb [1 ], rgb [2 ]),
1003+ (new_x , new_y ),
1004+ )
1005+ self ._tkPhotoImage .transparency_set (
1006+ new_x , new_y , is_transparent
1007+ )
1008+
9841009 self ._currentOrientation = orientation
9851010 self ._currentTilt = tilt
9861011 self ._screen ._drawimage (self ._item , position , self ._tkPhotoImage )
@@ -1000,9 +1025,7 @@ def __init__(self, type_, data=None):
10001025 if type_ == "polygon" :
10011026 if isinstance (data , list ):
10021027 data = tuple (data )
1003- elif type_ == "image" :
1004- assert (isinstance (data , TK .PhotoImage ))
1005- elif type_ == "transformable_image" :
1028+ elif type_ == "image" or type_ == "transformable_image" :
10061029 assert (isinstance (data , TK .PhotoImage ))
10071030 elif type_ == "compound" :
10081031 data = []
@@ -1241,8 +1264,8 @@ def register_shape(self, name, shape=None, rotate_image_shape=False):
12411264 of pairs of coordinates. Installs the corresponding
12421265 polygon shape
12431266 (4) name is an arbitrary string and shape is a
1244- (compound or transformable_image ) Shape object. Installs the corresponding
1245- shape.
1267+ (compound) Shape object. Installs the corresponding
1268+ compound shape.
12461269 To use a shape, you have to issue the command shape(shapename).
12471270
12481271 call: register_shape("turtle.gif")
@@ -3326,7 +3349,6 @@ def _clearstamp(self, stampid):
33263349 elif not isinstance (stampid , TransformableImage ):
33273350 self .screen ._delete (stampid )
33283351 self .stampItems .remove (stampid )
3329-
33303352 # Delete stampitem from undobuffer if necessary
33313353 # if clearstamp is called directly.
33323354 item = ("stamp" , stampid )
0 commit comments