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

wed code - colin


def chromakeyBasic():
  background = makePicture(getMediaPath("sting2.jpg"))
  bart = makePicture(getMediaPath("bart2.png"))

  #openPictureTool(background)

  xOffset = 198
  yOffset = 136

  for x in range(1, getWidth(bart)):
    for y in range(1, getHeight(bart)):
      p = getPixel(bart, x, y) # green one
      c = getColor(p)

      targetP = getPixel(background, x + xOffset, y + yOffset)

      # copies the pixels over if the distance is large enough
      # change > to < to copy over jREMOVEDt the green
      if distance(makeColor(0, 255, 0) , c) > 50:
        setColor(targetP, c)

  show(background)

def colbert():
  background = makePicture(getMediaPath("mars_panorama.jpg"))
  colbert = makePicture(getMediaPath("colbert_green.jpg"))
  #openPictureTool(colbert)

  # setting your own color since the original background color is not pure green
  bgColor = makeColor(81, 153, 67)
  chromakey(background, colbert, 80, bgColor)

  show(background)

def chromakey(background, colbert, threshold, bgColor):

  # different kind of copying REMOVEDing jREMOVEDt one loop
  for p in getPixels(colbert):
    c = getColor(p)
    
    # REMOVEDing getX and getY since we only have one loop
    targetP = getPixel(background, getX(p), getY(p))

    if distance(c, bgColor) > threshold:
      setColor(targetP, c)



Link to this Page