Draw text within a circle
in
Programming Questions
•
5 months ago
Hi all
I'm trying to achieve three things:
1. To draw with random rotation single characters from a text file inside the area of a circle, until they are all used once.
2. To draw the contents of the text file, in order, within columns which fit inside the same circle area, so they are readable.
3. To draw the contents of the text file, in order, as a spiral within the same circle area, so it's readable.
All of these are to be output to separate Pdfs.
I've managed most of the first part in the attached code, adapting an
example by kobby, but I'm unable to work out the rotation with this method.
Hopefully when this is done I can adapt it to achieve the other parts.
I'm guessing I have to get everything inside draw(), but I don't know how to do this and stop it when it reaches the last character.
best
P
- PFont f = createFont( "Courier", 10, true);
- float a = 200;
- float b = 200;
- float r;
- float x;
- float y;
- float t;
- void setup() {
- size(400, 400);
- textFont(f);
- background(50,0,255);
- String lines[] = loadStrings("list.txt");
- println("there are " + lines.length + " lines");
- for (int e = 0; e < lines.length; e++) {
- String[] words = split(lines[e], ' ');
- for(int i = 0; i< words.length; i++){
- for(int j = 0; j<words[i].length(); j++){
- char letter = words[i].charAt(j);
- println(letter);
- t = random(2*PI);
- r = random(100);
- x = a + r*(cos(t));
- y = b + r*(sin(t));
- text(letter, x, y);
- }
- }
- }
- }
- void draw() {
- }
1