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_
   Topics & Contributions
   Responsive Form, Games
(Moderator: REAS)
   color typewriter
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: color typewriter  (Read 1673 times)
Martin

122417302122417302martingomez_listsmg1ph WWW Email
color typewriter
« on: Aug 27th, 2002, 8:07pm »

hello.
 
Code:

// an improvised color typewriter v0.0001 on proce55ing
// by martin gomez, ateneo de manila university
//    pgomez@student.ateneo.edu
//    manila, philippines
//
// based on the color typewriter concept of
// professor john maeda
//
// desc:
// this program on p5 intends to be a rebirth of the
// color typewriter, a brainchild of professor john maeda,
// using proce55ing's own set of instructions.
//
// notes:
// * found a bug in the process of writing the code...
// * would really appreciate it if there's anyone out there
//   who could improve this code and post it at
//   proce55ing.net's discourse.
// * the color key combo was done brute force. will
//   device some sort of an algo in the future.
//
// side note:
// written in one night. ... am now sleepy hehe.
// gotta grab some sleep!
 
void setup() // initalization - run once
{
 
  size(301, 201);
  noFill();
  
  /* what not */
  println();  println();  println();  println();  println();
  println();  println();  println();  println();  println();
  println();  println();  println();  println();  println();
  println();  println();  println();  println();  println();
  println();  println();  println();  println();  println();
  println();  println();  println();  println();  println();
//  println( "an improvised color typewriter v0.0001 on proce55ing" );
     // bug: the display says "int"
     // when i use the word 'co_lor'
     // in the string (w/o the _ )
  println( "an improvised co_lor typewriter v0.0001 on proce55ing" );  
  println( "by martin gomez, ateneo de manila university. august 2002." );
// println ( "updated by: " + " _put_your_name_here_ " + "on" + " _put_the_date_here_ " );  
  println();
  println( "based on the co_lor typewriter concept of" );
  println( "professor john maeda, mit media lab." );
  println();
 
}
 
  /* define initial values of vars */
 
  int x = 1; // declarations
  int y = 5;
 
void loop() // infinite loop
{
 
// there is a need for data not to be erased
// while doing the loop
 
   if( keyPressed )
   {
    
        /* x-axis end test */
        if( x == 301 )       // when pixel reaches the x end
        {
          x = 1;                // reset x to 1
          y = ( y + 10 );       // set y to ( y + 10 )
        }
    
        /* y-axis end test */
        if( y > 195 )         // when pixel reaches the y end
        {
          x = 1;                // reset x to 1
          y = 10;               // reset y to 10
        }
    
      /* start color key matching */
      if(key == 'a' || key == 'A') {
        fill(50, 50, 50);
      } else if (key == 'b' || key == 'B') {
        fill(153, 153, 102);
      } else if (key == 'c' || key == 'C') {
        fill(102, 153, 153);
      } else if (key == 'd' || key == 'D') {
        fill(202, 153, 153);
      } else if (key == 'e' || key == 'E') {
        fill(102, 253, 153);
      } else if (key == 'f' || key == 'F') {
        fill(102, 100, 153);
      } else if (key == 'g' || key == 'G') {
        fill(102, 153, 53);
      } else if (key == 'h' || key == 'H') {
        fill(102, 53, 153);
      } else if (key == 'i' || key == 'I') {
        fill(212, 153, 153);
      } else if (key == 'j' || key == 'J') {
        fill(102, 103, 153);
      } else if (key == 'k' || key == 'K') {
        fill(102, 153, 253);
      } else if (key == 'l' || key == 'L') {
        fill(102, 200, 153);
      } else if (key == 'm' || key == 'M') {
        fill(50, 153, 153);
      } else if (key == 'n' || key == 'N') {
        fill(102, 60, 153);
      } else if (key == 'o' || key == 'O') {
        fill(102, 10, 153);
      } else if (key == 'p' || key == 'P') {
        fill(102, 153, 30);
      } else if (key == 'q' || key == 'Q') {
        fill(102, 153, 70);
      } else if (key == 'r' || key == 'R') {
        fill(102, 75, 153);
      } else if (key == 's' || key == 'S') {
        fill(80, 153, 153);
      } else if (key == 't' || key == 'T') {
        fill(102, 22, 153);
      } else if (key == 'u' || key == 'U') {
        fill(102, 153, 33);
      } else if (key == 'v' || key == 'V') {
        fill(102, 153, 168);
      } else if (key == 'w' || key == 'W') {
        fill(102, 133, 153);
      } else if (key == 'x' || key == 'X') {
        fill(102, 190, 153);
      } else if (key == 'y' || key == 'Y') {
        fill(102, 153, 220);
      } else if (key == 'z' || key == 'Z') {
        fill(240, 153, 153);
      } else {
        noFill();
      } // end
 
//        rect( x, y, ( x + 5 ), ( y + 5 ) ); // draw the rectangle
//        rect( x, y, 10, 10 ); // draw the rectangle
 
//      rect( x, 10, ( 1 + 5 - 2 ), ( 9 - 3 + 2 ) ); // draw the rectangle
    
        x = ( x + 5 );      // set x to ( x + 5 )
    
    }
    
      stroke(255); // i want a white border
      rect( x, y, 10, 10 ); // draw the rectangle
    
}

 
« Last Edit: Aug 28th, 2002, 8:02am by Martin »  
REAS


WWW
Re: color typewriter
« Reply #1 on: Sep 19th, 2002, 3:57pm »

hello martin, i made a few changes to make it behave more like i expected a typewriter to behave
 
// an improvised color typewriter v0.0001 on proce55ing  
// by martin gomez, ateneo de manila university  
//    pgomez@student.ateneo.edu  
//    manila, philippines  
//  
// based on the color typewriter concept of  
// professor john maeda  
//  
// desc:  
// this program on p5 intends to be a rebirth of the  
// color typewriter, a brainchild of professor john maeda,  
// using proce55ing's own set of instructions.  
//  
// notes:  
// * found a bug in the process of writing the code...  
// * would really appreciate it if there's anyone out there  
//   who could improve this code and post it at  
//   proce55ing.net's discourse.  
// * the color key combo was done brute force. will  
//   device some sort of an algo in the future.  
//  
// side note:  
// written in one night. ... am now sleepy hehe.  
// gotta grab some sleep!  
 
// modified by REAS to behave more like a typewriter.  
// - to leave marks on the page  
// - to only type one letter for each keypress  
// it stills need some modifications to act as expected  
 
// Global variables  
int x = 0;    // X position of the letters  
int y = 0;    // Y position of the letters  
int letter_height = 10;   // Height of the letters
 
int lc_letter_height = 5; //Height of lower case letters
 
int up_letter_height = 10; //Height of upper case letters  
 
int letter_offset = up_letter_height - lc_letter_height;
int letter_width = 5;     // Width of the letter  
int numChars = 26; // There are 26 characters in the alphabet  
 
int[] r = new int[numChars];  
int[] g = new int[numChars];  
int[] b = new int[numChars];  
 
// Initalization - run once  
void setup()  
{  
  size(301, 201);  
  noBackground();  
  stroke(255); // sets a white border  
 
  for (int i=0; i<30; i++) {  
    println();  
  }  
  println( "an improvised co_lor typewriter v0.0001 on proce55ing" );    
  println( "by martin gomez, ateneo de manila university. august 2002." );  
  println ( "updated by: " + " REAS " + "on" + " 19 Sept 2002 " );    
  println();  
  println( "based on the color typewriter concept of" );  
  println( "professor john maeda, mit media lab." );  
  println();  
 
  // Set each key to map to a random color  
  for(int i=0; i<numChars; i++) {  
    r[i] = int(random(0, 255));  
    g[i] = int(random(0, 255));  
    b[i] = int(random(0, 255));  
  }  
}  
 
// Infinite loop  
void loop()  
{  
  // Everything happens in this program when  
  // a key is pressed, so all actions are  
  // diverted to the keyPressed() method below    
}  
 
void keyPressed()  
{  
  // if the key is between 'A' and 'z'  
  if( key >= 'A' && key <= 'z') {  
    int keyIndex;  
    if(key <= 'Z') {  
 keyIndex = key-'A';  
 
 letter_height = up_letter_height;
 
 letter_offset = 0;
    } else {  
 keyIndex = key-'a';
 
 letter_height = lc_letter_height;
 
 letter_offset = up_letter_height - lc_letter_height;  
    }  
    fill(r[keyIndex], g[keyIndex], b[keyIndex]);      
  } else {  
    fill(255, 255, 255);  
  }  
 
  // Draw the "letter"  
  rect( x, y+letter_offset, letter_width, letter_height );      
  // Update the "letter" position    
  x = ( x + letter_width );  // set x to ( x + 5 )  
 
  // Wrap horizonally  
   if (x > width - letter_width) {  
    x = 0;  
    y+= up_letter_height;  
  }  
 
  // Wrap vertically  
  if( y > height - up_letter_height) {  
    y = 0; // reset y to 0  
  }  
}
« Last Edit: Oct 19th, 2002, 1:58pm by Processing »  
whatpot


Re: color typewriter
« Reply #2 on: Oct 19th, 2002, 12:49pm »

hi i'm a student of communication design at Srishti ,bangalore, India...
Is it possible to del a colour when one hits backspace...
i guess it wouldn't be a typewriter anymore if it were possible to delete...
 
Processing

WWW Email
Re: color typewriter
« Reply #3 on: Oct 19th, 2002, 2:03pm »

whatpot,
 
of course it's possible to delete a color with the backspace key. why don't you try to program it? the key (ascii) value for the backspace key is "8" so you can test if someone hit this key with:
if ( key == 8 ) { }
 
+ casey
 
Martin

122417302122417302martingomez_listsmg1ph WWW Email
Re: color typewriter
« Reply #4 on: Oct 23rd, 2002, 3:03pm »

hi casey,
 
noticed the changes you made to the code. cool! will be updating the code with more functionalities such as backspace, carriage return, special characters / punctuations, and numbers. will also do dynamic paper resizing -- this is possible if run within proce55ing... oh. a idea pops up... am musing at doing frames hehehe hacking the exported java file ...
 
hhmm... wondering if the special characters and numbers will also be allowed to be used like the letters... lemme try...
 
sembreak just started, so i now have the time to play around with proce55ing.
 
cheers!
 
martin
 
REAS


WWW
Re: color typewriter
« Reply #5 on: Oct 23rd, 2002, 5:46pm »

Go, Go.  
I'm looking forward to seeing what you come up with.
 
Martin

122417302122417302martingomez_listsmg1ph WWW Email
Re: color typewriter
« Reply #6 on: Oct 23rd, 2002, 7:46pm »

LOL! I tried pasting the code but it says that my message was too long hehehehe... Anyway, here it is...
 
Applet
http://www.instituteofmedia.com/martin/mediadesign/colortype5/index.html
 
Java Code
http://www.instituteofmedia.com/martin/mediadesign/colortype5/colortype5 .java
 
More to come. It's already late hehe...
 
** Add: Figured out that the .java file isn't properly formatted because of bugs so I have also uploaded the .pde file for more readability. : )
 
P5 Code
http://www.instituteofmedia.com/martin/mediadesign/colortype5/colortype5 .pde
« Last Edit: Oct 24th, 2002, 4:17am by Martin »  
REAS


WWW
Re: color typewriter
« Reply #7 on: Oct 24th, 2002, 8:48pm »

the "typewriter" is definately feeling more complete. the addition of short bars for letters is interesting. i think the next step is to assign non random colors to the key values. upper and lower case versions of the same letters have a relation or vowels having a relation, etc.
 
good. good.
 
Martin

122417302122417302martingomez_listsmg1ph WWW Email
Re: color typewriter
« Reply #8 on: Oct 25th, 2002, 7:29pm »

i'm still trying to figure out a way to surpass having to assign the colors for each key en brute. there must be an equation to automate this process!
 
here are a few things i'm thinking (for the letters) as my options:
- divide the rgb palette into 26 areas wherein the center color of  
  each area can be the representative of that area... but to be done  
  !(hard code)
- get key index then plug-into to an equation of sorts
- use the 16-color palette, exclude white, then add 11 more other  
  colors
- plug the values into a 1x3 matrix then try to manipulate the matrix  
  into sorts
- just stay at random, but also present a color key at the bottom
  ... hhmm... cryptography?
 
here are some more... (thanks to justin, a buddy and my former teacher on tipping me with numerical analysis)
- do a binary cycle to ensure that there is a complete pass and try  
  to extract a color
- do a sine wave cycle through the possible combinations where 255
  is the altitude (y = amplitude * sin 2 pi * (t/T - x/wavelength))
  and divide into segments
 
ahh... nuts. any other ideas?
 
REAS


WWW
Re: color typewriter
« Reply #9 on: Oct 28th, 2002, 9:06pm »

ahhh. so many ideas.  
 
try working in HSB space -- it's better for algorithmic color exploration. i think working with waves rather than linear progressions is a good place to continue.
 
Martin

122417302122417302martingomez_listsmg1ph WWW Email
Re: color typewriter
« Reply #10 on: Oct 31st, 2002, 5:13pm »

Hi!
 
Version 6 is up! Dual version...
 
Applets:
 
  Light and Bright (6a)
  www.instituteofmedia.com/martin/mediadesign/colortype6a/
 
  Shady Dandy (6b)
  www.instituteofmedia.com/martin/mediadesign/colortype6b/
 
Code:
  www.instituteofmedia.com/martin/mediadesign/colortype6b/colortype6.java
 
Guide:
  www.instituteofmedia.com/martin/mediadesign/colortype6b/colortype.xls
 
Updates:
  - Dual non-random color scheme (Light and Bright & Shady Dandy)
  - A guide to the color scheme used and how the colors were derived
  - Internal margin and internal border (10px margin)
  - Inclusion of special characters
  - Tab implemented
  - Multiple pages with option to save per page
  - Switched view to portrait from landscape
 
Re: Non-Random Colors ...
The colors were picked out this way: For version 6a... Vowels have a relation. They are the ones that carry the brightest / heaviest colors (red, yellow, green, cyan, blue -- in that order ). The letters in-between the vowels form a gradation. There are only three additions to 6b... While the gradation is still present, the saturation jumps up and down to have more variance. In addition to this, magenta participates in the game (6a uses blue to white grad). And of course, 6b is darker (lower brightness level). So given all these rules, I could actually design an algorithm for it! ... and perhaps name it "Non-Random Color Representation in Computational Media Design" hehehe... or maybe I could come up with a nicer name? hehehehe... Anyway...
 
People can refer to the Excel file for the complete list of character color representations.
 
A non-technical look at both color schemes...
 
Light and Bright tries to immitate a rainbow. Even though still lacking some parts, Light and Bright, as its name suggests, gives a bright feel to an already bright space. Typing with bright color on a bright paper would just give that glaring shining (yes, I'm redundant) effect, where the flowers of spring and the sun of summer radiate in full.
 
Shady Dandy tends to be more formal. With that darker feel that constrasts against the white paper, Shady Dandy presents a clear cut way in representing each character. This scheme gives a thicker experience with the medium. Shady Dandy delivers the message.
 
Ok. Back to tech.
 
I seem to be having problems with the app whenever I press characters that range from (Ascii value) 91 to 96. I still have to figure out why this is so... error is array out of bounds. ... but it clearly is not (from the P5 code...). Perhaps someone can take a look?
 
Cheers! Happy Halloween!
 
Martin

122417302122417302martingomez_listsmg1ph WWW Email
Re: color typewriter
« Reply #11 on: Jan 1st, 2003, 10:04am »

Hi,
 
Version 7 is up.
 
http://studio.instituteofmedia.com/colortype/
 
Updates:
  - Sound for every keystroke
  - Larger "font size"
  - Landscape orientation of the "paper"
 
Happy New Year!
« Last Edit: Jan 1st, 2003, 10:05am by Martin »  
Pages: 1 

« Previous topic | Next topic »