From a4529e8aa1c457f5342f1bbbf79c5352a58dfb0e Mon Sep 17 00:00:00 2001 From: TennesseeTrash Date: Sun, 8 Jun 2025 00:53:02 +0200 Subject: [PATCH] Write a more proper README --- README.md | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d3a50fa..2b6fb67 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,62 @@ # kanjivg-tools -Various utilities for working with the kanjivg dataset. \ No newline at end of file +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 +are expected in the public API (apart for error handling). + +### 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, +}); +```