/*
* @(#)GraphApplet.java 1.2 96/12/06
*
*/
import java.awt.Graphics;
public class GraphApplet extends java.applet.Applet {
double f(double x) {
return
(Math.cos(x/5) + Math.sin(x/7) + 2) * size().height / 4;
}
double h(double x) {
return
(Math.sin(x/5) + 2) * size().height / 4;
}
public void paint(Graphics g) {
for (int x = 0 ; x < size().width ; x++) {
g.drawLine(x, (int)f(x), x + 1, (int)f(x + 1));
}
g.drawLine(0, (int)f(0), size().width - 1, (int)f(0) );
for (int x = 0 ; x < size().width ; x++) {
for (int y = 0 ; y < size().width/4 ; y++) {
}
g.drawLine(x, (int)f(x-50), x + 1, (int)f(x + 1 -50 ));
}
}
}
|