Im a processing user, and in one project im working in, my teacher ask me to start using tabs.But when i try to do so, when i draw all the figures it works with out errors, but im using buttons to change the colours of them in certain range, with the help of "import controlP5.*;" an aleat appears when i run the project "Found out too many { characters with a } to match it", but as far as i know all the { do have a match }. So my question is why is this happening?
Main Tab
yoshi yoshi;
Tree tree;
void setup() {
size(900, 650);
smooth();
yoshi = new yoshi();
tree= new Tree();
}
void draw() {
background(255, 255, 255);
yoshi.run();
tree.run();
}
Yoshi tab
class yoshi {
import controlP5.*;
PShape bot, bot1, bot2;
PShape bot3, bot4, bot5;
PShape bot6, bot7, bot8;
PShape bot9, bot10, bot11;
PShape bot12, bot13, bot14;
PShape bot15, bot16;
ControlP5 cp5;
int c, c1, c2, c3, c4, c5;
void yoshi() {
}
void run() {
setup2();
}
void setup2() {
bot=loadShape("cabezaverde.svg");
bot1=loadShape("ojosblancos.svg");
bot2=loadShape("ojosnegros.svg");
bot3=loadShape("bocablanco.svg");
bot4=loadShape("cuerpoblanco.svg");
bot5=loadShape("cuerpoverde.svg");
bot6=loadShape("espinasrojas.svg");
bot7=loadShape("lineacaparazon.svg");
bot8=loadShape("caparazonrojo.svg");
bot9=loadShape("pieder.svg");
bot10=loadShape("suelader.svg");
bot11=loadShape("piernaizq.svg");
bot12=loadShape("pieizq.svg");
bot13=loadShape("suelaizq.svg");
bot14=loadShape("brazoizq.svg");
bot15=loadShape("brazoder.svg");
cp5 = new ControlP5(this);
cp5.addButton("figureA")
.setValue(0)
.setPosition(10, 10)
.setSize(40, 19)
;
cp5.addButton("figureB")
.setValue(100)
.setPosition(55, 10)
.setSize(40, 19)
;
cp5.addButton("figureC")
.setPosition(100, 10)
.setSize(40, 19)
.setValue(0)
;
cp5.addButton("figureD")
.setValue(0)
.setPosition(10, 35)
.setSize(40, 19)
;
cp5.addButton("figureE")
.setValue(100)
.setPosition(55, 35)
.setSize(40, 19)
;
display();
}
void display() {
bot.disableStyle();
bot1.disableStyle();
bot2.disableStyle();
bot3.disableStyle();
bot4.disableStyle();
bot5.disableStyle();
bot6.disableStyle();
bot7.disableStyle();
bot8.disableStyle();
bot9.disableStyle();
bot10.disableStyle();
bot11.disableStyle();
bot12.disableStyle();
bot13.disableStyle();
bot14.disableStyle();
bot15.disableStyle();
stroke(0, 0, 0);
strokeWeight(3);
fill(c2);
shape(bot, 404, 261, 100, 100);//cabeza-green
fill(c4);
shape(bot1, 424, 265, 100, 100);//ojos-white
fill(c1);
shape(bot2, 430, 268, 100, 100);//ojos-black
fill(c4);
shape(bot4, 436, 305, 100, 100);//cuerpo-white
fill(c2);
shape(bot5, 449, 303, 100, 100);//cuerpo-green
fill(c3);
shape(bot6, 452, 297, 100, 100);//espinas-red
fill(c4);
//shape(bot3, 20, -142, 100, 100);//boca-white
shape(bot3, 468, 284, 100, 100);
fill(c4);
shape(bot7, 467, 314, 100, 100);//caparazon-white
fill(c3);
shape(bot8, 470, 312, 100, 100);//caparazon-red
shape(bot9, 427, 336, 100, 100);//pieder-red
fill(c5)
shape(bot10, 427, 349, 100, 100);//suelader-golden
fill(c2);
shape(bot11, 457, 328, 100, 100);//piernaizq-green
fill(c3);
shape(bot12, 442, 340, 100, 100);//pieizq-red
fill(c5)
shape(bot13, 444, 354, 100, 100);//suelaizq-golden
fill(c2);
shape(bot14, 444, 311, 100, 100);//brazoizq-green
shape(bot15, 428, 320, 100, 100);//brazoder-green
}
public void figureA(int value) {
c1 = color(random(0, 27), random(0, 26), random(0, 26));//negro
}
public void figureB(int value) {
c2 = color(random(21, 63), random(198, 208), random(4, 54));//verde
}
public void figureC(int value) {
c3 =color(random(165, 255), random(0, 33), random(0, 33));//rojo
}
public void figureD(int value) {
c4 = color(random(230, 255), random(215, 255), random(215, 255));//blanco
}
public void figureE(int value) {
c5=color(random(203, 255), random(184, 222), random(0, 61));//dorado
}
}
Tree tab
class Tree {
int xpos=0, ypos=0;
int len;
Tree() {
}
void run() {
display();
}
void display() {
// Start the tree from the bottom of the screen
translate(width/2, height);
stroke(0);
branch(60);
//translate(width/3, height);
//stroke(0);
//branch(60);
noLoop();
}
void branch(float len) {
strokeWeight(2);
line(0, 0, 0, -len);
// Move to the end of that line
translate(0, -len);
len *= 0.66;
// All recursive functions must have an exit condition!!!!
// Here, ours is when the length of the branch is 2 pixels or less
if (len > 2) {
pushMatrix(); // Save the current state of transformation (i.e. where are we now)
rotate(PI/5); // Rotate by theta
branch(len); // Ok, now call myself to draw two new branches!!
popMatrix(); // Whenever we get back here, we "pop" in order to restore the previous matrix state
// Repeat the same thing, only branch off to the "left" this time!
pushMatrix();
rotate(-PI/5);
branch(len);
popMatrix();
}
}
}