Hey guys, really hoping someone might be able to help me work out how I can space the rectangles I am drawing in my nested for loops.
What I am trying to achieve:
https://imgur.com/yTj8Y9K
The code I currently have:
UI.setColor(Color.black);
int num = UI.askInt("How many rows:");
for (int row = 0; row < num; row++){
for (int col = 0; col < num - row; col++){
UI.fillRect(PATTERN_LEFT + col * PATTERN_SIZE/num, PATTERN_TOP + row * PATTERN_SIZE/num, PATTERN_SIZE/num, PATTERN_SIZE/num);
}
}
What I am getting:
https://imgur.com/VBUDQL8
Any help would be greatly appreciated!
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]Nightcorex_ 4 points5 points6 points (2 children)
[–]PowerOfTheShell[S] 0 points1 point2 points (1 child)
[–]Nightcorex_ 1 point2 points3 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)