Class 35 — Monday April 26

Chrestomatics and patterning

It’s simply smashing β€” For visitors on the Lawn β€” If they watch their steps


Look both ways


Agenda


Epistle


Gallery


Module cw.py


Module mash.py




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 fspot pixel on fg image

  nx = sx + fx # determine the shifted nspot 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)


Function previously written


Functions to be written

  • Should make use of function distance().

  • Should make use of function similar().


  • Should make use of functions inbounds() and is_background().










 


  πŸ¦† © 2022 Jim Cohoon   Resources from previous semesters are available.