Can't use translate()
in
Programming Questions
•
2 years ago
I need a teacher I guess. I spent hours to find a solution to this simple problem. How to get 3 times 6 balls, spread like a fan (eventail in french).
There is the very simple code .
// get 3 times 6 balls in order
float x, y, theta, r;
int nC = 0;
void setup() {
size(600, 400);
background(255);
theta = 0.0;
r = 50 ;
}
void draw() {
noLoop();
stroke(0);
//translate(width/2, height/4);
for (int n=0;n<3;n++) {
nC = n;
choixCouleur();
//pushMatrix();
translate(width/2, height/4);
for (int i=0;i<6;i++) {
x = r*cos(theta);
y = r*sin(theta);
theta +=0.3;
ellipse(x, y, 16, 16);
}
//popMatrix();
//x += 20;
//y += 20;
//theta = 0.0;
}
}
void choixCouleur() {
if (nC<1) {
fill(255, 0, 0);// rouge
}
else {
if (nC<2) {
fill(0, 255, 0);// vert
}
else {
fill(0, 0, 255);// bleu
}
}
}
1