
An example that I found very appealing while exploring Generative Gestaltung was the incorporation of text strings overlaid on images, so I adapted this example from the book to incorporate the poem “Afterglow” by Jorge Luis Borges with an aerial drone view of the sunset in the city of Cuernavaca, in the state of Morelos.
String inputText = "Siempre es conmovedor el ocaso por indigente o charro que sea, pero más conmovedor todavía es aquel brillo desesperado y final que herrumbra la llanura cuando el sol último se ha hundido.Nos duele sostener esa luz tirante y distinta, esa alucinación que impone al espacio el unánime miedo de la sombra y que cesa de golpe cuando notamos su falsía, como cesan los sueños cuando sabemos que soñamos.";
float fontSizeMax = 18;
float fontSizeMin = 5;
float spacing = 9; // line height
float kerning = 0.5; // between letters
boolean fontSizeStatic = false;
boolean blackAndWhite = false;
PFont font;
PImage img;
void setup() {
size(4000/3,2250/3);
smooth();
font = createFont("Sans",10);
img = loadImage("dji_fly_20230608_184950_165_1686277362243_photo_optimized.jpeg");
println(img.width+" x "+img.height);
}
void draw() {
background(255);
textAlign(LEFT);
float x = 0, y = 10;
int counter = 0;
while (y < height) {
int imgX = (int) map(x, 0,width, 0,img.width);
int imgY = (int) map(y, 0,height, 0,img.height);
color c = img.pixels[imgY*img.width+imgX];
int greyscale = round(red(c)*0.222 + green(c)*0.707 + blue(c)*0.071);
pushMatrix();
translate(x, y);
if (fontSizeStatic) {
textFont(font, fontSizeMax);
if (blackAndWhite) fill(greyscale);
else fill(c);
}
else {
// greyscale to fontsize
float fontSize = map(greyscale, 0,255, fontSizeMax,fontSizeMin);
fontSize = max(fontSize, 1);
textFont(font, fontSize);
if (blackAndWhite) fill(0);
else fill(c);
}
char letter = inputText.charAt(counter);
text(letter, 0, 0);
float letterWidth = textWidth(letter) + kerning;
x = x + letterWidth; // update x-coordinate
popMatrix();
// linebreaks
if (x+letterWidth >= width) {
x = 0;
y = y + spacing; // add line height
}
counter++;
if (counter > inputText.length()-1) counter = 0;
}
}
Bohnacker, H., Groß, B., Laub, J., & Lazzeroni, C. (2009). Generative Gestaltung: Entwerfen, Programmieren, Visualisieren. Verlag Hermann Schmidt GmbH & Co. KG.
