Drawing circles at the top

image

I have to create these circles at the top and for some reason I can’t get them centered…at the beginning, it starts with half a circle.

What am i doing wrong? here is my code

public void drawCircles()
{
  fill(255);
  strokeWeight(4);
  stroke(0);
   int x=0;
   int y=9;
   for(x=0; x < 400; x++)
{
  ellipseMode(CENTER);
  ellipse(x*20, y, 20, 20);
  noLoop();
}

x defines the position of the center of your circle.
your for-loop says:
start with x being 0 and increase it by 1
1: x = 020
2: x = 1
20
3: x = 3*20
and so on…

your code works perfectly :wink:

you should either not use ellipseMode(CENTER) and adjust y to 0
or add the missing distance (the radius of your circles) to x

as an aside: you don’t need to use inside your for loop, once inside the method would be enough.
if it is the only time in your patch that you change the mode, then it is enough to set it once in setup()

2 Likes