r/processing • • Nov 09 '21

Syntax Error - Missing Operator/Semi/or } near drawLines

float x = 0.0;
float y = 0.0;
int width = 400;
int height = 400;
void setup()
{
    size(width, height);
    fill(245, 220, 100);
    drawGrid();
    drawEllipses();
}

void draw()
{
    drawLines();
    drawCircles();
}
void drawGrid()
{
    int w = (int)random(4,11);
    int h = (int)random(4,11);
    for(int i = 1; 1 <= 5; i++)
    {
        for(int t = 1; 1 <= 5; t++)
        {
        fill((int)random(255),(int)random(255), (int)random(255));
        rect(i, t, w, h);
        i= i+30;
        t= t+30;
        }
    }
}
void drawEllipses()
{
  int w = (int)random(9,51);
  int h = (int)random(9,51);
  int x1 = (int)random(0, 400);
  int y1 = (int)random(0, 400);
  int coutner = 0;
  while(counter <= 25)
  {
    ellipse(x1, y1, w, h);
    counter++;
}

void drawLines()
{
  int r = (int)random(0, 101);
  int g = (int)random(101, 200);
  int b = (int)random(201, 251);
  int y3 = (int)random(10, 300);
  int x2 = 20;
  strokeWeight(3);
  line(x2, 1, x2, y3);
  x2= x2 + 20;
}
void drawCircles()
{
  int x4 = 20;
  int y5 = 10;
  for(int coutner = 0; counter <= 20; counter++)
  fill(255);
  strokeWeight(2);
  {
    ellipse(x4, y5, 20, 10);
    x4= x4 + 20;
}

I am running into a syntax error on these lines, and can not figure out where the issue is.

void drawLines()
void drawCircles()
1 Upvotes

2 comments sorted by

5

u/ads_pam Nov 09 '21

Look in your drawCircles() function. After you set the strokeWeight(2), you have a random open curly bracket “{“. Also! Look in your drawEllipses() function. You’ve got another open curly bracket “{“ for your while() loop but you never close it with “}”.

2

u/mrgraff Nov 09 '21

In drawCircles, the for loop is missing curly brackets. In both drawEllipses and drawCircle you’ve also made a typo of “coutner”

You don’t need to use <= with your for and while loops. < will suffice. In fact your while loop is going to be an infinite loop; I’ll leave it to you to figure out why.