Différences entre les versions de « Utilisateur:Joseph »
		
		
		
		
		
		Aller à la navigation
		Aller à la recherche
		
				
		
		
	
 (Page créée avec « Ce programme est destiné à créer aléatoirement des lignes qui se croisent afin de former de plus en plus d'amas. Ces lignes au fil de temps sont destinées à former u... »)  | 
				|||
| Ligne 4 : | Ligne 4 : | ||
traceur [] courbes;  | traceur [] courbes;  | ||
| − | |||
void setup(){  | void setup(){  | ||
   size(1280,720);  |    size(1280,720);  | ||
| − | + | courbes = new traceur[0];  | |
| − | + |  background(random(255),random(240),random(240));  | |
| − | |||
| − | |||
   stroke(random(240),random(240),random(240),3000);  |    stroke(random(240),random(240),random(240),3000);  | ||
   for(int a=3000;a<4000;a++){  |    for(int a=3000;a<4000;a++){  | ||
     courbes = (traceur[]) append (courbes, new traceur());  |      courbes = (traceur[]) append (courbes, new traceur());  | ||
   }  |    }  | ||
| − | + |   }  | |
| − | }  | ||
| − | |||
void draw(){  | void draw(){  | ||
   for(int a=10;a<courbes.length;a++){  |    for(int a=10;a<courbes.length;a++){  | ||
| Ligne 23 : | Ligne 18 : | ||
   }    |    }    | ||
}  | }  | ||
| − | |||
class traceur{  | class traceur{  | ||
     float x,y,an,v;  |      float x,y,an,v;  | ||
| Ligne 38 : | Ligne 32 : | ||
    float newy=y+sin(an)*v;  |     float newy=y+sin(an)*v;  | ||
    if(newx<3||newx>width||newy<0||newy>height){  |     if(newx<3||newx>width||newy<0||newy>height){  | ||
| − | + |   an+=random(-PI,PI);  | |
| − | |||
    rang[0]=random(-1.1,-1.05);  |     rang[0]=random(-1.1,-1.05);  | ||
    rang[1]=random(1.05, 1.1);  |     rang[1]=random(1.05, 1.1);  | ||
| Ligne 48 : | Ligne 41 : | ||
    }  |     }  | ||
    float angleChoisi=an;  |     float angleChoisi=an;  | ||
| − | |||
    float couleur=brightness(g.get(int(newx),int(newy)));  |     float couleur=brightness(g.get(int(newx),int(newy)));  | ||
| − | |||
    for(float a=an-PI*0.3;a<an+PI*0.3;a+=PI*0.15){  |     for(float a=an-PI*0.3;a<an+PI*0.3;a+=PI*0.15){  | ||
       int ixe=int(newx+cos(a)*v);  |        int ixe=int(newx+cos(a)*v);  | ||
| Ligne 57 : | Ligne 48 : | ||
       if(col<couleur){  |        if(col<couleur){  | ||
         couleur=col;  |          couleur=col;  | ||
| − | + |        }  | |
| − | |||
    }    |     }    | ||
    an=angleChoisi;  |     an=angleChoisi;  | ||
| Ligne 66 : | Ligne 56 : | ||
   }  |    }  | ||
}  | }  | ||
| − | |||
int value = 4;  | int value = 4;  | ||
void mouseClicked() {  | void mouseClicked() {  | ||
| Ligne 75 : | Ligne 64 : | ||
   }  |    }  | ||
}  | }  | ||
| − | |||
| − | |||
void keyReleased(){  | void keyReleased(){  | ||
   saveFrame("img#####.png");  |    saveFrame("img#####.png");  | ||
}  | }  | ||
Version du 3 mai 2016 à 06:57
Ce programme est destiné à créer aléatoirement des lignes qui se croisent afin de former de plus en plus d'amas. Ces lignes au fil de temps sont destinées à former un pattern, un motif qui l'on peut utiliser dans des formes, des couvertures.
CODE//à copier coller:
traceur [] courbes; void setup(){
size(1280,720);
courbes = new traceur[0];
background(random(255),random(240),random(240));
 stroke(random(240),random(240),random(240),3000);
 for(int a=3000;a<4000;a++){
   courbes = (traceur[]) append (courbes, new traceur());
 }
}
void draw(){
 for(int a=10;a<courbes.length;a++){
  courbes[a].dessine(); 
 } 
} class traceur{
   float x,y,an,v;
   float[] rang={-2.05,2.05};
 traceur(){
   x= random(width);y=random(height);
   an=random(TWO_PI);v=random(2.2,2.5);
  rang[0]=random(-1.1,-1.05);
  rang[1]=random(1.05, 1.1);
 }
 void dessine(){
  an+=random(rang[0],rang[1]);
  float newx=x+cos(an)*v;
  float newy=y+sin(an)*v;
  if(newx<3||newx>width||newy<0||newy>height){
an+=random(-PI,PI);
  rang[0]=random(-1.1,-1.05);
  rang[1]=random(1.05, 1.1);
  }
  if(random(255)<1){ 
  rang[0]=random(-1.1,-1.05);
  rang[1]=random(1.05, 1.1);
  }
  float angleChoisi=an;
  float couleur=brightness(g.get(int(newx),int(newy)));
  for(float a=an-PI*0.3;a<an+PI*0.3;a+=PI*0.15){
     int ixe=int(newx+cos(a)*v);
     int igr=int(newy+sin(a)*v);
     float col=brightness(g.get(ixe,igr));
     if(col<couleur){
       couleur=col;
      }
  } 
  an=angleChoisi;
  if(random(255)<1){an=an+random(-200,1);}
  line(x,y,newx,newy);
  x=newx;y=newy;
 }
} int value = 4; void mouseClicked() {
 if (value == 40) {
   value = 255;
 } else {
   value = 67;
 }
} void keyReleased(){
 saveFrame("img#####.png");
}