We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello there, Iam supposed to color some quads to make a chequered image. By the way something is wrong with my code. Method cambioColor isn't working can you help me?
void setup(){ size(800,600); Chess(); }
void Chess(){ boolean cColor=true; for(int i=1;i<9;i++){ for(int j=1;j<9;j++){ cambioColor(cColor); DibujarRect(i50,j50); cColor=!cColor; } cambioColor(cColor); cColor=!cColor; } }
void DibujarRect(int x,int y){ rect(x,y,50,50); }
void cambioColor(boolean x){ String s1=""; s1 = Boolean.toString(x); if(s1.equals(true)){ color crema= color(249,252,148); fill(crema); }else{ color cafe=color(#583C09); fill(cafe); } }
Answers
There is no need for the Boolean / String conversion. Your code works just fine if you use
x
directly:Thank you!!