Flipping and Rotating Revisited: Here's another example of how
there is often more than one way to create an effect. In order to do this
you need to use the following version of drawImage: g.drawImage(c, 0, 0, 200, 160, 200, 160, 0, 0, this); This version takes EIGHT integer values as arguments. The first four have to do with where in the applet the image is displayed, the second four define the upper-left corner and the lower-right corner of the image. So, this line would draw an image located with its upper-left corner at (0,0) and its lower-right corner at (200,160). But what is interesting is that it takes the lower-right corner of the image (200,160) and pins that to the upper-left corner of the area designated for drawing the image and then it takes the upper-left corner of the image (0,0) and pins that to the lower-right corner of the area designated for drawing the image. Not only can you rotate and flip using this version of drawImage, you can also crop (and still flip or rotate at the same time). |