# Recipe 23: Copying a picture to canvas

def copyBarb():

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

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

