Class Picture

java.lang.Object
  extended by SimplePicture
      extended by Picture
All Implemented Interfaces:
DigitalPicture

public class Picture
extends SimplePicture

A class that represents a picture. This class inherits from SimplePicture and allows the student to add functionality to the Picture class. Pictures are immutable (don't change). Each method that changes a picture creates a copy of the original picture and changes that. Copyright Georgia Institute of Technology 2004

Author:
Barbara Ericson ericson@cc.gatech.edu

Constructor Summary
Picture()
          Constructor that takes no arguments
Picture(int width, int height)
          Constructor that takes the width and height
Picture(Picture copyPicture)
          Constructor that takes a picture and creates a copy of that picture
Picture(java.lang.String fileName)
          Constructor that takes a file name and creates the picture
 
Method Summary
static Picture addBoxToBeach()
          Method to add a solid red rectangle to the beach picture
static Picture blendPictures()
          Method to blend pictures of Katie and Jenny
 Picture blendPictures(Picture sourcePict, double sourceAlpha)
          Method to blend two pictures, the current picture object and the passed sourcePict object.
 void blueChange()
          Method to set all blue values to 100 in the picture
 void blueOneHundred()
          Method to set the blue values to 100 in a rectangle of 100 pixels with x and y starting at 0 and ending at 99
 void blur(int numPixels)
          Method to blur the pixels
 Picture changeColors(double redAmount, double greenAmount, double blueAmount)
          Method to change the color of each pixel in a copy of the current picture object by the passed amounts.
 void changePixelsWithinDistance(java.awt.Color compareColor, double distance, double redFactor, double greenFactor, double blueFactor, int startX, int startY, int endX, int endY)
          Method to change all the pixels within a passed distance of a passed color in a range specified by a startX, startY, endX, and endY by passed red, green, and blue factors.
 Picture changeRed(double amount)
          Method to change the red by an amount
 void chromakey(Picture newBg)
          Method to do chromakey using a blue background
 void chromakeyBlue(Picture newBg)
          Method to do chromakey using a blue background
 void chromakeyRed(Picture newBg)
          Method to do chromakey using a red background
 Picture clearBlue()
          Method to clear the blue from a copy of the current picture (set the blue to 0 for all pixels)
 Picture clearBlue2()
          Method to clear the blue from a copy of the current picture (set the blue to 0 for all pixels)
 Picture clearBlue3()
          Method to clear the blue from a copy of the current picture (set the blue to 0 for all pixels)
 void clearSomeBlue()
          Method to set the blue to zero if the distance from this color to blue is greater than 100
 Picture clipToEllipse()
          Method to clip the picture to an ellipse
 Picture clipToMessage(java.lang.String message)
          Method to create a new picture from this picture that shows the part of the current picture that is inside a text message
 void copy(Picture source, int x, int y)
          Method to copy the passed picture into the current picture at the given x and y position in the current picture
 void copy(Picture sourcePicture, int startX, int startY, int endX, int endY, int targetStartX, int targetStartY)
          Method to copy from the passed source picture to current picture object The copying will start at startX, startY, and end at endX-1 and endY-1 The copy will be placed starting at targetStartX, targetStartY
 void copy2D(Picture source, int x, int y)
          Method to copy the passed picture into the current picture at the given x and y position in the current picture
static Picture copyFlowerLarger()
          Method to copy a flower but scaled to 2x normal size
static Picture copyFlowerSmaller()
          Method to copy the flower but smaller (half as big)
static Picture copyKatie()
          Method to copy the picture of Katie to the canvas
static Picture copyKatieLeftRotation()
          Method to copy the picture of Katie but rotate her left 90 degrees on the resulting picture
static Picture copyKatieMidway()
          Method to copy the picture of Katie to 100, 100 in the canvas
static Picture copyKatiesFace()
          Method to copy just Katie's face to the canvas
 void copyNonWhitePixels(Picture sourcePicture, int startX, int startY, int endX, int endY, int targetStartX, int targetStartY)
          Method to copy from the passed source picture to current picture object The copying will start at startX, startY, and end at endX-1 and endY-1 The copy will be placed starting at targetStartX, targetStartY
 void copyPicture(Picture sourcePict, java.awt.Rectangle sourceRect, java.awt.Rectangle targetRect, java.awt.Composite composite)
          Method to copy a picture into the current picture using the passed composite rule
 void copyPictureTo(Picture sourcePicture, int xStart)
          Method that will copy all of the passed source picture into the current picture object starting with the left corner given by xStart
 void copyPictureTo(Picture sourcePicture, int xStart, int yStart)
          Method that will copy all of the passed source picture into the current picture object starting with the left corner given by xStart, yStart
 int countWhitePixels()
          Method to count the number of white pixels in a picture
static Picture createCollage()
          Method to create a collage from the flower pictures.
static Picture createCollageBetter()
          Method to create a collage of flowers
static Picture createComposite()
          Method to try different composite rules in a picture with a gradient painted rectangle and a texture painted ellipse
 Picture darken()
          Method to darken the color in a copy of the current picture
 Picture decreaseBlue()
          Method to decrease the blue in a copy of the current picture by 30%
 Picture decreaseGreen()
          Method to decrease the green in a copy of the current picture by 30%
 Picture decreaseRed()
          Method to decrease the red by half in a copy of the current picture
 void doubleRedInRange(int startX, int startY, int endX, int endY, double distance, java.awt.Color compareColor)
          Method to double the red in a picture in a rectangular area if it is less than the passed distance to the passed color
 void drawBox(java.awt.Color color, int topLeftX, int topLeftY, int width, int height)
          Method to draw a filled box on the current picture
static Picture drawExample()
          Method to show using drawing on a picture
static Picture drawFace()
          Method to draw a face to demonstrate drawing ovals and arcs
static Picture drawFilledRectangles()
          Method to draw a picture with a succession of filled rectangles with the top left corner the darkest and the bottom right the lightest
static Picture drawGrayEffect()
          Method to draw a gray effect picture
 void drawGrid()
          Method to draw a grid on a picture
 void drawHorizontalCenteredString(java.lang.String text, int y)
          Method to draw a horizontally centered string on the current picture
static Picture drawRectangles()
          Method to draw a picture with a succession of rectangles
 void drawString(java.lang.String text, int x, int y)
          Method to draw a string on the current picture
 void drawSun(int x, int y, int width, int height)
          Method to add a gradient painted sun to the current picture
 void drawWideX(java.awt.Color color, float width)
          Method to add two crossed lines to a picture.
 void drawX(java.awt.Color color)
          Method to add two crossed lines to a picture.
 void edgeDetection(double amount)
          Method to do a simple edge detection by comparing the absolute value of the difference between the color intensities (average of the color values) between a pixel and the pixel below it.
 Picture grayscale()
          Method to change a copy of the current picture to grayscale
 Picture grayscaleWithLuminance()
          Method to change a copy of the current picture to gray scale with luminance
 void highlightLightAndDark(double amount, java.awt.Color replacementColor)
          Method to replace the pixel colors in the current picture object that have a color distance less than the passed amount to white or black with the passed replacement color
 Picture increaseRed()
          Method to increase the amount of red by 30% in a copy of the current picture
 Picture increaseRed2()
          Method to increase the amount of red by 1.3 in a copy of the current picture
 Picture increaseRed3()
          Method to increase the amount of red by 1.3 in a copy of the current picture
 Picture lighten()
          Method to lighten the colors in a copy of the current picture
 Picture lighten2()
          Method to lighten the colors in a copy of the current picture
 Picture makeSunset()
          Method to simulate a sunset by decreasing the green and blue in a copy of the current picture
 Picture makeSunset2()
          Method to make a copy of the current picture that looks like it was taken at sunset by reducing the blue and green to make it look more red
static void makeTurtleMovie(java.lang.String outputDirectory)
          Method to show a turtle crawling across the beach
 Picture mirrorHorizontal()
          Method to mirror around a horizontal line in the middle based on the height.
 Picture mirrorHorizontalBottomToTop()
          Method to mirror around a horiztonal line in the middle based on the height of the picture.
static Picture mirrorTemple()
          Method to mirror the piedmont of the temple
static Picture mirrorTemple2()
          Method to mirror the piedmont of the temple
static Picture mirrorTemple3()
          Method to mirror the piedmont of the temple
 Picture mirrorVertical()
          Method to mirror around a vertical line in the middle of the picture based on the width.
 Picture negate()
          Method to negate a copy of the current picture
static Picture overlapPictures(Picture p1, Picture p2, int startOverlap)
          Method to create a new picture by overlapping one picture with another horizontally.
static Picture pickAndShow()
          Method to allow the user to pick a file name and show a picture.
 void posterize()
          Method to posterize (reduce the number of colors) in the picture The number of reds, greens, and blues will be 4
 void posterize(int numLevels)
          Method to posterize (reduce the number of colors) in the picture
 void removeRedEye(int startX, int startY, int endX, int endY, java.awt.Color newColor)
          Method to remove red eye from the current picture object in the rectangle defined by startX, startY, endX, endY.
 Picture rotate(int degrees)
          Method to create a new picture by rotating the current picture by the given degrees
 Picture scale(double xFactor, double yFactor)
          Method to create a new picture by scaling the current picture by the given x and y factors
 Picture scaleUp(int numTimes)
          Method to create a new picture that is scaled up by the passed number of times.
 void sepiaTint()
          Method to change the current picture to a sepia tint (modify the middle colors to a light brown and the light colors to a light yellow and make the shadows darker
 void setBlue()
          Method to set the blue to zero if the current blue value is greater than 100
 Picture shear(double xFactor, double yFactor)
          Method to create a new picture by shearing the current picture by the given x and y factors
static Picture showNamed(java.lang.String fileName)
          Method to show a picture created from a passed file name
static Picture showSpecificPicture()
          Method to show a specific picture where the file name to show is specified in the method.
static void showTurtleMovie()
          Method to show a turtle crawling across the beach
 void swapBackground(Picture oldBackground, Picture newBackground)
          Method to replace the background in the current picture with the background from another picture
 void swapBackground(Picture oldBackground, Picture newBackground, double threshold)
          Method to replace the background in the current picture with the background from another picture
 java.lang.String toString()
          Method to return a string with information about this picture.
static Picture turnKatieRedHead()
          Method to turn to turn Katie into a red head
static Picture turnKatieRedHeadInRange()
          Method to turn to turn Katie into a red head using a range
 
Methods inherited from class SimplePicture
addMessage, copyPicture, createGraphics, explore, getBasicPixel, getBufferedImage, getExtension, getFileName, getGraphics, getHeight, getImage, getMediaPath, getPictureFrame, getPictureWithHeight, getPixel, getPixels, getTitle, getTranslationEnclosingRectangle, getWidth, load, load, loadPictureAndShowIt, repaint, setAllPixelsToAColor, setBasicPixel, setMediaPath, setPictureFrame, setTitle, show, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Picture

public Picture()
Constructor that takes no arguments


Picture

public Picture(java.lang.String fileName)
Constructor that takes a file name and creates the picture

Parameters:
fileName - the name of the file to create the picture from

Picture

public Picture(int width,
               int height)
Constructor that takes the width and height

Parameters:
width - the width of the desired picture
height - the height of the desired picture

Picture

public Picture(Picture copyPicture)
Constructor that takes a picture and creates a copy of that picture

Method Detail

toString

public java.lang.String toString()
Method to return a string with information about this picture.

Overrides:
toString in class SimplePicture
Returns:
a string with information about the picture such as fileName, height and width.

pickAndShow

public static Picture pickAndShow()
Method to allow the user to pick a file name and show a picture. This method will also return the created picture object.

Returns:
the picture object created from the picked file name

showSpecificPicture

public static Picture showSpecificPicture()
Method to show a specific picture where the file name to show is specified in the method. To change which picture you want to show you can edit the method and recompile it.

Returns:
the created picture object

showNamed

public static Picture showNamed(java.lang.String fileName)
Method to show a picture created from a passed file name

Parameters:
fileName - the name of the file to create the picture from
Returns:
the created picture object

decreaseRed

public Picture decreaseRed()
Method to decrease the red by half in a copy of the current picture

Returns:
a copy of the current picture with the red decreased by half

increaseRed

public Picture increaseRed()
Method to increase the amount of red by 30% in a copy of the current picture

Returns:
a copy of the picture with red increased

clearBlue

public Picture clearBlue()
Method to clear the blue from a copy of the current picture (set the blue to 0 for all pixels)

Returns:
a copy of the current picture with no blue

makeSunset

public Picture makeSunset()
Method to simulate a sunset by decreasing the green and blue in a copy of the current picture

Returns:
the copy with green and blue decreased

decreaseGreen

public Picture decreaseGreen()
Method to decrease the green in a copy of the current picture by 30%

Returns:
a copy of the current picture with green decreased by 30%

decreaseBlue

public Picture decreaseBlue()
Method to decrease the blue in a copy of the current picture by 30%

Returns:
the copy with blue decreased by 30%

makeSunset2

public Picture makeSunset2()
Method to make a copy of the current picture that looks like it was taken at sunset by reducing the blue and green to make it look more red

Returns:
a copy of the current picture with green and blue decreased

changeRed

public Picture changeRed(double amount)
Method to change the red by an amount

Parameters:
amount - the amount to change the red by
Returns:
a copy of the current picture with red changed (multiplied) by the passed amount

changeColors

public Picture changeColors(double redAmount,
                            double greenAmount,
                            double blueAmount)
Method to change the color of each pixel in a copy of the current picture object by the passed amounts.

Parameters:
redAmount - the amount to change the red value
greenAmount - the amount to change the green value
blueAmount - the amount to change the blue value
Returns:
a copy of the current picture with the red, green, and blue changed the the passed amounts

clearBlue2

public Picture clearBlue2()
Method to clear the blue from a copy of the current picture (set the blue to 0 for all pixels)

Returns:
a copy of the current picture with the blue values set to 0

clearBlue3

public Picture clearBlue3()
Method to clear the blue from a copy of the current picture (set the blue to 0 for all pixels)

Returns:
the copy with all the blue values set to 0

lighten

public Picture lighten()
Method to lighten the colors in a copy of the current picture

Returns:
the copy with the color lightened

darken

public Picture darken()
Method to darken the color in a copy of the current picture

Returns:
a copy of the current picture with the color darkened

negate

public Picture negate()
Method to negate a copy of the current picture

Returns:
the copy negated

grayscale

public Picture grayscale()
Method to change a copy of the current picture to grayscale

Returns:
a copy of the current picture in grayscale

grayscaleWithLuminance

public Picture grayscaleWithLuminance()
Method to change a copy of the current picture to gray scale with luminance

Returns:
a copy of the current picture that is changed to grayscale with luminance

increaseRed2

public Picture increaseRed2()
Method to increase the amount of red by 1.3 in a copy of the current picture

Returns:
the copy with red increased by 1.3

increaseRed3

public Picture increaseRed3()
Method to increase the amount of red by 1.3 in a copy of the current picture

Returns:
a copy of the current picture with red increased by 1.3

lighten2

public Picture lighten2()
Method to lighten the colors in a copy of the current picture

Returns:
a copy of the current picture with the color lightened

mirrorVertical

public Picture mirrorVertical()
Method to mirror around a vertical line in the middle of the picture based on the width. This is as if you placed a mirror in the midpoint of the width of the picture and held the mirror vertically.

Returns:
a copy with the picture mirrored around a vertical line in the middle of the picture

mirrorHorizontal

public Picture mirrorHorizontal()
Method to mirror around a horizontal line in the middle based on the height. It copies the top mirrored to the bottom

Returns:
a copy with top mirrored to the bottom

mirrorHorizontalBottomToTop

public Picture mirrorHorizontalBottomToTop()
Method to mirror around a horiztonal line in the middle based on the height of the picture. It copies the bottom to the top.

Returns:
a copy with the bottom mirrored to the top

mirrorTemple

public static Picture mirrorTemple()
Method to mirror the piedmont of the temple

Returns:
the corrected picture of the temple

mirrorTemple2

public static Picture mirrorTemple2()
Method to mirror the piedmont of the temple

Returns:
the corrected picture

mirrorTemple3

public static Picture mirrorTemple3()
Method to mirror the piedmont of the temple

Returns:
the corrected picture

copyKatie

public static Picture copyKatie()
Method to copy the picture of Katie to the canvas

Returns:
the canvas after the picture of Katie has been copied

copyKatieMidway

public static Picture copyKatieMidway()
Method to copy the picture of Katie to 100, 100 in the canvas

Returns:
the picture of Katie copied to 100,100

copyKatiesFace

public static Picture copyKatiesFace()
Method to copy just Katie's face to the canvas

Returns:
the canvas after the copying the face

createCollage

public static Picture createCollage()
Method to create a collage from the flower pictures. All the flower pictures will be lined up near the bottom of the canvas (5 pixels from the bottom)

Returns:
the collage as a picture object

copyPictureTo

public void copyPictureTo(Picture sourcePicture,
                          int xStart)
Method that will copy all of the passed source picture into the current picture object starting with the left corner given by xStart

Parameters:
sourcePicture - the picture object to copy
xStart - the x position to start the copy into

createCollageBetter

public static Picture createCollageBetter()
Method to create a collage of flowers

Returns:
the flower collage as a picture object

copy

public void copy(Picture sourcePicture,
                 int startX,
                 int startY,
                 int endX,
                 int endY,
                 int targetStartX,
                 int targetStartY)
Method to copy from the passed source picture to current picture object The copying will start at startX, startY, and end at endX-1 and endY-1 The copy will be placed starting at targetStartX, targetStartY

Parameters:
sourcePicture - the source picture to copy from
startX - the starting x value in the source picture
startY - the starting y value in the source picture
endX - the ending x value in the source picture
endY - the ending y value in the source picture
targetStartX - the starting x value in the current picture
targetStartY - the starting y value in the current picture

copyNonWhitePixels

public void copyNonWhitePixels(Picture sourcePicture,
                               int startX,
                               int startY,
                               int endX,
                               int endY,
                               int targetStartX,
                               int targetStartY)
Method to copy from the passed source picture to current picture object The copying will start at startX, startY, and end at endX-1 and endY-1 The copy will be placed starting at targetStartX, targetStartY

Parameters:
sourcePicture - the source picture to copy from
startX - the starting x value in the source picture
startY - the starting y value in the source picture
endX - the ending x value in the source picture
endY - the ending y value in the source picture
targetStartX - the starting x value in the current picture
targetStartY - the starting y value in the current picture

blendPictures

public static Picture blendPictures()
Method to blend pictures of Katie and Jenny

Returns:
the blended picture

copyPictureTo

public void copyPictureTo(Picture sourcePicture,
                          int xStart,
                          int yStart)
Method that will copy all of the passed source picture into the current picture object starting with the left corner given by xStart, yStart

Parameters:
sourcePicture - the picture object to copy
xStart - the x position to start the copy into on the target
yStart - the y position to start the copy into on the target

copyKatieLeftRotation

public static Picture copyKatieLeftRotation()
Method to copy the picture of Katie but rotate her left 90 degrees on the resulting picture


copyFlowerSmaller

public static Picture copyFlowerSmaller()
Method to copy the flower but smaller (half as big)

Returns:
the smaller flower picture

copyFlowerLarger

public static Picture copyFlowerLarger()
Method to copy a flower but scaled to 2x normal size

Returns:
the larger flower

turnKatieRedHead

public static Picture turnKatieRedHead()
Method to turn to turn Katie into a red head


turnKatieRedHeadInRange

public static Picture turnKatieRedHeadInRange()
Method to turn to turn Katie into a red head using a range


doubleRedInRange

public void doubleRedInRange(int startX,
                             int startY,
                             int endX,
                             int endY,
                             double distance,
                             java.awt.Color compareColor)
Method to double the red in a picture in a rectangular area if it is less than the passed distance to the passed color

Parameters:
startX - the x value at the top left of the rectangular area
startY - the y value at the top left of the rectangular area
endX - the bottom right x value of the rectangular area
endY - the bottom right y value of the rectangular area
distance - the amount that the distance must be less than
compareColor - the color to compare the current pixel color to

changePixelsWithinDistance

public void changePixelsWithinDistance(java.awt.Color compareColor,
                                       double distance,
                                       double redFactor,
                                       double greenFactor,
                                       double blueFactor,
                                       int startX,
                                       int startY,
                                       int endX,
                                       int endY)
Method to change all the pixels within a passed distance of a passed color in a range specified by a startX, startY, endX, and endY by passed red, green, and blue factors.

Parameters:
compareColor - the color to compare the current pixel color to
distance - the distance that this should be within (less than)
redFactor - the amount to multiply the current red value by
greenFactor - the amount to multiply the current green value by
blueFactor - the amount to multiply the current blue value by
startX - the starting x value to use in checking the pixels
startY - the starting y value to use in checking the pixels
endX - the ending x value to use in checking the pixels (< this)
endY - the ending y value to use in checking the pixels (< this)

removeRedEye

public void removeRedEye(int startX,
                         int startY,
                         int endX,
                         int endY,
                         java.awt.Color newColor)
Method to remove red eye from the current picture object in the rectangle defined by startX, startY, endX, endY. The red will be replaced with the passed newColor

Parameters:
startX - the top left corner x value of a rectangle
startY - the top left corner y value of a rectangle
endX - the bottom right corner x value of a rectangle
endY - the bottom right corner y value of a rectangle
newColor - the new color to use

sepiaTint

public void sepiaTint()
Method to change the current picture to a sepia tint (modify the middle colors to a light brown and the light colors to a light yellow and make the shadows darker


posterize

public void posterize()
Method to posterize (reduce the number of colors) in the picture The number of reds, greens, and blues will be 4


posterize

public void posterize(int numLevels)
Method to posterize (reduce the number of colors) in the picture

Parameters:
numLevels - the number of color levels to use

highlightLightAndDark

public void highlightLightAndDark(double amount,
                                  java.awt.Color replacementColor)
Method to replace the pixel colors in the current picture object that have a color distance less than the passed amount to white or black with the passed replacement color

Parameters:
replacementColor - the new color to use

scaleUp

public Picture scaleUp(int numTimes)
Method to create a new picture that is scaled up by the passed number of times.

Returns:
the new scaled up picture

blur

public void blur(int numPixels)
Method to blur the pixels

Parameters:
numPixels - the number of pixels to average in all directions so if the numPixels is 2 then we will average all pixels in the rectangle defined by 2 before the current pixel to 2 after the current pixel

edgeDetection

public void edgeDetection(double amount)
Method to do a simple edge detection by comparing the absolute value of the difference between the color intensities (average of the color values) between a pixel and the pixel below it. If the absolute value of the difference between the color intensities is less than a passed amount the top pixel color will be set to white. Otherwise it is set to black.

Parameters:
amount - if the absolute value of the differences in the color average is less than this set the color to white, else black

swapBackground

public void swapBackground(Picture oldBackground,
                           Picture newBackground)
Method to replace the background in the current picture with the background from another picture

Parameters:
oldBackground - a picture with the old background to replace
newBackground - a picture with the new background to use

swapBackground

public void swapBackground(Picture oldBackground,
                           Picture newBackground,
                           double threshold)
Method to replace the background in the current picture with the background from another picture

Parameters:
oldBackground - a picture with the old background to replace
newBackground - a picture with the new background to use
threshold - if the distance between the current pixel color and the background pixel color is less than this amount use the new background pixel color

chromakey

public void chromakey(Picture newBg)
Method to do chromakey using a blue background

Parameters:
newBg - the new background image to use to replace the blue from the current picture

chromakeyBlue

public void chromakeyBlue(Picture newBg)
Method to do chromakey using a blue background

Parameters:
newBg - the new background image to use to replace the blue from the current picture

chromakeyRed

public void chromakeyRed(Picture newBg)
Method to do chromakey using a red background

Parameters:
newBg - the new background image to use to replace the red from the current picture

blueOneHundred

public void blueOneHundred()
Method to set the blue values to 100 in a rectangle of 100 pixels with x and y starting at 0 and ending at 99


blueChange

public void blueChange()
Method to set all blue values to 100 in the picture


clearSomeBlue

public void clearSomeBlue()
Method to set the blue to zero if the distance from this color to blue is greater than 100


setBlue

public void setBlue()
Method to set the blue to zero if the current blue value is greater than 100


countWhitePixels

public int countWhitePixels()
Method to count the number of white pixels in a picture

Returns:
the number of white (r=255, g=255, b=255) pixels

drawGrid

public void drawGrid()
Method to draw a grid on a picture


addBoxToBeach

public static Picture addBoxToBeach()
Method to add a solid red rectangle to the beach picture


drawBox

public void drawBox(java.awt.Color color,
                    int topLeftX,
                    int topLeftY,
                    int width,
                    int height)
Method to draw a filled box on the current picture

Parameters:
color - the color to draw the box with
topLeftX - the top left x coordinate of the box
topLeftY - the top left y coordinate of the box
width - the width of the box
height - the height of the box

drawExample

public static Picture drawExample()
Method to show using drawing on a picture

Returns:
the example picture

drawFace

public static Picture drawFace()
Method to draw a face to demonstrate drawing ovals and arcs

Returns:
the face picture

drawString

public void drawString(java.lang.String text,
                       int x,
                       int y)
Method to draw a string on the current picture

Parameters:
text - the string to draw
x - the x location to start at
y - the y location of the baseline

drawHorizontalCenteredString

public void drawHorizontalCenteredString(java.lang.String text,
                                         int y)
Method to draw a horizontally centered string on the current picture

Parameters:
text - the string to draw
y - the y location of the baseline

drawGrayEffect

public static Picture drawGrayEffect()
Method to draw a gray effect picture

Returns:
the picture that shows the gray effect

drawFilledRectangles

public static Picture drawFilledRectangles()
Method to draw a picture with a succession of filled rectangles with the top left corner the darkest and the bottom right the lightest

Returns:
the picture with the filled rectangles

drawRectangles

public static Picture drawRectangles()
Method to draw a picture with a succession of rectangles

Returns:
the picture with the rectangles

drawX

public void drawX(java.awt.Color color)
Method to add two crossed lines to a picture. One line will go from the top left corner to the bottom right corner. The other will go from the bottom left corner to the top right corner.


drawWideX

public void drawWideX(java.awt.Color color,
                      float width)
Method to add two crossed lines to a picture. One line will go from the top left corner to the bottom right corner. The other will go from the bottom left corner to the top right corner.


rotate

public Picture rotate(int degrees)
Method to create a new picture by rotating the current picture by the given degrees

Parameters:
degrees - the number of degrees to rotate by
Returns:
the resulting picture

shear

public Picture shear(double xFactor,
                     double yFactor)
Method to create a new picture by shearing the current picture by the given x and y factors

Parameters:
xFactor - multiplier to use to shift in x direction based on y index
yFactor - multiplier to use to shift in y direction based on x index
Returns:
the resulting picture

scale

public Picture scale(double xFactor,
                     double yFactor)
Method to create a new picture by scaling the current picture by the given x and y factors

Parameters:
xFactor - the amount to scale in x
yFactor - the amount to scale in y
Returns:
the resulting picture

createComposite

public static Picture createComposite()
Method to try different composite rules in a picture with a gradient painted rectangle and a texture painted ellipse


copy

public void copy(Picture source,
                 int x,
                 int y)
Method to copy the passed picture into the current picture at the given x and y position in the current picture

Parameters:
source - the picture to copy
x - the x of the uppper left corner to copy to
y - the y to the upper left corner to copy to

copy2D

public void copy2D(Picture source,
                   int x,
                   int y)
Method to copy the passed picture into the current picture at the given x and y position in the current picture

Parameters:
source - the picture to copy
x - the x of the uppper left corner to copy to
y - the y to the upper left corner to copy to

overlapPictures

public static Picture overlapPictures(Picture p1,
                                      Picture p2,
                                      int startOverlap)
Method to create a new picture by overlapping one picture with another horizontally. First the part of the first picture before the overlap will be displayed, next to that will be the overlapping region up to the end of the first picture, after that is the remainder of the second picture

Parameters:
p1 - the first picture to display
p2 - the second picture to display
startOverlap - the x position where the overlap begins
Returns:
the resulting picture

drawSun

public void drawSun(int x,
                    int y,
                    int width,
                    int height)
Method to add a gradient painted sun to the current picture

Parameters:
x - the x location for the upper left corner of the rectangle enclosing the sun
y - the y location for the upper left corner of the rectangle enclosing the sun
width - the width of the enclosing rectangle
height - the height of the enclosing rectangle

clipToEllipse

public Picture clipToEllipse()
Method to clip the picture to an ellipse

Returns:
a new picture with the image clipped to an ellipse

clipToMessage

public Picture clipToMessage(java.lang.String message)
Method to create a new picture from this picture that shows the part of the current picture that is inside a text message

Parameters:
message - the message to show
Returns:
the new picture

blendPictures

public Picture blendPictures(Picture sourcePict,
                             double sourceAlpha)
Method to blend two pictures, the current picture object and the passed sourcePict object. The amount of the source picture to use is given in sourceAlpha. The amount of the current picture to use is (1.0 - sourceAlpha)

Parameters:
sourcePict - the source picture
sourceAlpha - the amount of the source picture to use
Returns:
the result of blending the source picture with the current picture object

copyPicture

public void copyPicture(Picture sourcePict,
                        java.awt.Rectangle sourceRect,
                        java.awt.Rectangle targetRect,
                        java.awt.Composite composite)
Method to copy a picture into the current picture using the passed composite rule

Parameters:
sourcePict - the source picture to copy from
sourceRect - the rectangle that describes what area to copy from
targetRect - the rectangle that describes what area to copy into
composite - the composite to use

showTurtleMovie

public static void showTurtleMovie()
Method to show a turtle crawling across the beach


makeTurtleMovie

public static void makeTurtleMovie(java.lang.String outputDirectory)
Method to show a turtle crawling across the beach