Objectives:
Let's
start out by having some fun with the Graphics class. Do you have a picture
of yourself or a friend?
| Assignment: Write a program which draws glasses on a person who does not normally wear glasses. This program will only work for this particular picture! Add a caption horizontally centered on the bottom of your picture using the drawString method. Hint: Look at code on p226 for centering text |
| Assignment: Did you struggle with the clipping a triangular shape in lab3? Your cruel professor wanted you to have practice with loops in a matrix and hid from you the fact that these tasks can be done easily with the Graphics2D class! Write a method which clips an image in the shape of a triangle. Hints: A triangle is a type of Polygon
with three sides. To create a polygon you need to provide two
arrays for the x coordinates and y coordinates of the three points
of the triangle. You can create an array like this: |
| Assignment: Write a method which rotates a picture by an amount specified by a parameter. Hints: Get the AffineTransform from the Graphics2D object and then use the rotate method on the transform. You will want to rotate the picture around the center point of the picture. Then set the transform and draw the image. |