diff --git a/Cargo.lock b/Cargo.lock index 664e5f1b..f37011c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -559,6 +559,15 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" +[[package]] +name = "colors-rgb" +version = "0.1.0" +dependencies = [ + "color-eyre", + "palette", + "ratatui", +] + [[package]] name = "compact_str" version = "0.8.1" diff --git a/examples/README.md b/examples/README.md index 8332b665..5ef21f7e 100644 --- a/examples/README.md +++ b/examples/README.md @@ -49,18 +49,30 @@ This is the demo example from the main README and crate page. [Source](./apps/de ![Demo2](https://github.com/ratatui/ratatui/blob/images/examples/demo2.gif?raw=true) -## Mouse Drawing demo - -Shows how to handle mouse events. [Source](./apps/mouse-drawing/). - ## Async GitHub demo Shows how to fetch data from GitHub API asynchronously. [Source](./apps/async-github/). -## Weather demo - -Shows how to render weather data using barchart widget. [Source](./apps/weather/). - ## Calendar explorer demo Shows how to render a calendar with different styles. [Source](./apps/calendar-explorer/). + +## Canvas demo + +Shows how to render a canvas with different shapes. [Source](./apps/canvas/). + +## Colors-RGB demo + +This example shows the full range of RGB colors in an animation. [Source](./apps/colors-rgb/). + +## Input form + +Shows how to render a form with input fields. [Source](./apps/input-form/). + +## Mouse Drawing demo + +Shows how to handle mouse events. [Source](./apps/mouse-drawing/). + +## Weather demo + +Shows how to render weather data using barchart widget. [Source](./apps/weather/). diff --git a/examples/apps/colors-rgb/Cargo.toml b/examples/apps/colors-rgb/Cargo.toml new file mode 100644 index 00000000..a5583fed --- /dev/null +++ b/examples/apps/colors-rgb/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "colors-rgb" +version = "0.1.0" +publish = false +license.workspace = true +edition.workspace = true +rust-version.workspace = true + +[dependencies] +color-eyre.workspace = true +palette = "0.7.6" +ratatui.workspace = true + +[lints] +workspace = true diff --git a/examples/apps/colors-rgb/README.md b/examples/apps/colors-rgb/README.md new file mode 100644 index 00000000..31ce0d71 --- /dev/null +++ b/examples/apps/colors-rgb/README.md @@ -0,0 +1,9 @@ +# Colors-RGB demo + +This example shows the full range of RGB colors in an animation. + +To run this demo: + +```shell +cargo run -p colors-rgb +``` diff --git a/ratatui/examples/colors_rgb.rs b/examples/apps/colors-rgb/src/main.rs similarity index 85% rename from ratatui/examples/colors_rgb.rs rename to examples/apps/colors-rgb/src/main.rs index 7557a4be..8ca3cbf2 100644 --- a/ratatui/examples/colors_rgb.rs +++ b/examples/apps/colors-rgb/src/main.rs @@ -1,30 +1,20 @@ -//! # [Ratatui] `Colors_RGB` example +//! A Ratatui example that shows the full range of RGB colors that can be displayed in the terminal. //! -//! The latest version of this example is available in the [examples] folder in the repository. +//! Requires a terminal that supports 24-bit color (true color) and unicode. //! -//! Please note that the examples are designed to be run against the `main` branch of the Github -//! repository. This means that you may not be able to compile with the latest release version on -//! crates.io, or the one that you have installed locally. +//! This example also demonstrates how implementing the Widget trait on a mutable reference +//! allows the widget to update its state while it is being rendered. This allows the fps +//! widget to update the fps calculation and the colors widget to update a cached version of +//! the colors to render instead of recalculating them every frame. //! -//! See the [examples readme] for more information on finding examples that match the version of the -//! library you are using. +//! This is an alternative to using the `StatefulWidget` trait and a separate state struct. It +//! is useful when the state is only used by the widget and doesn't need to be shared with +//! other widgets. //! -//! [Ratatui]: https://github.com/ratatui/ratatui -//! [examples]: https://github.com/ratatui/ratatui/blob/main/examples -//! [examples readme]: https://github.com/ratatui/ratatui/blob/main/examples/README.md - -// This example shows the full range of RGB colors that can be displayed in the terminal. -// -// Requires a terminal that supports 24-bit color (true color) and unicode. -// -// This example also demonstrates how implementing the Widget trait on a mutable reference -// allows the widget to update its state while it is being rendered. This allows the fps -// widget to update the fps calculation and the colors widget to update a cached version of -// the colors to render instead of recalculating them every frame. -// -// This is an alternative to using the `StatefulWidget` trait and a separate state struct. It -// is useful when the state is only used by the widget and doesn't need to be shared with -// other widgets. +//! This example runs with the Ratatui library code in the branch that you are currently reading. +//! See the [`latest`] branch for the code which works with the most recent Ratatui release. +//! +//! [`latest`]: https://github.com/ratatui/ratatui/tree/latest use std::time::{Duration, Instant}; diff --git a/ratatui/Cargo.toml b/ratatui/Cargo.toml index f7354b13..5b5a54d8 100644 --- a/ratatui/Cargo.toml +++ b/ratatui/Cargo.toml @@ -142,11 +142,6 @@ bench = false name = "main" harness = false -[[example]] -name = "colors_rgb" -required-features = ["crossterm", "palette"] -doc-scrape-examples = true - [[example]] name = "constraint-explorer" required-features = ["crossterm"]