Rendering drawings with tuhirender

Rendering drawings from point coordinates and pen pressure data

Recently, almost all my digital drawings were made with a Bamboo Slate tablet and Tuhi. It was good fun to take Tuhi’s drawing data and create my own renderer tuhirender, which can be used from the command line to produce some more advanced effects and tune more of the rendering knobs.

tuhirender replaces Tuhi’s own renderer by building on Tuhi’s JSON-based output format for line coordinates and pen pressure data.

Basic invocation

The basic invocation is:

tuhirender -width 200 -fit -o out.png < in/1593622352.json

All parameters are in principle optional, but this invocation shows the most commonly used options. -width specifies the desired output width in pixels.

Animate a drawing

To animate the drawing progress, use the gif output format by passing the flag --format gif and specifying a matching filename with -o out.gif:

An animated drawing

An animated drawing

Simplify line segments.

With the --simplify flag, tuhirender simplifies all lines. See my previuos post on the topic: Go: Path simplification library.

Original and simplified version side-by-side

Original and simplified version side-by-side

This picture is a bit of an extreme example to demonstrate the simplification. When tweaking the parameters a bit, the simplification is less visible. At some point, I might be able to use this for outputting vector graphics at reduced file size and acceptable quality loss.

Some sample pictures

A bigger picture: Winged Victory of Samothrace

A bigger picture: Winged Victory of Samothrace

This is the biggest picture I’ve drawn so far with the tablet; I’m happy with how it turned out. The hatching renders nicely and produces the desired shades.

A cartoon drawing: A man, a dog and a sausage

A cartoon drawing: A man, a dog and a sausage

This cartoon drawing is simpler and has a bigger zoom, so it’s easier to see how the change in pen pressure is rendered.

A gopher

A gopher

The gopher picture has a lot of nuanced Pen pressure, and arguably it looked slightly better on paper. At the moment, tuhirender renders pen pressure by modifying the line width on the go. I suspect that changing the line opacity might be better, but I’m still looking for an elegant algorithm to fix up the artifacts between line segments when doing that.

Comments