StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.
| 1 | use std::time::Duration; |
| 2 | |
| 3 | /// Configuration for the ShimmeringText element. |
| 4 | /// |
| 5 | /// The shimmer moves through each glyph in the text with a configurable number of "padding" |
| 6 | /// surrounding the text to ensure the shimmer moves smoothly into and out of the text. |
| 7 | /// |
| 8 | /// For example: Consider if the text is "foo" with the following configuration options: |
| 9 | /// * `period`: 2s |
| 10 | /// * `shimmer_radius`: 6 |
| 11 | /// * `padding`: 8 |
| 12 | /// This would mean that the shimmer would travel 19 glyphs (the |
| 13 | /// padding + the 3 characters in the text) over the course of 2 seconds. Any glyph within 6 glyphs |
| 14 | /// of the center will be considered part of the shimmer. |
| 15 | /// NOTE this means that part of the shimmer would span a glyph range that isn't visible to the user. |
| 16 | /// This is purposeful so that the shimmer smoothly moves into and out of the text range. |
| 17 | #[derive(Clone, Copy, Debug)] |
| 18 | pub struct ShimmerConfig { |
| 19 | /// How long the shimmer should take from the start to the end of the track. |
| 20 | pub period: Duration, |
| 21 | /// The radius of the shimmer in fractional glyphs. Any glyph more than this distance away from |
| 22 | /// the center of the shimmer is displayed with no intensity. |
| 23 | pub shimmer_radius: usize, |
| 24 | /// Any extra padding of the shimmer, in fractional glyphs. Padding is added around the overall |
| 25 | /// laid out glyphs to ensure the shimmer is smooth as it enters and exits the text. |
| 26 | pub padding: usize, |
| 27 | } |
| 28 | |
| 29 | impl Default for ShimmerConfig { |
| 30 | fn default() -> Self { |
| 31 | Self { |
| 32 | period: Duration::from_secs(3), |
| 33 | shimmer_radius: 6, |
| 34 | padding: 8, |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 |