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

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
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 just 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 using just one loop
  for p in getPixels(colbert):
    c = getColor(p)
    
    # using 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