Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9More Graphics3-23-2011Opening DiscussionMinute essay comments:Following along in class and little errors.Animation suggestionsg.drawAnimation?Importing movie files.Doing gradient paints.Add a Timer and cycle through images.IcP solutions.ImagesWe talked briefly last time about how to load images with ImageIO.We need to talk a bit more about the BufferedImage.It is a raster image, a 2-D grid of pixels.If you make a BufferedImage you can use createGraphics to get a Graphics2D that will draw to it.Double BufferingThe “proper” way to write the paint method is to have a BufferedImage that you draw to, then draw the image to the provided Graphics2D object.This is called double buffering and it prevents flicker and can make things run faster.Mouse EventsThere are several types of events that relate to the mouse.MouseClickedMouseDraggedMousePressed...Listen to one of the publishers on a component.mouse.clicksmouse.movesmouse.wheelKey EventsThere are three event types for keys.KeyPressedKeyReleasedKeyTypedListen to the keys object in a component to get these.Compare the key value in the event to values in the Key object.if(e.key==Key.A) …if(e.key==Key.Left) ...TexturePaintNow that we can use images we can test out the TexturePaint.Writing TransformsLast time we mentioned AffineTransforms, but didn't see what they can do.Let's take some time now to write code that uses an AffineTransform in our drawing.Minute EssayQuestions about graphics before we move to
View Full Document