# Recipe 26: Cropping a picture onto a canvas

def copyBarbsFace():

  # Set up the source and target pictures
  barbf=getMediaPath('barbara.jpg')
  barb = makePicture(barbf)
  canvas = makeEmptyPicture(400, 500)

  # Now, do the actual copying
  targetX = 100
  for sourceX in range(45,200):
    targetY = 100
    for sourceY in range(25,200):
      color = getColor(getPixel(barb,sourceX,sourceY))
      setColor(getPixel(canvas,targetX,targetY), color)
      targetY = targetY + 1
    targetX = targetX + 1
  show(barb)
  show(canvas)
  return canvas

