Problems with a pattern generator
in
Programming Questions
•
2 years ago
Hi,
I m a little bit frustrated because I want to write a code for a pattern generator, with circles they should crossed by rectangles in the middle. But the rectangles are not in the right position and also I dont know how I can multiply them.
I know, its tiny problem, but I' m rookie.
Here is my code:
void setup(){
smooth();
size(500,500);
}
void draw(){
background(0);
randomSeed(mouseX);
int wert1 = 20;
int wert2 = 20;
for(int i = 1; i<wert1; i++){
for(int j = 1; j<wert1; j++){
form1(width/wert1*j,height/wert1*i,random(5, 35),i*25,j*25,0);;
form2(width/wert1*j,height/wert1*i,i/wert1,j/wert1,255,255,255);
}
}
}
void form1(float x, float y, float r, float rot, float gruen, float blau){
noStroke();
fill(255,0,0);
ellipse(x,y,r,r);
fill(0,255,0);
ellipse(x,y,11,11);
}
void form2(float x, float y, float width, float height, float rot, float gruen, float blau){
noStroke();
fill(255);
rect(4,0,26,3);
rect(0,26,3,26);
}
I m a little bit frustrated because I want to write a code for a pattern generator, with circles they should crossed by rectangles in the middle. But the rectangles are not in the right position and also I dont know how I can multiply them.
I know, its tiny problem, but I' m rookie.
Here is my code:
void setup(){
smooth();
size(500,500);
}
void draw(){
background(0);
randomSeed(mouseX);
int wert1 = 20;
int wert2 = 20;
for(int i = 1; i<wert1; i++){
for(int j = 1; j<wert1; j++){
form1(width/wert1*j,height/wert1*i,random(5, 35),i*25,j*25,0);;
form2(width/wert1*j,height/wert1*i,i/wert1,j/wert1,255,255,255);
}
}
}
void form1(float x, float y, float r, float rot, float gruen, float blau){
noStroke();
fill(255,0,0);
ellipse(x,y,r,r);
fill(0,255,0);
ellipse(x,y,11,11);
}
void form2(float x, float y, float width, float height, float rot, float gruen, float blau){
noStroke();
fill(255);
rect(4,0,26,3);
rect(0,26,3,26);
}
1