import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;


public class Ch1_7 extends Applet {

	/**
	 * 双缓冲显示图片
	 */
	int width,height;
	Image image; //缓冲区对象
	Graphics gl;
	
	//Applet 初始化调用
	public void init(){
		setBackground(Color.black);//设置背景
		this.setSize(350,310);
		
		width = getSize().width;//获得窗口宽带
		height = getSize().height;
		image = createImage(width,height);//创建图像对象
		gl = image.getGraphics();
	}
	//绘图方法 
	public void paint(Graphics g){
		gl.create(0, 0, width, height);
		gl.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;
				//为了在中间显示,加了偏移量
				gl.fillOval((int) x,(int) y, 2, 2);
				gl.fillRect((int) x,(int) y, 1, 1);
				
			}
			//显示缓存区的可变Image对象
			g.drawImage(image, 0, 0, this);
		}
	}
	

}
最近下载更多
生米的  LV10 2023年3月5日
微信网友_5992582549164032  LV6 2022年6月25日
nnnnyyy  LV1 2022年4月18日
xtm123  LV18 2021年6月22日
1811841085  LV3 2020年10月15日
921019050  LV1 2019年7月13日
2338544941  LV2 2019年2月10日
lfz666  LV2 2018年12月18日
你没治疗了  LV1 2018年11月8日
wanlcl1314  LV1 2018年8月24日
最近浏览更多
EFWAGGFAWGR 2023年10月19日
暂无贡献等级
ZYM_97  LV2 2023年6月8日
ZYM_96  LV1 2023年6月8日
xingxing1234  LV10 2023年3月22日
生米的  LV10 2023年3月5日
Small CN  LV7 2022年12月6日
微信网友_6221960858275840 2022年11月16日
暂无贡献等级
微信网友_6184005683466240  LV11 2022年11月9日
孙纪龙啊  LV10 2022年11月8日
0791fx 2022年7月6日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友