#NEWLINE# def write( self , filename , debug = False ) : #NEWLINE# #INDENT# if ( Image is None ) : #NEWLINE# #INDENT# raise UserError ( 'Missing Python PIL which is required to create sprite sheets!' ) #NEWLINE# #UNINDENT# img = Image . new ( 'RGBA' , ( self . width , self . height ) ) #NEWLINE# draw = ImageDraw . Draw ( img ) #NEWLINE# for block in self . blocks : #NEWLINE# #INDENT# res = Image . open ( block . image . src ) #NEWLINE# ( x , y ) = ( block . fit . x , block . fit . y ) #NEWLINE# if block . rotated : #NEWLINE# #INDENT# Console . debug ( ( '%s is rotated' % block . image . src ) ) #NEWLINE# res = res . rotate ( 90 ) #NEWLINE# #UNINDENT# img . paste ( res , ( x , y ) ) #NEWLINE# del res #NEWLINE# if debug : #NEWLINE# #INDENT# ( x , y , w , h ) = ( block . fit . x , block . fit . y , block . w , block . h ) #NEWLINE# draw . rectangle ( ( x , y , ( x + w ) , ( y + h ) ) , outline = ( ( 0 , 0 , 255 , 255 ) if block . rotated else ( 255 , 0 , 0 , 255 ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if debug : #NEWLINE# #INDENT# for ( i , block ) in enumerate ( self . packer . getUnused ( ) ) : #NEWLINE# #INDENT# ( x , y , w , h ) = ( block . x , block . y , block . w , block . h ) #NEWLINE# draw . rectangle ( ( x , y , ( x + w ) , ( y + h ) ) , fill = ( 255 , 255 , 0 , 255 ) ) #NEWLINE# #UNINDENT# #UNINDENT# img . save ( filename )