Exercise 8: Painting

Home/Java - Tutorial/Java - Applet/Exercise 8: Painting
Exercise 8: Painting 2015-12-04T17:53:08+00:00

[ Home | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 ]

In addition to reducing flicker, a backbuffer can be used to store the accumulated results of drawing operations. We can easily implement a canvas-and-brush applet:

(Download the below file: Brush1.java)

Click and drag over the applet to paint:

 

Another example:

(Download the below file: Keyboard3.java)

Click and type; click again and type some more:

 

A third example:

(Download the below file: Brush2.java)

Programming a custom brush and canvas enables experimentation with behaviors not otherwise possible. An understanding of arithmetic, geometry, and trigonometry will enhance your own ability to “play” in this medium.