Rendering drawings with tuhirender
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.
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
Simplify line segments.
tuhirender simplifies all lines. See my
previuos post on the topic: Go: Path simplification
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
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.
This cartoon drawing is simpler and has a bigger zoom, so it’s easier to see how the change in pen pressure is rendered.
The gopher picture has a lot of nuanced Pen pressure, and arguably it
looked slightly better on paper. At the moment,
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.