2025-05-24 22:15:59 +00:00
|
|
|
# kanjivg-tools
|
|
|
|
|
2025-06-08 00:53:02 +02:00
|
|
|
WIP
|
|
|
|
|
|
|
|
## Kanimaji & KanimajiTool
|
|
|
|
|
|
|
|
This is a library & program pair that implements CSS animations for SVG files in the KanjiVG
|
|
|
|
dataset, roughly based on the original [kanimaji.py](https://github.com/maurimo/kanimaji) script
|
|
|
|
([mirror](https://code.3011.io/Mirrors/kanimaji)).
|
|
|
|
|
|
|
|
The program is just a dead simple executable driver for the library.
|
|
|
|
This project is currently still work in progress, but it is feature complete, and no major changes
|
2025-06-08 00:55:18 +02:00
|
|
|
are expected in the public API (apart from error handling).
|
2025-06-08 00:53:02 +02:00
|
|
|
|
|
|
|
### Library usage
|
|
|
|
|
|
|
|
In the simplest usecase, the library consists of just two public functions:
|
|
|
|
```cpp
|
|
|
|
void AnimateFile(const Path& source, const Path& destination,
|
|
|
|
const AnimationSettings& settings = AnimationSettings::Default());
|
|
|
|
|
|
|
|
std::string Animate(const std::string& source,
|
|
|
|
const AnimationSettings& settings = AnimationSettings::Default());
|
|
|
|
```
|
|
|
|
|
|
|
|
The former function takes in two paths, where the first one specifies the file to be read, and
|
|
|
|
the second one specified a path where the resulting animated SVG image shoule be stored.
|
|
|
|
|
|
|
|
The latter takes in a string that already contains the SVG kanji data, and returns a string
|
|
|
|
containing the animated SVG file. This function performs all operations in memory.
|
|
|
|
|
|
|
|
The default settings (currently) approximate the default settings in the kanimaji.py script.
|
|
|
|
In case these are not desired, it is possible to configure the animation to an extent, e.g. like
|
|
|
|
this:
|
|
|
|
```cpp
|
|
|
|
AnimateFile("084b8.svg", "084b8-out.svg", AnimationSettings {
|
|
|
|
.StrokeProgression = Progression::EaseInOut,
|
|
|
|
.UnfilledStroke = StrokeStyle {
|
|
|
|
.Width = 2.0,
|
|
|
|
.Colour = RGB::FromHex("#EEEEEE"),
|
|
|
|
},
|
|
|
|
.FilledStroke = StrokeStyle {
|
|
|
|
.Width = 3.0,
|
|
|
|
.Colour = RGB::FromHex("#000000"),
|
|
|
|
},
|
|
|
|
.StrokeFillingColour = RGB::FromHex("#FF0000"),
|
|
|
|
.EnableBrush = Flag::Enable,
|
|
|
|
.Brush = StrokeStyle {
|
|
|
|
.Width = 5.5,
|
|
|
|
.Colour = RGB::FromHex("#FF0000"),
|
|
|
|
},
|
|
|
|
.BrushBorder = StrokeStyle {
|
|
|
|
.Width = 7.0,
|
|
|
|
.Colour = RGB::FromHex("#666666"),
|
|
|
|
},
|
|
|
|
.LengthToTimeScaling = [] (double length) -> double {
|
|
|
|
return std::pow(length, 1.0 / 3.0) / 6.0;
|
|
|
|
},
|
|
|
|
.WaitBeforeRepeating = 1s,
|
|
|
|
.DelayBetweenStrokes = 50ms,
|
|
|
|
});
|
|
|
|
```
|