package com.mr.rocket;
import
java.applet.Applet;
import
java.awt.Color;
import
java.awt.Graphics;
import
java.awt.Image;
public
class
Test_2
extends
Applet{
int
width
,
height
;
Image
image
;
//缓冲区对象
Graphics
g1
;
public
void
init(){
//Applet 初始化时调用
setBackground(Color.
black
);
//设置背景
this
.setSize(350, 310);
width
= getSize().
width
;
//获得窗口宽度
height
= getSize().
height
;
image
= createImage(
width
,
height
);
//创建图像对象
g1
=
image
.getGraphics();
}
public
void
paint(Graphics g){
//绘图方法
g1
.clearRect(0, 0,
width
,
height
);
g1
.setColor(Color.
red
);
for
(
int
i = 0; i <= 90; i++)
for
(
int
j = 0; j <= 90; j++){
int
r = (
int
) (Math.
PI
/ 45 * i * (1 - Math.sin(Math.
PI
/ 45 * j)) * 18);
int
x = (
int
) (r * Math.cos(Math.
PI
/ 45 * j) * Math.sin(Math.
PI
/ 45 * i) +
width
/ 2);
//为了在中间显示,加了偏移量
int
y = (
int
) (-r * Math.sin(Math.
PI
/ 45 * j) +
height
/ 4);
g1
.fillOval((
int
) x, (
int
)y, 2,2);
g.drawImage(
image
, 0, 0,
this
);
}
}
/**
*
@param
args
*/
public
static
void
main(String[] args) {
//
TODO
Auto-generated method stub
}
}