tease/
cookbook.rs

1//! # A cookbook full of wonderful things
2//! ## The basics
3//! Starting out simple, we can run just a few lines of code that will set up a rudimentary GUI.
4//! ```rust, no_run
5#![doc = include_str!("../examples/minimal.rs")]
6//! ```
7//! This program draws on the default settings to produce a GUI that looks like this
8//! ![](https://raw.githubusercontent.com/cmccomb/tease/master/assets/minimal.png)
9//! The default settings are designed to demonstrate some of the functionality of the
10//! visual interface. There are inputs, there is an output, and there is a <kdb>Submit</kbd>
11//! button that uses the inputs to compute an output.
12//!
13//! Let's build a simple calculator to add two numbers together. We will need to have two inputs,
14//! and we will also need to define a function that sums those inputs together. Our code becomes
15//! ```rust, no_run
16//! use tease::{Input, Teaser};
17//!
18//! fn main() {
19//!     Teaser::default()
20//!         .with_inputs(vec![Input::default(); 2])
21//!         .with_function(move |x| x.iter().sum())
22//!         .run();
23//! }
24//! ```
25//! This will make the GUI look as follows. And it works! We can add numbers together!
26//! ![](https://raw.githubusercontent.com/cmccomb/tease/master/assets/addition_basic.png)
27//!
28//! We can spruce this up a little bit by adding a descriptive header and a short description of
29//! what the GUI does. Our code now becomes:
30//! ```rust, no_run
31#![doc = include_str!("../examples/addition.rs")]
32//! ```
33//! And when executed it creates this GUI:
34//! ![](https://raw.githubusercontent.com/cmccomb/tease/master/assets/addition.png)
35//!
36//! ## Input Types
37//! `tease` provides a variety of different input types for flexible interface creation. These include
38//! 1. Numbers
39//! 2. Sliders
40//! 3. Dropdowns
41//! ## Fun with Closures
42//! By now, you've probably realized something - anything that you can fit in a closure can be used
43//! as the backend for a GUI. For instance, you can train a model in [SmartCore](https://smartcorelib.org/)
44//! and then provide an interactive demo.
45//!```rust, no_run
46#![doc = include_str!("../examples/smartcore.rs")]
47//! ```
48//! ![](https://raw.githubusercontent.com/cmccomb/tease/master/assets/smartcore.png)
49//!