• fullscreen
  • oscillator.pde
  • strayBirds.pde
  • textCircler.pde
  • class Osc {
      private float origTheta;
      private float theta;
      private float thetaStep;
      private float radius;
      
      Osc(float theta, float thetaStep, float radius) {
        this.origTheta = theta;
        this.theta = theta;
        this.thetaStep = thetaStep;
        this.radius = radius;
      }
      Osc() {
        this(0, 0.1, 1);
      }
      
      float next() {
        theta += thetaStep;
        return cos(theta);
      }
      
      void reset() {
        theta = origTheta;
      }
    }
    
    String[] verseOne = 
              ("Stray birds of summer come to my window to sing and fly away. " +
               "And yellow leaves of autumn, which have no songs, flutter and fall there with a sigh.").split(" ");
               
    String[] verseTwo = "O troupe of little vagrants of the world, leave your footprints in my words.".split(" ");
    
    Osc colors = new Osc(0, 1, 1);
    TextCircler one;
    TextCircler two;
    
    float oneRadius;
    float oneYOff;
    float twoRadius;
    float twoYOff;
    
    void setup() {
      size(600, 600);
      background(255);
      
      smooth();
      textFont(loadFont("Aparajita-25.vlw"), 25);
      
      colorMode(HSB);
      
      one = new TextCircler(verseOne) {
        void drawWord(String word) {
          fill(map(colors.next(), -1, 1, 40, 90), 255, 150, 150);
          text(word, oneRadius, oneYOff);
        }
      };
      
      two = new TextCircler(verseTwo) {
        void drawWord(String word) {
          fill(map(colors.next(), -1, 1, 150, 190), 255, 150, 150);
          text(word, twoRadius, twoYOff);
        }
      };
    }
    
    void draw() {
     // fill(255, 100);
     // rect(0, 0, width, height);
      background(255);
      
      colors.reset();
      oneRadius = map(mouseX, 0, width, -100, 200);
      oneYOff = map(mouseY, height, 0, -200, 200);
      
      twoRadius = map(mouseX, 0, width, 200, -100);
      twoYOff = map(mouseY, height, 0, -200, 200);
      
      one.drawAt(300, 300, 0, TWO_PI);
      two.drawAt(300, 300, 0, TWO_PI);
    }
    
    abstract class TextCircler {
      private String[] words;
      
      TextCircler(String[] words) {
        this.words = words;
      }
      
      void drawAt(float x, float y, float thetaStart, float thetaEnd) {
        for(int i = 0; i < words.length; i++) {
          translate(x, y);
          rotate(thetaStart + (thetaEnd / words.length));
          drawWord(words[i]);
          translate(-x, -y);
        }
      }
      
      abstract void drawWord(String word);
    }
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    Dan Bernier

    Stray Birds

    Add to Faves Me Likey@! 5
    You must login/register to add this sketch to your favorites.

    "Stray birds of summer come to my window to sing and fly away. And yellow leaves of autumn, which have no songs, flutter and fall there with a sigh."

    "O troupe of little vagrants of the world, leave your footprints in my words."

    (http://www.sacred-texts.com/hin/tagore/strybrds.htm)

    Anthea Strezze
    5 May 2010
    I like it!
    You need to login/register to comment.