Homework 31

Due Thursday December 5


Module mash.py


Downloads


Primary function (already written)

def combine( bg, fg, sx, sy, back_screen ) :

  bw, bh = bg.size # size of background image

  fw, fh = fg.size # size of foreground image

  copy = bg.copy() # get a copy of background image

  new_image = copy.convert( 'RGB' ) # to be the basis of new image

  for fx in range( 0, fw ) : # consider every (fx, fy)

  for fy in range( 0, fh ): # possibility of the new image

  fspot = ( fx, fy ) # name spot (fx, fy )

  fpixel = fg.getpixel( fspot ) # get the pixel at fspot

  nx = sx + fx # determine spot on new image

  ny = sy + fy # to paint fpixel

  nspot = ( nx, ny )

  # check whether fpixel should be painted on new image at nspot

  if ( colorable( nspot, new_image, fpixel, back_screen ) ) :

  new_image.putpixel( nspot, fpixel )

  return new_image # return the mash up


Helpful constant (already defined)


Functions to be written







 























 


 

 

 
   
   
   
 
  © 2019 Jim Cohoon   Resources from previous semesters are available.