Various utilities for working with the kanjivg dataset.
Find a file
2025-06-14 19:52:18 +02:00
CMake [Megane] Add tiny library to translate utf8 characters to kvg code 2025-06-14 13:19:47 +02:00
Libraries [Common] Split RGB into a new Common library 2025-06-14 19:52:18 +02:00
Tools [Common] Split RGB into a new Common library 2025-06-14 19:52:18 +02:00
.gitignore Prepare the initial stubs 2025-05-25 00:42:58 +02:00
CMakeLists.txt Prepare the initial stubs 2025-05-25 00:42:58 +02:00
README.md Typo ... 2025-06-08 00:55:18 +02:00

kanjivg-tools

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 script (mirror).

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 are expected in the public API (apart from error handling).

Library usage

In the simplest usecase, the library consists of just two public functions:

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:

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,
});