Crate const_tweaker

Source
Expand description

§Runtime const tweaking

This library starts a web server at http://127.0.0.1:9938 where you can change the values of const variables in your crate.

f64 & bool are the types that are currently supported.

§Example

// Tweak `VALUE` when running in debug mode
// This will render a slider in the web GUI because the type here is a `f64`
#[const_tweaker::tweak]
const VALUE: f64 = 0.0;

// Enter a GUI/Game loop
loop {
    // ...

    // Print the constant value that can be changed from the website.
    println!("VALUE: {}", VALUE);
}

Some widgets have customizable options, as seen in the examples below:

f64:

// Spawns a slider
#[const_tweaker::tweak]
const DEFAULT_VALUE: f64 = 0.0;

// Spawns a slider with 10 steps from 0-1
#[const_tweaker::tweak(min = 0.0, max = 1.0, step = 0.1)]
const CUSTOM_VALUE: f64 = 0.0;

bool:

// Spawns a checkbox
#[const_tweaker::tweak]
const DEFAULT_VALUE: bool = true;

&str

// Spaws a textbox
#[const_tweaker::tweak]
const DEFAULT_VALUE: &str = "Hi";

Attribute Macros§

  • Expose a const variable to the web GUI so it can be changed from a live setting.