home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / visualj / msdev / samples / sun / simplegraph / graphapplet.java < prev    next >
Encoding:
Java Source  |  1996-07-23  |  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.