syntax-errorprocessingcustom-function

Syntax Error - missing operator, semicolon, or '}' near 'drawFrieze'


I am a beginner programmer taking a programming class using Processing 4. I have a project that is meant to use loops and custom functions to create a complex pattern. I have code that works without functions, but when I tried to rewrite it with functions I keep running into the error: "Syntax error - missing operator, semicolon, or '}' near 'drawFrieze'. The interesting thing is, when I take out the drawFrieze function, the error moves to the next function.

I've double checked the formatting of the function, and it has the proper number of curly brackets and semicolons. I've tried moving the functions before void draw() and even putting it on a separate tab, but the error still shows up. I don't know what I did wrong and I would appreciate input from more experienced people.

/*
Kathrine Lee
ITGM 220
Complex Pattern
7/12/2023
*/

void setup () {
size(1000,800);
background(black);
}

//color palette
color linen = color(#fef5ec);
color lightBlue = color(#95d2da);
color blue = color(#158da2);
color gold = color(#cc9214);
color tangerine = color(#ea851f);
color redOrange = color(#da481d);
color springGreen = color(#246f49);
color darkGreen = color(#173b28);
color black = color(#090607);

void drawCircles(float circlesX,float circlesY) {
 noStroke();
 fill(redOrange);
 rect(0,200,1000,400);
 noFill();
 { for(int x=0; x<1200; x=x+100){
  for(int y=0; y<500; y=y+100){
    stroke(gold);
    strokeWeight(10);
    circle(x,y+200,100);
  }
 }
}

{ for(int x=0; x<1200; x=x+100){
  for(int y=0; y<500; y=y+100){
    stroke(tangerine);
    strokeWeight(10);
    circle(x+50,y+250,100);
  }
 }
}

void drawFrieze(float friezeX, float friezeY) {
  noStroke();
  fill(black);
  rect(0,0,1000,200);
  rect(0,600,1000,200);
  noStroke();
  fill(linen);
  rect(0,50,1000,125);
  noStroke();
  fill(linen);
  rect(0,650,1000,725);
  stroke(blue);
  strokeWeight(10);
  noFill();
  line(0,0,1000,0);
  stroke(redOrange);
  line(0,10,1000,10);
  stroke(darkGreen);
  line(0,20,1000,20);
  line(0,50,1000,50);
  line(0,170,1000,170);
  line(0,200,1000,200);
   {for(int x=0; x<width; x=x+120){
     noStroke();
     fill(gold);
     rect(x,25,10,25);
     rect(x+40,25,10,25);
     rect(x+80,25,10,25);
     fill(blue);
     rect(x+10,25,30,25);
     fill(redOrange);
     rect(x+50,25,30,25);
     fill(springGreen);    
     rect(x+90,25,30,25);
     noFill();
     stroke(darkGreen);
     strokeWeight(5);
     line(x,25,x,50);
     line(x+10,25,x+10,50);
     line(x+40,25,x+40,50);
     line(x+50,25,x+50,50);
     line(x+80,25,x+80,50);
     line(x+90,25,x+90,50);
     noStroke();
     fill(gold);
     rect(x,175,10,25);
     rect(x+40,175,10,25);
     rect(x+80,175,10,25);
     fill(blue);
     rect(x+10,175,30,25);
     fill(redOrange);
     rect(x+50,175,30,25);
     fill(springGreen);    
     rect(x+90,175,30,25);
     noFill();
     stroke(darkGreen);
     strokeWeight(5);
     line(x,175,x,200);
     line(x+10,175,x+10,200);
     line(x+40,175,x+40,200);
     line(x+50,175,x+50,200);
     line(x+80,175,x+80,200);
     line(x+90,175,x+90,200);
    }
  }
}

void drawLotus(float lotusX, float lotusY) {
{for(int x=0; x<900; x=x+85){
  stroke(darkGreen);
  strokeWeight(3);
  fill(lightBlue);
  beginShape();
    vertex(x+45,70);
    bezierVertex(x+50,77,x+55,80,x+63,90);
    bezierVertex(x+70,100,x+68,110,x+66,110);
    vertex(x+50,120);
    vertex(x+30,120);
    vertex(x+22,110);
    bezierVertex(x+20,100,x+20,97,x+28,90);
    bezierVertex(x+35,82,x+38,77,x+45,70);
  endShape();
  fill(springGreen);
  rect(x+40,120,10,20);
  beginShape();
    vertex(x+45,105);
    bezierVertex(x+48,108,x+52,111,x+51,117);
    bezierVertex(x+54,112,x+58,108,x+66,110);
    bezierVertex(x+65,113,x+62,119,x+56,121);
    bezierVertex(x+53,122,x+51,123,x+47,124);
    bezierVertex(x+43,125,x+42,124,x+40,125);
    bezierVertex(x+36,124,x+33,124,x+28,119);
    bezierVertex(x+23,114,x+23,112,x+22,108);
    bezierVertex(x+27,110,x+33,113,x+37,117);
    bezierVertex(x+38,112,x+38,107,x+45,105);
  endShape();
  noStroke();
  fill(darkGreen);
  circle(x+45,150,30);
  fill(springGreen);
  circle(x+45,150,20);
  fill(gold);
  circle(x+45,150,10);
  stroke(darkGreen);
  beginShape();
    vertex(x+85,115);
    vertex(x+75,73);
    vertex(x+78,68);
    bezierVertex(x+80,65,x+84,58,x+87,58);
    bezierVertex(x+90,58,x+94,67,x+95,70);
    vertex(x+97,73);
    vertex(x+90,115);
    vertex(x+85,115);
  endShape();
  fill(blue);
  beginShape();
    vertex(x+85,110);
    bezierVertex(x+86,96,x+81,81,x+78,66);
    bezierVertex(x+63,51,x+58,60,x+54,66);
    bezierVertex(x+74,71,x+75,96,x+75,113);
    bezierVertex(x+78,112,x+81,112,x+85,110);
  endShape();
  beginShape();
    vertex(x+90,110);
    bezierVertex(x+90,96,x+91,72,x+95,69);
    bezierVertex(x+100,63,x+105,51,x+120,66);
    bezierVertex(x+104,73,x+99,75,x+97,114);
    bezierVertex(x+94,113,x+92,112,x+90,110);
  endShape();
  fill(springGreen);
  rect(x+84,124,6,40);
  beginShape();
    vertex(x+75,115);
    vertex(x+87,110);
    vertex(x+98,115);
    bezierVertex(x+97,117,x+100,125,x+87,128);
    bezierVertex(x+82,127,x+75,124,x+75,115);
  endShape();
  }
 }
}

void drawEyes(float eyesX, float eyesY) {
{for(int x=0;x<width;x=x+200){
  stroke(black);
  strokeWeight(10);
  fill(linen);
  beginShape();
    vertex(x+86,260);
    bezierVertex(x+146,325,x+148,485,x+86,550);
    bezierVertex(x+26,485,x+20,325,x+86,260);
  endShape();
  noStroke();
  fill(darkGreen);
  if (x>200) {
    fill(springGreen);
  }
  if (x>600) {
    fill(blue);
  }
  circle(x+86,410,90);
  fill(springGreen);
  if (x>200) {
    fill(blue);
  }
  if (x>600) {
    fill(lightBlue);
  }
  circle(x+86,410,60);
  fill(blue);
  if (x>100) {
    fill(lightBlue);
  }
  if (x>200) {
    fill(darkGreen);
  }
  if (x>400) {
    fill(lightBlue);
  }
  if (x>600) {
    fill(blue);
  }
  circle(x+86,410,40);
  fill(black);
  circle(x+86,410,20);
  }
 }
}

void draw () {
  drawCircles(0,0);
  drawFrieze(0,0);
  drawFrieze(0,600);
  drawLotus(0,0);
  drawLotus(0,600);
  drawEyes(0,0);
}

Solution

  • You are missing a "}" to close out drawCircles. Also note you do not need to have your "for loops" surrounded by braces. It is making it harder to spot the issue with the code.

    void drawCircles(float circlesX,float circlesY) {
     noStroke();
     fill(redOrange);
     rect(0,200,1000,400);
     noFill();
     for(int x=0; x<1200; x=x+100){
      for(int y=0; y<500; y=y+100){
        stroke(gold);
        strokeWeight(10);
        circle(x,y+200,100);
      }
     }
    
     for(int x=0; x<1200; x=x+100){
      for(int y=0; y<500; y=y+100){
        stroke(tangerine);
        strokeWeight(10);
        circle(x+50,y+250,100);
      }
     }
    } // end drawCircles