# Generative text assignment

In last week’s class, I was really interested in the circle of letters code, so I wanted to do something similar for my generative text assignment. I borrowed a lot of code from the circle code document, and in this week’s assignment, a lot of my time was put into studying the code in order to apply the additions that I wanted to.

Regarding my idea, the circle of letters reminded me of Iron man 1, when Pepper gave Tony the gift that said: “Proof that Tony Stark has a heart.” Our assignment was to create generative texts, so I couldn’t just create a stagnant version of the gift. Instead, I decided to make it blink, like how tony’s reactor would blink sometimes.

Code wise, some lines in the code was really helpful in helping me understand arrays and objects. For instance:

`Circle letters[] = new Circle[s.length()];`

I was still unfamiliar with calling multiple objects and putting them into arrays, so this line helped clear things up for me well. The use of trigonometry was also inspiring for my future approaches to OOP.

Here is my full code:

```String s = "        PROOF THAT TONY STARK                    TRAEH A SAH            ";
PImage img;
float speed = 2;

Circle letters[] = new Circle[s.length()];
PFont f;
float r = 250;
float dir = 1;
float font_size = 30;

void setup(){
size(640, 640);
}

void draw(){
background(0);
f = createFont("Arial", font_size);
textFont(f);
float startingAngle = PI;
float circleCenterX = width/2;
float circleCenterY = height/2;

for (int i =0; i<s.length();i++){
float angle = startingAngle + i*TWO_PI/s.length();
float x = cos(angle)*radius + circleCenterX;
float y = sin(angle)*radius + circleCenterY;
letters[i] = new Circle(x, y, s.charAt(i));
}

for (int i =0; i<s.length();i++){
letters[i].display();
}

if (r >=  250){
dir = -dir;
}
else if (r <= 20){
dir = 1;
}
imageMode(CENTER);
image(img, width/2+font_size/3, height/2-font_size/3,  r*2-font_size, r*2-font_size);

if (dir == -1){
font_size = font_size - speed/8;
}
else if (dir == 1){
font_size = font_size + speed/8;
}

r = r + speed * dir;

}```

Circle class:

```class Circle {
float x, y;
char letter;

Circle(float _x, float _y, char _c) {
x = _x;
y = _y;
letter = _c;
}

void display() {
fill(255);
text(letter,x,y);
}
}```

Video:

## One thought on “Generative text assignment”

1. Aaron says:

A nice addition would be to make the size change based on sine, rather than linearly. This would make it look more like it’s breathing. Another option would be trying to make the size change beat like a heart, since the idea is about Tony Stark’s heart.