Apple

来源:互联网 发布:起爆点指标公式源码 编辑:程序博客网 时间:2024/04/29 16:36
import java.awt.*; import java.applet.*; public class Apple extends Applet{    int width, height;    Image image;    Graphics draw_Curve;    public void init(){ setBackground(Color.black); this.setSize(350, 310); width = getSize().width; height = getSize().height; image = createImage(width, height); draw_Curve = image.getGraphics();    }    public void paint(Graphics g){ draw_Curve.clearRect(0, 0, width, height); draw_Curve.setColor(Color.red); int i, j; double x, y, r; for(i = 0; i <= 90; i++) for(j = 0; j  <= 90; j++){ r = Math.PI / 45 * i * (1 - Math.sin(Math.PI / 45 * j)) * 18; x = r * Math.cos(Math.PI / 45 * j) * Math.sin(Math.PI / 45 * i) + width / 2; y = -r * Math.sin(Math.PI / 45 * j) + height / 4; draw_Curve.fillOval((int) x, (int)y, 2, 2); } g.drawImage(image, 0, 0, this);    }    } 
copy过来的,只是想借助其来编程一个心形图形,但是心形图是由不同的文字组成。

0 0