首页 > 中学考试杂题 > 题目详情
public void draw( Graphics g) {Graphics2D g2d = (Graphics2D)
题目内容:
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 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) );
}
}
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) );
}
}
本题链接: