PictureWorld Contract

Picture Combinators

These are methods that return Picture objects. Remember that the picture grid is a 1x1 square where (0.0,0.0) is the bottom left corner and (1.0,1.0) is the top right corner.

empty

public Picture empty()
Returns the empty picture.

Methods which rotate Pictures

public Picture clockwise90 (Picture p)
Returns a Picture which is the original Picture p rotated 90 degrees in the clockwise direction.

public Picture clockwise180 (Picture p)
Returns a Picture which is the original Picture p rotated 180 degrees in the clockwise direction.

public Picture clockwise270 (Picture p)
Returns a Picture which is the original Picture p rotated 270 degrees in the clockwise direction.


p1

clockwise90(p1)

clockwise180(p1)

clockwise270(p1)

Methods which flip Pictures around an axes

The axes are defined as shown in the diagram below:

public Picture flipHorizontally (Picture p)
Returns a Picture which is the original Picture p flipped around its middle horizontal axis (from (0.0,0.5) to (1.0,0.5)).

public Picture flipVertically (Picture p)
Returns a Picture which is the original Picture p flipped around its middle vertical axis (from (0.5,0.0) to (0.5,1.0)).

public Picture flipDiagonally (Picture p)
Returns a Picture which is the original Picture p flipped around its diagonal axis (from (0.0,0.0) to (1.0,1.0)).


p1

flipHorizontally(p1)

flipVertically(p1)

flipDiagonally(p1)

overlay

public Picture overlay (Picture p1, Picture p2)
Returns a Picture which is the result of placing Picture p1 on top of Picture p2.


p1

p2

overlay(p1,p2)

Methods which place Pictures next to each other

public Picture beside (Picture p1, Picture p2)
Returns a Picture which is the result of placing Picture p1 to the left of Picture p2 where each Picture takes up half of the screen.

public Picture beside (Picture p1, Picture p2, double fraction)
Returns a Picture which is the result of placing Picture p1 to the left of Picture p2 where p1 takes up the specified fraction of the screen. fraction is a decimal number between 0.0 (none of the screen) and 1.0 (the entire screen).

public Picture above (Picture p1, Picture p2)
Returns a Picture which is the result of placing Picture p1 above Picture p2 where each Picture takes up half of the screen.

public Picture above (Picture p1, Picture p2, double fraction)
Returns a Picture which is the result of placing Picture p1 above Picture p2 where p1 takes up the specified fraction of the screen. fraction is a decimal number between 0.0 (none of the screen) and 1.0 (the entire screen).


beside(p1,p1)

beside(p1,p1,0.25)

above(p1,p1)

above(p1,p1,0.66)

Picture Choice Manipulators

public void initializePictureChoices()
This method is invoked when a PictureWorld applet is created.

public void addPictureChoice(String name, Picture pic)
This method adds the choice name to the list of Picture choices and associates it with the Picture pic.