dimanche 8 mars 2015

Setting a pattern with a loop

Ok, Trying to Draw an American flag


I just did the overall thing manually, but not wanting to manually enter points for each individual star, i wanted to use a loop to set them row by row


There are probably easier ways of doing this, but my idea was to use a for-loop, using the control variable as teh additive to place each star (so when loop control increments by 5, first start is placed, then second is placed 5 points away, then by 10 til the row has 6 stars)


By my logic, i have no problems, the IDE has no errors and it complies successfully...........Except the Stars do not show up. At all.


before i implemented the for-loop, the 1 star i had showed up. with it, none do. not even the 1 star


there doesn't appear to be any error yet it isn't working, so is my Idea just fundamentally wrong or what?


The bit that matters:



double StarX[] = {13.0, 15.0, 21.0, 16.0, 18.0, 13.0, 8.0, 11.0, 5.0, 11.0};
double StarY[] = {50.0, 57.0, 57.0, 61.0, 68.0, 64.0, 68.0, 61.0, 57.0, 57.0};

for (int i = 0; i < 30; i = i + 5) {
Polygon Star = new Polygon();
Star.getPoints().addAll(new Double[]{
StarX[0], StarY[0],
StarX[1], StarY[1],
StarX[2], StarY[2],
StarX[3], StarY[3],
StarX[4], StarY[4],
StarX[5], StarY[5],
StarX[6], StarY[6],
StarX[7], StarY[7],
StarX[8], StarY[8],
StarX[9], StarY[9],
});

Star.setFill(Color.BLACK);
pane.getChildren().add(Star);

}
pane.getChildren().add(S1);
pane.getChildren().add(S2);

Aucun commentaire:

Enregistrer un commentaire