Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Associating videos to characters generatively

$
0
0

Hi

I'm trying to create a movie-based typeface. I want each letter to create a movie object. for example letter X needs to call X.mov and become an item in and array.

   currentLetter = new Movie[str.length()];
  for (int i=0; i<str.length(); i++) {
    currentLetter[i] = new Movie(this, str.charAt(i)+".mov");
    currentLetter[i].jump(random(currentLetter[i].duration()));
  }

this returns:

"Could not load movie file .mov"

here is the entire code:

String str = "abab aba";
int wordsNum = 1;

int t = 0;

int[] wordsLength;

float kerning = -130;
float leading = 0;
float charLocation = 0;
float lineLocation = 0;

float fontHeight = 120;
float fontWidth = 160;

float horMargin = 100;
float vertMargin = 100;

Movie[] currentLetter;


import processing.video.*;
void setup() {
  size(1200, 900);
  frameRate(30);
  // finding out how many words are there    (important for the wordsLength array)

  for (int i = 0; i<str.length(); i++) {
    if (str.charAt(i)==' ') {
      wordsNum++;
    }
  }
  println("number of words is: ", wordsNum);


  int letCount = 0;

  wordsLength = new int[wordsNum];
  for (int i = 0; i<str.length(); i++) {
    if (str.charAt(i)==' ') {
      wordsLength[t]=letCount;
      letCount=0;
      t++;
    } else {
      letCount++;
    }
  }
  println(wordsLength);

  currentLetter = new Movie[str.length()];
  for (int i=0; i<str.length(); i++) {
    currentLetter[i] = new Movie(this, str.charAt(i)+".mov");
    currentLetter[i].jump(random(currentLetter[i].duration()));
  }


  t=0;
}

void draw() {
  background(255);
  blendMode(DARKEST);
  charLocation = 0;
  lineLocation = 0;
  t = 0;
  for (int let = 0; let < str.length(); let++) {
    float letterxLocation = width-horMargin+charLocation-fontWidth;
    image(currentLetter[let], letterxLocation, vertMargin+lineLocation, fontWidth, fontHeight);

    // Character Location

    charLocation = charLocation - fontWidth - kerning;

    // checking if it's a new word

    if (str.charAt(let)==' ' && t < wordsNum) {

      // creatng a new line

      if (width-horMargin+charLocation-wordsLength[t]*(fontWidth+kerning) < horMargin) {
        charLocation = 0;
        lineLocation = lineLocation + fontHeight + leading;
      }
      t++;
    }
  }
}

void movieEvent(Movie m) {
  m.read();
}

Any ideas? :) Thank you!


Viewing all articles
Browse latest Browse all 2896

Trending Articles