Trig mind bender for spiralling text
in
Programming Questions
•
1 month ago
I would like to have some text follow the path of a spiral, such that whenever it has gone 180 degrees along the spiral, it is upside down. (This means, for example, that when it has gone 90 degrees, it will be perpendicular, with the bottom of the text facing left.) What I can't work out is how to coordinate the expanding radius of the spiral with the degree of rotation of the text. (Also, I want the time it takes to complete one cycle of the spiral to be constant.)
Here's what I have so far (the chosen values are just stabs in the dark):
- float r = 0; //radius
- float theta = 0;
- PFont font;
- void setup() {
- size(800, 800, P3D);
- background(255);
- smooth();
- font = loadFont("Georgia-48.vlw");
- textFont(font);
- textAlign(CENTER);
- textSize(24);
- fill(0);
- }
- void draw() {
- background(255);
- // Polar to Cartesian conversion
- float x = r * cos(theta);
- float y = r * sin(theta);
- // Draw an ellipse at x,y
- // Adjust for center of window
- translate(x+width/2, y+height/2, 0); //rotation of the disk
- rotate(radians((r * 23) % 360), 0, 0, 1 ); //rotation of the word
- text("foo", 0, 0);
- // Increment the angle
- theta += .0333;
- // Increment the radius
- r += 0.1;
- }
1