Two new examples show how to use the new ShapeBasedPlacer, and the Event callbacks introduced in 0.6.0. Also, some examples were still using the old WordCram.NO_SPACE constants – thanks to Pierre Haessig for a fix. Look under File > Examples > Contributed Libraries > WordCram to see them.

WordCram 0.6.0 is here, and brings with it arbitrary shape-based layouts, SVG export, event callbacks so you can monitor your sketch’s progress, and as usual, a few bug fixes. Special thanks to simpsus for helping out so much!

Event callbacks

Ever wonder what WordCram’s doing in there? Ever have a WordCram just hang, making your fan whir, and you have no idea why it’s taking so long? Callbacks can help you figure it out.

Add methods like this to your Processing sketch, the way you do for mouse or keyboard events:

It can be slow sometimes, though the event callbacks can help you see where it’s spending its time, and tune accordingly. And the API isn’t totally there yet – I’ll work on smoothing out both for the future. But the capability is there, so give it a try.

WordCram 0.5.7 is out, and it’s about making things just a little easier.

You can make a WordCram from multiple text sources, by piling them on top of each other. Before, WordCram would forget about your old text source, and only remember the last one you told it about; now, it remembers, and uses, them all.

If you’re loading an HTML document, you can pass a CSS selector to narrow down the content. Handy for pages with navigation, headers, and footers.

Words now have, by default, 1 pixel of space between them. It used to be zero, which made for some pretty dense images. If you want, you can always go back by calling withWordPadding(0).

This is a quick release, because simpsus is helping me smooth out making WordCrams from shapes, which will be the next release:

You installed WordCram, gave it a list of words, and ran it – and some of your words are missing. What’s up?

WordCram will try really hard to place all your words, but if it has a hard time placing one, it’ll eventually move on to the next word. (If it didn’t, you might still be waiting now for a WordCram you started to render a year-and-a-half ago.) Normally, this is ok, because WordCram isn’t rendering mission-critically important data – it’s for fun.

But if it’s not rendering some words that you really want to see, what can you do?

The first thing is to understand why it’s skipping your words. Paste this code into your sketch, right after yourWordCram renders:

2014-10-09: Updated that code sample to reflect the new WordSkipReason enum.

Let’s look at each of these cases:

It’s too small. The word was rendered too small, based on its weight, and the WordSizer. Try using bigger fonts: see sizedByWeight or sizedByRank.

It’s over the limit. You called maxNumberOfWordsToDraw, telling WordCram to only render so many words, and this word was over the limit. You should only use this if your corpus has tons of distinct words, and you need to keep WordCram from chugging for ever. If this is you, try setting a higher limit. But this probably isn’t your problem – why would you be worried about a word that’s so low in weight?

There’s no room. This last one is the most likely culprit: there wasn’t enough room to place the word where you wanted it to go. Try sizing your words smaller, or using a different strategy for placing your words.

Here’s a bit more about that last case, not having enough room. Suppose your sketch only has 3 words, and you placed them all spread out, like below. WordCram should have no problem placing them where you want them to go.

But now suppose you put them all in the same corner. On the same spot, they’ll overlap:

To fix this, WordCram nudges them around, so they’re close to where you want:

With only 3 words, this is pretty easy. With 30 words, it’s still easy, if they’re small enough.

But with too many words, WordCram eventually will throw up its hands and move on to the next word.

This release is mostly a fix for issue #4. dbasch couldn’t make a word cloud, because cue.language couldn’t decide what language his text was in. Next time cue gets confused, instead of stopping the whole show, WordCram will gracefully ignore it, and include the word.