📄 j_drawsin.java
字号:
// ////////////////////////////////////////////////////////
//
// J_DrawSin.java
//
// ////////////////////////////////////////////////////////
import java.awt.Graphics;
import java.applet.Applet;
// ////////////////////////////////////////////////////////
// Display y=sin(x)
public class J_DrawSin extends Applet
{
public void paint(Graphics g)
{
super.paint( g ); // Call system's method.
double d, tx;
int x, y, x0, y0;
d= Math.PI/100; // The curve is divided into 200 segments
x0=y0=0;
for (tx= 0, x= 20; tx<= 2*Math.PI; tx+=d, x++)
{ // Draw the curve
y= 120-(int)(Math.sin(tx)*50+60); // Scaling, translation and symmetry
if (x>20)
g.drawLine(x0, y0, x, y);
x0= x;
y0= y;
} // End of the loop: for
g.drawString("y=sin(x)", 10, 70);
} // End of method: paint
} // End of class: J_DrawSin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -