WordCram

open-source word clouds for Processing

Follow WordCram on Twitter @wordcram

Ask a Question in the Forum /wordcram

Pull Requests Welcome on GitHub danbernier/WordCram

Latest News

WordCram 1.0.0 Released, for Processing 3.0

WordCram 0.6.2 Released

WordCram 0.6.1 Released

All posts

New daily: WordCram to PDF

WordCram now outputs to PDF. It’ll be in the 0.5 release, but you can grab the new daily build right now (zip or tar) and try it out. The only new code you’ll need is normal Processing PDF stuff, all the WordCram code stays the same. Just import processing.pdf.*, and use size(width, height, PDF, "path/to/output.pdf").

Here’s an example, a PDF word cloud from the Wikipedia page on PDF. Here’s the code to produce it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import processing.pdf.*;
import wordcram.*;

void setup() {
  size(700, 700, PDF, "wordcram.pdf");

  background(255);

  new WordCram(this)
    .fromWebPage("http://en.wikipedia.org/wiki/Portable_Document_Format")
    .withColors(#000000, #777777, #ff0000)
    .withFonts("LiberationSans")
    .sizedByWeight(1, 200)
    .withWordPadding(1)
    .angledAt(0)
    .withPlacer(new WordPlacer() {
      public PVector place(Word w, int r, int c, int ww, int wh, int fw, int fh) {
        float xScatter = (1-w.weight);
        float x = map(random(-xScatter, xScatter), -1, 1, 30, fw-ww-30);
        float y = (1-pow(w.weight, 0.25)) * (fh - wh) + 30;
        return new PVector(x, y);
      }
    })
    .drawAll();
}

I’m pretty excited about this. PDF output was one of the first features asked for, and it’s been a goal of mine to finish it. But more importantly, we can now print some really nice, high-res word clouds!

<<

>>