Learned loop this week. i feel that it is not easy for me. Because I need time to understand the conditional determination of i. Although worksheet let me finish the exercise, I still feel difficult when I do the pattern by myself.
First I followed the code in the previous worksheet and made a circular arrangement by imitating it. 10 in the horizontal row and 10 in the vertical row.
Explanation of loop:
let i = 0: Initializes variable i to 0.
i < cols: the loop continues as long as i is less than the value of cols.
i++: After each loop iteration, i is incremented by 1
On the basis of this again, I want to put a small circle in a large circle. So put diameter*0.4
I want to add another small circle to the gap between the four circles.
for (let i = 0; i < cols - 1; i++) { for (let j = 0; j < rows - 1; j++) { let x = (i + 0.5) * diameter + diameter / 2;
// Calculate the x-coordinate of the center of the four great circles.
let y = (j + 0.5) * diameter + diameter / 2;
// Calculate the y-coordinate of the center of the four great circles.
ellipse(x, y, diameter * 0.3);