lundi 10 octobre 2016

Looping random circles JAVA

Im trying to produced 30 random circles. I'm trying to for loop it but I'm a little confused on how to do it. If anyone can give me advice to help, that would be great! Thanks!

/** * Constructor for objects of class RandomCircles * @param primaryStage the main window */

public void start(Stage primaryStage)
{
   Group root = new Group();
   Random gen = new Random();
   radius = getRadius; 

   for(int i = 1; i <= 30; i++);
   {
   int size = gen.nextInt(66) + 10; 
   int x = gen.nextInt(601);
   int y = gen.nextInt(401);

   Circle circle1 = new Circle(x - size, y - size, size);
   circle1.setStroke(Color.rgb(gen.nextInt(256), gen.nextInt(256), gen.nextInt(256)));  
   circle1.setStrokeWidth(3);
   circle1.setFill(Color.rgb(255, 255, 255, 0.00));
   root.getChildren().add(circle1);

  }


  // if( >  with radius 



  Scene scene = new Scene(root, 600, 500);


    primaryStage.setTitle("GraphicsAndLoops");
    primaryStage.setScene(scene);
    primaryStage.show();

    primaryStage.setOnCloseRequest(e -> System.exit(0));




Aucun commentaire:

Enregistrer un commentaire