public void draw( Graphics g) {Graphics2D g2d = (Graphics2D) g;final int x = getX();final int y = getY();g2d.setColor( Color.GREEN );g2d.setPaint( new GradientPaint( x,y,Color.GREEN,x + RADIUS/4,y + RADIUS/4,Color.BLACK,true) );int xOffset = 0;int yO
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/27 17:09:50
public void draw( Graphics g) {Graphics2D g2d = (Graphics2D) g;final int x = getX();final int y = getY();g2d.setColor( Color.GREEN );g2d.setPaint( new GradientPaint( x,y,Color.GREEN,x + RADIUS/4,y + RADIUS/4,Color.BLACK,true) );int xOffset = 0;int yO
public void draw( Graphics g) {
Graphics2D g2d = (Graphics2D) g;
final int x = getX();
final int y = getY();
g2d.setColor( Color.GREEN );
g2d.setPaint( new GradientPaint( x,y,Color.GREEN,x + RADIUS/4,y + RADIUS/4,Color.BLACK,true) );
int xOffset = 0;
int yOffset = 0;
for( int i = 0; i < DENSITY; i++) {
xOffset = (int) (Math.random()*RADIUS);
yOffset = (int) (Math.random()*RADIUS);
g2d.draw( new Ellipse2D.Double( x + xOffset,y + yOffset,x + xOffset+3,y + yOffset+3) );
}
}
public void draw( Graphics g) {Graphics2D g2d = (Graphics2D) g;final int x = getX();final int y = getY();g2d.setColor( Color.GREEN );g2d.setPaint( new GradientPaint( x,y,Color.GREEN,x + RADIUS/4,y + RADIUS/4,Color.BLACK,true) );int xOffset = 0;int yO
public void draw( Graphics g) {
Graphics2D g2d = (Graphics2D) g;//转化g的类型为Graphics2D
final int x = getX()//;取得x坐标
final int y = getY();//取得y坐标
g2d.setColor( Color.GREEN );//设置填充色green
g2d.setPaint( new GradientPaint( x, y, Color.GREEN, x + RADIUS/4, y + RADIUS/4, Color.BLACK, true) );//设置填充方式,从点x,y到点x + RADIUS/4, y + RADIUS/4的颜色渐变从green到black
int xOffset = 0;//初始化x轴偏移变量
int yOffset = 0;//初始化y轴偏移变量
for( int i = 0; i < DENSITY; i++) {循环
xOffset = (int) (Math.random()*RADIUS);
yOffset = (int) (Math.random()*RADIUS);
g2d.draw( new Ellipse2D.Double( x + xOffset, y + yOffset, x + xOffset+3, y + yOffset+3) );//画一个椭圆
}
}