GUI and Graphics Case Study Exercise

7.1 (Drawing Spirals) In this exercise, you’ll draw spirals with methods drawLine and drawArc.

a) Draw a square-shaped spiral (as in the left screen capture of Fig. 7.27), centered on the panel, using method drawLine. One technique is to use a loop that increases the line length after drawing every second line. The direction in which to draw the next line should follow a distinct pattern, such as down, left, up, right.

Image

Fig. 7.27 | Drawing a spiral using drawLine (left) and drawArc (right).

b) Draw a circular spiral (as in the right screen capture of Fig. 7.27), using method drawArc to draw one semicircle ...

Get Java™ How To Program (Early Objects), Tenth 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.