API Documentation for functions in media.py _ setMediaPath|setMediaPath:(directory)
directory: The directory you want to set as the media folder.
Takes a directory as input. JES then will look for files in that directory unless given a full path, i.e. one that starts with "c:\". You can leave out the directory. If you do, JES will open up a file chooser to let you select a directory.
Examples:
def openBobsSong():
  setMediaPath()
  song = makeSound("BobsSong.wav")
  return song
This will let the user set a folder to look for files in, and then open the file "BobsSong.wav" in that folder.
def openMarysSong():
  setMediaPath("C:/music")
  song = makeSound("MarysSong.wav")
  return song
This sets the folder to look in to "C:/music", and then open the file "MarysSong.wav" in that folder. _ getMediaPath|getMediaPath(filename):
filename: the name of the file you want
returns: the complete path to the file specified
getMediaPath() builds the whole path to the file you specify, as long as you've already used setMediaFolder() or setMediaPath() to pick out the place where you keep your media. getMediaPath|getMediaPath():
returns: The current setting for media path.
Takes no input and returns a String with the current folder for the media path. _ setMediaFolder|setMediaFolder:(directory)
directory: The directory you want to set as the media folder.
Takes a directory as input. JES then will look for files in that directory unless given a full path, i.e. one that starts with "c:\". You can leave out the directory. If you do, JES will open up a file chooser to let you select a directory.
Examples:
def openBobsSong():
  setMediaFolder()
  song = makeSound("BobsSong.wav")
  return song
This will let the user set a folder to look for files in, and then open the file "BobsSong.wav" in that folder.
def openMarysSong():
  setMediaFolder("C:/music")
  song = makeSound("MarysSong.wav")
  return song
This sets the folder to look in to "C:/music", and then open the file "MarysSong.wav" in that folder. _ getMediaFolder|getMediaFolder(filename):
filename: the name of the file you want
returns: the complete path to the file specified
getMediaFolder() builds the whole path to the file you specify, as long as you've already used setMediaFolder() or setMediaPath() to pick out the place where you keep your media. getMediaFolder|getMediaFolder():
returns: The current setting for media path.
Takes no input and returns a String with the current folder for the media path. _ getShortPath|getShortPath(path):
path: a path to a file, as a string
returns: a shorter, non-absolute version of that path
Takes a file path as input and returns the short version of that path. For example, calling getShortPath("c:\images\kittens\fluffy.jpg") would return "kittens\fluffy.jpg". _ setLibPath|setLibPath(directory):
directory: A path to a directory, as a string. You can leave this out. If you do, JES will open up a file chooser for you to select a directory yourself.
setLibPath() allows you to add a directory where JES can look for modules that you want to be able to import. _ makeSound|makeSound(A String):
argument1: A String, a path to a wav file.
returns: A Sound, created from the file at the given path.
Takes a filename as input, reads the file, and creates a sound from it. Returns the sound.
Example:
def openAnySound():
  file = pickAFile()
  return makeSound(file)
This opens up a file selector dialog. The user picks a file, and the function returns it as a sound. _ makeEmptySound|makeEmptySound(samples, samplingRate):
samples: The length of the blank sound you want to create in samples.
samplingRate: The sampling rate you want to use. You can leave this out.
Creates and returns an empty sound (all sample values are 0) of a particular length. _ makeEmptySoundBySeconds|makeEmptySoundBySeconds(seconds, samplingRate):
seconds: The length of the blank sound you want to create in seconds.
samplingRate: The sampling rate you want to use. You can leave this out.
Creates and returns an empty sound (all sample values are 0) of a particular length. _ duplicateSound|duplicateSound(sound):
sound: A sound that you want to copy.
Creates and returns a copy of the sound given as input. _ getSamples|getSamples(sound):
sound: A Sound, the sound you want to extract the samples from
returns: A collection of all the samples in the sound
Takes a sound as input and returns the Samples in that sound.
Example:
def printFirstTen(sound):
  samps = getSamples(sound)
  for num in range(0, 10):
    print samps[num]
This will take in a sound and print the first 10 samples in that sound _ play|play(sound):
sound: The sound you want to be played.
Plays a sound provided as input. No return value.
Example:
def playAnySound():
  file = pickAFile()
  sound = makeSound(file)
  play(sound)
This will open up a file selector box, make a sound from the chosen file, and then play that sound back. _ blockingPlay|blockingPlay(sound):
sound: the sound that you want to play.
Plays the sound provided as input, and makes sure that no other sound plays at the exact same time. (Try two playØs right after each other.)
Example:
def playSoundTwice():
  sound = makeSound(r"C:\My Sounds\preamble.wav")
  blockingPlay(sound)
  blockingPlay(sound)
This will play the preamble.wav twice, back-to-back. _ stopPlaying|stopPlaying(sound):
sound: The sound that you want to stop playing.
Stops a sound that is currently playing. Example:
def playAndStop():
  sound = makeSound(r"C:\My Sounds\preamble.wav")
  play(sound)
  stopPlaying(sound)
This will start playing preamble.wav and stop it shortly after it starts. _ getSamplingRate|getSamplingRate(sound):
sound: A Sound, the sound you want to get the sampling rate from.
returns: An Integer representing the number of samples per second.
Takes a sound as input and returns the number representing the number of samples in each second for the sound.
Example:
def getDoubleSamplingRate(sound):
  rate = getSamplingRate(sound)
  return (rate * 2)
This will take in a sound an return the sampling rate multiplied by 2. _ setSampleValueAt|setSampleValueAt(sound, index, value):
sound: A Sound, the sound you want to change a sample in.
index: An Integer, the index of the sample you want to set.
value: An Integer, the new value of the sample you want to set.
Takes a sound, an index, and a value (should be between -32000 and 32000), and sets the value of the sample at the given index in the given sound to the given value.
Example:
def setTenthToTen(sound):
  setSampleValueAt(sound, 10, 10)
This takes in a sound and sets the value of the 10th sample to 10. _ getSampleValueAt|getSampleValueAt(sound, index):
sound: A Sound, the sound you want to use the sample from.
index: An Integer, the index of the sample you want to get the value of.
Takes a sound and an index (an integer value), and returns the value of the sample (between -32000 and 32000) for that object.
Example:
def getTenthSampleValue(sound):
  num = getSampleValueAt(sound, 10)
  return num
This will take in a sound and return the integer value of the tenth sample _ getSampleObjectAt|getSampleObjectAt(sound, index):
sound: A Sound, the sound you want to get the sample from.
index: An Integer, the index value of the sample you want to get.
returns: The sample object at that index.
Takes a sound and an index (an integer value), and returns the Sample object at that index.
Example:
def getTenthSample(sound):
  samp = getSampleObjectAt(sound, 10)
  return samp
This takes a sound, and returns the 10th sample in the sound. _ setSampleValue|setSampleValue(sample, value):
sample: A Sample, the sound sample tou want to change the value of.
value: An Integer, the value you want to set the sample to.
Takes a Sample object and a value, and sets the sample to that value.
Example:
def setTenthSample(sound, value):
  samp = getSampleObjectAt(sound, 10)
  setSampleValue(samp, value)
This takes a sound and an integer, and then sets the value of the 10th sample in the sound to the passed in value. _ getSampleValue|getSampleValue(sample):
sample: A Sample, a sample of a sound.
returns: The integer value of that sample.
Takes a Sample object and returns its value (between -32000 and 32000)
Example:
def sampleToInt(sample):
  return getSampleValue(sample)
This will convert a sample object into an integer. _ getSound|getSound(sample):
sample: A Sample, a sample belonging to a sound.
return: A Sound, the sound the sample belongs to.
Takes a Sample object and returns the Sound that it remembers as its own.
Example:
def getSamplesFromAnySample(sample):
  sound = getSound(sample)
  return getSamples(sound)
This will take in a sample and return a collection of samples from the original sound. _ getLength|getLength(sound):
sound: the sound you want to find the length of (how many samples it has).
returns: the number of samples in sound.
Takes a sound as input and returns the number of samples in that sound.
Example:
def songLength():
  sound = makeSound(r"C:\My Sounds\2secondsong.wav")
  print getLength(sound)
This will print out the number of samples in the sound. For a 2 second song at 44kHz, it will print out 88000. _ getNumSamples|getNumSamples(sound):
sound: the sound you want to find the length of (how many samples it has).
returns: the number of samples in sound.
Takes a sound as input and returns the number of samples in that sound.
Example:
def songLength():
  sound = makeSound(r"C:\My Sounds\2secondsong.wav")
  print getNumSamples(sound)
This will print out the number of samples in the sound. For a 2 second song at 44kHz, it will print out 88000. _ getDuration|getDuration(sound):
sound: the sound you want to find the length of (in seconds).
returns: the number of seconds the sound lasts.
Takes a sound as input and returns the number of seconds that sound lasts.
Example:
def songLength():
  sound = makeSound(r"C:\My Sounds\2secondsong.wav")
  print getDuration(sound)
This will print out the number of seconds in the sound. For a song with 88000 samples at 44kHz, it will print out 2. _ writeSoundTo|writeSoundTo(sound, filename):
sound: A Sound, the sound you want to write out to a file.
filename: A String, the path of the location you want to write the sound.
Takes a sound and a filename (a string) and writes the sound to that file as a WAV file. (Make sure that the filename ends in Ó.wavÔ if you want the operating system to treat it right.)
Example:
def writeTempSound(sound):
  writeSoundTo(sound, 'C:\temp\temp.wav')
This takes in a sound and writes it out to a file called temp.wav in c:\temp\. _ makeStyle|makeStyle(fontname,emph,size):
fontname: The name of the font you'd like to use
emph: Emphasis
size: Font size, in points
returns: a Font object, suitable for passing to other commands
Builds a Font object with the specified font name, emphasis, and size. If you need to use this, please see the appropriate Java documentation in java.awt.Font.
_ setColorWrapAround|setColorWrapAround(flag):
flag: Should be true (1) or false (0).
Temporarily sets the color wrap around option. If the option is on, color values will wrap around if they go outside 0-255. If off, color values will be capped at 0 or 255. _ getColorWrapAround|getColorWrapAround():
returns: Returns true (1) if RGB values will wrap around if they go outside the bounds of 0-255. Returns false (0) if RGB values will be capped at 0 or 255.
Takes no input, but returns the status of the color wraparound option. _ pickAColor|pickAColor():
returns: the color selected in the picker
Takes no input, but puts up a color picker. Find the color you want, and the function will return the Color object of what you picked. _ makePicture|makePicture(path):
path: the name of the file you want to open as a picture
returns: a picture object made from the file
Takes a filename as input, reads the file, and creates a picture from it. Returns the picture.
Example:
def makePictureSelector():
    file = pickAFile()
    return makePicture(file)
This function will open a file selector box and then return the picture object made from that file. _ makeEmptyPicture|makeEmptyPicture(width, height, color):
width: the desired width of the blank picture
height: the desired height of the blank picture
color: the desired color of the blank picture. You can leave this out. If you do, the picture will be white.
Creates a blank picture object and returns it. _ getPixels|getPixels(picture):
picture: the picture you want to get the pixels from
returns: a list of all the pixels in the picture
Takes a picture as input and returns the sequence of Pixel objects in the picture.
Example:
def getTenthPixel(picture):
  pixels = getPixels(picture)
  return pixels[10]
This takes in a picture and returns the 10th pixel in that picture. _ getAllPixels|getAllPixels(picture):
picture: the picture you want to get the pixels from
returns: a list of all the pixels in the picture
Takes a picture as input and returns the sequence of Pixel objects in the picture.
Example:
def getTenthPixel(picture):
  pixels = getAllPixels(picture)
  return pixels[10]
This takes in a picture and returns the 10th pixel in that picture. _ getWidth|getWidth(picture):
picture: the picture you want to get the width of
returns: the width of the picture
Takes a picture as input and returns its length in the number of pixels left-to-right in the picture.
Example:
def howWide(picture)
  width = getWidth(picture)
  print "The picture is " + str(width) + " pixels wide."
This takes in a picture and prints a descriptive message about its width. _ getHeight|getHeight(picture):
picture: the picture you want to get the height of
returns: the height of the picture
Takes a picture as input and returns its length in the number of pixels top-to-bottom in the picture.
Example:
def howTall(picture)
  height = getHeight(picture)
  print "The picture is " + str(height) + " pixels tall."
This takes in a picture and prints a descriptive message about its height. _ show|show(picture):
picture: the picture you want to see
Shows the picture provided as input. _ repaint|repaint(picture):
picture: the picture you want to repaint
Repaints the picture if it has been opened in a window from show(picture). _ addLine|addLine(picture, startX, startY, endX, endY, color):
picture: the picture you want to draw the line on
startX: the x position you want the line to start
startY: the y position you want the line to start
endX: the x position you want the line to end
endY: the y position you want the line to end
color: The color of the line. You can leave this out. If you do, the line will be black.
Takes a picture, a starting (x, y) position (two numbers), and an ending (x, y) position (two more numbers, four total) and draws a black line from the starting point to the ending point in the picture. You can add a color as the last argument to set the color of the line.
Examples:
def drawVertical(picture):
  addLine(picture, 100, 20, 100, 250)
This will take in a picture and draw a black vertical line on it from (100,20) to (100,250)
def drawDiagonal(picture):
  addLine(picture, 0, 15, 100, 115, blue)
This will take in a picture and draw a blue diagonal line on it from (0,15) to (100, 115). _ addText|addText(picture, xpos, ypos, text, color):
picture: the picture you want to add the text to
xpos: the x-coordinate where you want to start writing the text
ypos: the y-coordinate where you want to start writing the text
text: a string containing the text you want written
color: The color you want the text to be. You can leave this out. If you do, the text will be black.
Takes a picture, an x position and a y position (two numbers), and some text as a string, which will get drawn into the picture. You can add a color as the last argument to set the color of the text.
Examples:
def addDate(picture):
  str = "Today is the first day of the rest of your life."
  addText(picture, 0, 0, str)
This takes in a picture and adds a black date stamp to the upper left corner.
def addHappyBirthday(picture):
  str = "Happy Birthday!!!"
  addText(picture, 0, 0, str, orange)
This takes in a picture and adds an orange Happy Birthday message to the upper left corner.
_ addTextWithStyle|addTextWithStyle(picture, xpos, ypos, text, style, color):
picture: the picture you want to add the text to
xpos: the x-coordinate where you want to start writing the text
ypos: the y-coordinate where you want to start writing the text
text: a string containing the text you want written
style: a font created using makeStyle()
color: The color you want the text to be. You can leave this out. If you do, the text will be black.
Takes a picture, an x position and a y position (two numbers), some text as a string, and a font style which will get drawn into the picture. You can add a color as the last argument to set the color of the text.
Examples:
def addDate(picture):
  import java.awt.Font as Font
  str = "Today is the first day of the rest of your life."
  myFont = makeStyle("Comic Sans", Font.BOLD, 96)
  addTextWithStyle(picture, 0, 0, str, myFont)
This takes in a picture and adds a black date stamp to the upper left corner in Size 96 bold Comic Sans.
def addHappyBirthday(picture):
  import java.awt.Font as Font
  str = "Happy Birthday!!!"
  myFont = makeStyle("Wingdings", Font.ITALICS, 24)
  addText(picture, 0, 0, str, orange)
This takes in a picture and adds an orange Happy Birthday message to the upper left corner in Size 24 italcized Wingdings.
_ addRect|addRect(picture, startX, startY, width, height, color):
picture: the picture you want to draw the rectangle on
startX: the x-coordinate of the upper left-hand corner of the rectangle
startY: the y-coordinate of the upper left-hand corner of the rectangle
width: the width of the rectangle
height: the height of the rectangle
color: The color of the rectangle. You can leave this out. If you do, the rectangle will be black.
Takes a picture, a starting (x, y) position (two numbers), and a width and height (two more numbers, four total) then draws a black rectangle in outline of the given width and height with the position (x, y) as the upper left corner. You can add a color as the last argument to set the color of the rectangle.
Examples:
def addSquare(picture, startX, startY, edge):
  addRect(picture, startX, startY, edge, edge)
This will take in a picture, start coordinates, and a edge length and call addRect to draw a rectangle with all sides the same length.
def addBlueSquare(picture, startX, startY, edge):
  addRect(picture, startX, startY, edge, edge, blue)
This will take in a picture, start coordinates, and an edge length and call addRect to draw a blue rectangle with all sides the same length. _ addRectFilled|addRectFilled(picture, startX, startY, width, height, color):
picture: the picture you want to draw the rectangle on
startX: the x-coordinate of the upper left-hand corner of the rectangle
startY: the y-coordinate of the upper left-hand corner of the rectangle
width: the width of the rectangle
height: the height of the rectangle
color: The color of the rectangle. You can leave this out. If you do the rectangle will be black.
Takes a picture, a starting (x, y) position (two numbers), and a width and height (two more numbers, four total) then draws a black-filled rectangle of the given width and height with the position (x, y) as the upper left corner. You can add a color as the last argument to set the color of the rectangle.
Examples:
def addSquareFilled(picture, startX, startY, edge):
  addRectFilled(picture, startX, startY, edge, edge)
This will take in a picture, start coordinates, and a edge length and call addRectFilled to draw a solid rectangle with all sides the same length.
def addBlueSquareFilled(picture, startX, startY, edge):
  addRectFilled(picture, startX, startY, edge, edge, blue)
This will take in a picture, start coordinates, and a edge length and call addRectFilled to draw a solid blue rectangle with all sides the same length. _ addOval|addOval(picture, startX, startY, width, height, color):
picture: the picture you want to draw the oval on
startX: the x-coordinate of the upper left-hand corner of the bounding rectangle of the oval
startY: the y-coordinate of the upper left-hand corner of the bounding rectangle of the oval
width: the width of the oval
height: the height of the oval
color: The color of the oval. You can leave this out. If you do, the oval will be black.
Takes a picture, a starting (x, y) position (two numbers), and a width and height (two more numbers, four total) then draws a black oval in outline of the given width and height with the position (x, y) as the upper left corner. You can add a color as the last argument to set the color of the oval.
Examples:
def addCircle(picture, startX, startY, radius):
  addOval(picture, startX, startY, radius, radius)
This will take in a picture, start coordinates, and a radius length and call addOval to draw a oval with equal width and height.
def addBlueCircle(picture, startX, startY, radius):
  addOval(picture, startX, startY, radius, radius, blue)
This will take in a picture, start coordinates, and an radius length and call addOval to draw a blue oval with equal width and height. _ addOvalFilled|addOvalFilled(picture, startX, startY, width, height, color):
picture: the picture you want to draw the oval on
startX: the x-coordinate of the upper left-hand corner of the bounding rectangle of the oval
startY: the y-coordinate of the upper left-hand corner of the bounding rectangle of the oval
width: the width of the oval
height: the height of the oval
color: The color of the oval. You can leave this out. If you do the oval will be black.
Takes a picture, a starting (x, y) position (two numbers), and a width and height (two more numbers, four total) then draws a black-filled oval of the given width and height with the position (x, y) as the upper left corner. You can add a color as the last argument to set the color of the oval.
Examples:
def addCircleFilled(picture, startX, startY, radius):
  addOvalFilled(picture, startX, startY, radius, radius)
This will take in a picture, start coordinates, and a radius length and call addOvalFilled to draw a solid oval with equal width and height.
def addBlueCircleFilled(picture, startX, startY, radius):
  addOvalFilled(picture, startX, startY, radius, radius, blue)
This will take in a picture, start coordinates, and a radius length and call addOvalFilled to draw a solid blue oval with equal width and height. _ addArc|addArc(picture, startX, startY, width, height, start, angle, color):
picture: the picture you want to draw the arc on
startX: the x-coordinate of the center of the arc
startY: the y-coordinate of the center of the arc
width: the width of the arc
height: the height of the arc
start: the starting angle of the arc
angle: the angle of the arc, relative to the start angle
color: The color of the arc. You can leave this out. If you do, the arc will be black.
Takes a picture, a starting (x, y) position (two numbers), a width and height (two more numbers), a starting angle and an angle for the arc (two more numbers, six total) then draws a black arc in outline of the given width, height, and angles with the position (x, y) as the center. You can add a color as the last argument to set the color of the arc.
Examples:
def addSemiCircle(picture, startX, startY, radius, start):
  addArc(picture, startX, startY, radius, radius, start, 180)
This will take in a picture, start coordinates, a radius length, and a starting angle and call addArc to draw an arc with equal width and height.
def addBlueSemiCircle(picture, startX, startY, radius, start):
  addArc(picture, startX, startY, radius, radius, start, 180, blue)
This will take in a picture, start coordinates, a radius length, and a starting angle and call addArc to draw a blue arc with equal width and height. _ addArcFilled|addArcFilled(picture, startX, startY, width, height, start, angle, color):
picture: the picture you want to draw the arc on
startX: the x-coordinate of the center of the arc
startY: the y-coordinate of the center of the arc
width: the width of the arc
height: the height of the arc
color: The color of the arc. You can leave this out. If you do the arc will be black.
Takes a picture, a starting (x, y) position (two numbers), a width and height (two more numbers), a starting angle and an angle for the arc (two more numbers, six total) then draws a black-filled arc in outline of the given width, height, and angles with the position (x, y) as the center. You can add a color as the last argument to set the color of the arc.
Examples:
def addFilledSemiCircle(picture, startX, startY, radius, start):
  addArcFilled(picture, startX, startY, radius, radius, start, 180)
This will take in a picture, start coordinates, a radius length, and a starting angle and call addArcFilled to draw a filled black arc with equal width and height.
def addBlueFilledSemiCircle(picture, startX, startY, radius, start):
  addArcFilled(picture, startX, startY, radius, radius, start, 180, blue)
This will take in a picture, start coordinates, a radius length, and a starting angle and call addArcFilled to draw a filled blue arc with equal width and height. _ getPixel|getPixel(picture, xpos, ypos):
picture: the picture you want to get the pixel from
xpos: the x-coordinate of the pixel you want
ypos: the y-coordinate of the pixel you want
Takes a picture, an x position and a y position (two numbers), and returns the Pixel object at that point in the picture.
Example:
def getUpperLeftPixel(picture)
  return getPixel(picture, 1, 1)
This will take in a picture and return the pixel in the upper left-hand corner, (1, 1). This does the same thing as getPixelAt(). _ getPixelAt|getPixelAt(picture, xpos, ypos):
picture: the picture you want to get the pixel from
xpos: the x-coordinate of the pixel you want
ypos: the y-coordinate of the pixel you want
Takes a picture, an x position and a y position (two numbers), and returns the Pixel object at that point in the picture.
Example:
def getUpperLeftPixel(picture)
  return getPixelAt(picture, 1, 1)
This will take in a picture and return the pixel in the upper left-hand corner, (1, 1). _ setRed|setRed(pixel, redValue):
pixel: the pixel you want to set the red value in.
redValue: a number (0 - 255) for the new red value of the pixel
Takes in a Pixel object and a value (between 0 and 255) and sets the redness of that pixel to the given value.
Example:
def zeroRed(pixel):
  setRed(pixel, 0)
This will take in a pixel and set its amount of red to 0. _ setGreen|setGreen(pixel, greenValue):
pixell: the pixel you want to set the green value in.
greenValue: a number (0 - 255) for the new green value of the pixel
Takes in a Pixel object and a value (between 0 and 255) and sets the greenness of that pixel to the given value.
Example:
def zeroGreen(pixel):
  setGreen(pixel, 0)
This will take in a pixel and set its amount of green to 0. _ setBlue|setBlue(pixel, blueValue):
pixel: the pixel you want to set the blue value in.
blueValue: a number (0 - 255) for the new blue value of the pixel
Takes in a Pixel object and a value (between 0 and 255) and sets the blueness of that pixel to the given value.
Example:
def zeroBlue(pixel):
  setBlue(pixel, 0)
This will take in a pixel and set its amount of blue to 0. _ getRed|getRed(pixel):
pixel: the pixel you want to get the amount of red from
returns: the red value of the pixel
Takes a Pixel object and returns the value (between 0 and 255) of the amount of redness in that pixel.
Example:
def getHalfRed(pixel):
  red = getRed(pixel)
  return red / 2
This takes in a pixel and returns the amount of red in that pixel divided by two. _ getGreen|getGreen(pixel):
pixel: the pixel you want to get the amount of green from
returns: the green value of the pixel
Takes a Pixel object and returns the value (between 0 and 255) of the amount of greenness in that pixel.
Example:
def getHalfGreen(pixel):
  green = getGreen(pixel)
  return green / 2
This takes in a pixel and returns the amount of green in that pixel divided by two. _ getBlue|getBlue(pixel):
pixel: the pixel you want to get the amount of blue from
returns: the blue value of the pixel
Takes a Pixel object and returns the value (between 0 and 255) of the amount of blueness in that pixel.
Example:
def getHalfBlue(pixel):
  blue = getBlue(pixel)
  return blue / 2
This takes in a pixel and returns the amount of blue in that pixel divided by two. _ getColor|getColor(pixel):
pixel: the pixel you want to extract the color from
returns: a Color, the color from the pixel
Takes a Pixel and returns the Color object at that pixel.
Example:
def getDistanceFromRed(pixel):
  red = makeColor(255, 0, 0)
  col = getColor(pixel)
  return distance(red, col)
This takes in a pixel and returns that pixel's color's distance from red. _ setColor|setColor(pixel, color):
pixel: the pixel you want to set the color of
color: the Color you want to set the pixel to
Takes in a pixel and a Color, and sets the pixel to the provided color. Example:
def makeMoreBlue(pixel):
  myBlue = getBlue(pixel) + 60
  newColor = makeColor(getRed(pixel), getGreen(pixel), myBlue)
  setColor(pixel, newColor)
This will take in a pixel and increase its level of blue by 60. _ getX|getX(pixel):
pixel: the pixel you want to find the x-coordinate of
returns: the x-coordinate of the pixel Takes in a pixel object and returns the x position of where that pixel is in the picture.
Example:
def getHalfX(pixel):
  pos = getX(pixel)
  return pos / 2
This will take in a pixel and return half of its x-coordinate. _ getY|getY(pixel):
pixel: the pixel you want to find the y-coordinate of
returns: the y-coordinate of the pixel
Takes in a pixel object and returns the y position of where that pixel is in the picture.
Example:
def getHalfY(pixel):
  pos = getY(pixel)
  return pos / 2
This will take in a pixel and return half of its y-coordinate. _ distance|distance(color1, color2):
color1: the first color you want compared
color2: the second color you want compared
Takes two Color objects and returns a single number representing the distance between the colors. The red, green, and blue values of the colors are taken as a point in (x, y, z) space, and the cartesian distance is computed.
Example:
def showDistRedAndBlue():
  red = makeColor(255, 0, 0)
  blue = makeColor(0, 0, 255)
  print distance(red, blue)
This will print the distance between red and blue, 360.62445840513925. _ writePictureTo|writePictureTo(picture, path):
picture: the picture you want to be written out to a file
path: the path to the file you want the picture written to
Takes a picture and a file name (string) as input, then writes the picture to the file as a JPEG, PNG, or BMP. (Be sure to end the filename in ".jpg" or ".png" or ".bmp" for the operating system to understand it well.)
Example:
def writeTempPic(picture):
  file = r"C:\Temp\temp.jpg"
  writePictureTo(picture, file)
This takes in a picture and writes it to C:\Temp\temp.jpg. _ makeDarker|makeDarker(color):
color: the color you want to darken
returns: the new, darker color
Takes a color and returns a slightly darker version of the original color.
Example:
def makeMuchDarker(color):
  return makeDarker(makeDarker(makeDarker(color)))
Takes in a color and returns a much darker version of it by calling makeDarker three times. _ makeBrighter|makeBrighter(color):
color: the color you want to brighten
returns: the new, brighter color
Takes a color and returns a slightly brighter version of the original color. This does the same thing as makeLighter(color).
Example:
def makeMuchBrighter(color):
  return makeBrighter(makeBrighter(makeBrighter(color)))
Takes in a color and returns a much lighter version of it by calling makeBrighter three times. _ makeLighter|makeLighter(color):
color: the color you want to lighten
returns: the new, lighter color
Takes a color and returns a slightly lighter version of the original color. This does the same thing as makeBrighter(color).
Example:
def makeMuchLighter(color):
  return makeLighter(makeLighter(makeLighter(color)))
Takes in a color and returns a much lighter version of it by calling makeLighter three times. _ makeColor|makeColor(red, green, blue):
red: the amount of red you want in the color
green: the amount of green you want in the color
blue: the amount of blue you want in the picture
returns: the color made from the inputs
Takes three inputs: For the red, green, and blue components (in order), then returns a color object.
Example:
def makeGrey(amount):
  return makeColor(amount, amount, amount)
This will take in an amount and make a grey color based on that. _ setAllPixelsToAColor|setAllPixelsToAColor(picture, color):
picture: the picture to modify
color: the color to set each pixel to
Modifies the whole image so that every pixel in that image is the given color. _ duplicatePicture|duplicatePicture(pic):
pic: the picture that you want to duplicate
returns: a new picture object, copied from pic.
Takes a picture as input, returns a new copy of it.
Example:
file = pickAFile()
mypic = makePicture(file)
copyofmypic = duplicatePicture(mypic)
This opens up a file chooser, makes a Picture object using the chosen file, and then creates a second Picture object by copying the first one. _ requestNumber|requestNumber(message):
message: the message to prompt the user with
Opens a message dialog to the user asking for a number _ requestInteger|requestInteger(message):
message: the message to prompt the user with
Opens a message dialog to the user asking for an integer _ requestIntegerInRange|requestIntegerInRange(message, min, max):
message: the message to prompt the user with
min: the smallest integer allowed
max: the largest integer allowed
Opens a message dialog to the user asking for an integer in a specific range _ requestString|requestString(message):
message: the message to prompt the user with
Opens a message dialog to the user for a string value _ showWarning|showWarning(message):
message: the message to show to the user
Opens a message dialog to the user showing a warning _ showInformation|showInformation(message):
message: the message to show to the user
Opens a message dialog to the user showing information _ showError|showError(message):
message: the message to show to the user
Opens a message dialog to the user showing an error _ playNote|playNote(note, duration, intensity):
note: the note (a number > 0) you want to be played.
duration: the duration you want the note to be played in milliseconds.
intensity: the intensity (a number between 0 and 127) you want the note to be played. You can leave this out. If you do, JES will use 64.
Plays a note. No return value.
Example:
        # this plays a scale
        intensity = 64
        dur = 1000
        playNote(60, dur, intensity)
        playNote(62, dur, intensity)
        playNote(64, dur, intensity)
        playNote(65, dur, intensity)
        playNote(67, dur, intensity)
        playNote(69, dur, intensity)
        playNote(71, dur, intensity)
        playNote(72, dur, intensity)
_ pickAFile|pickAFile():
returns: A String, the path to the file chosen in the dialog box.
Opens a file chooser and lets the user pick a file and returns the complete path name as a string. No input.
Example:
def openAnySound():
  file = pickAFile()
  return makeSound(file)
This opens up a file selector dialog. The user picks a file, and the function returns it as a sound. _ pickAFolder|pickAFolder():
returns: A String, the path to the folder chosen in the dialog box.
Opens a file chooser to let the user pick a folder and returns the complete path name as a string. No input.
Lets the user pick a folder and returns the complete path name as a string. No input. _ quit|quit():
Forces JES to stop running the program. _ openPictureTool|openPictureTool(picture)
picture: the picture that you want to examine
Opens the Picture Tool explorer, which lets you examine the pixels of an image. _ openFrameSequencerTool|openFrameSequencerTool(movie)
movie: the movie that you want to examine
Opens the Frame Sequencer Tool explorer, which lets you examine and manipulate the frames of a movie. _ openSoundTool|openSoundTool(sound)
sound : the sound that you want to examine
Opens the Sound Tool explorer, which lets you examine the waveform of a sound. _ turn|turn(turtle, degrees):
turtle: the turtle to operate on
degrees: how many degrees to turn. If you leave this out, JES will use 90.
Turns the turtle; positive numbers of degrees mean turning to the turtle's right, negative numbers of degrees mean turning to the turtle's left
Example:
w = makeWorld(500, 500)
t = makeTurtle(w)
penUp(t)
moveTo(t, int(500/3), 250)
penDown(t)
for i in range(0, 360):
    turn(t, 1)
    forward(t, 3)
This will create a world and a turtle. The turtle will move to (166,250) without drawing, then draw a circle 1 degree at a time. _ turnLeft|turnLeft(turtle):
turtle: the turtle to operate on
Turns the turtle left 90 degrees
Example:
w = makeWorld(300, 200)
t = makeTurtle(w)
penUp(t)
forward(t, 50)
turnLeft(t)
penDown(t)
forward(t, 30)
This will create a world and a turtle. The turtle will move ahead 50 without drawing, then turn 90 degrees to the left, and go forward 30 while drawing. _ turnRight|turnRight(turtle):
turtle: the turtle to operate on
Turns the turtle right 90 degrees Example:
w = makeWorld(300, 200)
t = makeTurtle(w)
penUp(t)
forward(t, 50)
turnRight(t)
penDown(t)
forward(t, 30)
This will create a world and a turtle. The turtle will move ahead 50 without drawing, then turn 90 degrees to the right, and go forward 30 while drawing. _ turnToFace|turnToFace(turtle, x, y):
turtle: the turtle to operate on
x: the X coordinate in the world
y: the Y coordinate in the world
Makes the turtle look towards (x, y).
Example:
w = makeWorld(500, 500)
t = makeTurtle(w)
turn(t, 63)
backward(t, 40)
turnToFace(t, 200, 100)
forward(t, 300)
moveTo(t, 150, 150)
This will create a world and a turtle. The turtle will turn 63 degrees, go backwards 40 pixels, turn to face pixel (200,100), move forward 300 pixels and then move to pixel (150,150).
turnToFace(turtle, otherTurtle):
turtle: the turtle to operate on
otherTurtle: the turtle that you want turtle to face
Makes turtle look towards otherTurtle.
Example:
w = makeWorld(500,500)
leo = makeTurtle(w)
mike = makeTurtle(w)
forward(leo, 40)
turnRight(leo)
forward(leo, 30)
turnToFace(mike, leo)
forward(mike, 50)
This will create a world with two turtles. One turtle will move ahead 40 pixels then right 30 pixels. The second turtle will turn to face the first turtle and move ahead 50 pixels. _ forward|forward(turtle, distance):
turtle: the turtle to operate on
distance: how far to go
Moves the turtle forward
Example:
w = makeWorld(500, 500)
t = makeTurtle(w)
turn(t, 63)
backward(t, 40)
turnToFace(t, 200, 100)
forward(t, 300)
moveTo(t, 150, 150)
This will create a world and a turtle. The turtle will turn 63 degrees, go backwards 40 pixels, turn to face pixel (200,100), move forward 300 pixels and then move to pixel (150,150). _ backward|backward(turtle, distance):
turtle: the turtle to operate on
distance: how far back to go
Moves the turtle backward
Example:
w = makeWorld(500, 500)
t = makeTurtle(w)
turn(t, 63)
backward(t, 40)
turnToFace(t, 200, 100)
forward(t, 300)
moveTo(t, 150, 150)
This will create a world and a turtle. The turtle will turn 63 degrees, go backwards 40 pixels, turn to face pixel (200,100), move forward 300 pixels and then move to pixel (150,150). _ moveTo|moveTo(turtle, x, y):
turtle: the turtle to operate on
x: the X coordinate in the world
y: the Y coordinate in the world
Moves the turtle to the specified location. If the turtle's pen is down, it will draw a line from its old location to the new one.
Example:
w = makeWorld(500, 500)
t = makeTurtle(w)
turn(t, 63)
backward(t, 40)
turnToFace(t, 200, 100)
forward(t, 300)
moveTo(t, 150, 150)
This will create a world and a turtle. The turtle will turn 63 degrees, go backwards 40 pixels, turn to face pixel (200,100), move forward 300 pixels and then move to pixel (150,150). _ makeTurtle|makeTurtle(world):
world: a world to put the turtle in
Makes a turtle and returns it
Example:
w = makeWorld(500, 500)
t = makeTurtle(w)
penUp(t)
moveTo(t, int(500/3), 250)
penDown(t)
for i in range(0, 360):
    turn(t, 1)
    forward(t, 3)
_ penUp|penUp(turtle):
turtle: the turtle to operate on
Makes it so the turtle doesn't leave a trail when it moves.
Example:
w = makeWorld(300, 200)
t = makeTurtle(w)
penUp(t)
forward(t, 50)
turnRight(t)
penDown(t)
forward(t, 30)
_ penDown|penDown(turtle):
turtle: the turtle to operate on
Makes it so the turtle leaves a trail when it moves.
w = makeWorld(300, 200)
t = makeTurtle(w)
penUp(t)
forward(t, 50)
turnRight(t)
penDown(t)
forward(t, 30)
_ drop|drop(turtle, picture):
turtle: the turtle who will do the dropping
picture: the picture that the turtle will drop
The turtle specified "drops" a picture where it is currently sitting, rotated so that the top of the picture points where the turtle is facing.
Example:
w = makeWorld()
t = makeTurtle(w)
pic = makePicture("adorable-kitten.jpg")
turn(t, 180)
drop(t, pic)
This creates a world and a turtle, and places adorable-kitten.jpg in the world upside-down. _ getXPos|getXPos(turtle):
turtle: the turtle whose X position we want
returns: An Integer, the X position of turtle.
Returns the X position of the turtle in question.
Example:
w = makeWorld()
todd = makeTurtle(w)
toddsxposition = getXPos(todd)
_ getYPos|getYPos(turtle):
turtle: the turtle whose Y position we want
returns: An Integer, the X position of turtle.
Returns the Y position of the turtle in question.
Example:
w = makeWorld()
timmy = makeTurtle(w)
timmysposition = getYPos(timmy)
_ getHeading|getHeading(turtle):
turtle: the turtle whose heading we want
returns: A number, the heading of the turtle
Returns the degrees of the direction the turtle is facing.
Example:
w = makeWorld()
jane = makeTurtle(w)
janesheading = getHeading(jane)
_ makeWorld|makeWorld(width, height):
width: the width for your new world
height: the height for your new world
Returns a new world, where you can put turtles. You can leave out width and height. For example, these both work:
Example:
earth = makeWorld()
mars = makeWorld(500, 500)
_ getTurtleList|getTurtleList(world):
world: the world to get the turtles from
Returns a list of turtles in the world. _ printNow|printNow(output):
output: What we want to print
Prints the specified output to the JES command area right now, without waiting for buffering. Helpful for debugging, if your program is throwing an exception! _ playMovie|playMovie(movie):
movie: the Movie object to play
Plays the movie within JES.
Example:
def playMyMovie():
  myMovie = makeMovieFromInitialFile(r"C:\mymovie\frame001.jpg")
  playMovie(myMovie)
_ writeQuicktime|writeQuicktime(movie, framesPerSec):
movie: A Movie object that you want to write out. The frames must either all be in the same directory, or the frames must have been written out to a directory since the last change was made.
framesPerSec: The frame rate for the movie. You can leave this out. If you do, JES will use 16 frames per second.
Writes a movie out in Quicktime format. _ writeAVI|writeAVI(movie, framesPerSec):
movie: A Movie object that you want to write out. The frames must either all be in the same directory, or the frames must have been written out to a directory since the last change was made.
framesPerSec: The frame rate for the movie. You can leave this out. If you do, JES will use 16 frames per second.
Writes a movie out in AVI format. _ makeMovie|makeMovie():
No input. Returns a new empty Movie. _ makeMovieFromInitialFile|makeMovieFromInitialFile(filename):
filename: A string containing the full path to the first frame of the movie. Returns a new movie when you give it a filename of one of the images that should be in the movie, with the other frames in the same directory.
Example:
m = makeMovieFromInitialFile('/tmp/frame001.jpg')
_ addFrameToMovie|addFrameToMovie(frame, movie):
frame: the picture object to add
movie: the movie object to add the frame to
Adds a frame to a movie _ writeFramesToDirectory|writeFramesToDirectory(movie, directory):
movie: the movie object to get the frames from
directory: the directory to write the images to
Example:
writeFramesToDirectory(movie, pickAFolder())
After you write the frames out, you can encode them into a video file with another program. If you are using windows or mac os, you might be able to use quicktime. If you are using linux, you might use mencoder like this (from the manual):

Encode all *.jpg files in the current dir:
 mencoder  "mf://*.jpg" -mf fps=25 -o output.avi -ovc lavc -lavcopts vcodec=mpeg4
Also, you could use the writeQuicktime() or writeAVI() methods
_ copyInto|copyInto(smallPicture, bigPicture, startX, startY):
smallPicture: the picture to paste into the big picture
bigPicture: the picture to be modified
startX: the X coordinate of where to place the small picture on the big one
startY: the Y coordinate of where to place the small picture on the big one
This modifies the big picture by copying pixels from the small picture onto the big one. _ explore|explore(someMedia):
someMedia: A Picture, Sound, or Movie that you want to view using Media Tools.
Example:
def exploreAPicture():
  file = pickAFile()
  pic = makePicture(file)
  explore(pic)
This creates a Picture object from a file and opens it in the Media Tools. _ makeMovieFromPictures|makeMovieFromPictures(frames, path, framerate):
frames: a list of pictures to write out as frames of the movie
path: the path to the file where you want the movie written
framerate: OPTIONAL the framerate in frames per second you want the movie to play. If not given, it will default to 30.
Takes a list of frames and writes them out to a quicktime movie. Make sure that the file you write out to ends in ".mov". The movie will be created from the frames in order by index from the first to last. The speed of the movie may be specified or default to 30. _ openMovie|openMovie(filename):
filename: the path to the movie you wish to open in the player
Opens the movie at the given path into a movie player. _