Skip to content
This repository has been archived by the owner on Dec 18, 2020. It is now read-only.
/ flro Public archive

Not maintained, since Rive 2 is using the new RIV format. AWK script for optimizing JSON formatted FLR files

License

Notifications You must be signed in to change notification settings

tsinis/flro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌐 english | český | русский

FLRO

FLR Optimizer is a AWK-based script for optimizing JSON formatted FLR files (exported from Rive). This experimental script was greatly influenced by the SVGO project. Please don't take it too seriously. ☺️

Screenshot

Why?

FLR files, especially those exported in JSON format, usually contain a lot of useless information. Such as non-optimal, too long values and so on, that can be safely converted without affecting the FLR rendering result much.

Where?

AWK is a domain-specific language designed for text processing and typically used as a data extraction and reporting tool. It is a standard feature of most Unix-like operating systems, such as macOS and Linux distributions.

Note about Windows: AWK is not available in Windows by default. Please use either gawk (you will need to change the command syntax a little) or in Windows 10 (from build 14328 and later), simply run a command from Linux Bash Shell (i have personally tested it there too).

Usage

In terminal navigate to folder with your FLR file and run following command:

awk '{
    while (match($0, /[0-9]+\.[0-9]+/)) {
        printf "%s%.2f", substr($0, 1, RSTART-1), substr($0, RSTART, RLENGTH)
        $0 = substr($0, RSTART+RLENGTH)
    }
    print
}' original.flr > optimized.flr

Parameters:

  • 2f is the number of digits after the decimal point (I do not recommend reducing it below 2).
  • original.flr is the name of your FLR file.
  • optimized.flr is the name of optimized FLR file.

Showcase in Flutter

The FLR file from the assets folder, in this repository, was optimized by this script. To test results of this script — please run following commands in terminal:

flutter upgrade
git clone https://github.com/tsinis/flro.git
cd flro
flutter create .
flutter run

License and Copyright

This project is released under the terms of the MIT license.

About

Not maintained, since Rive 2 is using the new RIV format. AWK script for optimizing JSON formatted FLR files

Topics

Resources

License

Stars

Watchers

Forks