graphic = (Graphics2D)canvasImage.getGraphics();
balls = new ArrayList<Ball>();
int numballs = 19;
Ball ball;
Color[] color = { Color.orange, Color.gray, Color.cyan,
Color.green, Color.lightGray, Color.yellow,
Color.magenta, Color.pink, Color.red,
Color.white
};
int dx = 65;
int dy = 65;
int y = Config.MARGIN + 15;
int x = Config.MARGIN + 15;
// now generating the random balls
for (int i=0;i<numballs;i++){
int radius = 20 - ((int) Math.random() * 10);
ball = new Ball(color[i%color.length], radius);
ball.setCoords( x , y );
x += dx;
if( x > Config.WIDTH_E - dx){
x = Config.MARGIN + 15;
y += dy;
}
ball.setAngle(45 + Math.toRadians( (int) (Math.random() * 90) ));
ball.setSpeed(1 + (int) (Math.random()*10));
addBall(ball);
}
//run();