Skip to the content.

Rusty Aquarium

Cross-compile

A monitoring visualization as an aquarium written in Rust.

Screenshot

Demo

Run Rusty Aquarium in your browser:

Download executables for different platforms:

Usage

Use these keys to control the fish tank.

Generate input data

The file assets/inputdata.json is read to define what fish to display.

The field school must be an array of objects, one for each fish to display.

The fish field must match a name in the map of fishes in the config.json file.

The fields size, speed, and bubbles are multipliers that will be applied to the corresponding value from the fish configuration.

The legend field is optional, and can be used to send information to show when opening the legend screen. The description will be shown at the top, and each fish_legend will be shown in a list below it. If present, this will override the legend field in the scene configuration.

Example

{
    "legend": {
        "description": "A description to be shown when showing legend.",
        "fish_legends": [
            {
                "fish": "crab",
                "description": "A description of this fish type."
            }
        ]
    },
    "school": [
        { "fish": "crab", "size": 1.0, "speed": 1.0, "bubbles": 1.0 },
    ]
}

System monitoring

The systemdata binary generates an inputdata.json file based on CPU, processes and disks.

bin/systemdata > assets/inputdata.json

Build

Use this command line if you want to compile the binary yourself.

cargo build --features build-systemdata --bin systemdata  

Google Sheets Data

The googlesheetsdata binary generates an inputdata.json file from a Google Sheets spreadsheet. A file called credentials.json is needed that contains Google API credientials. Use the flag --interval N to keep the program running and recreate the inputdata.json file every N seconds. Use the flag --help for more options.

The sheet needs to have a row for every fish to show. The columns need to be fishname, size, speed, and bubbles. The fishname need to match the name of a configured fish, and the other values need to be a number.

Information on how to create a credentials.json file can be found here: https://developers.google.com/workspace/guides/configure-oauth-consent

bin/googlesheetsdata --spreadsheet SPREADSHEET-ID --output assets/inputdata.json

Usage

These are the available options:

A small tool to read data from Google Sheets and export to Rusty Aquarium

Usage: googlesheetsdata [OPTIONS] --spreadsheet <SPREADSHEET>

Options:
  -s, --spreadsheet <SPREADSHEET>  Spreadsheet ID to read
  -o, --output <OUTPUT>            Path to output file to store json data [default: inputdata.json]
  -i, --interval <INTERVAL>        Automatically regenerate the JSON file every N seconds
  -r, --range <RANGE>              Range of values to get from spreadsheet, like the name of a sheet [default: Sheet1]
  -c, --credentials <CREDENTIALS>  Path to Google OAuth2 credentials json file [default: credentials.json]
  -t, --tokencache <TOKENCACHE>    Path to file to store token authentication cache [default: tokencache.json]
  -h, --help                       Print help

Build

Use this command line if you want to compile the binary yourself.

cargo build --features build-googlesheetsdata --bin googlesheetsdata 

CSV Data

The csvdata binary generates an inputdata.json file from a comma separated file of data. Use the flag --listen to keep the program running and update the inputdata.json file every time the CSV file is changed. The flag --description can be used to set the description in the legend data to show at the top of the legend screen. Use the flag --help for more options.

The columns in the CSV files are fishname, count, size, speed, bubbles, and description. The count defines how many fishes of the type fishname to create. The columns size, speed, and bubbles are decimal numbers which will be used as multipliers for those values. Each row will generate a legend row, with the fish name and the text from description.

bin/csvdata --file csvfile.csv --output assets/inputdata.json --description "A short description for the legend screen"

Usage

These are the available options:

Usage: csvdata [OPTIONS]

Options:
  -f, --file <FILE>                Path to input CSV file to convert [default: fishdata.csv]
  -o, --output <OUTPUT>            Path to output file to store json data [default: inputdata.json]
  -l, --listen                     Listen to changes in file and automatically update output file
  -d, --description <DESCRIPTION>  Description for the Legend data
  -h, --help                       Print help

Build

Use this command line if you want to compile the binary yourself.

cargo build --features build-csvdata --bin csvdata

Configuration

The file assets/config.json can be used to configure the fish tank. It has some general configuration values, paths to PNG files to load for background images and fish sprites. It also defines which fish types are available, with default values for them.

File format

Example

{
    "input_data_path": "assets/inputdata.json",
    "display_time": 10,
    "backgrounds": [
        "assets/background.png",
    ],
    "water_sprite": "water.png",
    "scenes": [
        {
            "input_data_path": "inputdata.json",
            "display_time": 5,
            "background": 3
        },
        {
            "input_data_path": "inputdata2.json",
            "display_time": 5,
            "background": 2,
            "legend": {
                "description": "These are the different fishes in this aquarium.",
                "fish_legends": [
                    {
                        "fish": "crab",
                        "description": "A happy rustacean!"
                    }
                ]
            }
        }
    ],
    "fishes": {
        "crab": {
            "texture": "assets/ferris.png",
            "size": 7.0,
            "size_randomness": 1.0,
            "movement": "Crab",
            "bubbles": 0,
            "collision_aversion": 0.3,
            "speed": {
                "x": 12.0,
                "y": 4.0
            },
            "speed_randomness": {
                "x": 1.0,
                "y": 1.0
            },
            "area": {
                "x": 5.0,
                "y": 56.0,
                "w": 90.0,
                "h": 6.0
            }
        },
    }
}

License

The code for Rusty Aquarium is released under the MIT License. See LICENSE file for more details.

The images are not covered by the license, and are to the best of my knowledge public domain.

Build scripts

The build scripts require the cargo-run-scripts package to be installed.

cargo install cargo-run-script

Build a web package in demo/

cargo run-script build-web

Start a web server

cargo run-script serve-web

Build windows binary

cargo run-script build-win

Build Android APK

cargo run-script build-apk

Related links