I wanted to create a new cover for my twitter, so I used code to make a procedural texture. I want to share the code:
float [] sizeX= new float [10000]; float [] sizeY= new float [10000]; void setup(){ size (700,400); colorMode(HSB); for(int i=0; i<2000;i++){ for(int j=0; j<2000;j++){ sizeX[i]=random (5,50); sizeY[i]=random (5,50); } } } void draw (){ background (0); if(mousePressed){ for(int i=0; i<2000;i++){ for(int j=0; j<2000;j++){ sizeX[i]=random (5,50); sizeY[i]=random (5,50); } } } for(int i=0; i<2000;i+=20){ for(int j=0; j<2000;j+=20){ //noStroke(); rectMode(CENTER); fill(i%360,300,300,i%50); rect (i,j,sizeX[i+j],sizeX[i+j]); fill(255); //ellipse (i,j,2,2); } } if(keyPressed){ if (key== 's'||key=='S'){ save("image.jpg"); } } else{ text("Press 's' to save image, click to generate new texture", 30,30); text("PS. Don't worry, this text will desapear when you hit the key", 30,50); } }
With few changes in the code, the result changes radically,
No comments:
Post a Comment