Successfully reported this slideshow.
Upcoming SlideShare
×

# Grid help, Processing

732 views

Published on

Small help for using nested loops in Processing.

Published in: Education
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

### Grid help, Processing

1. 1. int gridX = 12; int gridY = 16; int gridSize = 32; size( 12*32, 16*32); size (384, 512); size( gridX * gridSize, gridY * gridSize ); raster_sketch1.pde
2. 2. for (int i = 0; i < gridX; i++) { for (int j = 0; j < gridY; j++) { ..... } } i=0, i=1, i=2 ... -> j=0,j=1,j=2...-> raster_sketch1.pde
3. 3. for (int i = 0; i < gridX; i++) { for (int j = 0; j < gridY; j++) { ... ellipse(i*gridSize, j*gridSize, gridSize*0.7, gridSize*0.7); ... } } i=0, i=1, i=2 ... -> j=0,j=1,j=2...-> raster_sketch1.pde
4. 4. translate(gridSize/2, gridSize/2); verschieb alles um ein halbes “Kästchen” raster_sketch1.pde
5. 5. int gridX = 10; int gridY = 10; int gridSize = 22; int gridX = 50; int gridY = 20; int gridSize = 22; int gridX = 5; int gridY = 7; int gridSize = 110;
6. 6. raster_sketch2.pde for (int i = 0; i < gridX; i++) { for (int j = 0; j < gridY; j++) { ... pushMatrix(); translate(i*gridSize, j*gridSize); rotate(QUARTER_PI); fill(farbe2); rect(0, 0, gridSize*0.5, gridSize*0.5); popMatrix(); ... } }
7. 7. raster_sketch3.pde for (int i = 0; i < gridX; i++) { for (int j = 0; j < gridY; j++) { float objectSize; objectSize = map(j, 0, gridY-1, -gridSize, gridSize ); pushMatrix(); translate(i*gridSize, j*gridSize); rotate(QUARTER_PI); fill(farbe2); rect(0, 0, objectSize*0.5, objectSize*0.5); popMatrix(); } } gridY-1 gridSize 0 <-> 15 map(...) -32 <-> 32
8. 8. raster_sketch4.pde for (int i = 0; i < gridX; i++) { for (int j = 0; j < gridY; j++) { float randomNumber = random(0, 100); if (randomNumber > 80) { fill(farbe1); } else { fill(farbe2); } ... rect(...); } }
9. 9. raster_sketch5.pde for (int i = 0; i < gridX; i++) { for (int j = 0; j < gridY; j++) { if ( (i > 1) && (i < gridX-2) && (j > 1) && (j < gridY-2) ) { ... } else { ... }