6.13 (Optional) GUI and Graphics Case Study: Colors and Filled Shapes

Class GraphicsContext provides many more capabilities than drawing lines, rectangles and ovals. The next two features we introduce are colors and filled shapes. Adding color enriches the drawings a user sees on the computer screen. For example, IDEs generally “syntax color” Java code to help you distinguish different code elements, like keywords and comments. Shapes can be filled with solid colors. As we show in Chapter 22, shapes also can be filled with images or with so-called gradients that transition gradually between colors. In this section, we’ll create the DrawSmiley app that uses solid colors and filled shapes to draw a smiley face.

Solid colors displayed on computer ...

Get Java How to Program, Early Objects, 11th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.