Recently, almost all my digital drawings were made with a [Bamboo
Slate](https://www.amazon.de/Wacom-Bamboo-Slate-Smartpad-Digitalisierungs-Funktion/dp/B01L1V61MC)
tablet and [Tuhi](https://github.com/tuhiproject/tuhi). It was good
fun to take Tuhi's drawing data and create my own renderer
[tuhirender](https://github.com/gnoack/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`:

![](/images/drawing.gif)
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](https://blog.gnoack.org/post/path-simplification-lib/).

![An original and a path-simplified picture side-by-side](/images/hippie.png)
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

![](/images/winged-victory-of-samothrace.png)
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.

![](/images/sausage.png)
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.

![](/images/gopher.png)
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.
