Skip to content

Commit a66a355

Browse files
author
Benedikt Gross
committed
initial commit
1 parent 1a29710 commit a66a355

File tree

871 files changed

+82578
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

871 files changed

+82578
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

01_P/P_1_0_01/P_1_0_01.pde

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// P_1_0_01.pde
2+
//
3+
// Generative Gestaltung, ISBN: 978-3-87439-759-9
4+
// First Edition, Hermann Schmidt, Mainz, 2009
5+
// Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni
6+
// Copyright 2009 Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni
7+
//
8+
// http://www.generative-gestaltung.de
9+
//
10+
// Licensed under the Apache License, Version 2.0 (the "License");
11+
// you may not use this file except in compliance with the License.
12+
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
19+
/**
20+
* changing colors and size by moving the mouse
21+
*
22+
* MOUSE
23+
* position x : size
24+
* position y : color
25+
*
26+
* KEYS
27+
* s : save png
28+
* p : save pdf
29+
*/
30+
31+
import processing.pdf.*;
32+
boolean savePDF = false;
33+
34+
35+
void setup() {
36+
size(720, 720);
37+
noCursor();
38+
}
39+
40+
41+
void draw() {
42+
// this line will start pdf export, if the variable savePDF was set to true
43+
if (savePDF) beginRecord(PDF, timestamp()+".pdf");
44+
45+
colorMode(HSB, 360, 100, 100);
46+
rectMode(CENTER);
47+
noStroke();
48+
background(mouseY/2, 100, 100);
49+
50+
fill(360-mouseY/2, 100, 100);
51+
rect(360, 360, mouseX+1, mouseX+1);
52+
53+
// end of pdf recording
54+
if (savePDF) {
55+
savePDF = false;
56+
endRecord();
57+
}
58+
}
59+
60+
61+
void keyPressed() {
62+
if (key=='s' || key=='S') saveFrame(timestamp()+"_##.png");
63+
if (key=='p' || key=='P') savePDF = true;
64+
}
65+
66+
67+
String timestamp() {
68+
Calendar now = Calendar.getInstance();
69+
return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now);
70+
}
71+
72+
73+

01_P/P_1_0_01/P_1_0_01.png

5.74 KB
Loading

01_P/P_1_1_1_01/P_1_1_1_01.pde

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// P_1_1_1_01.pde
2+
//
3+
// Generative Gestaltung, ISBN: 978-3-87439-759-9
4+
// First Edition, Hermann Schmidt, Mainz, 2009
5+
// Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni
6+
// Copyright 2009 Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni
7+
//
8+
// http://www.generative-gestaltung.de
9+
//
10+
// Licensed under the Apache License, Version 2.0 (the "License");
11+
// you may not use this file except in compliance with the License.
12+
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
19+
/**
20+
* draw the color spectrum by moving the mouse
21+
*
22+
* MOUSE
23+
* position x/y : resolution
24+
*
25+
* KEYS
26+
* s : save png
27+
* p : save pdf
28+
*/
29+
30+
import processing.pdf.*;
31+
boolean savePDF = false;
32+
33+
int stepX;
34+
int stepY;
35+
36+
void setup(){
37+
size(800, 400);
38+
background(0);
39+
}
40+
41+
void draw(){
42+
if (savePDF) beginRecord(PDF, timestamp()+".pdf");
43+
44+
noStroke();
45+
colorMode(HSB, width, height, 100);
46+
47+
stepX = mouseX+2;
48+
stepY = mouseY+2;
49+
for (int gridY=0; gridY<height; gridY+=stepY){
50+
for (int gridX=0; gridX<width; gridX+=stepX){
51+
fill(gridX, height-gridY, 100);
52+
rect(gridX, gridY, stepX, stepY);
53+
}
54+
}
55+
56+
if (savePDF) {
57+
savePDF = false;
58+
endRecord();
59+
}
60+
}
61+
62+
void keyPressed() {
63+
if (key=='s' || key=='S') saveFrame(timestamp()+"_##.png");
64+
if (key=='p' || key=='P') savePDF = true;
65+
}
66+
67+
// timestamp
68+
String timestamp() {
69+
Calendar now = Calendar.getInstance();
70+
return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now);
71+
}
72+
73+

01_P/P_1_1_1_01/P_1_1_1_01.png

5.76 KB
Loading

01_P/P_1_1_2_01/P_1_1_2_01.pde

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// P_1_1_2_01.pde
2+
//
3+
// Generative Gestaltung, ISBN: 978-3-87439-759-9
4+
// First Edition, Hermann Schmidt, Mainz, 2009
5+
// Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni
6+
// Copyright 2009 Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni
7+
//
8+
// http://www.generative-gestaltung.de
9+
//
10+
// Licensed under the Apache License, Version 2.0 (the "License");
11+
// you may not use this file except in compliance with the License.
12+
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
19+
/**
20+
* changing the color circle by moving the mouse.
21+
*
22+
* MOUSE
23+
* position x : saturation
24+
* position y : brighness
25+
*
26+
* KEYS
27+
* 1-5 : number of segments
28+
* s : save png
29+
* p : save pdf
30+
*/
31+
32+
import processing.pdf.*;
33+
boolean savePDF = false;
34+
35+
int segmentCount = 360;
36+
int radius = 300;
37+
38+
39+
void setup(){
40+
size(800, 800);
41+
}
42+
43+
void draw(){
44+
if (savePDF) beginRecord(PDF, timestamp()+".pdf");
45+
46+
noStroke();
47+
colorMode(HSB, 360, width, height);
48+
background(360);
49+
50+
float angleStep = 360/segmentCount;
51+
52+
beginShape(TRIANGLE_FAN);
53+
vertex(width/2, height/2);
54+
for (float angle=0; angle<=360; angle+=angleStep){
55+
float vx = width/2 + cos(radians(angle))*radius;
56+
float vy = height/2 + sin(radians(angle))*radius;
57+
vertex(vx, vy);
58+
fill(angle, mouseX, mouseY);
59+
}
60+
endShape();
61+
62+
if (savePDF) {
63+
savePDF = false;
64+
endRecord();
65+
}
66+
}
67+
68+
void keyReleased(){
69+
if (key=='s' || key=='S') saveFrame(timestamp()+"_##.png");
70+
if (key=='p' || key=='P') savePDF = true;
71+
72+
switch(key){
73+
case '1':
74+
segmentCount = 360;
75+
break;
76+
case '2':
77+
segmentCount = 45;
78+
break;
79+
case '3':
80+
segmentCount = 24;
81+
break;
82+
case '4':
83+
segmentCount = 12;
84+
break;
85+
case '5':
86+
segmentCount = 6;
87+
break;
88+
}
89+
}
90+
91+
// timestamp
92+
String timestamp() {
93+
Calendar now = Calendar.getInstance();
94+
return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now);
95+
}
96+
97+
98+
99+
100+
101+
102+
103+

01_P/P_1_1_2_01/P_1_1_2_01.png

75.9 KB
Loading

01_P/P_1_2_1_01/P_1_2_1_01.pde

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
// P_1_2_1_01.pde
2+
//
3+
// Generative Gestaltung, ISBN: 978-3-87439-759-9
4+
// First Edition, Hermann Schmidt, Mainz, 2009
5+
// Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni
6+
// Copyright 2009 Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni
7+
//
8+
// http://www.generative-gestaltung.de
9+
//
10+
// Licensed under the Apache License, Version 2.0 (the "License");
11+
// you may not use this file except in compliance with the License.
12+
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
13+
// Unless required by applicable law or agreed to in writing, software
14+
// distributed under the License is distributed on an "AS IS" BASIS,
15+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
// See the License for the specific language governing permissions and
17+
// limitations under the License.
18+
19+
/**
20+
* shows how to interpolate colors in different styles/ color modes
21+
*
22+
* MOUSE
23+
* left click : new random color set
24+
* position x : interpolation resolution
25+
* position y : row count
26+
*
27+
* KEYS
28+
* 1-2 : switch interpolation style
29+
* s : save png
30+
* p : save pdf
31+
* c : save color palette
32+
*/
33+
34+
import generativedesign.*;
35+
import processing.pdf.*;
36+
boolean savePDF = false;
37+
38+
int tileCountX = 2;
39+
int tileCountY = 10;
40+
41+
color[] colorsLeft = new color[tileCountY];
42+
color[] colorsRight = new color[tileCountY];
43+
color[] colors;
44+
45+
boolean interpolateShortest = true;
46+
47+
48+
void setup() {
49+
size(800, 800);
50+
colorMode(HSB,360,100,100,100);
51+
noStroke();
52+
shakeColors();
53+
}
54+
55+
56+
void draw() {
57+
if (savePDF) {
58+
beginRecord(PDF, timestamp()+".pdf");
59+
noStroke();
60+
colorMode(HSB,360,100,100,100);
61+
}
62+
63+
tileCountX = (int) map(mouseX,0,width,2,100);
64+
tileCountY = (int) map(mouseY,0,height,2,10);
65+
float tileWidth = width / (float)tileCountX;
66+
float tileHeight = height / (float)tileCountY;
67+
color interCol;
68+
69+
// just for ase export
70+
colors = new color[tileCountX*tileCountY];
71+
int i = 0;
72+
73+
for (int gridY=0; gridY< tileCountY; gridY++) {
74+
color col1 = colorsLeft[gridY];
75+
color col2 = colorsRight[gridY];
76+
77+
for (int gridX=0; gridX< tileCountX ; gridX++) {
78+
float amount = map(gridX,0,tileCountX-1,0,1);
79+
80+
if (interpolateShortest) {
81+
// switch to rgb
82+
colorMode(RGB,255,255,255,255);
83+
interCol = lerpColor(col1,col2, amount);
84+
// switch back
85+
colorMode(HSB,360,100,100,100);
86+
}
87+
else {
88+
interCol = lerpColor(col1,col2, amount);
89+
}
90+
fill(interCol);
91+
92+
float posX = tileWidth*gridX;
93+
float posY = tileHeight*gridY;
94+
rect(posX, posY, tileWidth, tileHeight);
95+
96+
// just for ase export
97+
colors[i] = interCol;
98+
i++;
99+
}
100+
}
101+
102+
if (savePDF) {
103+
savePDF = false;
104+
endRecord();
105+
}
106+
}
107+
108+
109+
void shakeColors() {
110+
for (int i=0; i<tileCountY; i++) {
111+
colorsLeft[i] = color(random(0,60), random(0,100), 100);
112+
colorsRight[i] = color(random(160,190), 100, random(0,100));
113+
}
114+
}
115+
116+
117+
void mouseReleased() {
118+
shakeColors();
119+
}
120+
121+
122+
void keyReleased() {
123+
if (key == 'c' || key == 'C') GenerativeDesign.saveASE(this, colors, timestamp()+".ase");
124+
if (key == 's' || key == 'S') saveFrame(timestamp()+"_##.png");
125+
if (key == 'p' || key == 'P') savePDF = true;
126+
127+
if (key == '1') interpolateShortest = true;
128+
if (key == '2') interpolateShortest = false;
129+
}
130+
131+
// timestamp
132+
String timestamp() {
133+
Calendar now = Calendar.getInstance();
134+
return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now);
135+
}
136+
137+
138+
139+
140+
141+
142+
143+
144+

01_P/P_1_2_1_01/P_1_2_1_01.png

3.17 KB
Loading

0 commit comments

Comments
 (0)