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.
addArc addArc(picture, startX, startY, width, height, start, angle[, color]):
picture: the picture you want to draw the line on
startX: the x position you want the arc to start
startY: the y position you want the arc to start
width: the width of the arc
height: the height of the arc
start: the start angle of the arc in degrees
angle: the angle of the arc relative to start in degrees
color: the color you want to draw in (optional)
Takes a picture, (x,y) coordinates, width, height, two integer angles, and (optionally) a color as input. Adds an outline of an arc starting at (x,y) at an initial angle of "start" with the given width and height. The angle of the arc itself is "angle", which is relative to "start." Default color is black.
addArcFilled addArcFilled(picture, startX, startY, width, height, start, angle[, color]):
picture: the picture you want to draw the line on
startX: the x position you want the arc to start
startY: the y position you want the arc to start
width: the width of the arc
height: the height of the arc
start: the start angle of the arc in degrees
angle: the angle of the arc relative to start in degrees
color: the color you want to draw in (optional)
Takes a picture, (x,y) coordinates, width, height, two integer angles, and (optionally) a color as input. Adds a filled arc starting at (x,y) at an initial angle of "start" with the given width and height. The angle of the arc itself is "angle", which is relative to "start." Default color is black.
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 you want to draw in (optional)
Takes a picture, a starting (x, y) position (two numbers), and an ending (x, y) position (two more numbers, four total) and draws a line of the given color (black by default) from the starting point to the ending point in the picture.
addOval
addOval(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 you want to draw in (optional)
Takes a picture, a starting (x, y) position (two numbers), a width and height (two more numbers, four total), and (optionally) a color as input. Adds an oval outline of the given dimensions using the (x,y) as the upper left corner of the bounding rectangle. Default color is black.
addOvalFilled
addOvalFilled(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 you want to draw in (optional)
Takes a picture, a starting (x, y) position (two numbers), a width and height (two more numbers, four total), and (optionally) a color as input. Adds a filled oval of the given dimensions using the (x,y) as the upper left corner of the bounding rectangle. Default color is black.
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 you want to draw in (optional)
Takes a picture, a starting (x, y) position (two numbers), a width and height (two more numbers, four total), and (optionally) a color as input. Adds a rectangular outline of the specified dimensions using the (x,y) as the upper left corner. Default color is black.
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 you want to draw in (optional)
Takes a picture, a starting (x, y) position (two numbers), a width and height (two more numbers, four total), and (optionally) a color as input. Adds a filled rectangle of the specified dimensions using the (x,y) as the upper left corner. Default color is black.
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: string containing the text you want written
color: the color you want to draw in (optional)
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, in the specified color. Default is black.
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: string containing the text you want written
style: the font style you want to draw in (See makeStyle)
color: the color you want to draw in (optional)
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, in the given font style and specified color. Default is black.
distance distance(color1, color2):
color1: the first color you want compared
color2: the second color you want compared
returns: a floating point number representing the Cartesian distance between the colors
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.
duplicatePicture
duplicatePicture(picture):
picture: the picture you want to duplicate.
returns: a new picture object with the same image as the original.
Takes a picture as input and returns a new picture object with the same image as the original.
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.
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.
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.
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.
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.
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.
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. This is another name for "getPixels".
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.
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.
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.
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.
makeBrighter makeBrighter(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. (Same as makeLighter)
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.
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.
makeColor makeColor(red[, green, blue]):
red: the amount of red you want in the color (or a Color object you want to duplicate)
green: the amount of green you want in the color (optional)
blue: the amount of blue you want in the picture (optional)
returns: the color made from the inputs
Takes integer inputs: For the red, green, and blue components (in order), then returns a color object. If green or blue are omitted, the red value is used as the intensity of a gray color. Also takes a color input: returns a new color object with the same RGB values as the original.
makeEmptyPicture makeEmptyPicture(width, height[, color]):
width: the width of the empty picture
height: height of the empty picture
color: background color of the empty picture (optional)
returns: a new picture object, with all the pixels set to the specified color (Default is black)
Makes a new "empty" picture and returns it to you. Width and height must be between 0 and 10000.
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.
makeStyle makeStyle(fontName, emphasis, size):
fontName: the name of the font you want in the style (sansSerif, serif, mono)
emphasis: the type of emphasis you want in the style (italic, bold, italic + bold, plain)
size: the size of the font you want in the style
returns: the style made from the inputs
Takes a font name, emphasis, and size in points as input. Returns a Font object with the given parameters.
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.
pickAFile pickAFile():
returns: a string containing the path to the file selected in the file picker
Lets the user pick a file and returns the complete path name as a string. No input.
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.
repaint repaint(picture):
picture: the picture you want to repaint
Repaints the picture if it has been opened in a window from show(picture).
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.
setGreen setGreen(pixel, greenValue):
pixel: 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.
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.
setColorWrapAround setColorWrapAround(flag):
returns: a boolean (1/true or 0/false) for the new ColorWrapAround value.
Takes a boolean as input. If flag is true, color values will wrap-around (356 mod 256 = 100); if false, color values lower than 0 will be forced to 0 and higher than 255 forced to 255. Default is false.
This only temporarily changes the value. ColorWrapAround will be restored to its value defined in the JES options menu by: Running setColorWrapAround(bool) where bool is the default value, re-saving options, or by restarting JES.
getColorWrapAround getColorWrapAround():
returns: a boolean (1/true or 0/false) for the current value of ColorWrapAround.
Takes no input, and reutrns the current value of ColorWrapAround. If it is true, color values will wrap-around (356 mod 256 = 100); if false, color values lower than 0 will be forced to 0 and higher than 255 forced to 255. Default is false.
If setColorWrapAround has not been used since re-saving options or restarting JES, This will return the value in the JES options menu. Otherwise, it will return the last flag specified in setColorWrapAround(flag).
show show(picture):
picture: the picture you want to see
Shows the picture provided as input.
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. (Be sure to end the filename in ".jpg" for the operating system to understand it well.)


jump to top