FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Programs
(Moderators: fry, REAS)
   tracking time while typing
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: tracking time while typing  (Read 3236 times)
dylan178

Email
tracking time while typing
« on: Apr 16th, 2005, 9:53pm »

i'm looking for a little help. i'm a graphic design student and for the pasts weeks i have been trying to use processing to create a program that will:
 
--------------------------------------------------
1. keep track of the speed in which a person types and based on that speed (and more importantly the pauses between thoughts, words and letters) display the text accordingly.  
            
example:
- if i type at a very even and consistent pace the text will look like this.
 
- i f    i      t y p     e         at   a n     un  e      ven        pa ce       th      e      te   xt   will    loo    k    mo   re   lik    e   thi    s.
 
basically i want to adjust to the letter-spacing of a document based on the elapsed time between thoughts.
 
 
2. in addition, or as a variation on it's own, i want to use this same time element to effect the percentage of black (0-100%) in the letterform.  
 
example:
- the more even you type the lower the percentage of black. (the thought being that these words are less deliberated over.)
 
- the more considered words are and the longer they take to formulate the darker the letterform.
 
 
3. finally, i'd like this program to be able to function in the "background" of other applications - mostly email apps.  as a tracking device. this way, i can compare the two: what i typed vs. what i really typed... most revealing.
----------------------------------------------------
 
does anybody have an any existing code (or one that can easily be tweaked) that you would consider sending me to achieve these results?
 
 
i appreciate any help,
dylan
 
Ricard


Re: tracking time while typing
« Reply #1 on: Apr 18th, 2005, 10:47am »

Hi dylan,
 
I think it's a very good idea!!!  I would like to add another variation, that would be to give each word a different color (maybe alternate between to different colors each time the spacebar is pressed) in order to separate words and thoughts.
 
I will try to look at the coding of this when I get home this afternoon.  I think it's very interesting.
 
cheers
ricard
 
PS: I think that integrating it with email writing and others will be hard with Processing, since it cannot act as a daemon/service that I know of.  But it would be an interesting thing to program in C++ or other.
« Last Edit: Apr 18th, 2005, 10:48am by Ricard »  
Ricard


Re: tracking time while typing
« Reply #2 on: Apr 18th, 2005, 2:08pm »

Hi again,
 
here is a bit of code that does the trick.
I really enjoy your idea and I'm going to develop this bit of code a bit further in order to visualize the thinking time in different ways.  If you want, I will put the variations in this forum.  Let me know, otherwise I'll just keep them to me, after all it's your idea.
 
 
Code:

BFont f;
TypeTracker tf;
int leftmargin = 20;
int rightmargin = 20;
int topmargin = 40;
int bottommargin = 20;
 
float now;
float horizPos=0, vertPos=0;
float coeffSpace=0.05;
float coeffScale=0.005;
float coeffColor=0.05;
 
void setup()
{
  size(500, 500);
  framerate(20);
 
  translate(0,0);
 
  // load the font. fonts are located within the  
  // main Processing directory/folder and they
  // must be placed within the data directory
  // of your sketch for them to load
  f = loadFont("Univers66.vlw.gz");
  textFont(f, 24);
 
  // Store the cursor rectangle's position
  horizPos = leftmargin;
  vertPos = topmargin;
  rect(horizPos, vertPos, 10, 21);
   
   
  // create the class TypeTracker
  tf = new TypeTracker();
 
  // white type, black background
  fill(0);
}
 
void loop()
{
  background(255);
  tf.draw();
}
 
 
void keyPressed()
{
  if ((key >= 0x20 && key <= 0x7e)||(key ==8 )||(key==10))
  {
    float dt=millis()-now;
    now+=dt;
    tf.addChar(char(key),dt);
  }
}
 
 
class TypeTracker{
  String texts="";
  float delays[];
  int index=0;
   
   
  TypeTracker(){
    delays = new float[1000];
  }
   
  void draw(){
    push();
 translate(horizPos,vertPos);  // place the cursor at the beginning of the text display field
 //scale(25.0f);       // scale the text
 
 char k;
 float horizAdv=0,vertAdv=0,scaling=1.0;
 boolean beginLine=true;
 
 for(int i=0;i<texts.length();i++){
   k = texts.charAt(i);
   
   horizAdv+=delays[i]*coeffSpace;
   //scaling=delays[i]*coeffScale;
   //println(horizAdv);
   if(horizAdv>=(width-leftmargin-rightmargin-f.width(k))){
     horizAdv=0;
     vertAdv+=40;
   }
   push();
     translate(horizAdv,vertAdv);
     //scale(scaling);
     text(k,0,0);
   pop();
 
   horizAdv+=f.width(k);
 }
    pop();
  }
   
  void addChar(char k,float dt){
    if(k == char(8)) // special case for Backspace
    {
 if(texts.length()>0){
   texts=texts.substring(0,texts.length() - 1);
   index--;
 }
    }
    else
    {
 texts=texts + k;
 delays[index++]=dt;
    }
  }
}
 
Pages: 1 

« Previous topic | Next topic »