mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
blue book examples
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Synthesis 1: Form and Code
|
||||
* Wilson Grids by Casey Reas (www.processing.org)
|
||||
* p. 152
|
||||
*
|
||||
* Step 1, basic embedded for structure.
|
||||
*/
|
||||
|
||||
|
||||
size(600, 600);
|
||||
background(255);
|
||||
int sqNum = 12;
|
||||
int sqSize = width/sqNum;
|
||||
int halfSize = sqSize/2;
|
||||
|
||||
for (int y = halfSize; y < width; y = y+sqSize) {
|
||||
for (int x = halfSize; x < height; x = x+sqSize) {
|
||||
rect(x-halfSize+2, y-halfSize+2, sqSize-4, sqSize-4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Synthesis 1: Form and Code
|
||||
* Wilson Grids by Casey Reas (www.processing.org)
|
||||
* p. 152
|
||||
*
|
||||
* Step 2, textures inside the grid by adding a third for structure.
|
||||
*/
|
||||
|
||||
|
||||
size(600, 600);
|
||||
background(255);
|
||||
int numSquares = 12;
|
||||
int gap = 4;
|
||||
int sqSize = (width-gap*2)/numSquares;
|
||||
int halfSize = sqSize/2;
|
||||
int offset = halfSize+gap;
|
||||
int ydiv = sqSize/12;
|
||||
|
||||
for(int y = 0; y < numSquares; y++) {
|
||||
for(int x = 0; x < numSquares; x++) {
|
||||
float xp = offset + (x*sqSize);
|
||||
float yp = offset + (y*sqSize);
|
||||
for(int i=0; i<=sqSize-gap*2; i=i+ydiv) {
|
||||
float yy = i*halfSize+gap+i;
|
||||
line(xp-halfSize+gap, yp-halfSize+gap+i, xp+halfSize-gap, yp-halfSize+gap+i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Synthesis 1: Form and Code
|
||||
* Wilson Grids by Casey Reas (www.processing.org)
|
||||
* p. 152
|
||||
*
|
||||
* Step 3, changing the size of each grid element.
|
||||
*/
|
||||
|
||||
|
||||
size(600, 600);
|
||||
background(0);
|
||||
stroke(255, 204);
|
||||
int numSquares = 6;
|
||||
int gap = 8;
|
||||
int sqSize = (width-gap*2)/numSquares;
|
||||
|
||||
for (float y=0; y<numSquares; y=y+1) {
|
||||
for (float x=0; x<numSquares; x=x+1) {
|
||||
int sqArea = int(random(10, 100));
|
||||
int halfArea = sqArea/2;
|
||||
int ydiv = sqArea/12;
|
||||
float offset = sqSize/2+gap;
|
||||
float xp = offset + (x*sqSize);
|
||||
float yp = offset + (y*sqSize);
|
||||
for (int i = 0; i <= sqArea-gap*2; i = i+ydiv) {
|
||||
float yy = i*halfArea+gap+i;
|
||||
line(xp-halfArea+gap, yp-halfArea+gap+i, xp+halfArea-gap, yp-halfArea+gap+i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Synthesis 1: Form and Code
|
||||
* Wilson Grids by Casey Reas (www.processing.org)
|
||||
* p. 152
|
||||
*
|
||||
* Step 4.
|
||||
*/
|
||||
|
||||
size(600, 600);
|
||||
background(0);
|
||||
stroke(255, 204);
|
||||
float numSquares = 6.0;
|
||||
int gap = 8;
|
||||
float xUnit = (width-gap*2)/numSquares;
|
||||
float yUnit = (height-gap*2)/numSquares;
|
||||
float squareWidth = xUnit;
|
||||
int squareHeight = int(yUnit);
|
||||
|
||||
for(float y=0; y<numSquares; y=y+1) {
|
||||
for(float x=0; x<numSquares; x=x+1) {
|
||||
squareWidth = int(random(10, 300));
|
||||
squareHeight = int(squareWidth);
|
||||
//squareHeight = int(random(10, 100));
|
||||
int ydiv = squareHeight/12;
|
||||
float xoff = xUnit/2+gap;
|
||||
float yoff = yUnit/2+gap;
|
||||
float xp = xoff + (x*xUnit);
|
||||
float yp = yoff + (y*yUnit);
|
||||
for(int i=0; i<=squareHeight-gap*2; i=i+ydiv) {
|
||||
float yy = i*squareHeight/2+gap+i;
|
||||
line(xp-squareWidth/2+gap, yp-squareHeight/2+gap+i, xp+squareWidth/2-gap, yp-squareHeight/2+gap+i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Synthesis 1: Form and Code
|
||||
* Wilson Grids by Casey Reas (www.processing.org)
|
||||
* p. 152
|
||||
*
|
||||
* Step 5.
|
||||
*/
|
||||
|
||||
|
||||
size(600, 600);
|
||||
background(0);
|
||||
stroke(255, 204);
|
||||
float numSquares = 12.0;
|
||||
int gap = 4;
|
||||
float xUnit = (width-gap*2)/numSquares;
|
||||
float yUnit = (height-gap*2)/numSquares;
|
||||
float squareWidth = xUnit;
|
||||
float squareHeight = yUnit;
|
||||
|
||||
for (float y = 0; y < numSquares; y = Y + 1) {
|
||||
for (float x = 0; x < numSquares; x = x+1) {
|
||||
float ydiv = squareHeight/12;
|
||||
float xoff = xUnit/2+gap;
|
||||
float yoff = yUnit/2+gap;
|
||||
float xp = xoff + (x*xUnit);
|
||||
float yp = yoff + (y*yUnit);
|
||||
for(float i=0; i<=squareHeight-gap*2; i=i+ydiv) {
|
||||
float yy = i*squareHeight/2+gap+i;
|
||||
line(xp-squareWidth/2+gap, yp-squareHeight/2+gap+i, xp+squareWidth/2-gap, yp-squareHeight/2+gap+i);
|
||||
}
|
||||
|
||||
ydiv = random(1.0, squareHeight/4);
|
||||
|
||||
for(float i=0; i<=squareHeight-gap*2; i=i+ydiv) {
|
||||
float yy = i*squareHeight/2+gap+i;
|
||||
line(xp-squareWidth/2+gap, yp-squareHeight/2+gap+i, xp+squareWidth/2-gap, yp-squareHeight/2+gap+i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// save("Synthesis-3--3-" + int(random(0, 100)) + ".tif");
|
||||
Reference in New Issue
Block a user