function setup() {
  createCanvas(windowWidth, windowHeight);
  // createCanvas(windowWidth, round(windowWidth*1.343));
  // createCanvas(windowWidth*2, round(windowWidth*1.343)*2);

  joinedText = joinedText.join(' ');
  // If you want to get rid of all number chars too, just uncomment the following line
  // joinedText = joinedText.replace(/\d+/g, '');
  var words = joinedText.match(/\w+/g);

  // create the main treemap
  treemap = new gd.Treemap(1, 1, width - 3, height - 3, {
    sort: doSort,
    direction: rowDirection,
    padding: 2,
    ignore: []
  });

  // make an array for the nested treemaps
  var subTreemaps = [];

  // count words
  for (var i = 0; i < words.length; i++) {
    var w = words[i].toLowerCase();
    var index = w.length;
    // Add only words with less than 10 letters
    if (index < 10) {
      var t = subTreemaps[index];
      if (t == undefined) {
        t = treemap.addTreemap(index);
        subTreemaps[index] = t;
      }
      t.addData(w);
    }
  }

  treemap.calculate();
}
Counting the words of a text and display them in a treemap diagram.
All words with the same number of letters are grouped in a nested treemap.
Only words with less than 10 letters are stored.

KEYS
r                   : toggle random mode
h                   : only horizontal rows
v                   : only vertical rows
b                   : both kind of rows
1-9                 : switch on and off words with this number of letters
0                   : show all words
s                   : save png