1
0

tui_color_test.rs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. use dioxus::prelude::*;
  2. fn main() {
  3. dioxus::tui::launch_cfg(
  4. app,
  5. dioxus::tui::Config::default().with_rendering_mode(dioxus::tui::RenderingMode::Ansi),
  6. );
  7. }
  8. fn app(cx: Scope) -> Element {
  9. let steps = 50;
  10. cx.render(rsx! {
  11. div{
  12. width: "100%",
  13. height: "100%",
  14. flex_direction: "column",
  15. (0..=steps).map(|x|
  16. {
  17. let hue = x as f32*360.0/steps as f32;
  18. cx.render(rsx! {
  19. div{
  20. width: "100%",
  21. height: "100%",
  22. flex_direction: "row",
  23. (0..=steps).map(|y|
  24. {
  25. let alpha = y as f32*100.0/steps as f32;
  26. cx.render(rsx! {
  27. div {
  28. left: "{x}px",
  29. top: "{y}px",
  30. width: "10%",
  31. height: "100%",
  32. background_color: "hsl({hue}, 100%, 50%, {alpha}%)",
  33. }
  34. })
  35. }
  36. )
  37. }
  38. })
  39. }
  40. )
  41. }
  42. })
  43. }