Table of Contents > Understanding Pictures in JES > Picture Functions in JES
Picture Functions in JES

This is a list of functions that you may find useful when you are creating programs to manipulate or create pictures in JES. Remember, these functions are part of a special library, and are not available in other Jython programming environments.
addLine 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.
addRect
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.
addRectFilled
Exactly like addRect, but fills the rectangle with black.
addText
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.
distance 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.
getColor
Takes a Pixel and returns the Color object at that pixel.
getRed, getGreen, getBlue
Each of these functions takes a Pixel object and returns the value (between 0 and 255) of the amount of redness, greenness, and blueness (respectively) in that pixel.
getHeight
Takes a picture as input and returns its length in the number of pixels top-to-bottom in the picture.
getPixels
Takes a picture as input and returns the sequence of Pixel objects in the picture.
getPixel
Takes a picture, an x position and a y position (two numbers), and returns the Pixel object at that point in the picture.
getWidth
Takes a picture as input and returns its width in the number of pixels across the picture.
getX, getY
Takes a Pixel object and returns the x or y (respectively) position of where that Pixel is at in the picture.
makeColor
Takes three inputs: For the red, green, and blue components (in order), then returns a color object.
makeDarker, makeLighter
Each take a color and return a slightly darker or lighter (respectively) version of the color.
makePicture
Takes a filename as input, reads the file, and creates a picture from it. Returns the picture.
pickAColor
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.
pickAFile
Lets the user pick a file and returns the complete path name as a string. No input
setColor
Takes a Pixel object and a Color object and sets the color for that pixel.
setRed, setGreen, setBlue
Each of these functions takes a Pixel object and a value (between 0 and 244) and sets the redness, greenness, or blueness (respectively) of that pixel to the given value.
show
Shows a picture provided as input. No return value.
writePictureTo Takes a picture and a file name (string) as input, then writes the picture to the file as a JPEG. (Be sure to end the filename in “.jpg” for the operating system to understand it well.)


jump to top