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

FUNctions

Takes the sunset function to the next level. Replaces all pixels within a distance of a color with a night sky complete with stars.

Inputs-  
Picture: A picture 
Color: Color of the Sky in the Picture.
Dist: Distance From Color To Replace.
Starshade: Determines how many stars will be visible. Try 245-255


import random

def replaceColorRand(picture,color,dist,starshade):
  for pixel in getPixels(picture):
    if distance(color, getColor(pixel)) <= dist:
      rand=random.random()*255
      makeColor(rand,rand,rand)
      if rand >= starshade:
        setColor(pixel,makeColor(rand,rand,rand))
      if rand < starshade:
        setColor(pixel,makeColor(0,0,0))
    if distance(color, getColor(pixel)) > dist:
      setColor(pixel,makeDarker(makeDarker(getColor(pixel))))
  show(picture)