Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

This page removed for FERPA compliance
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Example Cartoon Collage

REMOVED's an example program that produces a little cartoon.

Notice that this composition maps the robot onto the scene with no cropping or scaling. If we wanted to scale, we'd change how we incremented targetX and targetY, as the easiest thing.

def makeScene():
  bg = makePicture(getMediaPath("horse.jpg"))
  robot = makePicture(getMediaPath("robot.jpg"))
  #Put robot near bottom (20 pixels from bottom) on left (x=20)
  targetX = 20
  for sourceX in range(1,getWidth(robot)):
    targetY = getHeight(bg)-getHeight(robot)-20
    for sourceY in range(1,getHeight(robot)):
      color=getColor(getPixel(robot,sourceX,sourceY))
      setColor(getPixel(bg,targetX,targetY),color)
      targetY = targetY + 1
    targetX = targetX + 1
  # Add something that the robot is saying
  # JREMOVEDt above his head
  targetX = 20
  targetY = getHeight(bg)-getHeight(robot)-40
  addText(bg,targetX,targetY,"Take me to your leader!")
  show(bg)
  return bg



And here's the result:
Uploaded Image: robot-horse.jpg