home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / Java++ / VJ / SAMPLES / SUN / SIMPLEGRAPH / GRAPHAPPLET.JAVA < prev    next >
Encoding:
Java Source  |  1996-11-11  |  351 b   |  15 lines

  1.  
  2. import java.awt.Graphics;
  3.  
  4. public class graphapplet extends java.applet.Applet {
  5.     double f(double x) {
  6.     return (Math.cos(x/5) + Math.sin(x/7) + 2) * size().height / 4;
  7.     }
  8.  
  9.     public void paint(Graphics g) {
  10.         for (int x = 0 ; x < size().width ; x++) {
  11.         g.drawLine(x, (int)f(x), x + 1, (int)f(x + 1));
  12.         }
  13.     }
  14. }
  15.