Help for a method code please, beggin' you ^^'
in
Programming Questions
•
1 years ago
Hello everybody !!
I'm a very beginner, so i begin to understand the loops..
I tried to use a "method" to draw every ellipses i made with my four loops but it didn't work ...
I give a name : for example " void ..... (){" to each one and write names of method like "...(); in the "void draw" and nothing happened
I tried also with ' void mousePressed' to change the color ; to turn the red dark points into red and the red into dark point but i think i miss something and i would like to have the possibilty of making grow the circles if the mouse is Pressed...
This is my code , can you help me please ?
//declaration des variables
float x1 = 0;
float y1 = 0 ;
float xxl = 250;
float yyl = 250;
float intx = 10;
float inty= 10;
float size = 50;
float i = 0;
float j = 0;
void setup()
{
size(400,300);
smooth();
ellipseMode(CENTER);
}
void draw()
{
background(255);
//cercles
for (int x1 = 0; x1 < 500; x1 = x1+100) {
for (int y1 = 0; y1 < 500; y1 = y1+100) {
fill(255);
strokeWeight(2);
stroke(252,8,8);
ellipse(x1,y1,size,size);
}
}
// petits pois rouges
for (int xx1 = 50; xx1 < 500; xx1 = xx1+100) {
for (int yy1 = 50; yy1 < 500; yy1 = yy1+100) {
fill(252,8,8);
noStroke();
ellipse(xx1,yy1,size-30,size-30);
}
}
// intérieurs roses
for (int intx = 0; intx < 500;intx = intx+100) {
for (int inty = 0; inty < 500; inty = inty+100) {
fill (255,200,200);
noStroke();
ellipse(intx,inty,size-10,size-8);
}
}
//pois foncés
for (float i = 50; i < 400; i = i+50) {
for (float j = 50; j < 300; j = j+50) {
fill(139,6,39);
noStroke();
ellipse(i,j,size-40,size-40);
}
}
}
I'm a very beginner, so i begin to understand the loops..
I tried to use a "method" to draw every ellipses i made with my four loops but it didn't work ...
I give a name : for example " void ..... (){" to each one and write names of method like "...(); in the "void draw" and nothing happened
I tried also with ' void mousePressed' to change the color ; to turn the red dark points into red and the red into dark point but i think i miss something and i would like to have the possibilty of making grow the circles if the mouse is Pressed...
This is my code , can you help me please ?
//declaration des variables
float x1 = 0;
float y1 = 0 ;
float xxl = 250;
float yyl = 250;
float intx = 10;
float inty= 10;
float size = 50;
float i = 0;
float j = 0;
void setup()
{
size(400,300);
smooth();
ellipseMode(CENTER);
}
void draw()
{
background(255);
//cercles
for (int x1 = 0; x1 < 500; x1 = x1+100) {
for (int y1 = 0; y1 < 500; y1 = y1+100) {
fill(255);
strokeWeight(2);
stroke(252,8,8);
ellipse(x1,y1,size,size);
}
}
// petits pois rouges
for (int xx1 = 50; xx1 < 500; xx1 = xx1+100) {
for (int yy1 = 50; yy1 < 500; yy1 = yy1+100) {
fill(252,8,8);
noStroke();
ellipse(xx1,yy1,size-30,size-30);
}
}
// intérieurs roses
for (int intx = 0; intx < 500;intx = intx+100) {
for (int inty = 0; inty < 500; inty = inty+100) {
fill (255,200,200);
noStroke();
ellipse(intx,inty,size-10,size-8);
}
}
//pois foncés
for (float i = 50; i < 400; i = i+50) {
for (float j = 50; j < 300; j = j+50) {
fill(139,6,39);
noStroke();
ellipse(i,j,size-40,size-40);
}
}
}
1