martedì 31 gennaio 2012

Processing Text-image generator Processing

This is a simple post about a processing sketch that makes you able to generate from a normal image an image like this, formed by letter/numbers of differents colors.

This is the processing sketch:

PImage img;
String txt = "hello"; //here goes your text
float spacex = txt.length()*2.9;

//you should need to recalibrate this variable
float spacey = 5.0;

void setup(){
  img = loadImage("img2.jpg");
  size(img.width*2, img.height*2);

void draw(){
  for(int xpix = 0; xpix <= img.width; xpix += spacex){
    for(int ypix = 0; ypix <= img.height; ypix += spacey){
      color pixcol = img.get(xpix, ypix);
      text(txt, int(map(xpix, 10, img.width, 10, img.width*2)), int(map(ypix, 10, img.height, 10, img.height*2)));

This sketch simply create the image getting the color of the processed pixel and save the final result (saveFrame) as an image.
This sketch can generate from this image:

this image:

I hope you like this post, if you have questions comment or send me an e-mail to

Bye, Dami

P.S.:the sketch it's calibrated to wite "0" but if you want to write something else you have to recalibrate some things.